|
<?xml version="1.0" encoding="utf-8" ?> |
|
<xsl:stylesheet |
|
version="1.0" |
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
xmlns:umb="urn:umbraco.library" |
|
xmlns:make="urn:schemas-microsoft-com:xslt" |
|
exclude-result-prefixes="umb make" |
|
> |
|
|
|
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> |
|
|
|
<!-- Name of the QueryString parameter --> |
|
<xsl:variable name="cssParam" select="'css'" /> |
|
|
|
<!-- Name of Cookie key --> |
|
<xsl:variable name="cssCookieKey" select="'CSSFILE'" /> |
|
|
|
<xsl:variable name="mode" select="/macro/mode" /> |
|
<xsl:variable name="cssfile" select="umb:RequestQueryString($cssParam)" /> |
|
<xsl:variable name="cssCookie" select="umb:RequestCookies($cssCookieKey)" /> |
|
|
|
<!-- Configure available StyleSheets here --> |
|
<xsl:variable name="stylesheetsProxy"> |
|
<css name="Smaller" id="small">/css/small.css</css> |
|
<css name="Bigger" id="large">/css/large.css</css> |
|
<!-- Last one is default --> |
|
<css name="Standard" id="normal">/css/normal.css</css> |
|
</xsl:variable> |
|
<xsl:variable name="stylesheets" select="make:node-set($stylesheetsProxy)/css" /> |
|
|
|
<!-- Get the active stylesheet using some set trickery --> |
|
<xsl:variable name="activeCSS" select="($stylesheets[@id = $cssCookie][not(normalize-space($cssfile))] | $stylesheets[@id = $cssfile][normalize-space($cssfile)] | $stylesheets[last()])[1]" /> |
|
|
|
<xsl:template match="/"> |
|
<xsl:choose> |
|
<xsl:when test="$mode = 'link'"> |
|
<xsl:call-template name="writeLink" /> |
|
</xsl:when> |
|
<xsl:when test="$mode = 'switcher'"> |
|
<xsl:call-template name="writeSwitcher" /> |
|
</xsl:when> |
|
</xsl:choose> |
|
|
|
<!-- If a valid StyleSheet was selected, set the Cookie --> |
|
<xsl:if test="$stylesheets[@id = $cssfile]"> |
|
<xsl:value-of select="umb:setCookie($cssCookieKey, $cssfile)" /> |
|
</xsl:if> |
|
</xsl:template> |
|
|
|
<xsl:template name="writeLink"> |
|
<link rel="stylesheet" href="{$activeCSS}" /> |
|
</xsl:template> |
|
|
|
<xsl:template name="writeSwitcher"> |
|
<xsl:for-each select="$stylesheets"> |
|
<a href="?{$cssParam}={@id}" title="Use '{@name}' view"> |
|
<!-- Mark the active one --> |
|
<xsl:if test="@id = $activeCSS/@id"><xsl:attribute name="class">active</xsl:attribute></xsl:if> |
|
<xsl:value-of select="@name" /> |
|
</a> |
|
</xsl:for-each> |
|
</xsl:template> |
|
|
|
</xsl:stylesheet> |