Added code to parse local menus
svn path=/trunk/; revision=11518
This commit is contained in:
parent
1fcf792c90
commit
17b16dcad0
@ -256,8 +256,79 @@
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Insert local menu -->
|
||||
<xsl:template match="localmenu">
|
||||
<xsl:variable name="set">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@set">
|
||||
<xsl:value-of select="@set"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>0</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="dir">
|
||||
<xsl:value-of select="/buildinfo/@dirname"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="language">
|
||||
<xsl:value-of select="/buildinfo/@language"/>
|
||||
</xsl:variable>
|
||||
<xsl:element name="div">
|
||||
<xsl:attribute name="class">localmenu</xsl:attribute>
|
||||
<xsl:element name="p">
|
||||
<xsl:text>[ </xsl:text>
|
||||
<xsl:for-each select="/buildinfo/localmenuset/localmenuitems/menu[@dir=$dir and @set=$set]">
|
||||
<xsl:sort select="@id"/>
|
||||
<xsl:variable name="style"><xsl:value-of select="@style"/></xsl:variable>
|
||||
<xsl:variable name="id"><xsl:value-of select="@id"/></xsl:variable>
|
||||
<xsl:variable name="localmenutext">
|
||||
<xsl:choose>
|
||||
<xsl:when
|
||||
test="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language=$language]">
|
||||
<xsl:value-of
|
||||
select="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language=$language]"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of
|
||||
select="/buildinfo/localmenuset/translate/lang_part[@dir=$dir and @id=$id and @language='en']"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="class">local_menu_item</xsl:attribute>
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(substring-before(concat(/buildinfo/@filename ,'.html'), string(.)))">
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
|
||||
<xsl:value-of select="$localmenutext"/>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$localmenutext"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:element>
|
||||
<xsl:if test="position()!=last()">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$style='number'">
|
||||
<xsl:text> | </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text> ] [ </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:text> ]</xsl:text>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
||||
<!-- Do not copy non-HTML elements to output -->
|
||||
<xsl:template match="timestamp|translator|buildinfo/set|buildinfo/textset|buildinfo/menuset|buildinfo/trlist"/>
|
||||
<xsl:template match="timestamp|translator|buildinfo/set|buildinfo/textset|buildinfo/menuset|buildinfo/trlist|buildinfo/localmenuset"/>
|
||||
|
||||
<!-- For all other nodes, copy verbatim -->
|
||||
<xsl:template match="@*|node()" priority="-1">
|
||||
|
@ -174,6 +174,9 @@ open (TRANSLATIONS, '>', "$opts{o}/translations.log");
|
||||
# <tr id="sv">Svenska</tr>
|
||||
# ...
|
||||
# </trlist>
|
||||
# <localmenuset> <!-- Local menu items for some directories -->
|
||||
# ...
|
||||
# </localmenuset>
|
||||
# <menuset> <!-- The menu items for the right hand bar -->
|
||||
# ...
|
||||
# </menuset>
|
||||
@ -193,6 +196,7 @@ open (TRANSLATIONS, '>', "$opts{o}/translations.log");
|
||||
#
|
||||
# buildinfo/@original The language code of the original document
|
||||
# buildinfo/@filename The filename without language or trailing .html
|
||||
# buildinfo/@filename The path to the file
|
||||
# buildinfo/@language The language that we're building into
|
||||
# buildinfo/@outdated Set to "yes" if the original is newer than this page
|
||||
# document/@language The language that this documents is in
|
||||
@ -325,6 +329,13 @@ sub process {
|
||||
|
||||
$root->setAttribute("filename", "/$file");
|
||||
|
||||
#
|
||||
# Set the directory name attribute
|
||||
#
|
||||
my (undef, $current_dir, undef) = fileparse($file);
|
||||
|
||||
$root->setAttribute("dirname", "$current_dir");
|
||||
|
||||
#
|
||||
# Find all translations for this document, and create the trlist set
|
||||
# for them.
|
||||
@ -338,6 +349,16 @@ sub process {
|
||||
}
|
||||
$root->appendChild($trlist);
|
||||
|
||||
#
|
||||
# Load the file with local menu's
|
||||
#
|
||||
my $localmenu = "$opts{i}/localmenuinfo.xml";
|
||||
if (-f $localmenu) {
|
||||
my $menudoc = $dom->createElement("localmenuset");
|
||||
$root->appendChild($menudoc);
|
||||
clone_document($menudoc, $localmenu);
|
||||
}
|
||||
|
||||
#
|
||||
# Transform it, once for every focus!
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user