- Foundry now supports related links

- Some refactoring in content-items.xsl. Replaced an xsl:choose on a attribute of the content-item element by equivalent match rules
  for templates.


git-svn-id: https://svn.libreccm.org/ccm/trunk@2906 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-10-09 14:59:36 +00:00
parent b6e174b2ee
commit c79c9f4870
5 changed files with 189 additions and 25 deletions

View File

@ -14,6 +14,9 @@
</content-item> </content-item>
<default>content-items/detail-default.xml</default> <default>content-items/detail-default.xml</default>
</detail> </detail>
<link>
<default>content-items/link-default.xml</default>
</link>
<list> <list>
<default>content-items/list-default.xml</default> <default>content-items/list-default.xml</default>
</list> </list>

View File

@ -31,6 +31,7 @@
<xsl:import href="content-items/article.xsl"/> <xsl:import href="content-items/article.xsl"/>
<xsl:import href="content-items/assets/notes.xsl"/> <xsl:import href="content-items/assets/notes.xsl"/>
<xsl:import href="content-items/assets/related-links.xsl"/>
<foundry:doc section="user" type="template-tag"> <foundry:doc section="user" type="template-tag">
<foundry:doc-desc> <foundry:doc-desc>
@ -87,21 +88,7 @@
</foundry:doc-see-also> </foundry:doc-see-also>
</foundry:doc-desc> </foundry:doc-desc>
</foundry:doc> </foundry:doc>
<xsl:template match="content-item"> <xsl:template match="content-item[@mode = 'detail' or not(@mode)]">
<xsl:variable name="mode">
<xsl:choose>
<xsl:when test="./@mode = 'detail'">
<xsl:value-of select="'detail'"/>
</xsl:when>
<xsl:when test="./@mode = 'list'">
<xsl:value-of select="'list'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'detail'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$data-tree/cms:contentPanel or $data-tree/nav:greetingItem"> <xsl:if test="$data-tree/cms:contentPanel or $data-tree/nav:greetingItem">
<xsl:variable name="contentitem-tree"> <xsl:variable name="contentitem-tree">
<xsl:choose> <xsl:choose>
@ -132,14 +119,7 @@
<xsl:variable name="content-type" select="$contentitem-tree/objectType"/> <xsl:variable name="content-type" select="$contentitem-tree/objectType"/>
<xsl:variable name="template-map"> <xsl:variable name="template-map">
<xsl:choose> <xsl:copy-of select="document(foundry:gen-path('conf/templates.xml'))/templates/content-items/detail/*"/>
<xsl:when test="$mode = '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(foundry:gen-path('conf/templates.xml'))/templates/content-items/detail/*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:choose> <xsl:choose>
@ -267,7 +247,7 @@
<xsl:call-template name="foundry:process-contentitem-template"> <xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file" <xsl:with-param name="template-file"
select="concat('contentitem-default-', $mode ,'.xml')"/> select="'contentitem-default-detail.xml'"/>
<xsl:with-param name="contentitem-tree" <xsl:with-param name="contentitem-tree"
select="$contentitem-tree"/> select="$contentitem-tree"/>
<xsl:with-param name="internal" select="true()"/> <xsl:with-param name="internal" select="true()"/>
@ -277,6 +257,55 @@
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="content-item[@mode = 'link']">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:variable name="oid" select="$contentitem-tree/@oid"/>
<xsl:variable name="content-type" select="$contentitem-tree/objectType"/>
<xsl:variable name="template-map">
<xsl:copy-of select="document(foundry:gen-path('conf/templates.xml'))/templates/content-items/link/*"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$template-map/content-item[@content-type = $content-type]">
<xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="$template-map/content-item[@content-type = $content-type]"/>
<xsl:with-param name="contentitem-tree"
select="$contentitem-tree"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$template-map/default">
<xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="$template-map/default"/>
<xsl:with-param name="contentitem-tree"
select="$contentitem-tree"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:value-of select="foundry:message-info('No template for item found and not default configured. Using internal default')"/>
</xsl:message>
<xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="'contentitem-default-link.xml'"/>
<xsl:with-param name="contentitem-tree"
select="$contentitem-tree"/>
<xsl:with-param name="internal" select="true()"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="content-item[@mode = 'list']">
</xsl:template>
<xsl:template name="foundry:process-contentitem-template"> <xsl:template name="foundry:process-contentitem-template">
<xsl:param name="template-file" as="xs:string"/> <xsl:param name="template-file" as="xs:string"/>
<xsl:param name="internal" as="xs:boolean" select="false()"/> <xsl:param name="internal" as="xs:boolean" select="false()"/>
@ -308,4 +337,10 @@
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:template> </xsl:template>
<xsl:template match="content-item-layout//content-item-title">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:value-of select="$contentitem-tree/title"/>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014 Jens Pelzetter for the LibreCCM Foundation
This file is part of the Foundry Theme Engine for LibreCCM
Foundry is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Foundry is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foundry If not, see <http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:cms="http://www.arsdigita.com/cms/1.0"
xmlns:foundry="http://foundry.libreccm.org"
xmlns:nav="http://ccm.redhat.com/navigation"
xmlns:ui="http://www.arsdigita.com/ui/1.0"
exclude-result-prefixes="xsl xs bebop cms foundry nav ui"
version="2.0">
<xsl:template match="related-links">
<xsl:if test="$data-tree/cms:contentPanel/cms:item/links
or $data-tree/nav:greetingItem/cms:item/links">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="related-links//related-link">
<xsl:variable name="links-layout-tree" select="current()"/>
<xsl:variable name="contentitem-tree">
<xsl:choose>
<xsl:when test="$data-tree/nav:greetingItem">
<xsl:copy-of select="$data-tree/nav:greetingItem/cms:item/*"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$data-tree/cms:contentPanel/cms:item/*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:for-each select="$contentitem-tree/*[name() = 'links']">
<xsl:sort select="linkOrder"/>
<xsl:choose>
<xsl:when test="./targetType = 'internalLink'">
<xsl:apply-templates select="$links-layout-tree/internal/*">
<xsl:with-param name="link-title" tunnel="yes" select="./linkTitle"/>
<xsl:with-param name="link-desc" tunnel="yes" select="./linkDescription"/>
<xsl:with-param name="href"
tunnel="yes"
select="concat($context-prefix, '/redirect/?oid=', ./targetItem/@oid)"/>
<xsl:with-param name="target-item-title"
tunnel="yes"
select="./targetItem/title"/>
<xsl:with-param name="contentitem-tree"
tunnel="yes">
<xsl:copy-of select="./targetItem/*"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$links-layout-tree/external/*">
<xsl:with-param name="link-title" tunnel="yes" select="./linkTitle"/>
<xsl:with-param name="link-desc" tunnel="yes" select="./linkDescription"/>
<xsl:with-param name="href" tunnel="yes" select="./targetURI"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template match="related-link//related-link-title">
<xsl:param name="link-title" tunnel="yes"/>
<xsl:value-of select="$link-title"/>
</xsl:template>
<xsl:template match="related-link//related-link-desc">
<xsl:param name="link-desc" tunnel="yes"/>
<xsl:value-of select="$link-desc"/>
</xsl:template>
<xsl:template match="related-link//internal//target-item-title">
<xsl:param name="target-item-title" tunnel="yes"/>
<xsl:value-of select="$target-item-title"/>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<content-item-layout>
<a>
<content-item-title/>
</a>
</content-item-layout>

View File

@ -49,11 +49,28 @@
</nav> </nav>
<main> <main>
<div> <div>
<h1>TEST</h1>
<content-item/> <content-item/>
</div> </div>
</main> </main>
<aside> <aside>
<related-links>
<ul>
<related-link>
<internal>
<li>
<content-item mode="link"/>
</li>
</internal>
<external>
<li>
<a>
<related-link-title/>
</a>
</li>
</external>
</related-link>
</ul>
</related-links>
<notes> <notes>
<div id="notes"> <div id="notes">
<note> <note>