PublicPersonalProfile: Navigation funktionsfähig, inkl. Anzeige der verknüpften Content-Items
git-svn-id: https://svn.libreccm.org/ccm/trunk@1054 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
2474aab6dd
commit
375fa32580
|
|
@ -2,4 +2,6 @@
|
|||
<registry>
|
||||
<config class="com.arsdigita.cms.contenttypes.PublicPersonalProfileConfig"
|
||||
storage="ccm-cms-publicpersonalprofile/profile.properties"/>
|
||||
<config class="com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig"
|
||||
storage="ccm-cms-publicpersonalprofile/navigation.properties"/>
|
||||
</registry>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.runtime.AbstractConfig;
|
||||
import com.arsdigita.util.parameter.Parameter;
|
||||
import com.arsdigita.util.parameter.StringParameter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfileConfig extends AbstractConfig {
|
||||
|
||||
private final Parameter homeNavItemLabels;
|
||||
|
||||
public PublicPersonalProfileConfig() {
|
||||
homeNavItemLabels = new StringParameter(
|
||||
"com.arsdigita.cms.publicpersonalprofile.navitem.home.labels",
|
||||
Parameter.REQUIRED,
|
||||
"en:Home, de:Allgemein");
|
||||
|
||||
register(homeNavItemLabels);
|
||||
|
||||
loadInfo();
|
||||
}
|
||||
|
||||
public final String getHomeNavItemLabels() {
|
||||
return (String) get(homeNavItemLabels);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.title = The labels for the home link of a profile
|
||||
com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.purpose = The labels for the home link of a profile
|
||||
com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.example = en:Home,de:Start
|
||||
com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.format = [String]
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfileXmlGenerator extends SimpleXMLGenerator {
|
||||
|
||||
private ContentItem item;
|
||||
|
||||
public PublicPersonalProfileXmlGenerator(final ContentItem item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentItem getContentItem(final PageState state) {
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,6 +15,12 @@ public class PublicPersonalProfiles extends Application {
|
|||
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfile";
|
||||
private static PublicPersonalProfileConfig config =
|
||||
new PublicPersonalProfileConfig();
|
||||
|
||||
static {
|
||||
config.load();
|
||||
}
|
||||
|
||||
public PublicPersonalProfiles(final DataObject dobj) {
|
||||
super(dobj);
|
||||
|
|
@ -30,6 +36,10 @@ public class PublicPersonalProfiles extends Application {
|
|||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public static PublicPersonalProfileConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletPath() {
|
||||
return "/profiles/";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||
import com.arsdigita.db.DbHelper;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
|
|
@ -34,13 +35,13 @@ public class PublicPersonalProfilesInitializer extends CompoundInitializer {
|
|||
|
||||
DomainObjectFactory.registerInstantiator(
|
||||
PublicPersonalProfiles.BASE_DATA_OBJECT_TYPE,
|
||||
new ACSObjectInstantiator() {
|
||||
new ACSObjectInstantiator() {
|
||||
|
||||
@Override
|
||||
public DomainObject doNewInstance(
|
||||
final DataObject dataObject) {
|
||||
return new PublicPersonalProfiles(dataObject);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public DomainObject doNewInstance(
|
||||
final DataObject dataObject) {
|
||||
return new PublicPersonalProfiles(dataObject);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.kernel.ACSObjectInstantiator;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
|
|
@ -73,9 +74,9 @@ public class PublicPersonalProfilesLoader extends PackageLoader {
|
|||
|
||||
Application.createApplication(
|
||||
PublicPersonalProfiles.BASE_DATA_OBJECT_TYPE,
|
||||
"profiles",
|
||||
"PublicPersonalProfiles",
|
||||
null);
|
||||
"profiles",
|
||||
"PublicPersonalProfiles",
|
||||
null);
|
||||
}
|
||||
}.run();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,15 @@ package com.arsdigita.cms.publicpersonalprofile;
|
|||
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageFactory;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.contentassets.RelatedLink;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.Link;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.Session;
|
||||
|
|
@ -16,6 +22,8 @@ import com.arsdigita.web.BaseApplicationServlet;
|
|||
import com.arsdigita.xml.Document;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
@ -82,7 +90,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
Label label;*/
|
||||
|
||||
page = PageFactory.buildPage("PublicPersonalProfile",
|
||||
"Hello World from profiles");
|
||||
"");
|
||||
/*form = new Form("HelloWorld");*/
|
||||
|
||||
if (pathTokens.length < 1) {
|
||||
|
|
@ -157,7 +165,33 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
}
|
||||
profileElem.setText(owner.getFullName());
|
||||
|
||||
createNavigation(profile, root);
|
||||
createNavigation(profile, root, navPath);
|
||||
|
||||
if (navPath == null) {
|
||||
//ToDo: Show start page.
|
||||
} else {
|
||||
final DataCollection links =
|
||||
RelatedLink.getRelatedLinks(profile,
|
||||
PublicPersonalProfile.LINK_LIST_NAME);
|
||||
links.addFilter(String.format("linkTitle = '%s'", navPath));
|
||||
|
||||
if (links.size() == 0) {
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
} else {
|
||||
links.next();
|
||||
final RelatedLink link =
|
||||
(RelatedLink) DomainObjectFactory.
|
||||
newInstance(links.getDataObject());
|
||||
final ContentItem item = link.getTargetItem();
|
||||
final PublicPersonalProfileXmlGenerator generator =
|
||||
new PublicPersonalProfileXmlGenerator(
|
||||
item);
|
||||
generator.generateXML(new PageState(page, request,
|
||||
response),
|
||||
root, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -171,7 +205,25 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
}
|
||||
|
||||
private void createNavigation(final PublicPersonalProfile profile,
|
||||
final Element root) {
|
||||
final Element root,
|
||||
final String navPath) {
|
||||
PublicPersonalProfileConfig config = PublicPersonalProfiles.getConfig();
|
||||
|
||||
String homeLabelsStr = config.getHomeNavItemLabels();
|
||||
|
||||
Map<String, String> homeLabels = new HashMap<String, String>();
|
||||
String[] homeLabelsArry = homeLabelsStr.split(",");
|
||||
String[] homeLabelSplit;
|
||||
for (String homeLabelEntry : homeLabelsArry) {
|
||||
homeLabelSplit = homeLabelEntry.split(":");
|
||||
if (homeLabelSplit.length == 2) {
|
||||
homeLabels.put(homeLabelSplit[0].trim(),
|
||||
homeLabelSplit[1].trim());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Element navRoot =
|
||||
root.newChildElement("nav:categoryMenu",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
|
|
@ -195,11 +247,77 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
navHome.addAttribute("AbstractTree", "AbstractTree");
|
||||
navHome.addAttribute("description", "");
|
||||
navHome.addAttribute("id", profile.getID().toString());
|
||||
navHome.addAttribute("isSelected", "true");
|
||||
if (navPath == null) {
|
||||
navHome.addAttribute("isSelected", "true");
|
||||
} else {
|
||||
navHome.addAttribute("isSelected", "false");
|
||||
}
|
||||
navHome.addAttribute("sortKey", "");
|
||||
navHome.addAttribute("title", "Allgemein");
|
||||
String homeLabel = homeLabels.get(DispatcherHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
if (homeLabel == null) {
|
||||
navHome.addAttribute("title", "Home");
|
||||
} else {
|
||||
navHome.addAttribute("title", homeLabel);
|
||||
}
|
||||
navHome.addAttribute("url", String.format("/ccm/%s",
|
||||
profile.getProfileUrl()));
|
||||
|
||||
//Get the available Navigation items
|
||||
PublicPersonalProfileNavItemCollection navItems =
|
||||
new PublicPersonalProfileNavItemCollection();
|
||||
navItems.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
final Map<String, PublicPersonalProfileNavItem> navItemMap =
|
||||
new HashMap<String, PublicPersonalProfileNavItem>();
|
||||
PublicPersonalProfileNavItem navItem;
|
||||
while (navItems.next()) {
|
||||
navItem = navItems.getNavItem();
|
||||
navItemMap.put(navItem.getKey(), navItem);
|
||||
}
|
||||
|
||||
//Get the related links of the profiles
|
||||
DataCollection links =
|
||||
RelatedLink.getRelatedLinks(profile,
|
||||
PublicPersonalProfile.LINK_LIST_NAME);
|
||||
links.addOrder(Link.ORDER);
|
||||
RelatedLink link;
|
||||
String navLinkKey;
|
||||
Element navElem;
|
||||
while (links.next()) {
|
||||
link = (RelatedLink) DomainObjectFactory.newInstance(links.
|
||||
getDataObject());
|
||||
|
||||
navLinkKey = link.getTitle();
|
||||
navItem = navItemMap.get(navLinkKey);
|
||||
|
||||
if (navItem == null) {
|
||||
//ToDo
|
||||
}
|
||||
|
||||
navElem =
|
||||
navList.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/london/navigation");
|
||||
navElem.addAttribute("AbstractTree", "AbstractTree");
|
||||
navElem.addAttribute("description", "");
|
||||
//navHome.addAttribute("id", "");
|
||||
if ((navPath != null) && navPath.equals(navLinkKey)) {
|
||||
navElem.addAttribute("isSelected", "true");
|
||||
} else {
|
||||
navElem.addAttribute("isSelected", "false");
|
||||
}
|
||||
navElem.addAttribute("sortKey", "");
|
||||
if (navItem == null) {
|
||||
navElem.addAttribute("title", navLinkKey);
|
||||
} else {
|
||||
navElem.addAttribute("title", navItem.getLabel());
|
||||
}
|
||||
navElem.addAttribute("url", String.format("/ccm/profiles/%s/%s",
|
||||
profile.getProfileUrl(),
|
||||
navLinkKey));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
|
||||
<servlet>
|
||||
<servlet-name>PublicPersonalProfiles</servlet-name>
|
||||
<servlet-class>com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfilesServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>PublicPersonalProfiles</servlet-name>
|
||||
<url-pattern>/profiles/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
|
||||
<xsl:import href="../../../../packages/bebop/xsl/bebop.xsl"/>
|
||||
<xsl:import href="../../../../packages/ui/xsl/ui.xsl"/>
|
||||
<xsl:import href="../../../../packages/content-section/xsl/cms-public.xsl"/>
|
||||
<xsl:import href="../../../../packages/content-section/xsl/cms-item.xsl"/>
|
||||
|
||||
<xsl:import href="../../../../packages/content-section/xsl/cms-item.xsl"/>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8?>
|
||||
<xsl:stylesheet
|
||||
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
|
||||
<!-- <xsl:import href="../../../packages/bebop/xsl/bebop.xsl"/>
|
||||
<xsl:import href="../../../packages/ui/xsl/ui.xsl"/>-->
|
||||
</xsl:stylesheet>
|
||||
Loading…
Reference in New Issue