Incorporating TUV r1847/1848 - add PathInfo

git-svn-id: https://svn.libreccm.org/ccm/trunk@96 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2009-03-15 14:52:33 +00:00
parent 584e543e08
commit 9434792c52
1 changed files with 35 additions and 4 deletions

View File

@ -21,11 +21,13 @@ package com.arsdigita.cms.dispatcher;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentSectionServlet;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element;
/**
* <p>This <code>ContentPanel</code> component fetches
* the {@link com.arsdigita.cms.dispatcher.XMLGenerator} for the content
@ -36,7 +38,7 @@ import com.arsdigita.xml.Element;
*/
public class ContentPanel extends SimpleComponent {
public static final String versionId = "$Id: ContentPanel.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/17 23:15:09 $";
public static final String versionId = "$Id: ContentPanel.java 1848 2009-03-10 03:17:42Z terry $ by $Author: terry $, $DateTime: 2004/08/17 23:15:09 $";
public ContentPanel() {
super();
@ -52,7 +54,7 @@ public class ContentPanel extends SimpleComponent {
*/
protected XMLGenerator getXMLGenerator(PageState state) {
ContentSection section = CMS.getContext().getContentSection();
Assert.assertNotNull(section);
Assert.exists(section);
return section.getXMLGenerator();
}
@ -64,15 +66,44 @@ public class ContentPanel extends SimpleComponent {
* @see com.arsdigita.cms.dispatcher.XMLGenerator
*/
public void generateXML(PageState state, Element parent) {
if ( isVisible(state) ) {
if (isVisible(state)) {
Element content = parent.newChildElement("cms:contentPanel", CMS.CMS_XML_NS);
exportAttributes(content);
// Generate path information about the content item
generatePathInfoXML(state, content);
// Take advantage of caching in the CMS Dispatcher.
XMLGenerator xmlGenerator = getXMLGenerator(state);
xmlGenerator.generateXML(state, content, null);
}
}
/**
* Generate information about the path to this content item.
*
* @param state the page state
* @param parent the element that will contain the path info
*/
protected void generatePathInfoXML(PageState state, Element parent) {
Element pathInfo = parent.newChildElement("cms:pathInfo", CMS.CMS_XML_NS);
if (CMS.getContext().hasContentSection()) {
pathInfo.newChildElement("cms:sectionPath", CMS.CMS_XML_NS).setText(
CMS.getContext().getContentSection().getPath());
}
String url = DispatcherHelper.getRequestContext().getRemainingURLPart();
if (url.startsWith(CMSDispatcher.PREVIEW)) {
pathInfo.newChildElement("cms:previewPath", CMS.CMS_XML_NS).setText(ContentSectionServlet.PREVIEW);
}
pathInfo.newChildElement("cms:templatePrefix", CMS.CMS_XML_NS).setText(
"/" + AbstractItemResolver.TEMPLATE_CONTEXT_PREFIX);
if (CMS.getContext().hasContentItem()) {
ContentItem item = CMS.getContext().getContentItem();
ContentItem bundle = (ContentItem) item.getDraftVersion().getParent();
pathInfo.newChildElement("cms:itemPath", CMS.CMS_XML_NS).setText("/" + bundle.getPath());
}
}
}