From 7adb99fadde7df116e4bbbc8104dcfbd2cddeca1 Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 14 Sep 2011 09:02:16 +0000 Subject: [PATCH] =?UTF-8?q?Kleinere=20Verbesserungen=20an=20PublicPersonal?= =?UTF-8?q?Profile:=20-=20theme-Prefix=20und=20preview=20werden=20bei=20de?= =?UTF-8?q?r=20Erzeugung=20der=20Navigationslink=20beachtet=20-=20SelectBo?= =?UTF-8?q?x=20f=C3=BCr=20die=20Auswahl=20der=20Person=20beim=20Create-Ste?= =?UTF-8?q?p=20wird=20jetzt=20aktualisert=20(Ticket=20653)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@1118 8810af33-2d31-482b-a856-94f89814c4df --- ...ublicPersonalProfileExtraXmlGenerator.java | 6 +- .../PublicPersonalProfileXmlUtil.java | 33 ++- .../ui/PublicPersonalProfileCreate.java | 65 +++-- .../PublicPersonalProfilesServlet.java | 237 +++++++++--------- 4 files changed, 198 insertions(+), 143 deletions(-) diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileExtraXmlGenerator.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileExtraXmlGenerator.java index bbcc523bc..0e6040180 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileExtraXmlGenerator.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileExtraXmlGenerator.java @@ -38,7 +38,11 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator final Element navigation = element.newChildElement("profileNavigation"); final PublicPersonalProfileXmlUtil util = new PublicPersonalProfileXmlUtil(); - util.createNavigation(profile, navigation, showItem); + String prefix = DispatcherHelper.getDispatcherPrefix(state.getRequest()); + if (prefix == null) { + prefix = ""; + } + util.createNavigation(profile, navigation, showItem, prefix, "", false); if ((showItem != null) && !showItem.trim().isEmpty()) { final Element profileContent = element.newChildElement( diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileXmlUtil.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileXmlUtil.java index a01fbdcf9..9f73d5376 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileXmlUtil.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileXmlUtil.java @@ -21,8 +21,11 @@ public class PublicPersonalProfileXmlUtil { getConfig(); public void createNavigation(final PublicPersonalProfile profile, - final Element root, - final String navPath) { + final Element root, + final String navPath, + final String prefix, + final String appPath, + final boolean previewMode) { String homeLabelsStr = config.getHomeNavItemLabels(); Map homeLabels = new HashMap(); @@ -37,6 +40,13 @@ public class PublicPersonalProfileXmlUtil { continue; } } + + String appUrl = null; + if (previewMode) { + appUrl = String.format("%s/ccm%s/preview", prefix, appPath); + } else { + appUrl = String.format("%s/ccm%s", prefix, appPath); + } Element navRoot = root.newChildElement("nav:categoryMenu", @@ -52,8 +62,15 @@ public class PublicPersonalProfileXmlUtil { navList.addAttribute("isSelected", "true"); navList.addAttribute("sortKey", ""); navList.addAttribute("title", "publicPersonalProfileNavList"); - navList.addAttribute("url", String.format("/ccm/%s", - profile.getProfileUrl())); + if (previewMode) { + navList.addAttribute("url", String.format("%s/%s", + appUrl, + profile.getProfileUrl())); + } else { + navList.addAttribute("url", String.format("%s/%s", + appUrl, + profile.getProfileUrl())); + } Element navHome = navList.newChildElement("nav:category", @@ -74,7 +91,8 @@ public class PublicPersonalProfileXmlUtil { } else { navHome.addAttribute("title", homeLabel); } - navHome.addAttribute("url", String.format("/ccm/profiles/%s", + navHome.addAttribute("url", String.format("%s/%s", + appUrl, profile.getProfileUrl())); //Get the available Navigation items @@ -126,10 +144,11 @@ public class PublicPersonalProfileXmlUtil { } else { navElem.addAttribute("title", navItem.getLabel()); } - navElem.addAttribute("url", String.format("/ccm/profiles/%s/%s", + navElem.addAttribute("url", String.format("%s/%s/%s", + appUrl, profile.getProfileUrl(), navLinkKey)); - + navElem.addAttribute("navItem", navLinkKey); } diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/PublicPersonalProfileCreate.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/PublicPersonalProfileCreate.java index 10be78747..6dce49521 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/PublicPersonalProfileCreate.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/PublicPersonalProfileCreate.java @@ -5,9 +5,11 @@ import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.parameters.DateParameter; import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.ParameterModel; @@ -32,8 +34,10 @@ import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.SessionManager; import com.arsdigita.util.Assert; +import com.arsdigita.util.UncheckedWrapperException; import java.math.BigDecimal; import java.util.Date; +import java.util.TooManyListenersException; /** * @@ -75,28 +79,47 @@ public class PublicPersonalProfileCreate extends PageCreate { SingleSelect ownerSelect = new SingleSelect(ownerModel); ownerSelect.addValidationListener(new NotNullValidationListener()); - String personType = config.getPersonType(); - if ((personType == null) || (personType.isEmpty())) { - personType = "com.arsdigita.cms.contenttypes.GenericPerson"; + try { + ownerSelect.addPrintListener(new PrintListener() { + + public void prepare(final PrintEvent event) { + final SingleSelect ownerSelect = (SingleSelect) event. + getTarget(); + + String personType = config.getPersonType(); + if ((personType == null) || (personType.isEmpty())) { + personType = + "com.arsdigita.cms.contenttypes.GenericPerson"; + } + + ContentTypeCollection types = + ContentType.getAllContentTypes(); + types.addFilter( + String.format("className = '%s'", personType)); + if (types.size() == 0) { + personType = + "com.arsdigita.cms.contenttypes.GenericPerson"; + } + DataCollection persons = SessionManager.getSession(). + retrieve( + personType); + persons.addFilter("profile is null"); + persons.addFilter(String.format("version = '%s'", + ContentItem.DRAFT)); + ownerSelect.addOption(new Option("", "")); + while (persons.next()) { + GenericPerson person = + (GenericPerson) DomainObjectFactory. + newInstance(persons.getDataObject()); + ownerSelect.addOption(new Option( + person.getID().toString(), person.getFullName())); + } + } + }); + } catch (TooManyListenersException ex) { + throw new UncheckedWrapperException(ex); } - ContentTypeCollection types = ContentType.getAllContentTypes(); - types.addFilter(String.format("className = '%s'", personType)); - if (types.size() == 0) { - personType = "com.arsdigita.cms.contenttypes.GenericPerson"; - } - DataCollection persons = SessionManager.getSession().retrieve( - personType); - persons.addFilter("profile is null"); - persons.addFilter(String.format("version = '%s'", ContentItem.DRAFT)); - ownerSelect.addOption(new Option("", "")); - while (persons.next()) { - GenericPerson person = - (GenericPerson) DomainObjectFactory.newInstance(persons. - getDataObject()); - ownerSelect.addOption(new Option(person.getID().toString(), person. - getFullName())); - } add(ownerSelect); if (!ContentSection.getConfig().getHideLaunchDate()) { @@ -199,7 +222,7 @@ public class PublicPersonalProfileCreate extends PageCreate { profiles.addFilter( String.format("version = '%s'", ContentItem.DRAFT)); } - + return profileUrl; } } diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java index 931dc06e1..02fe34adb 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java @@ -179,9 +179,19 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet { Element profileOwnerName = profileElem.newChildElement( "ppp:ownerName", PPP_NS); profileOwnerName.setText(owner.getFullName()); - - final PublicPersonalProfileXmlUtil util = new PublicPersonalProfileXmlUtil(); - util.createNavigation(profile, root, navPath); + + final PublicPersonalProfileXmlUtil util = + new PublicPersonalProfileXmlUtil(); + String prefix = DispatcherHelper.getDispatcherPrefix(request); + if (prefix == null) { + prefix = ""; + } + util.createNavigation(profile, + root, + navPath, + prefix, + app.getPath(), + preview); if (navPath == null) { final PublicPersonalProfileXmlGenerator generator = @@ -294,118 +304,117 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet { } /*private void createNavigation(final PublicPersonalProfile profile, - final Element root, - final String navPath) { - String homeLabelsStr = config.getHomeNavItemLabels(); - - Map homeLabels = new HashMap(); - 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"); - navRoot.addAttribute("id", "categoryMenu"); - - Element navList = - navRoot.newChildElement("nav:category", - "http://ccm.redhat.com/london/navigation"); - navList.addAttribute("AbstractTree", "AbstractTree"); - navList.addAttribute("description", ""); - navList.addAttribute("id", ""); - navList.addAttribute("isSelected", "true"); - navList.addAttribute("sortKey", ""); - navList.addAttribute("title", "publicPersonalProfileNavList"); - navList.addAttribute("url", String.format("/ccm/%s", - profile.getProfileUrl())); - - Element navHome = - navList.newChildElement("nav:category", - "http://ccm.redhat.com/london/navigation"); - navHome.addAttribute("AbstractTree", "AbstractTree"); - navHome.addAttribute("description", ""); - navHome.addAttribute("id", profile.getID().toString()); - if (navPath == null) { - navHome.addAttribute("isSelected", "true"); - } else { - navHome.addAttribute("isSelected", "false"); - } - navHome.addAttribute("sortKey", ""); - 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/profiles/%s", - profile.getProfileUrl())); - - //Get the available Navigation items - PublicPersonalProfileNavItemCollection navItems = - new PublicPersonalProfileNavItemCollection(); - navItems.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). - getLanguage()); - final Map navItemMap = - new HashMap(); - 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)); - - } + final Element root, + final String navPath) { + String homeLabelsStr = config.getHomeNavItemLabels(); + + Map homeLabels = new HashMap(); + 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"); + navRoot.addAttribute("id", "categoryMenu"); + + Element navList = + navRoot.newChildElement("nav:category", + "http://ccm.redhat.com/london/navigation"); + navList.addAttribute("AbstractTree", "AbstractTree"); + navList.addAttribute("description", ""); + navList.addAttribute("id", ""); + navList.addAttribute("isSelected", "true"); + navList.addAttribute("sortKey", ""); + navList.addAttribute("title", "publicPersonalProfileNavList"); + navList.addAttribute("url", String.format("/ccm/%s", + profile.getProfileUrl())); + + Element navHome = + navList.newChildElement("nav:category", + "http://ccm.redhat.com/london/navigation"); + navHome.addAttribute("AbstractTree", "AbstractTree"); + navHome.addAttribute("description", ""); + navHome.addAttribute("id", profile.getID().toString()); + if (navPath == null) { + navHome.addAttribute("isSelected", "true"); + } else { + navHome.addAttribute("isSelected", "false"); + } + navHome.addAttribute("sortKey", ""); + 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/profiles/%s", + profile.getProfileUrl())); + + //Get the available Navigation items + PublicPersonalProfileNavItemCollection navItems = + new PublicPersonalProfileNavItemCollection(); + navItems.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). + getLanguage()); + final Map navItemMap = + new HashMap(); + 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)); + + } }*/ - private void generateProfileOwnerXml(final Element profileElem, final GenericPerson owner, final PageState state) {