<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!--
### nfo_html1.xsl
### raBit, www.netfrag.org, 2006-03-01, 14:00 - 2006-08-31, 14:40
-->

<!--[ Global settings: ]-->

<xsl:output
	method="xml"
	doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
	indent="no"
	media-type="text/html"
/>
<xsl:strip-space elements="*" />

<!--[ Global variables: ]-->

<!-- Inner width of HTML body (w/o margin): -->
<xsl:variable name="html_min_width" select="764" />
<!-- Inner width of navigation box (w/o padding and borders): -->
<xsl:variable name="html_nav_width" select="161" />
<!-- Spacing between boxes: -->
<xsl:variable name="html_box_spacing" select="4" />

<!--[ Global parameters (set in php): ]-->

<xsl:param name="login_username" />

<!--[ Global documents: ]-->

<xsl:variable name="index" select="document('inc/dxml/index.xml')/index" />
<xsl:variable name="navigation" select="document('inc/dxml/navigation.xml')/navigation" />

<!--[ Named templates: ]-->

<xsl:template name="link_page">
<xsl:param name="caption" />
<xsl:param name="doc_key" />
<xsl:param name="params" />
<xsl:variable name="page" select="$index//page[@key=$doc_key]" />
<!-- xsl:if test="$page" -->
<xsl:variable name="page_title" select="$page/@title" />
<img alt="Page." class="texticon" src="gfx/ticon_page.gif" />
<a>
<xsl:attribute name="title">Open page '<xsl:value-of select="$page_title" />'.</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="concat('?k=', $doc_key)" />
<xsl:if test="$params"><xsl:value-of select="concat('&amp;', $params)" /></xsl:if>
</xsl:attribute>
<xsl:choose>
<xsl:when test="not($caption='')"><xsl:value-of select="$caption" /></xsl:when>
<xsl:otherwise><xsl:value-of select="$page_title" /></xsl:otherwise>
</xsl:choose>
</a>
<!-- /xsl:if -->
</xsl:template>

<xsl:template name="link_url">
<xsl:param name="caption" />
<xsl:param name="url" />
<xsl:param name="ext">1</xsl:param>
<xsl:param name="link_cap">
<xsl:if test="not($caption) or $caption=''"><xsl:value-of select="$url" /></xsl:if>
<xsl:value-of select="$caption" />
</xsl:param>
<img alt="New window." class="texticon" src="gfx/ticon_ext.gif" />
<a>
<xsl:if test="$ext">
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:attribute name="title">Open '<xsl:value-of select="$url" />' in a new window.</xsl:attribute>
</xsl:if>
<xsl:if test="not($ext)">
<xsl:attribute name="title">Open '<xsl:value-of select="$link_cap" />'.</xsl:attribute>
</xsl:if>
<xsl:attribute name="href"><xsl:value-of select="$url" /></xsl:attribute>
<xsl:value-of select="$link_cap" />
</a>
</xsl:template>

<xsl:template name="navigation">
  <xsl:param name="branch" select="$navigation/*" />
  <table cellpadding="0" cellspacing="0" style="margin-left:-14px;"><tr><td>
    <xsl:apply-templates select="$branch" />
  </td></tr></table>
</xsl:template>

<!--[ Template rules: ]-->

<!-- Page root element: -->
<xsl:template match="document/page">
<xsl:variable name="doc_key" select="/document/@key" />
<xsl:variable name="doc_info" select="/document/documentinfo" />
<xsl:variable name="doc_history" select="$doc_info/history" />
<xsl:variable name="index_doc" select="$index/page[@key=$doc_key]" />
<xsl:variable name="doc_title">
<xsl:choose>
<xsl:when test="$index_doc">
<xsl:value-of select="$index/page[@key=$doc_key]/@title" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$doc_key" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<html>
<head>
<title>NetFrag.org - <xsl:value-of select="$doc_title" /></title>
<style type="text/css">
a { color:#3f5f7f; text-decoration:none; }
a:hover { color:#3f7f9f; }
body { background-color:#3f7f9f; margin:<xsl:value-of select="$html_box_spacing" />px;}
body, input, select, table, textarea { font:12px verdana,arial,serif black; color:black; }
input, select, textarea, .bg1 { background-color:#7fdfff; }
ul { list-style-type:square; margin-left:24px; }
.box1, .box2, .box3 { border:1px solid #1f3f5f; border-bottom:2px solid #0f1f3f; border-right:2px solid #0f1f3f; padding:8px; }
.box1 { background-color:#efffff; }
.box2, .code { background-color:#bfdfef; }
.box3 { background-color:#0f1f3f; }
.code { background-color:#e7f7f7; }
.code, .note { border:1px solid #bfdfef; padding:2px; padding-left:4px; padding-right:4px; }
.note { font-size:10px; }
.h1 { border-bottom:2px solid #3f7f9f; color:#0f1f3f; font-size:14px; font-weight:bold; }
.h2 { border-bottom:1px solid #3f7f9f; color:#0f1f3f; font-weight:bold; }
.texticon { height:10px; width:14px; }
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0" id="top" width="100%"><tr>
<td class="box3" colspan="3">
<table cellpadding="0" cellspacing="0" width="100%"><tr>
<td align="center" rowspan="2" style="padding-top:8px;">
<img alt="" height="1" src="gfx/blank.gif">
<xsl:attribute name="width"><xsl:value-of select="$html_nav_width + 8" /></xsl:attribute>
</img><br />
<img alt="NetFrag" height="46" src="http://games.netfrag.org/gfx/netfrag_logo_b2.png" width="134" /></td>
<td rowspan="2"><xsl:attribute name="width"><xsl:value-of select="$html_box_spacing + 11" /></xsl:attribute><img alt="" height="1" src="gfx/blank.gif"><xsl:attribute name="width"><xsl:value-of select="$html_box_spacing + 11" /></xsl:attribute></img></td>
<td align="right" style="border-bottom:2px solid #1f3f5f; color:#3f7f9f;" valign="top" width="1048576">
<small>Theme/XSL by <b>raBit</b> @ NFo</small><br />
(<xsl:call-template name="link_url"><xsl:with-param name="caption" select="'XSL stylesheet'" /><xsl:with-param name="url" select="'inc/xsl/nfo_html1.xsl'" /></xsl:call-template>, <xsl:call-template name="link_url"><xsl:with-param name="caption" select="'navigation.xml'" /><xsl:with-param name="url" select="'inc/dxml/navigation.xml'" /></xsl:call-template>)
</td>
</tr><tr>
<td style="color:#bfdfef;" valign="bottom"><big><xsl:value-of select="$doc_title" /></big></td>
</tr></table>
</td>
</tr><tr>
<td colspan="3"><img alt="" src="gfx/blank.gif"><xsl:attribute name="height"><xsl:value-of select="$html_box_spacing" /></xsl:attribute><xsl:attribute name="width"><xsl:value-of select="$html_min_width" /></xsl:attribute></img></td>
</tr><tr>
<td class="box2" valign="top">
<p><span class="h2">Site navigation:</span><br />
<img alt="" height="0" src="gfx/blank.gif"><xsl:attribute name="width"><xsl:value-of select="$html_nav_width" /></xsl:attribute></img>
</p>
<xsl:call-template name="navigation">
<xsl:with-param name="branch" select="$navigation//link[@doc-key='NFo-Home']/*" />
</xsl:call-template>
<p><span class="h2">NFo web:</span></p>
<xsl:call-template name="navigation">
<xsl:with-param name="branch" select="$navigation//link[@doc-key='NFo-Web']/*" />
</xsl:call-template>
<p><span class="h2">Calendar:</span></p>
<center>
<img alt="Calendar" height="83" src="gfx/php/cal2.php" width="91" />
</center>
<br />
<p><span class="h2">User login:</span></p>
<form action="?k=NFo-Login" method="post">
<xsl:choose>
<xsl:when test="$login_username=''">
<table cellpadding="0" cellspacing="0"><tr>
<td align="right">User:</td><td><img alt="" src="gfx/blank.gif" width="4" /></td><td><input size="16" name="username" /></td>
</tr><tr>
<td align="right">Pass:</td><td></td><td><input size="16" name="password" type="password" /></td>
</tr><tr>
<td align="right" colspan="3"><input name="action" type="submit" value="login" /></td>
</tr></table>
<xsl:value-of select="$login_username" />
</xsl:when>
<xsl:otherwise>
<center>
You are logged in as<br />
<b><xsl:value-of select="$login_username" /></b>.<br />
<br />
<input name="action" type="submit" value="logout" />
</center>
</xsl:otherwise>
</xsl:choose>
</form>
</td>
<td><img alt="" src="gfx/blank.gif"><xsl:attribute name="width"><xsl:value-of select="$html_box_spacing" /></xsl:attribute></img></td>
<td class="box1" valign="top" width="1048576">
<xsl:apply-templates />
<p align="right"><font color="#3f7f9f"><small>
<xsl:if test="$doc_history/event/@action='create'">
Page created by <b><xsl:value-of select="$doc_history/event/@author" /></b> on <xsl:value-of select="$doc_history/event/@date" />, <xsl:value-of select="$doc_history/event/@time" /><br />
</xsl:if>
Get page as: </small>
<xsl:call-template name="link_url"><xsl:with-param name="caption" select="'XML'" /><xsl:with-param name="url" select="concat('inc/xml/', $doc_key, '.xml')" /></xsl:call-template>
</font></p>
</td>
</tr><tr>
<td colspan="3"><img alt="" src="gfx/blank.gif"><xsl:attribute name="height"><xsl:value-of select="$html_box_spacing" /></xsl:attribute><xsl:attribute name="width"><xsl:value-of select="$html_min_width" /></xsl:attribute></img></td>
</tr><tr>
<td align="center" class="box2" colspan="3">
<table cellpadding="0" cellspacing="0" width="100%"><tr>
<td align="right"><img alt="Powered by Apache2." border="0" src="/icons/apache_pb.gif" /></td>
<td align="right"><a href="http://validator.w3.org/check?uri=referer" target="_blank"><img alt="This page is valid XHTML 1.0 Transitional (click to revalidate)." border="0" height="31" src="http://games.netfrag.org/gfx/valid-xhtml10.gif" width="88" /></a></td>
<td align="center"><img alt="This page is valid CSS." border="0" height="31" src="http://games.netfrag.org/gfx/valid-css.gif" width="88" /></td>
</tr></table>
</td>
</tr></table>
</body>
</html>
</xsl:template>

<xsl:template match="page//b">
<b><xsl:apply-templates /></b>
</xsl:template>

<xsl:template match="p/br|code/br">
<br />
</xsl:template>

<xsl:template match="page//c">
<p><span class="h2"><xsl:apply-templates /></span></p>
</xsl:template>

<xsl:template match="page//code">
<pre class="code">
<xsl:apply-templates />
</pre>
</xsl:template>

<xsl:template match="page//colour">
<font>
<xsl:choose>
<xsl:when test="@hex">
<xsl:attribute name="color">#<xsl:value-of select="@hex" /></xsl:attribute>
<xsl:apply-templates />
</xsl:when>
<xsl:when test="@name">
<xsl:attribute name="color"><xsl:value-of select="@name" /></xsl:attribute>
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</font>
</xsl:template>

<xsl:template match="page/form">
<form action="" method="post">
<table cellpadding="0" cellspacing="0">
<xsl:apply-templates />
<tr><td align="center" colspan="3">
<input type="submit">
<xsl:attribute name="value"><xsl:value-of select="@submit-caption" /></xsl:attribute>
</input>
</td></tr>
</table>
</form>
</xsl:template>

<xsl:template match="form/input">
<xsl:choose>
<xsl:when test="@type='checkbox'">
</xsl:when>
<xsl:otherwise>
<tr>
<td align="right"><xsl:value-of select="@caption" />:</td>
<td><img alt="" src="gfx/blank.gif" width="4" /></td>
<td>
<input size="64">
<xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="@value" /></xsl:attribute>
</input>
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
<tr><td colspan="3"><img alt="" height="4" src="gfx/blank.gif" /></td></tr>
</xsl:template>

<xsl:template match="page//h">
<p>
<xsl:if test="@toc">
<xsl:attribute name="id">
<xsl:text>id</xsl:text>
<xsl:value-of select="@toc" />
</xsl:attribute>
</xsl:if>
<span class="h1">
<xsl:if test="@toc">
<xsl:value-of select="@toc" />
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:apply-templates />
</span>
<xsl:if test="@toc">
<xsl:text> (</xsl:text>
<a href="#top">top</a>
<xsl:text>)</xsl:text>
</xsl:if>
</p>
</xsl:template>

<xsl:template match="page//i">
<i><xsl:apply-templates /></i>
</xsl:template>

<xsl:template match="page//link">
<xsl:choose>
<xsl:when test="@doc-key">
<xsl:call-template name="link_page">
<xsl:with-param name="caption" select="." />
<xsl:with-param name="doc_key" select="@doc-key" />
<xsl:with-param name="params" select="@params" />
</xsl:call-template>
</xsl:when>
<xsl:when test="@url">
<xsl:call-template name="link_url">
<xsl:with-param name="caption" select="." />
<xsl:with-param name="url" select="@url" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><i>[ Invalid link! ]</i></xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="page//list">
<ul>
<xsl:apply-templates />
</ul>
</xsl:template>

<xsl:template match="list/item">
<li>
<xsl:apply-templates />
</li>
</xsl:template>

<xsl:template match="page/note">
<p align="justify" class="note">
<b>Note:</b>
<xsl:text> </xsl:text>
<xsl:apply-templates />
</p>
</xsl:template>

<xsl:template match="page//p">
<p align="justify">
<xsl:apply-templates />
</p>
</xsl:template>

<xsl:template match="page/picture">
<p align="center">
<img>

<xsl:choose>
<xsl:when test="@url">
<xsl:attribute name="src"><xsl:value-of select="@url" /></xsl:attribute>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>

</img>
</p>
</xsl:template>

<xsl:template match="page//u">
<u><xsl:apply-templates /></u>
</xsl:template>

<xsl:template match="page//user">
<xsl:call-template name="link_page">
<xsl:with-param name="caption" select="@name" />
<xsl:with-param name="doc_key" select="'NFo-User_profile'" />
<xsl:with-param name="params" select="concat('u=',@name)" />
</xsl:call-template>
</xsl:template>

<xsl:template match="page/toc">
<p><span class="h1">Table of contents</span></p>
<ul>
<xsl:for-each select="/document/page//h[@toc]">
<!--xsl:variable name="inner_data" select="/document/@key" /-->
<li>
<!--img alt="Chapter." class="texticon" src="gfx/ticon_page.gif" /-->
<a>
<xsl:attribute name="href"><xsl:value-of select="concat('#id', @toc)" /></xsl:attribute>
<xsl:value-of select="@toc" />
<xsl:text>. </xsl:text>
<xsl:value-of select="." />
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>

<xsl:template match="/navigation//link">
<table cellpadding="0" cellspacing="0" style="margin-left:14px;"><tr><td>
<xsl:choose>
<xsl:when test="@doc-key">
<xsl:call-template name="link_page">
<xsl:with-param name="doc_key" select="@doc-key" />
</xsl:call-template>
</xsl:when>
<xsl:when test="@url">
<xsl:call-template name="link_url">
<xsl:with-param name="caption" select="@title" />
<xsl:with-param name="url" select="@url" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><i>[ Invalid link! ]</i></xsl:otherwise>
</xsl:choose>
<br />
<xsl:apply-templates />
</td></tr></table>
</xsl:template>

</xsl:stylesheet>

