PublicPersonalProfile: Ausgabe Personen und Kontakt-Informationen
git-svn-id: https://svn.libreccm.org/ccm/trunk@1055 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
375fa32580
commit
481d877ad9
|
|
@ -13,6 +13,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
|||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
|
|
@ -40,20 +41,20 @@ import java.util.Date;
|
|||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfileCreate extends PageCreate {
|
||||
|
||||
|
||||
private static final String SELECTED_PERSON = "selectedPerson";
|
||||
private static final PublicPersonalProfileConfig config =
|
||||
new PublicPersonalProfileConfig();
|
||||
|
||||
new PublicPersonalProfileConfig();
|
||||
|
||||
static {
|
||||
config.load();
|
||||
}
|
||||
|
||||
|
||||
public PublicPersonalProfileCreate(final ItemSelectionModel itemModel,
|
||||
final CreationSelector parent) {
|
||||
final CreationSelector parent) {
|
||||
super(itemModel, parent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
//super.addWidgets();
|
||||
|
|
@ -66,19 +67,19 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
add(new Label(type.getLabel()));
|
||||
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
|
||||
add(new LanguageWidget(LANGUAGE));
|
||||
|
||||
|
||||
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||
"publicpersonalprofile.ui.create.select_person")));
|
||||
ParameterModel ownerModel =
|
||||
new StringParameter(PublicPersonalProfile.OWNER);
|
||||
SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
||||
ownerSelect.addValidationListener(new NotNullValidationListener());
|
||||
|
||||
ownerSelect.addValidationListener(new NotNullValidationListener());
|
||||
|
||||
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) {
|
||||
|
|
@ -87,6 +88,8 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
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.
|
||||
|
|
@ -95,7 +98,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
getFullName()));
|
||||
}
|
||||
add(ownerSelect);
|
||||
|
||||
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
add(new Label(GlobalizationUtil.globalize(
|
||||
"cms.ui.authoring.page_launch_date")));
|
||||
|
|
@ -112,40 +115,46 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
add(launchDate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validate(FormSectionEvent fse) throws FormProcessException {
|
||||
Folder folder = m_parent.getFolder(fse.getPageState());
|
||||
Assert.exists(folder);
|
||||
String id = (String) fse.getFormData().get(
|
||||
PublicPersonalProfile.OWNER);
|
||||
|
||||
|
||||
if ((id == null) || id.trim().isEmpty()) {
|
||||
fse.getFormData().addError(PublicPersonalProfileGlobalizationUtil.
|
||||
globalize("publicpersonalprofile.ui.person.required"));
|
||||
return;
|
||||
}
|
||||
|
||||
GenericPerson owner = new GenericPerson(new BigDecimal(id));
|
||||
|
||||
|
||||
validateNameUniqueness(folder,
|
||||
fse,
|
||||
String.format("%s-profile",
|
||||
GenericPerson.urlSave(
|
||||
owner.getFullName())));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
final ContentSection section = m_parent.getContentSection(state);
|
||||
final Folder folder = m_parent.getFolder(state);
|
||||
|
||||
|
||||
Assert.exists(section, ContentSection.class);
|
||||
|
||||
|
||||
String id = (String) fse.getFormData().get(
|
||||
PublicPersonalProfile.OWNER);
|
||||
|
||||
|
||||
GenericPerson owner = new GenericPerson(new BigDecimal(id));
|
||||
String name = String.format("%s-profile",
|
||||
GenericPerson.urlSave(owner.getFullName()));
|
||||
String title = String.format("%s (Profil)", owner.getFullName());
|
||||
|
||||
|
||||
final ContentPage item = createContentPage(state);
|
||||
item.setLanguage((String) data.get(LANGUAGE));
|
||||
item.setName(name);
|
||||
|
|
@ -153,18 +162,17 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
item.setLaunchDate((Date) data.get(LAUNCH_DATE));
|
||||
}
|
||||
|
||||
|
||||
final ContentBundle bundle = new ContentBundle(item);
|
||||
bundle.setParent(folder);
|
||||
bundle.setContentSection(m_parent.getContentSection(state));
|
||||
bundle.save();
|
||||
|
||||
PublicPersonalProfile profile = new PublicPersonalProfile(item.
|
||||
getOID());
|
||||
|
||||
PublicPersonalProfile profile = new PublicPersonalProfile(item.getOID());
|
||||
profile.setOwner(owner);
|
||||
profile.setProfileUrl(owner.getSurname().toLowerCase());
|
||||
profile.save();
|
||||
|
||||
|
||||
m_parent.editItem(state, item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.runtime.AbstractConfig;
|
||||
import com.arsdigita.util.parameter.BooleanParameter;
|
||||
import com.arsdigita.util.parameter.Parameter;
|
||||
import com.arsdigita.util.parameter.StringParameter;
|
||||
|
||||
|
|
@ -12,19 +13,42 @@ import com.arsdigita.util.parameter.StringParameter;
|
|||
public class PublicPersonalProfileConfig extends AbstractConfig {
|
||||
|
||||
private final Parameter homeNavItemLabels;
|
||||
private final Parameter showPersonInfoEverywhere;
|
||||
private final Parameter contactType;
|
||||
|
||||
public PublicPersonalProfileConfig() {
|
||||
homeNavItemLabels = new StringParameter(
|
||||
"com.arsdigita.cms.publicpersonalprofile.navitem.home.labels",
|
||||
Parameter.REQUIRED,
|
||||
"en:Home, de:Allgemein");
|
||||
|
||||
Parameter.REQUIRED,
|
||||
"en:Home, de:Allgemein");
|
||||
|
||||
showPersonInfoEverywhere =
|
||||
new BooleanParameter(
|
||||
"com.arsdigita.cms.publicpersonalprofile.show_person_info_everywhere",
|
||||
Parameter.REQUIRED,
|
||||
false);
|
||||
|
||||
contactType = new StringParameter(
|
||||
"com.arsdigita.cms.publicpersonalprofile.contactType",
|
||||
Parameter.REQUIRED,
|
||||
"commonContact");
|
||||
|
||||
register(homeNavItemLabels);
|
||||
|
||||
register(showPersonInfoEverywhere);
|
||||
register(contactType);
|
||||
|
||||
loadInfo();
|
||||
}
|
||||
|
||||
|
||||
public final String getHomeNavItemLabels() {
|
||||
return (String) get(homeNavItemLabels);
|
||||
}
|
||||
|
||||
public final Boolean getShowPersonInfoEverywhere() {
|
||||
return (Boolean) get(showPersonInfoEverywhere);
|
||||
}
|
||||
|
||||
public final String getContactType() {
|
||||
return (String) get(contactType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,3 +3,13 @@ com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.purpose = The labels
|
|||
com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.example = en:Home,de:Start
|
||||
com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.format = [String]
|
||||
|
||||
com.arsdigita.cms.publicpersonalprofile.show_person_info_everywhere.title = Show person information everywhere
|
||||
com.arsdigita.cms.publicpersonalprofile.show_person_info_everywhere.purpose = If set to true, the information about the person (name, title, contacts etc.) are included in the XML output regardless which navigation item has been chosen. If set to false (default) the information will only be included into the XML output if no navigation item is selected.
|
||||
com.arsdigita.cms.publicpersonalprofile.show_person_info_everywhere.example = false
|
||||
com.arsdigita.cms.publicpersonalprofile.show_person_info_everywhere.format = [Boolean]
|
||||
|
||||
com.arsdigita.cms.publicpersonalprofile.contactType.title = Contact type to use
|
||||
com.arsdigita.cms.publicpersonalprofile.contactType.purpose = Determines the type of the contact to use in the profiles
|
||||
com.arsdigita.cms.publicpersonalprofile.contactType.title.example = commonContact
|
||||
com.arsdigita.cms.publicpersonalprofile.contactType.title.format = [String]
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class PublicPersonalProfiles extends Application {
|
|||
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfile";
|
||||
private static PublicPersonalProfileConfig config =
|
||||
private final static PublicPersonalProfileConfig config =
|
||||
new PublicPersonalProfileConfig();
|
||||
|
||||
static {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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.GenericPersonContactCollection;
|
||||
import com.arsdigita.cms.contenttypes.Link;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||
|
|
@ -41,12 +42,15 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
Logger.getLogger(
|
||||
PublicPersonalProfilesServlet.class);
|
||||
private static final String PREVIEW = "preview";
|
||||
private final PublicPersonalProfileConfig config = PublicPersonalProfiles.
|
||||
getConfig();
|
||||
|
||||
@Override
|
||||
protected void doService(final HttpServletRequest request,
|
||||
final HttpServletResponse response,
|
||||
final Application app) throws ServletException,
|
||||
IOException {
|
||||
PublicPersonalProfileConfig config = PublicPersonalProfiles.getConfig();
|
||||
String path = "";
|
||||
|
||||
logger.debug("PublicPersonalProfileServlet is starting...");
|
||||
|
|
@ -81,7 +85,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
response.getWriter().append("Please choose an application.");
|
||||
} else {
|
||||
final String[] pathTokens = path.split("/");
|
||||
boolean preview = false;;
|
||||
boolean preview = false;
|
||||
String profileOwner = "";
|
||||
String navPath = null;
|
||||
|
||||
|
|
@ -129,8 +133,8 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
|
||||
Document document = page.buildDocument(request, response);
|
||||
Element root = document.getRootElement();
|
||||
Element test = root.newChildElement("test");
|
||||
test.setText("test");
|
||||
//Element test = root.newChildElement("test");
|
||||
//test.setText("test");
|
||||
|
||||
final Session session = SessionManager.getSession();
|
||||
|
||||
|
|
@ -153,6 +157,8 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
throw new IllegalStateException(
|
||||
"More than one matching members found...");
|
||||
} else {
|
||||
final PageState state = new PageState(page, request, response);
|
||||
|
||||
profiles.next();
|
||||
PublicPersonalProfile profile =
|
||||
(PublicPersonalProfile) DomainObjectFactory.
|
||||
|
|
@ -168,7 +174,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
createNavigation(profile, root, navPath);
|
||||
|
||||
if (navPath == null) {
|
||||
//ToDo: Show start page.
|
||||
generateProfileOwnerXml(profileElem, owner, state);
|
||||
} else {
|
||||
final DataCollection links =
|
||||
RelatedLink.getRelatedLinks(profile,
|
||||
|
|
@ -179,6 +185,10 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
} else {
|
||||
if (config.getShowPersonInfoEverywhere()) {
|
||||
generateProfileOwnerXml(profileElem, owner, state);
|
||||
}
|
||||
|
||||
links.next();
|
||||
final RelatedLink link =
|
||||
(RelatedLink) DomainObjectFactory.
|
||||
|
|
@ -194,9 +204,6 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
PresentationManager presentationManager = Templating.
|
||||
getPresentationManager();
|
||||
presentationManager.servePage(document, request, response);
|
||||
|
|
@ -207,8 +214,6 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
private void createNavigation(final PublicPersonalProfile profile,
|
||||
final Element root,
|
||||
final String navPath) {
|
||||
PublicPersonalProfileConfig config = PublicPersonalProfiles.getConfig();
|
||||
|
||||
String homeLabelsStr = config.getHomeNavItemLabels();
|
||||
|
||||
Map<String, String> homeLabels = new HashMap<String, String>();
|
||||
|
|
@ -317,7 +322,58 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
navLinkKey));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void generateProfileOwnerXml(final Element profileElem,
|
||||
final GenericPerson owner,
|
||||
final PageState state) {
|
||||
Element profileOwnerElem = profileElem.newChildElement(
|
||||
"profileOwner");
|
||||
/*if ((owner.getSurname() != null)
|
||||
&& !owner.getSurname().trim().isEmpty()) {
|
||||
Element surname =
|
||||
profileOwnerElem.newChildElement("surname");
|
||||
surname.setText(owner.getSurname());
|
||||
}
|
||||
if ((owner.getGivenName() != null)
|
||||
&& !owner.getGivenName().trim().isEmpty()) {
|
||||
Element givenName = profileOwnerElem.newChildElement(
|
||||
"givenName");
|
||||
givenName.setText(owner.getGivenName());
|
||||
}
|
||||
if ((owner.getTitlePre() != null)
|
||||
&& !owner.getTitlePre().trim().isEmpty()) {
|
||||
Element titlePre = profileOwnerElem.newChildElement("titlePre");
|
||||
titlePre.setText(owner.getTitlePre());
|
||||
}
|
||||
if ((owner.getTitlePost() != null)
|
||||
&& !owner.getTitlePost().trim().isEmpty()) {
|
||||
Element titlePost = profileOwnerElem.newChildElement(
|
||||
"titlePost");
|
||||
titlePost.setText(owner.getTitlePost());
|
||||
}*/
|
||||
|
||||
PublicPersonalProfileXmlGenerator personXml =
|
||||
new PublicPersonalProfileXmlGenerator(
|
||||
owner);
|
||||
personXml.generateXML(state,
|
||||
profileOwnerElem,
|
||||
"");
|
||||
|
||||
/*if (owner.hasContacts()) {
|
||||
final GenericPersonContactCollection contacts = owner.getContacts();
|
||||
final String contactType = config.getContactType();
|
||||
|
||||
contacts.addFilter(String.format("link.link_key = '%s'",
|
||||
contactType));
|
||||
|
||||
if (contacts.size() > 0) {
|
||||
contacts.next();
|
||||
PublicPersonalProfileXmlGenerator contactXml =
|
||||
new PublicPersonalProfileXmlGenerator(
|
||||
contacts.getContact());
|
||||
contactXml.generateXML(state, profileOwnerElem, "");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue