A navigation component for showing a specific content item
git-svn-id: https://svn.libreccm.org/ccm/trunk@5313 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
14ac96b687
commit
156aeb36e7
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.navigation.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ContentItemComponent extends GreetingItem {
|
||||||
|
|
||||||
|
private String contentItemOID;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ACSObject getObject() {
|
||||||
|
|
||||||
|
final DataObject dataObject = SessionManager
|
||||||
|
.getSession()
|
||||||
|
.retrieve(OID.valueOf(contentItemOID));
|
||||||
|
|
||||||
|
final ContentItem item = new ContentItem(dataObject);
|
||||||
|
if (item.isDraftVersion()) {
|
||||||
|
return (ContentItem) item.getLiveVersion().getParent();
|
||||||
|
} else {
|
||||||
|
return (ContentItem) item.getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getElementName() {
|
||||||
|
return "contentItem";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContentItemOID() {
|
||||||
|
return contentItemOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentItemOID(final String contentItemOID) {
|
||||||
|
this.contentItemOID = contentItemOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -61,8 +61,13 @@ public class GreetingItem extends AbstractComponent {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(GreetingItem.class);
|
private static final Logger s_log = Logger.getLogger(GreetingItem.class);
|
||||||
|
|
||||||
|
protected String getElementName() {
|
||||||
|
return "greetingItem";
|
||||||
|
}
|
||||||
|
|
||||||
public Element generateXML(HttpServletRequest request,
|
public Element generateXML(HttpServletRequest request,
|
||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
|
|
||||||
ContentItem item = (ContentItem) getObject();
|
ContentItem item = (ContentItem) getObject();
|
||||||
if (null == item || !item.isLive()) {
|
if (null == item || !item.isLive()) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -72,7 +77,7 @@ public class GreetingItem extends AbstractComponent {
|
||||||
item = item.getLiveVersion();
|
item = item.getLiveVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
Element content = Navigation.newElement("greetingItem");
|
Element content = Navigation.newElement(getElementName());
|
||||||
Party currentParty = Kernel.getContext().getParty();
|
Party currentParty = Kernel.getContext().getParty();
|
||||||
if (currentParty == null) {
|
if (currentParty == null) {
|
||||||
currentParty = Kernel.getPublicUser();
|
currentParty = Kernel.getPublicUser();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue