Foundry support for ObjectLists. Paginator and filters are not yet supported, will be added in the next commit.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2954 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-11-06 16:16:01 +00:00
parent bd8d621d28
commit c4e40a3a5c
13 changed files with 341 additions and 8 deletions

View File

@ -23,6 +23,9 @@
<default>content-items/link-default.xml</default> <default>content-items/link-default.xml</default>
</link> </link>
<list> <list>
<content-item content-type="com.arsdigita.cms.contenttypes.Article">
content-items/article-list.xml
</content-item>
<default>content-items/list-default.xml</default> <default>content-items/list-default.xml</default>
</list> </list>
</content-items> </content-items>

View File

@ -30,6 +30,7 @@
<xsl:import href="template-tags/html-tags.xsl"/> <xsl:import href="template-tags/html-tags.xsl"/>
<xsl:import href="template-tags/loaders.xsl"/> <xsl:import href="template-tags/loaders.xsl"/>
<xsl:import href="template-tags/navigation.xsl"/> <xsl:import href="template-tags/navigation.xsl"/>
<xsl:import href="template-tags/object-list.xsl"/>
<xsl:import href="template-tags/portal-workspace.xsl"/> <xsl:import href="template-tags/portal-workspace.xsl"/>
<xsl:import href="template-tags/portal-workspace-grid.xsl"/> <xsl:import href="template-tags/portal-workspace-grid.xsl"/>
<xsl:import href="template-tags/subsite.xsl"/> <xsl:import href="template-tags/subsite.xsl"/>

View File

@ -47,7 +47,7 @@
<foundry:doc section="user" type="template-tag"> <foundry:doc section="user" type="template-tag">
<foundry:doc-desc> <foundry:doc-desc>
<p> <p>
The <code>content-item</code> tag with the attribute <code>mode</code> set the The <code>content-item</code> element with the attribute <code>mode</code> set to
<code>detail</code> or without the attribute inserts the HTML representation of the <code>detail</code> or without the attribute inserts the HTML representation of the
detail view of the current content item. The content item can either be the greeting detail view of the current content item. The content item can either be the greeting
item or normal item. item or normal item.
@ -57,7 +57,7 @@
with the <code>contentitem-layout</code> element as root. Usually these templates with the <code>contentitem-layout</code> element as root. Usually these templates
are located in the <code>templates/content-items</code> folder. Which template is are located in the <code>templates/content-items</code> folder. Which template is
used for a particular content item is defined by the <code>conf/templates.xml</code> used for a particular content item is defined by the <code>conf/templates.xml</code>
file. In this file there is a <code>content-items</code> below the file. In this file there is a <code>content-items</code> element below the
<code>templates</code> element. The association between templates and <code>templates</code> element. The association between templates and
content items is described by the <code>content-item</code> elements in the content items is described by the <code>content-item</code> elements in the
<code>content-items</code> element. The <code>content-item</code> has four <code>content-items</code> element. The <code>content-item</code> has four
@ -263,7 +263,8 @@
select="'contentitem-default-detail.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()"/>
</xsl:call-template> </xsl:call-template>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
@ -325,8 +326,172 @@
</xsl:template> </xsl:template>
<foundry:doc section="user" type="template-tag">
<foundry:doc-desc>
<p>
The <code>content-item</code> element with the <code>mode</code> attribute set to
<code>list</code> inserts the HTML representation of the the list view of a content
item. The list view is primarily used in object lists.
</p>
<p>
As for the detail view, the HTML representation of the list view of a conten item is
defined using special templates with the <code>contentitem-layout</code> element as
root. Usually these templates are located in the
<code>templates/content-items</code> folder. Which is used for a particular content
item is defined in the <code>conf/templates.xml</code> file. In this file there is
a <code>content-items</code> element below the <code>templates</code> element.
</p>
<p>
There three attributes which can be used to define in which cases a specific
template is used:
</p>
<dl>
<dt>style</dt>
<dd>
Used to select a specific style for the list view of the item. To select a style
add a <code>style</code> attribute to the <code>content-item</code> attribute
in the application layout file.
</dd>
<dt>content-type</dt>
<dd>The content-type of the item.</dd>
<dt>
<code>category</code>
</dt>
<dd>
The template is only used for the content item if the item is viewed as item of
the category. The category is set as a path contains the names the categories.
</dd>
</dl>
</foundry:doc-desc>
<foundry:doc-see-also>
<foundry:doc-link href="#layout-templates">The template system</foundry:doc-link>
</foundry:doc-see-also>
</foundry:doc>
<xsl:template match="content-item[@mode = 'list']"> <xsl:template match="content-item[@mode = 'list']">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:variable name="category" select="foundry:read-current-category()"/>
<xsl:variable name="content-type"
select="$contentitem-tree/nav:attribute[@name = 'objectType']"/>
<xsl:variable name="style">
<xsl:choose>
<xsl:when test="./@style">
<xsl:value-of select="./@style"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="''"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="template-map">
<xsl:copy-of select="document(foundry:gen-path('conf/templates.xml'))/templates/content-items/list/*"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$style != ''">
<xsl:choose>
<xsl:when test="$template-map/content-item[@style = $style
and @content-type = $content-type
and @category = $category]">
<xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="$template-map/content-item[@style = $style
and @content-type = $content-type
and @category = $category]"/>
<xsl:with-param name="contentitem-tree"
select="$contentitem-tree"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$template-map/content-item[@style = $style
and @content-type = $content-type
and not(@category)]">
<xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="$template-map/content-item[@style = $style
and @content-type = $content-type
and not(@category)]"/>
<xsl:with-param name="contentitem-tree"
select="$contentitem-tree"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$template-map/content-item[@style = $style
and not(@content-type)
and not(@category)]">
<xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="$template-map/content-item[@style = $style
and not(@content-type)
and not(@category)]"/>
<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:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="'contentitem-default-list.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:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$template-map/content-item[@content-type = $content-type
and @category = $category]">
<xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="$template-map/content-item[@content-type = $content-type
and @category = $category]"/>
<xsl:with-param name="contentitem-tree"
select="$contentitem-tree"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$template-map/content-item[@content-type = $content-type
and not(@category)]">
<xsl:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="$template-map/content-item[@content-type = $content-type
and not(@category)]"/>
<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:call-template name="foundry:process-contentitem-template">
<xsl:with-param name="template-file"
select="'contentitemitem-default-list'"/>
<xsl:with-param name="contentitem-tree"
select="$contentitem-tree"/>
<xsl:with-param name="internal"
select="true()"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template> </xsl:template>
<xsl:template name="foundry:process-contentitem-template"> <xsl:template name="foundry:process-contentitem-template">
@ -363,7 +528,14 @@
<xsl:template match="content-item-layout//content-item-title"> <xsl:template match="content-item-layout//content-item-title">
<xsl:param name="contentitem-tree" tunnel="yes"/> <xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:value-of select="$contentitem-tree/title"/> <xsl:choose>
<xsl:when test="$contentitem-tree/title">
<xsl:value-of select="$contentitem-tree/title"/>
</xsl:when>
<xsl:when test="$contentitem-tree/nav:attribute[@name = 'title']">
<xsl:value-of select="$contentitem-tree/nav:attribute[@name = 'title']"/>
</xsl:when>
</xsl:choose>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -31,7 +31,14 @@
<xsl:template match="/content-item-layout//lead-text"> <xsl:template match="/content-item-layout//lead-text">
<xsl:param name="contentitem-tree" tunnel="yes"/> <xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:value-of select="$contentitem-tree/lead"/> <xsl:choose>
<xsl:when test="$contentitem-tree/lead">
<xsl:value-of select="$contentitem-tree/lead"/>
</xsl:when>
<xsl:when test="$contentitem-tree/nav:attribute[@name = 'lead']">
<xsl:value-of select="$contentitem-tree/nav:attribute[@name = 'lead']"/>
</xsl:when>
</xsl:choose>
</xsl:template> </xsl:template>
<xsl:template match="/content-item-layout//main-text"> <xsl:template match="/content-item-layout//main-text">

View File

@ -81,10 +81,10 @@
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<pre> <!---<pre>
<xsl:value-of select="concat('from = ', $from)"/> <xsl:value-of select="concat('from = ', $from)"/>
<xsl:value-of select="concat('; to = ', $to)"/> <xsl:value-of select="concat('; to = ', $to)"/>
</pre> </pre>-->
<xsl:for-each select="$contentitem-tree/imageAttachments[sortKey &gt;= $from and sortKey &lt;= $to]"> <xsl:for-each select="$contentitem-tree/imageAttachments[sortKey &gt;= $from and sortKey &lt;= $to]">

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE stylesheet [<!ENTITY nbsp '&#160;'>
<!ENTITY shy '&#173;'>]>
<!--
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:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:foundry="http://foundry.libreccm.org"
xmlns:nav="http://ccm.redhat.com/navigation"
xmlns:ui="http://www.arsdigita.com/ui/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl xs bebop foundry ui"
version="2.0">
<xsl:template match="object-list">
<xsl:variable name="object-list-id" select="./@id"/>
<xsl:if test="$data-tree//nav:simpleObjectList[@id = $object-list-id]
| $data-tree//nav:complexObjectList[@id = $object-list-id]
| $data-tree//nav:customizableObjectList[@id = $object-list-id]
| $data-tree//nav:atozObjectList[@id = $object-list-id]
| $data-tree//nav:filterObjectList[@id = $object-list-id]">
<xsl:variable name="object-list-datatree">
<xsl:choose>
<xsl:when test="$data-tree//nav:simpleObjectList[@id = $object-list-id]">
<xsl:copy-of select="$data-tree//nav:simpleObjectList[@id = $object-list-id]/*"/>
</xsl:when>
<xsl:when test="$data-tree//nav:complexObjectList[@id = $object-list-id]">
<xsl:copy-of select="$data-tree//nav:complexObjectList[@id = $object-list-id]/*"/>
</xsl:when>
<xsl:when test="$data-tree//nav:customizableObjectList[@id = $object-list-id]">
<xsl:copy-of select="$data-tree//nav:customizableObjectList[@id = $object-list-id]/*"/>
</xsl:when>
<xsl:when test="$data-tree//nav:atozObjectList[@id = $object-list-id]">
<xsl:copy-of select="$data-tree//nav:atozObjectList[@id = $object-list-id]/*"/>
</xsl:when>
<xsl:when test="$data-tree//nav:filterObjectList[@id = $object-list-id]">
<xsl:copy-of select="$data-tree//nav:filterObjectList[@id = $object-list-id]/*"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:apply-templates>
<xsl:with-param name="object-list-datatree"
tunnel="yes"
select="$object-list-datatree"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match="object-list//object-list-item">
<xsl:param name="object-list-datatree" tunnel="yes"/>
<!--<pre>Object-list-item</pre>
<pre>
<xsl:value-of select="concat('count(object-list-datatree) = ', count($object-list-datatree))"/>
</pre>
<pre>
<xsl:value-of select="concat('count(object-list-datatree/*) = ', count($object-list-datatree/*))"/>
</pre>
<pre>
<xsl:value-of select="concat('name(object-list-datatree/*[1]) = ', name($object-list-datatree/*[1]))"/>
</pre>
</xsl:template>-->
<xsl:variable name="object-list-item-layouttree" select="current()"/>
<xsl:for-each select="$object-list-datatree/nav:objectList/nav:item">
<xsl:apply-templates select="$object-list-item-layouttree/*">
<xsl:with-param name="contentitem-tree" tunnel="yes" select="current()"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View File

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

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<content-item-layout>
<div>
<show-property name="pageDescription"/>
</div>
</content-item-layout>

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

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<content-item-layout>
<h2>
<content-item-title/>
</h2>
<div class="lead">
<lead-text/>
</div>
</content-item-layout>

View File

@ -2,6 +2,5 @@
<content-item-layout> <content-item-layout>
<div> <div>
<show-property name="pageDescription"/> <show-property name="pageDescription"/>
</div> </div>
</content-item-layout> </content-item-layout>

View File

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

View File

@ -58,6 +58,28 @@
</image-attachment> </image-attachment>
</image-attachments> </image-attachments>
</div> </div>
<div id="item-list-wrapper">
<object-list id="itemList">
<ul>
<object-list-item>
<li>
<content-item mode="list"/>
</li>
</object-list-item>
</ul>
</object-list>
</div>
<div id="news-list-wrapper">
<object-list id="newsList">
<ul>
<object-list-item>
<li>
<pre>news-item</pre>
</li>
</object-list-item>
</ul>
</object-list>
</div>
</main> </main>
<aside> <aside>
<related-links> <related-links>