MultiPartArticle lässt sich, unter Nutzung der Template mparticle-index.jsp (zuzuweisen unter navigation/admin) jetzt als IndexItem nutzen. Dafür waren einige
kleinere Änderungen in ArticleSectionPanel notwendig, unter anderem die Möglichkeit den anzuzeigenden MultiPartArticle von außen zu setzen. Das ist notwendig, da sich das Index-Item nicht über einen der im Modul MultiPartArticle verfügbaren Wege abfragen lässt. git-svn-id: https://svn.libreccm.org/ccm/trunk@622 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
3f78796a73
commit
d02a207bba
|
|
@ -25,6 +25,7 @@ import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
import com.arsdigita.cms.CMS;
|
import com.arsdigita.cms.CMS;
|
||||||
import com.arsdigita.cms.CMSContext;
|
import com.arsdigita.cms.CMSContext;
|
||||||
import com.arsdigita.cms.CMSExcursion;
|
import com.arsdigita.cms.CMSExcursion;
|
||||||
|
import com.arsdigita.cms.ContentBundle;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.cms.ExtraXMLGenerator;
|
import com.arsdigita.cms.ExtraXMLGenerator;
|
||||||
|
|
@ -33,6 +34,7 @@ import com.arsdigita.cms.contenttypes.ArticleSectionCollection;
|
||||||
import com.arsdigita.cms.contenttypes.MultiPartArticle;
|
import com.arsdigita.cms.contenttypes.MultiPartArticle;
|
||||||
import com.arsdigita.cms.dispatcher.XMLGenerator;
|
import com.arsdigita.cms.dispatcher.XMLGenerator;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import com.arsdigita.web.Web;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -52,13 +54,17 @@ import org.apache.log4j.Logger;
|
||||||
* @version $Revision: #7 $ $Date: 2004/08/17 $
|
* @version $Revision: #7 $ $Date: 2004/08/17 $
|
||||||
* @version $Id: ArticleSectionPanel.java 1167 2006-06-14 12:27:28Z fabrice $
|
* @version $Id: ArticleSectionPanel.java 1167 2006-06-14 12:27:28Z fabrice $
|
||||||
*/
|
*/
|
||||||
public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGenerator {
|
public class ArticleSectionPanel extends SimpleComponent implements
|
||||||
|
ExtraXMLGenerator {
|
||||||
private static final Logger s_log = Logger.getLogger(ArticleSectionPanel.class);
|
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
ArticleSectionPanel.class);
|
||||||
private PageParameter m_page;
|
private PageParameter m_page;
|
||||||
private boolean m_showAllSections = false;
|
private boolean m_showAllSections = false;
|
||||||
|
/**
|
||||||
|
* Variable for holding an injected item.
|
||||||
|
*/
|
||||||
|
private ContentItem m_item = null;
|
||||||
public static final String PAGE_NUMBER_PARAM = "page";
|
public static final String PAGE_NUMBER_PARAM = "page";
|
||||||
|
|
||||||
public ArticleSectionPanel() {
|
public ArticleSectionPanel() {
|
||||||
|
|
@ -94,7 +100,8 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
||||||
}
|
}
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Item id ; "+item.getOID()+" - "+item.getContentSection()+" - "+item);
|
s_log.debug("Item id ; " + item.getOID() + " - " + item.
|
||||||
|
getContentSection() + " - " + item);
|
||||||
}
|
}
|
||||||
section = item.getContentSection();
|
section = item.getContentSection();
|
||||||
CMS.getContext().setContentSection(section);
|
CMS.getContext().setContentSection(section);
|
||||||
|
|
@ -109,13 +116,46 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
||||||
protected ContentItem getContentItem(PageState state) {
|
protected ContentItem getContentItem(PageState state) {
|
||||||
CMSContext context = CMS.getContext();
|
CMSContext context = CMS.getContext();
|
||||||
|
|
||||||
|
if (m_item != null) {
|
||||||
|
return m_item;
|
||||||
|
}
|
||||||
|
|
||||||
if (!context.hasContentItem()) {
|
if (!context.hasContentItem()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return context.getContentItem();
|
return context.getContentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArticleSection[] getSections(ContentItem item, final PageState state) {
|
/**
|
||||||
|
* This method provides a way for injecting the item to show if the other
|
||||||
|
* ways for retrieving the item to show do not work. An example for this
|
||||||
|
* is the index/greeting item of a category.
|
||||||
|
*
|
||||||
|
* @param item The item to inject.
|
||||||
|
*/
|
||||||
|
public void setContentItem(ContentItem item) {
|
||||||
|
if (item instanceof ContentBundle) {
|
||||||
|
ContentBundle bundle;
|
||||||
|
HttpServletRequest request;
|
||||||
|
ContentItem resolved = null;
|
||||||
|
String lang;
|
||||||
|
|
||||||
|
bundle = (ContentBundle) item;
|
||||||
|
request = Web.getRequest();
|
||||||
|
|
||||||
|
if (request == null) {
|
||||||
|
resolved = bundle.getPrimaryInstance();
|
||||||
|
} else {
|
||||||
|
resolved = bundle.negotiate(request.getLocales());
|
||||||
|
}
|
||||||
|
m_item = resolved;
|
||||||
|
} else {
|
||||||
|
m_item = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArticleSection[] getSections(ContentItem item,
|
||||||
|
final PageState state) {
|
||||||
PageNumber number = null;
|
PageNumber number = null;
|
||||||
try {
|
try {
|
||||||
number = (PageNumber) state.getValue(m_page);
|
number = (PageNumber) state.getValue(m_page);
|
||||||
|
|
@ -177,7 +217,8 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
||||||
}
|
}
|
||||||
return new ArticleSection[]{};
|
return new ArticleSection[]{};
|
||||||
}
|
}
|
||||||
ArticleSection section = (ArticleSection)sections.getArticleSection();
|
ArticleSection section = (ArticleSection) sections.
|
||||||
|
getArticleSection();
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Skipping " + section.getOID());
|
s_log.debug("Skipping " + section.getOID());
|
||||||
}
|
}
|
||||||
|
|
@ -199,7 +240,8 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ArticleSection section = (ArticleSection)sections.getArticleSection();
|
ArticleSection section = (ArticleSection) sections.
|
||||||
|
getArticleSection();
|
||||||
page.add(section);
|
page.add(section);
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Keeping section " + section.getOID());
|
s_log.debug("Keeping section " + section.getOID());
|
||||||
|
|
@ -234,13 +276,12 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
||||||
final Element parent) {
|
final Element parent) {
|
||||||
ContentItem item = getContentItem(state);
|
ContentItem item = getContentItem(state);
|
||||||
|
|
||||||
if (!isVisible(state) || item == null ||
|
if (!isVisible(state) || item == null
|
||||||
!(item instanceof MultiPartArticle)) {
|
|| !(item instanceof MultiPartArticle)) {
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Skipping generate XML isVisible: " +
|
s_log.debug("Skipping generate XML isVisible: " + isVisible(
|
||||||
isVisible(state) +
|
state) + " item "
|
||||||
" item " +
|
+ (item == null ? null : item.getOID()));
|
||||||
(item == null ? null : item.getOID()));
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +298,8 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
||||||
@Override
|
@Override
|
||||||
public void generateXML(ContentItem item, Element element, PageState state) {
|
public void generateXML(ContentItem item, Element element, PageState state) {
|
||||||
|
|
||||||
Element content = element.newChildElement("cms:articleSectionPanel", CMS.CMS_XML_NS);
|
Element content = element.newChildElement("cms:articleSectionPanel",
|
||||||
|
CMS.CMS_XML_NS);
|
||||||
exportAttributes(content);
|
exportAttributes(content);
|
||||||
|
|
||||||
XMLGenerator xmlGenerator = getXMLGenerator(state, item);
|
XMLGenerator xmlGenerator = getXMLGenerator(state, item);
|
||||||
|
|
@ -276,6 +318,7 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
||||||
final ContentItem section,
|
final ContentItem section,
|
||||||
final XMLGenerator xmlGenerator) {
|
final XMLGenerator xmlGenerator) {
|
||||||
CMSExcursion excursion = new CMSExcursion() {
|
CMSExcursion excursion = new CMSExcursion() {
|
||||||
|
|
||||||
public void excurse() {
|
public void excurse() {
|
||||||
setContentItem(section);
|
setContentItem(section);
|
||||||
xmlGenerator.generateXML(state, parent, null);
|
xmlGenerator.generateXML(state, parent, null);
|
||||||
|
|
@ -341,15 +384,14 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
||||||
return new PageNumber(encoded);
|
return new PageNumber(encoded);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException(getName()
|
||||||
(getName() + " should be a BigDecimal: '" + encoded + "'");
|
+ " should be a BigDecimal: '"
|
||||||
|
+ encoded + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class getValueClass() {
|
public Class getValueClass() {
|
||||||
return PageNumber.class;
|
return PageNumber.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,8 @@ public class GreetingItem extends AbstractComponent {
|
||||||
ContentBundle bundle = (ContentBundle) item;
|
ContentBundle bundle = (ContentBundle) item;
|
||||||
|
|
||||||
/* Fix by Jens Pelzetter, 2009-08-28
|
/* Fix by Jens Pelzetter, 2009-08-28
|
||||||
* bundle.getPrimaryInstance() does not about the preferred languages
|
* bundle.getPrimaryInstance() does not care about the preferred
|
||||||
|
* languages
|
||||||
* of the User Client, instead it returns the primary instance of
|
* of the User Client, instead it returns the primary instance of
|
||||||
* a ContentItem (the first language created).
|
* a ContentItem (the first language created).
|
||||||
*
|
*
|
||||||
|
|
@ -137,4 +138,5 @@ public class GreetingItem extends AbstractComponent {
|
||||||
|
|
||||||
renderer.walk(item, SimpleXMLGenerator.ADAPTER_CONTEXT);
|
renderer.walk(item, SimpleXMLGenerator.ADAPTER_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -352,6 +352,12 @@ public class Loader extends PackageLoader {
|
||||||
+ "subdepartments",
|
+ "subdepartments",
|
||||||
"/packages/navigation/templates/SciDepartmentFinishedProjects.jsp");
|
"/packages/navigation/templates/SciDepartmentFinishedProjects.jsp");
|
||||||
|
|
||||||
|
template =
|
||||||
|
Template.create(
|
||||||
|
"MultiPartArticle as Index Item",
|
||||||
|
"Display a MultiPartArticle as index item",
|
||||||
|
"/packages/navigation/templates/mparticle-index.jsp");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
|
||||||
|
xmlns:define="/WEB-INF/bebop-define.tld"
|
||||||
|
xmlns:show="/WEB-INF/bebop-show.tld"
|
||||||
|
version="1.2">
|
||||||
|
|
||||||
|
<jsp:directive.page import="com.arsdigita.dispatcher.DispatcherHelper"/>
|
||||||
|
<jsp:directive.page import="com.arsdigita.bebop.parameters.BigDecimalParameter"/>
|
||||||
|
<jsp:directive.page import="com.arsdigita.london.navigation.Navigation"/>
|
||||||
|
<jsp:directive.page import="com.arsdigita.london.navigation.cms.CMSDataCollectionDefinition"/>
|
||||||
|
<jsp:directive.page import="com.arsdigita.london.navigation.cms.CMSDataCollectionRenderer"/>
|
||||||
|
|
||||||
|
<jsp:scriptlet>
|
||||||
|
long age = Navigation.getConfig().getIndexPageCacheLifetime();
|
||||||
|
if (age == 0) {
|
||||||
|
DispatcherHelper.cacheDisable(response);
|
||||||
|
} else {
|
||||||
|
DispatcherHelper.cacheForWorld(response, (int)age);
|
||||||
|
}
|
||||||
|
</jsp:scriptlet>
|
||||||
|
|
||||||
|
<define:page name="defaultItemPage" application="navigation"
|
||||||
|
title="Navigation" cache="true">
|
||||||
|
|
||||||
|
<define:component name="greetingItem"
|
||||||
|
classname="com.arsdigita.london.navigation.ui.GreetingItem"/>
|
||||||
|
<define:component name="sectionXML"
|
||||||
|
classname="com.arsdigita.cms.contenttypes.ui.mparticle.ArticleSectionPanel"/>
|
||||||
|
<jsp:scriptlet>
|
||||||
|
com.arsdigita.cms.ContentItem item = (com.arsdigita.cms.ContentItem)((com.arsdigita.london.navigation.ui.GreetingItem) greetingItem).getObject();
|
||||||
|
((com.arsdigita.cms.contenttypes.ui.mparticle.ArticleSectionPanel) sectionXML).setContentItem(item);
|
||||||
|
</jsp:scriptlet>
|
||||||
|
<define:component name="categoryPath"
|
||||||
|
classname="com.arsdigita.london.navigation.ui.category.Path"/>
|
||||||
|
<define:component name="categoryMenu"
|
||||||
|
classname="com.arsdigita.london.navigation.ui.category.Menu"/>
|
||||||
|
<define:component name="itemList"
|
||||||
|
classname="com.arsdigita.london.navigation.ui.object.SimpleObjectList"/>
|
||||||
|
<jsp:scriptlet>
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).setDefinition(new CMSDataCollectionDefinition());
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).setRenderer(new CMSDataCollectionRenderer());
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getDefinition().setObjectType("com.arsdigita.cms.ContentPage");
|
||||||
|
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getDefinition().setDescendCategories(false);
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getDefinition().addOrder("parent.categories.link.sortKey");
|
||||||
|
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().setPageSize(30);
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute("objectType");
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute("title");
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute( "definition");
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute( "summary");
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute( "lead");
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute( "description");
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute( "eventDate");
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute( "startDate" );
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute( "endDate");
|
||||||
|
((com.arsdigita.london.navigation.ui.object.SimpleObjectList) itemList).getRenderer().addAttribute( "newsDate");
|
||||||
|
</jsp:scriptlet>
|
||||||
|
|
||||||
|
<define:component name="assignedTerms"
|
||||||
|
classname="com.arsdigita.london.navigation.ui.CategoryIndexAssignedTerms"/>
|
||||||
|
|
||||||
|
</define:page>
|
||||||
|
<show:all/>
|
||||||
|
</jsp:root>
|
||||||
|
|
||||||
Loading…
Reference in New Issue