Kleinere Verbesserungen an PublicPersonalProfile:

- theme-Prefix und preview werden bei der Erzeugung der Navigationslink beachtet
- SelectBox für die Auswahl der Person beim Create-Step wird jetzt aktualisert (Ticket 653)


git-svn-id: https://svn.libreccm.org/ccm/trunk@1118 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-09-14 09:02:16 +00:00
parent d0a7b174b5
commit 7adb99fadd
4 changed files with 198 additions and 143 deletions

View File

@ -38,7 +38,11 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
final Element navigation = element.newChildElement("profileNavigation"); final Element navigation = element.newChildElement("profileNavigation");
final PublicPersonalProfileXmlUtil util = final PublicPersonalProfileXmlUtil util =
new PublicPersonalProfileXmlUtil(); 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()) { if ((showItem != null) && !showItem.trim().isEmpty()) {
final Element profileContent = element.newChildElement( final Element profileContent = element.newChildElement(

View File

@ -21,8 +21,11 @@ public class PublicPersonalProfileXmlUtil {
getConfig(); getConfig();
public void createNavigation(final PublicPersonalProfile profile, public void createNavigation(final PublicPersonalProfile profile,
final Element root, final Element root,
final String navPath) { final String navPath,
final String prefix,
final String appPath,
final boolean previewMode) {
String homeLabelsStr = config.getHomeNavItemLabels(); String homeLabelsStr = config.getHomeNavItemLabels();
Map<String, String> homeLabels = new HashMap<String, String>(); Map<String, String> homeLabels = new HashMap<String, String>();
@ -37,6 +40,13 @@ public class PublicPersonalProfileXmlUtil {
continue; 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 = Element navRoot =
root.newChildElement("nav:categoryMenu", root.newChildElement("nav:categoryMenu",
@ -52,8 +62,15 @@ public class PublicPersonalProfileXmlUtil {
navList.addAttribute("isSelected", "true"); navList.addAttribute("isSelected", "true");
navList.addAttribute("sortKey", ""); navList.addAttribute("sortKey", "");
navList.addAttribute("title", "publicPersonalProfileNavList"); navList.addAttribute("title", "publicPersonalProfileNavList");
navList.addAttribute("url", String.format("/ccm/%s", if (previewMode) {
profile.getProfileUrl())); navList.addAttribute("url", String.format("%s/%s",
appUrl,
profile.getProfileUrl()));
} else {
navList.addAttribute("url", String.format("%s/%s",
appUrl,
profile.getProfileUrl()));
}
Element navHome = Element navHome =
navList.newChildElement("nav:category", navList.newChildElement("nav:category",
@ -74,7 +91,8 @@ public class PublicPersonalProfileXmlUtil {
} else { } else {
navHome.addAttribute("title", homeLabel); navHome.addAttribute("title", homeLabel);
} }
navHome.addAttribute("url", String.format("/ccm/profiles/%s", navHome.addAttribute("url", String.format("%s/%s",
appUrl,
profile.getProfileUrl())); profile.getProfileUrl()));
//Get the available Navigation items //Get the available Navigation items
@ -126,10 +144,11 @@ public class PublicPersonalProfileXmlUtil {
} else { } else {
navElem.addAttribute("title", navItem.getLabel()); 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(), profile.getProfileUrl(),
navLinkKey)); navLinkKey));
navElem.addAttribute("navItem", navLinkKey); navElem.addAttribute("navItem", navLinkKey);
} }

View File

@ -5,9 +5,11 @@ import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.parameters.DateParameter; import com.arsdigita.bebop.parameters.DateParameter;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
@ -32,8 +34,10 @@ import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.TooManyListenersException;
/** /**
* *
@ -75,28 +79,47 @@ public class PublicPersonalProfileCreate extends PageCreate {
SingleSelect ownerSelect = new SingleSelect(ownerModel); SingleSelect ownerSelect = new SingleSelect(ownerModel);
ownerSelect.addValidationListener(new NotNullValidationListener()); ownerSelect.addValidationListener(new NotNullValidationListener());
String personType = config.getPersonType(); try {
if ((personType == null) || (personType.isEmpty())) { ownerSelect.addPrintListener(new PrintListener() {
personType = "com.arsdigita.cms.contenttypes.GenericPerson";
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); add(ownerSelect);
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
@ -199,7 +222,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
profiles.addFilter( profiles.addFilter(
String.format("version = '%s'", ContentItem.DRAFT)); String.format("version = '%s'", ContentItem.DRAFT));
} }
return profileUrl; return profileUrl;
} }
} }

View File

@ -179,9 +179,19 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
Element profileOwnerName = profileElem.newChildElement( Element profileOwnerName = profileElem.newChildElement(
"ppp:ownerName", PPP_NS); "ppp:ownerName", PPP_NS);
profileOwnerName.setText(owner.getFullName()); profileOwnerName.setText(owner.getFullName());
final PublicPersonalProfileXmlUtil util = new PublicPersonalProfileXmlUtil(); final PublicPersonalProfileXmlUtil util =
util.createNavigation(profile, root, navPath); new PublicPersonalProfileXmlUtil();
String prefix = DispatcherHelper.getDispatcherPrefix(request);
if (prefix == null) {
prefix = "";
}
util.createNavigation(profile,
root,
navPath,
prefix,
app.getPath(),
preview);
if (navPath == null) { if (navPath == null) {
final PublicPersonalProfileXmlGenerator generator = final PublicPersonalProfileXmlGenerator generator =
@ -294,118 +304,117 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
} }
/*private void createNavigation(final PublicPersonalProfile profile, /*private void createNavigation(final PublicPersonalProfile profile,
final Element root, final Element root,
final String navPath) { final String navPath) {
String homeLabelsStr = config.getHomeNavItemLabels(); String homeLabelsStr = config.getHomeNavItemLabels();
Map<String, String> homeLabels = new HashMap<String, String>(); Map<String, String> homeLabels = new HashMap<String, String>();
String[] homeLabelsArry = homeLabelsStr.split(","); String[] homeLabelsArry = homeLabelsStr.split(",");
String[] homeLabelSplit; String[] homeLabelSplit;
for (String homeLabelEntry : homeLabelsArry) { for (String homeLabelEntry : homeLabelsArry) {
homeLabelSplit = homeLabelEntry.split(":"); homeLabelSplit = homeLabelEntry.split(":");
if (homeLabelSplit.length == 2) { if (homeLabelSplit.length == 2) {
homeLabels.put(homeLabelSplit[0].trim(), homeLabels.put(homeLabelSplit[0].trim(),
homeLabelSplit[1].trim()); homeLabelSplit[1].trim());
} else { } else {
continue; continue;
} }
} }
Element navRoot = Element navRoot =
root.newChildElement("nav:categoryMenu", root.newChildElement("nav:categoryMenu",
"http://ccm.redhat.com/london/navigation"); "http://ccm.redhat.com/london/navigation");
navRoot.addAttribute("id", "categoryMenu"); navRoot.addAttribute("id", "categoryMenu");
Element navList = Element navList =
navRoot.newChildElement("nav:category", navRoot.newChildElement("nav:category",
"http://ccm.redhat.com/london/navigation"); "http://ccm.redhat.com/london/navigation");
navList.addAttribute("AbstractTree", "AbstractTree"); navList.addAttribute("AbstractTree", "AbstractTree");
navList.addAttribute("description", ""); navList.addAttribute("description", "");
navList.addAttribute("id", ""); navList.addAttribute("id", "");
navList.addAttribute("isSelected", "true"); navList.addAttribute("isSelected", "true");
navList.addAttribute("sortKey", ""); navList.addAttribute("sortKey", "");
navList.addAttribute("title", "publicPersonalProfileNavList"); navList.addAttribute("title", "publicPersonalProfileNavList");
navList.addAttribute("url", String.format("/ccm/%s", navList.addAttribute("url", String.format("/ccm/%s",
profile.getProfileUrl())); profile.getProfileUrl()));
Element navHome = Element navHome =
navList.newChildElement("nav:category", navList.newChildElement("nav:category",
"http://ccm.redhat.com/london/navigation"); "http://ccm.redhat.com/london/navigation");
navHome.addAttribute("AbstractTree", "AbstractTree"); navHome.addAttribute("AbstractTree", "AbstractTree");
navHome.addAttribute("description", ""); navHome.addAttribute("description", "");
navHome.addAttribute("id", profile.getID().toString()); navHome.addAttribute("id", profile.getID().toString());
if (navPath == null) { if (navPath == null) {
navHome.addAttribute("isSelected", "true"); navHome.addAttribute("isSelected", "true");
} else { } else {
navHome.addAttribute("isSelected", "false"); navHome.addAttribute("isSelected", "false");
} }
navHome.addAttribute("sortKey", ""); navHome.addAttribute("sortKey", "");
String homeLabel = homeLabels.get(DispatcherHelper.getNegotiatedLocale(). String homeLabel = homeLabels.get(DispatcherHelper.getNegotiatedLocale().
getLanguage()); getLanguage());
if (homeLabel == null) { if (homeLabel == null) {
navHome.addAttribute("title", "Home"); navHome.addAttribute("title", "Home");
} else { } else {
navHome.addAttribute("title", homeLabel); navHome.addAttribute("title", homeLabel);
} }
navHome.addAttribute("url", String.format("/ccm/profiles/%s", navHome.addAttribute("url", String.format("/ccm/profiles/%s",
profile.getProfileUrl())); profile.getProfileUrl()));
//Get the available Navigation items //Get the available Navigation items
PublicPersonalProfileNavItemCollection navItems = PublicPersonalProfileNavItemCollection navItems =
new PublicPersonalProfileNavItemCollection(); new PublicPersonalProfileNavItemCollection();
navItems.addLanguageFilter(DispatcherHelper.getNegotiatedLocale(). navItems.addLanguageFilter(DispatcherHelper.getNegotiatedLocale().
getLanguage()); getLanguage());
final Map<String, PublicPersonalProfileNavItem> navItemMap = final Map<String, PublicPersonalProfileNavItem> navItemMap =
new HashMap<String, PublicPersonalProfileNavItem>(); new HashMap<String, PublicPersonalProfileNavItem>();
PublicPersonalProfileNavItem navItem; PublicPersonalProfileNavItem navItem;
while (navItems.next()) { while (navItems.next()) {
navItem = navItems.getNavItem(); navItem = navItems.getNavItem();
navItemMap.put(navItem.getKey(), navItem); navItemMap.put(navItem.getKey(), navItem);
} }
//Get the related links of the profiles //Get the related links of the profiles
DataCollection links = DataCollection links =
RelatedLink.getRelatedLinks(profile, RelatedLink.getRelatedLinks(profile,
PublicPersonalProfile.LINK_LIST_NAME); PublicPersonalProfile.LINK_LIST_NAME);
links.addOrder(Link.ORDER); links.addOrder(Link.ORDER);
RelatedLink link; RelatedLink link;
String navLinkKey; String navLinkKey;
Element navElem; Element navElem;
while (links.next()) { while (links.next()) {
link = (RelatedLink) DomainObjectFactory.newInstance(links. link = (RelatedLink) DomainObjectFactory.newInstance(links.
getDataObject()); getDataObject());
navLinkKey = link.getTitle(); navLinkKey = link.getTitle();
navItem = navItemMap.get(navLinkKey); navItem = navItemMap.get(navLinkKey);
if (navItem == null) { if (navItem == null) {
//ToDo //ToDo
} }
navElem = navElem =
navList.newChildElement("nav:category", navList.newChildElement("nav:category",
"http://ccm.redhat.com/london/navigation"); "http://ccm.redhat.com/london/navigation");
navElem.addAttribute("AbstractTree", "AbstractTree"); navElem.addAttribute("AbstractTree", "AbstractTree");
navElem.addAttribute("description", ""); navElem.addAttribute("description", "");
//navHome.addAttribute("id", ""); //navHome.addAttribute("id", "");
if ((navPath != null) && navPath.equals(navLinkKey)) { if ((navPath != null) && navPath.equals(navLinkKey)) {
navElem.addAttribute("isSelected", "true"); navElem.addAttribute("isSelected", "true");
} else { } else {
navElem.addAttribute("isSelected", "false"); navElem.addAttribute("isSelected", "false");
} }
navElem.addAttribute("sortKey", ""); navElem.addAttribute("sortKey", "");
if (navItem == null) { if (navItem == null) {
navElem.addAttribute("title", navLinkKey); navElem.addAttribute("title", navLinkKey);
} else { } else {
navElem.addAttribute("title", navItem.getLabel()); navElem.addAttribute("title", navItem.getLabel());
} }
navElem.addAttribute("url", String.format("/ccm/profiles/%s/%s", navElem.addAttribute("url", String.format("/ccm/profiles/%s/%s",
profile.getProfileUrl(), profile.getProfileUrl(),
navLinkKey)); navLinkKey));
} }
}*/ }*/
private void generateProfileOwnerXml(final Element profileElem, private void generateProfileOwnerXml(final Element profileElem,
final GenericPerson owner, final GenericPerson owner,
final PageState state) { final PageState state) {