- Encapsulated the generation of a path to a resource file in function
- Some enhancements for the CSS loader


git-svn-id: https://svn.libreccm.org/ccm/trunk@2904 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-10-08 13:32:46 +00:00
parent 9d79023640
commit f04b1dfadd
10 changed files with 110 additions and 48 deletions

View File

@ -1,3 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<css-files>
<application name="navigation">
<css-file>public.css</css-file>
</application>
<default>
<css-file>public.css</css-file>
</default>
</css-files>

View File

@ -155,7 +155,7 @@ processor, some are read from the configuration files of Foundry and some are de
</foundry:doc-desc>
</foundry:doc>
<xsl:variable name="supported-languages"
select="document(concat($theme-prefix, '/conf/global.xml'))/foundry:configuration/supported-languages"/>
select="document(foundry:gen-path('conf/global.xml'))/foundry:configuration/supported-languages"/>
<foundry:doc section="devel">
<foundry:doc-desc>

View File

@ -199,14 +199,14 @@
<xsl:choose>
<xsl:when test="$internal = true()">
<xsl:apply-templates select="document(concat($theme-prefix,
'foundry/templates/',
normalize-space($template-file)))"/>
<xsl:apply-templates select="document(foundry:gen-path(
concat('foundry/templates/',
normalize-space($template-file))))"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="document(concat($theme-prefix,
'/templates/',
normalize-space($template-file)))"/>
<xsl:apply-templates select="document(foundry:gen-path(
concat('/templates/',
normalize-space($template-file))))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

View File

@ -133,10 +133,10 @@
<xsl:variable name="template-map">
<xsl:choose>
<xsl:when test="$mode = 'list'">
<xsl:copy-of select="document(concat($theme-prefix, '/conf/templates.xml'))/templates/content-items/list/*"/>
<xsl:copy-of select="document(foundry:gen-path('conf/templates.xml'))/templates/content-items/list/*"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="document(concat($theme-prefix, '/conf/templates.xml'))/templates/content-items/detail/*"/>
<xsl:copy-of select="document(foundry:gen-path('conf/templates.xml'))/templates/content-items/detail/*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
@ -283,18 +283,18 @@
<xsl:choose>
<xsl:when test="$internal = true()">
<xsl:apply-templates select="document(concat($theme-prefix,
'foundry/templates/',
normalize-space($template-file)))">
<xsl:apply-templates select="document(foundry:gen-path(
concat('foundry/templates/',
normalize-space($template-file))))">
<xsl:with-param name="contentitem-tree"
tunnel="yes"
select="$contentitem-tree"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="document(concat($theme-prefix,
'/templates/',
normalize-space($template-file)))">
<xsl:apply-templates select="document(foundry:gen-path(
concat('/templates/',
normalize-space($template-file))))">
<xsl:with-param name="contentitem-tree"
tunnel="yes"
select="$contentitem-tree"/>

View File

@ -156,7 +156,7 @@
</xsl:choose>
</xsl:when>
<xsl:when test="$section-generate != ''">
<xsl:apply-templates select="document(concat($theme-prefix, '/foundry/main.xsl'))"
<xsl:apply-templates select="document(foundry:gen-path('foundry/main.xsl'))"
mode="doc">
<xsl:with-param name="section-generate"
tunnel="yes"
@ -186,7 +186,7 @@
</xsl:template>
<xsl:template match="foundry:doc[@type='function']" mode="doc">
<xsl:apply-templates select="document(concat($theme-prefix, '/foundry/templates/doc/function-layout.xml'))">
<xsl:apply-templates select="document(foundry:gen-path('foundry/templates/doc/function-layout.xml'))">
<xsl:with-param name="function-name"
tunnel="yes"
select="./following::xsl:function[1]/@name"/>
@ -303,7 +303,7 @@
</xsl:template>
<xsl:template match="foundry:doc[@type='template-tag']" mode="doc">
<xsl:apply-templates select="document(concat($theme-prefix, '/foundry/templates/doc/template-tag-layout.xml'))">
<xsl:apply-templates select="document(foundry:gen-path('foundry/templates/doc/template-tag-layout.xml'))">
<xsl:with-param name="matches"
tunnel="yes"
select="./following::xsl:template[1]/@match"/>

View File

@ -478,7 +478,7 @@
<xsl:value-of select="./@href-static"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($theme-prefix, ./@href-static)"/>
<xsl:value-of select="foundry:gen-path(./@href-static)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@ -652,7 +652,7 @@
<xsl:value-of select="./@src"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($theme-prefix, ./@src)"/>
<xsl:value-of select="foundry:gen-path(./@src)"/>
</xsl:otherwise>
</xsl:choose>

View File

@ -53,8 +53,8 @@
</xsl:variable>
<xsl:choose>
<xsl:when test="document(concat($theme-prefix, '/conf/css-files.xml'))/css-files/application[@name=$application]">
<xsl:for-each select="document(concat($theme-prefix, '/conf/css-files.xml'))/css-files/application[@name=$application]/css-file">
<xsl:when test="document(foundry:gen-path('conf/css-files.xml'))/css-files/application[@name = $application]">
<xsl:for-each select="document(foundry:gen-path('conf/css-files.xml'))/css-files/application[@name = $application]/css-file">
<xsl:call-template name="foundry:load-css-file">
<xsl:with-param name="filename" select="."/>
<xsl:with-param name="media" select="./@media"/>
@ -62,7 +62,7 @@
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="document(concat($theme-prefix, '/conf/css-files.xml'))/css-files/default/css-file">
<xsl:for-each select="document(foundry:gen-path('conf/css-files.xml'))/css-files/default/css-file">
<xsl:call-template name="foundry:load-css-file">
<xsl:with-param name="filename" select="."/>
<xsl:with-param name="media" select="./@media"/>
@ -76,8 +76,8 @@
conditional comments in the other CSS files instead? -->
<xsl:if test="$msie_version >= '5' and $msie_version &lt; '7'">
<xsl:choose>
<xsl:when test="document(concat($theme-prefix, '/conf/css-files.xml'))/css-files/application[@name=$application]">
<xsl:for-each select="document(concat($theme-prefix, '/conf/css-files.xml'))/css-files/application[@name=$application]/iehacks">
<xsl:when test="document(foundry:gen-path('/conf/css-files.xml'))/css-files/application[@name=$application]">
<xsl:for-each select="document(foundry:gen-path('conf/css-files.xml'))/css-files/application[@name=$application]/iehacks">
<xsl:call-template name="foundry:load-css-file">
<xsl:with-param name="filename" select="."/>
<xsl:with-param name="media" select="./@media"/>
@ -85,7 +85,7 @@
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="document(concat($theme-prefix, '/conf/css-files.xml'))/css-files/default/iehacks">
<xsl:for-each select="document(foundry:gen-path('/conf/css-files.xml'))/css-files/default/iehacks">
<xsl:call-template name="foundry:load-css-file">
<xsl:with-param name="filename" select="."/>
<xsl:with-param name="media" select="./@media"/>
@ -114,18 +114,25 @@
<xsl:template name="foundry:load-css-file">
<xsl:param name="filename"/>
<xsl:param name="media" select="''"/>
<xsl:choose>
<xsl:when test="string-length($media) &gt; 0">
<!--<link rel="stylesheet"
type="text/css"
href="{$theme-prefix}/styles/{$media}/{$filename}"
media="{$media}" />-->
<link rel="stylesheet"
type="text/css"
href="{$theme-prefix}/css/{$media}/{$filename}"
href="{foundry:gen-path(concat('styles/', $media, '/', $filename))}"
media="{$media}" />
</xsl:when>
<xsl:otherwise>
<!--<link rel="stylesheet"
type="text/css"
href="{$theme-prefix}/styles/{$filename}" />-->
<link rel="stylesheet"
type="text/css"
href="{$theme-prefix}/css/{$filename}" />
href="{foundry:gen-path(concat('styles/', $filename))}" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

View File

@ -126,9 +126,53 @@ XSLT 2.0 functions.
<xsl:sequence select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<foundry:doc section="devel" type="function">
<foundry:doc-desc>
<p>
Helper function for generating paths to theme resources like CSS files etc. Use this
function instead of concatenating paths yourself. For example, instead of
</p>
<pre>
document(concat($theme-prefix, 'path/to/resource/file')
</pre>
<p>
use <code>foundry:gen-path</code>:
</p>
<pre>
document(foundry:gen-path('path/to/resource/file'))
</pre>
<p>
<code>path/to/resource/file</code> is meant as a placeholder here. A real world
example is a settings file, for example <code>conf/global.xml</code>. For this file
a usage of the <code>foundry:gen-path</code> function would look like this
</p>
<pre>
document(foundry:gen-path('conf/global.xml')
</pre>
<p>
The advantage of this function is the encapsulation of the path generation process.
<code>foundry:gen-path</code>.
</p>
</foundry:doc-desc>
<foundry:doc-parameters>
<foundry:doc-parameter name="path" mandatory="yes" type="string">
The path of the file to generate to path to, relative to the theme directory.
</foundry:doc-parameter>
</foundry:doc-parameters>
<foundry:doc-result type="string">
<p>
The absolute path for the file.
</p>
</foundry:doc-result>
</foundry:doc>
<xsl:function name="foundry:gen-path" as="xs:string">
<xsl:param name="path" as="xs:string"/>
<xsl:sequence select="concat($theme-prefix, '/', $path)"/>
</xsl:function>
<foundry:doc section="devel" type="function">
<foundry:doc-params>
<foundry:doc-param name="level"
@ -472,10 +516,10 @@ XSLT 2.0 functions.
<xsl:sequence select="$node"/>
</xsl:when>
<xsl:when test="$module = ''">
<xsl:sequence select="document(concat($theme-prefix, '/conf/global.xml'))/foundry:configuration/setting[@id=$setting]"/>
<xsl:sequence select="document(foundry:gen-path('conf/global.xml'))/foundry:configuration/setting[@id=$setting]"/>
</xsl:when>
<xsl:when test="not($module = '') and document(concat($theme-prefix, '/conf/', $module, '.xml'))/foundry:configuration/setting[@id=$setting]">
<xsl:sequence select="document(concat($theme-prefix, '/conf/', $module, '.xml'))/foundry:configuration/setting[@id=$setting]"/>
<xsl:when test="not($module = '') and document(foundry:gen-path(concat('conf/', $module, '.xml')))/foundry:configuration/setting[@id=$setting]">
<xsl:sequence select="document(foundry:gen-path(concat('conf/', $module, '.xml')))/foundry:configuration/setting[@id=$setting]"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>
@ -556,23 +600,23 @@ XSLT 2.0 functions.
<xsl:param name="html" as="xs:boolean"/>
<xsl:param name="lang" as="xs:string"/>
<xsl:message>
<!--<xsl:message>
<xsl:value-of select="foundry:message-info('get-static-text(string, string, boolean, string) called')"/>
</xsl:message>
<xsl:message>
<xsl:value-of select="foundry:message-info(concat('Trying to get ', $theme-prefix, '/texts/', $module ,'.xml/foundry:static-texts/text[@id=', $id, ']/translation[@lang = ', $lang, ']'))"/>
</xsl:message>
</xsl:message>-->
<xsl:choose>
<xsl:when test="$module = '' and document(concat($theme-prefix, '/texts/global.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]">
<xsl:when test="$module = '' and document(foundry:gen-path('texts/global.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]">
<xsl:message>
<xsl:value-of select="'using global.xml for texts...'"/>
</xsl:message>
<xsl:sequence select="document(concat($theme-prefix, '/texts/global.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]"/>
<xsl:sequence select="document(foundry:gen-path('texts/global.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]"/>
</xsl:when>
<xsl:when test="not($module = '') and document(concat($theme-prefix, '/texts/', $module, '.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]">
<xsl:sequence select="document(concat($theme-prefix, '/texts/', $module, '.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]"/>
<xsl:when test="not($module = '') and document(foundry:gen-path(concat('texts/', $module, '.xml')))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]">
<xsl:sequence select="document(foundry:gen-path(concat('texts/', $module, '.xml')))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>
@ -592,10 +636,10 @@ XSLT 2.0 functions.
<span class="foundry-missing-translation-path">
<xsl:choose>
<xsl:when test="$module = ''">
<xsl:value-of select="document(concat($theme-prefix, '/texts/global.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]"/>
<xsl:value-of select="document(foundry:gen-path('texts/global.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="document(concat($theme-prefix, '/texts/', $module, '.xml'))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]"/>
<xsl:value-of select="document(foundry:gen-path(concat('texts/', $module, '.xml')))/foundry:static-texts/text[@id=$id]/translation[@lang=$lang]"/>
</xsl:otherwise>
</xsl:choose>
</span>

View File

@ -50,22 +50,22 @@
<xsl:variable name="class" select="@class" />
<xsl:choose>
<xsl:when test="document(concat($theme-prefix, '/conf/templates.xml'))/templates/applications/application[@name=$application and @class=$class]">
<xsl:when test="document(foundry:gen-path('conf/templates.xml'))/templates/applications/application[@name=$application and @class=$class]">
<xsl:message>
<xsl:value-of select="foundry:message-info('Using application template')"/>
</xsl:message>
<xsl:call-template name="foundry:process-template">
<xsl:with-param name="template-file"
select="document(concat($theme-prefix, '/conf/templates.xml'))/templates/applications/application[@name=$application and @class=$class]"/>
select="document(foundry:gen-path('conf/templates.xml'))/templates/applications/application[@name=$application and @class=$class]"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="document(concat($theme-prefix, '/conf/templates.xml'))/templates/applications/application[@name=$application and not(@class)]">
<xsl:when test="document(foundry:gen-path('conf/templates.xml'))/templates/applications/application[@name=$application and not(@class)]">
<xsl:message>
<xsl:value-of select="foundry:message-info('Using application template')"/>
</xsl:message>
<xsl:call-template name="foundry:process-template">
<xsl:with-param name="template-file"
select="document(concat($theme-prefix, '/conf/templates.xml'))/templates/applications/application[@name=$application and not(@class)]"/>
select="document(foundry:gen-path('conf/templates.xml'))/templates/applications/application[@name=$application and not(@class)]"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
@ -73,10 +73,10 @@
<xsl:value-of select="foundry:message-info('Using default layout')"/>
</xsl:message>
<xsl:choose>
<xsl:when test="document(concat($theme-prefix, '/conf/templates.xml'))/templates/applications/default">
<xsl:when test="document(foundry:gen-path('conf/templates.xml'))/templates/applications/default">
<xsl:call-template name="foundry:process-template">
<xsl:with-param name="template-file"
select="document(concat($theme-prefix, '/conf/templates.xml'))/templates/applications/default"/>
select="document(foundry:gen-path('conf/templates.xml'))/templates/applications/default"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
@ -107,7 +107,7 @@
</foundry:doc-desc>
</foundry:doc>-->
<xsl:template match="/foundry:documentation">
<xsl:apply-templates select="document(concat($theme-prefix, '/foundry/templates/doc/foundry-documentation.xml'))"/>
<xsl:apply-templates select="document(foundry:gen-path('foundry/templates/doc/foundry-documentation.xml'))"/>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,5 @@
/*
Public CSS file
*/