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.CMSContext;
|
||||
import com.arsdigita.cms.CMSExcursion;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
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.dispatcher.XMLGenerator;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import com.arsdigita.web.Web;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -52,13 +54,17 @@ import org.apache.log4j.Logger;
|
|||
* @version $Revision: #7 $ $Date: 2004/08/17 $
|
||||
* @version $Id: ArticleSectionPanel.java 1167 2006-06-14 12:27:28Z fabrice $
|
||||
*/
|
||||
public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGenerator {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(ArticleSectionPanel.class);
|
||||
public class ArticleSectionPanel extends SimpleComponent implements
|
||||
ExtraXMLGenerator {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
ArticleSectionPanel.class);
|
||||
private PageParameter m_page;
|
||||
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 ArticleSectionPanel() {
|
||||
|
|
@ -94,7 +100,8 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
}
|
||||
if (section == null) {
|
||||
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();
|
||||
CMS.getContext().setContentSection(section);
|
||||
|
|
@ -109,13 +116,46 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
protected ContentItem getContentItem(PageState state) {
|
||||
CMSContext context = CMS.getContext();
|
||||
|
||||
if (m_item != null) {
|
||||
return m_item;
|
||||
}
|
||||
|
||||
if (!context.hasContentItem()) {
|
||||
return null;
|
||||
}
|
||||
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;
|
||||
try {
|
||||
number = (PageNumber) state.getValue(m_page);
|
||||
|
|
@ -144,10 +184,10 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("No page number provided");
|
||||
}
|
||||
ArticleSection[] page = new ArticleSection[(int)sections.size()];
|
||||
ArticleSection[] page = new ArticleSection[(int) sections.size()];
|
||||
int i = 0;
|
||||
while (sections.next()) {
|
||||
page[i] = (ArticleSection)sections.getArticleSection();
|
||||
page[i] = (ArticleSection) sections.getArticleSection();
|
||||
i++;
|
||||
}
|
||||
return page;
|
||||
|
|
@ -175,9 +215,10 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Hit end of section list");
|
||||
}
|
||||
return new ArticleSection[] {};
|
||||
return new ArticleSection[]{};
|
||||
}
|
||||
ArticleSection section = (ArticleSection)sections.getArticleSection();
|
||||
ArticleSection section = (ArticleSection) sections.
|
||||
getArticleSection();
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Skipping " + section.getOID());
|
||||
}
|
||||
|
|
@ -199,7 +240,8 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
}
|
||||
break;
|
||||
}
|
||||
ArticleSection section = (ArticleSection)sections.getArticleSection();
|
||||
ArticleSection section = (ArticleSection) sections.
|
||||
getArticleSection();
|
||||
page.add(section);
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Keeping section " + section.getOID());
|
||||
|
|
@ -219,7 +261,7 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
s_log.debug("All done " + page.size() + " sections found");
|
||||
}
|
||||
|
||||
return (ArticleSection[])page.toArray(new ArticleSection[page.size()]);
|
||||
return (ArticleSection[]) page.toArray(new ArticleSection[page.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -234,13 +276,12 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
final Element parent) {
|
||||
ContentItem item = getContentItem(state);
|
||||
|
||||
if (!isVisible(state) || item == null ||
|
||||
!(item instanceof MultiPartArticle)) {
|
||||
if (!isVisible(state) || item == null
|
||||
|| !(item instanceof MultiPartArticle)) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Skipping generate XML isVisible: " +
|
||||
isVisible(state) +
|
||||
" item " +
|
||||
(item == null ? null : item.getOID()));
|
||||
s_log.debug("Skipping generate XML isVisible: " + isVisible(
|
||||
state) + " item "
|
||||
+ (item == null ? null : item.getOID()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -257,13 +298,14 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
@Override
|
||||
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);
|
||||
|
||||
XMLGenerator xmlGenerator = getXMLGenerator(state, item);
|
||||
|
||||
ArticleSection sections[] = getSections(item, state);
|
||||
for (int i= 0 ; i < sections.length ; i++) {
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
generateSectionXML(state,
|
||||
content,
|
||||
sections[i],
|
||||
|
|
@ -276,11 +318,12 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
final ContentItem section,
|
||||
final XMLGenerator xmlGenerator) {
|
||||
CMSExcursion excursion = new CMSExcursion() {
|
||||
public void excurse() {
|
||||
setContentItem(section);
|
||||
xmlGenerator.generateXML(state, parent, null);
|
||||
}
|
||||
};
|
||||
|
||||
public void excurse() {
|
||||
setContentItem(section);
|
||||
xmlGenerator.generateXML(state, parent, null);
|
||||
}
|
||||
};
|
||||
try {
|
||||
excursion.run();
|
||||
} catch (ServletException ex) {
|
||||
|
|
@ -298,7 +341,7 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
private Integer m_number;
|
||||
|
||||
public PageNumber(String number)
|
||||
throws NumberFormatException {
|
||||
throws NumberFormatException {
|
||||
|
||||
if ("all".equals(number.toLowerCase())) {
|
||||
m_all = true;
|
||||
|
|
@ -327,12 +370,12 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
}
|
||||
|
||||
public Object transformValue(HttpServletRequest request)
|
||||
throws IllegalArgumentException {
|
||||
throws IllegalArgumentException {
|
||||
return transformSingleValue(request);
|
||||
}
|
||||
|
||||
public Object unmarshal(String encoded)
|
||||
throws IllegalArgumentException {
|
||||
throws IllegalArgumentException {
|
||||
|
||||
if (encoded == null || encoded.length() == 0) {
|
||||
return null;
|
||||
|
|
@ -341,15 +384,14 @@ public class ArticleSectionPanel extends SimpleComponent implements ExtraXMLGene
|
|||
return new PageNumber(encoded);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalArgumentException
|
||||
(getName() + " should be a BigDecimal: '" + encoded + "'");
|
||||
throw new IllegalArgumentException(getName()
|
||||
+ " should be a BigDecimal: '"
|
||||
+ encoded + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public Class getValueClass() {
|
||||
return PageNumber.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ public class GreetingItem extends AbstractComponent {
|
|||
ContentBundle bundle = (ContentBundle) item;
|
||||
|
||||
/* 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
|
||||
* a ContentItem (the first language created).
|
||||
*
|
||||
|
|
@ -137,4 +138,5 @@ public class GreetingItem extends AbstractComponent {
|
|||
|
||||
renderer.walk(item, SimpleXMLGenerator.ADAPTER_CONTEXT);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,6 +352,12 @@ public class Loader extends PackageLoader {
|
|||
+ "subdepartments",
|
||||
"/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