Moved the generation of the links to the sections of a MPA to Java code. The XML now provides a toc element containing the
links to all sections of the MPA the correct parameters. Foundry uses these informations now, with a fallback to the XSL based generation of the links which does not work in some cases. This commit should solve the issues #2366, #2354 and #2358. git-svn-id: https://svn.libreccm.org/ccm/trunk@3268 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
9259c8ec59
commit
70b7a5e4be
|
|
@ -51,6 +51,8 @@ public class ArticleSectionXMLGenerator implements ExtraXMLGenerator {
|
||||||
final Element content = element.newChildElement("cms:articleSectionPanel",
|
final Element content = element.newChildElement("cms:articleSectionPanel",
|
||||||
CMS.CMS_XML_NS);
|
CMS.CMS_XML_NS);
|
||||||
|
|
||||||
|
generateToc(item, content);
|
||||||
|
|
||||||
final XMLGenerator xmlGenerator = getXMLGenerator(state, item);
|
final XMLGenerator xmlGenerator = getXMLGenerator(state, item);
|
||||||
|
|
||||||
final ArticleSection sections[] = getSections(item, state);
|
final ArticleSection sections[] = getSections(item, state);
|
||||||
|
|
@ -89,6 +91,34 @@ public class ArticleSectionXMLGenerator implements ExtraXMLGenerator {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void generateToc(final ContentItem item, final Element parent) {
|
||||||
|
if (!(item instanceof MultiPartArticle)) {
|
||||||
|
throw new IllegalArgumentException("Item is not a MultiPartArticle");
|
||||||
|
}
|
||||||
|
|
||||||
|
final Element tocElem = parent.newChildElement("toc");
|
||||||
|
|
||||||
|
final MultiPartArticle mparticle = (MultiPartArticle) item;
|
||||||
|
final ArticleSectionCollection sections = mparticle.getSections();
|
||||||
|
int sectionNr = 1;
|
||||||
|
int pageNr = 1;
|
||||||
|
ArticleSection section;
|
||||||
|
Element sectionElem;
|
||||||
|
while(sections.next()) {
|
||||||
|
section = sections.getArticleSection();
|
||||||
|
sectionElem = tocElem.newChildElement("section");
|
||||||
|
sectionElem.setCDATASection(section.getTitle());
|
||||||
|
sectionElem.addAttribute("link", String.format("?page=%d#section-%d",
|
||||||
|
pageNr,
|
||||||
|
sectionNr));
|
||||||
|
sectionElem.addAttribute("rank", section.getRank().toString());
|
||||||
|
sectionNr++;
|
||||||
|
if (section.isPageBreak()) {
|
||||||
|
pageNr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void generateSectionXML(final PageState state,
|
protected void generateSectionXML(final PageState state,
|
||||||
final Element parent,
|
final Element parent,
|
||||||
final ContentItem section,
|
final ContentItem section,
|
||||||
|
|
|
||||||
|
|
@ -76,42 +76,56 @@
|
||||||
<xsl:variable name="number-of-pages"
|
<xsl:variable name="number-of-pages"
|
||||||
select="$contentitem-tree/cms:mpadata/numberOfPages"/>
|
select="$contentitem-tree/cms:mpadata/numberOfPages"/>
|
||||||
|
|
||||||
<xsl:for-each select="$contentitem-tree/sections">
|
<xsl:choose>
|
||||||
<xsl:sort select="./rank" data-type="number"/>
|
<xsl:when test="$contentitem-tree/cms:articleSectionPanel/toc">
|
||||||
|
<xsl:for-each select="$contentitem-tree/cms:articleSectionPanel/toc/section">
|
||||||
|
<xsl:apply-templates select="$section-layout-tree/*">
|
||||||
|
<xsl:with-param name="mpa-section-title" tunnel="yes" select="."/>
|
||||||
|
<xsl:with-param name="href" tunnel="yes" select="@link"/>
|
||||||
|
</xsl:apply-templates>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
|
||||||
<xsl:variable name="current-rank" select="./rank"/>
|
<xsl:for-each select="$contentitem-tree/sections">
|
||||||
<xsl:variable name="page-number"
|
<xsl:sort select="./rank" data-type="number"/>
|
||||||
|
|
||||||
|
<xsl:variable name="current-rank" select="./rank"/>
|
||||||
|
<xsl:variable name="page-number"
|
||||||
select="count($contentitem-tree/sections[./pageBreak = 'true'
|
select="count($contentitem-tree/sections[./pageBreak = 'true'
|
||||||
and ./rank < ($current-rank + 1)])"/>
|
and ./rank < ($current-rank + 1)])"/>
|
||||||
|
|
||||||
<xsl:apply-templates select="$section-layout-tree/*">
|
<xsl:apply-templates select="$section-layout-tree/*">
|
||||||
|
|
||||||
<xsl:with-param name="mpa-section-title" tunnel="yes" select="./title"/>
|
<xsl:with-param name="mpa-section-title" tunnel="yes" select="./title"/>
|
||||||
<xsl:with-param name="href" tunnel="yes">
|
<xsl:with-param name="href" tunnel="yes">
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="./pageBreak = 'true'
|
|
||||||
or ($page-number <= $number-of-pages)">
|
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$current-page = 'all'
|
<xsl:when test="./pageBreak = 'true'
|
||||||
|
or ($page-number <= $number-of-pages)">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$current-page = 'all'
|
||||||
or $page-number = $current-page">
|
or $page-number = $current-page">
|
||||||
<xsl:value-of select="concat('#section-', $current-rank)"/>
|
<xsl:value-of select="concat('#section-',
|
||||||
</xsl:when>
|
$current-rank)"/>
|
||||||
<xsl:otherwise>
|
</xsl:when>
|
||||||
<xsl:value-of select="concat('?page=',
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="concat('?page=',
|
||||||
$page-number,
|
$page-number,
|
||||||
'#section-',
|
'#section-',
|
||||||
$current-rank)"/>
|
$current-rank)"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="concat('#section-', $current-rank)"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
</xsl:with-param>
|
||||||
</xsl:when>
|
</xsl:apply-templates>
|
||||||
<xsl:otherwise>
|
</xsl:for-each>
|
||||||
<xsl:value-of select="concat('#section-', $current-rank)"/>
|
</xsl:otherwise>
|
||||||
</xsl:otherwise>
|
</xsl:choose>
|
||||||
</xsl:choose>
|
|
||||||
</xsl:with-param>
|
|
||||||
</xsl:apply-templates>
|
|
||||||
</xsl:for-each>
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<foundry:doc section="user" type="template-tag">
|
<foundry:doc section="user" type="template-tag">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue