PublicPersonalProfile jetzt vollständig mehrsprachenfähig
git-svn-id: https://svn.libreccm.org/ccm/trunk@1384 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b3b2306ce1
commit
e27f16659d
|
|
@ -15,10 +15,11 @@
|
|||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
// import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.contentassets.RelatedLink;
|
||||
import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles;
|
||||
// import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
|
|
@ -38,7 +39,8 @@ import java.util.Map;
|
|||
public class PublicPersonalProfileXmlUtil {
|
||||
|
||||
private final com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig config =
|
||||
PublicPersonalProfiles.getConfig();
|
||||
PublicPersonalProfiles.
|
||||
getConfig();
|
||||
|
||||
public void createNavigation(final PublicPersonalProfile profile,
|
||||
final Element root,
|
||||
|
|
@ -103,7 +105,8 @@ public class PublicPersonalProfileXmlUtil {
|
|||
}
|
||||
navHome.addAttribute("sortKey", "");
|
||||
|
||||
String homeLabel = homeLabels.get(GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
||||
String homeLabel = homeLabels.get(GlobalizationHelper.
|
||||
getNegotiatedLocale().getLanguage());
|
||||
if (homeLabel == null) {
|
||||
navHome.addAttribute("title", "Home");
|
||||
} else {
|
||||
|
|
@ -141,7 +144,8 @@ public class PublicPersonalProfileXmlUtil {
|
|||
homeElem.addAttribute("url", String.format("/ccm/%s",
|
||||
UI.getConfig().getRootPage()));
|
||||
|
||||
final Element profileElem = pathElem.newChildElement("nav:category",
|
||||
final Element profileElem =
|
||||
pathElem.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/navigation");
|
||||
profileElem.addAttribute("url", String.format("%s/%s",
|
||||
appUrl,
|
||||
|
|
@ -157,7 +161,8 @@ public class PublicPersonalProfileXmlUtil {
|
|||
String navLinkKey;
|
||||
Element navElem;
|
||||
while (links.next()) {
|
||||
link = (RelatedLink) DomainObjectFactory.newInstance(links.getDataObject());
|
||||
link = (RelatedLink) DomainObjectFactory.newInstance(links.
|
||||
getDataObject());
|
||||
|
||||
navLinkKey = link.getTitle();
|
||||
navItem = navItemMap.get(navLinkKey);
|
||||
|
|
@ -166,6 +171,17 @@ public class PublicPersonalProfileXmlUtil {
|
|||
//ToDo
|
||||
}
|
||||
|
||||
ContentItem targetItem = link.getTargetItem();
|
||||
if (!(targetItem instanceof PublicPersonalProfile)
|
||||
&& (targetItem instanceof ContentPage)) {
|
||||
ContentPage targetPage = (ContentPage) targetItem;
|
||||
if (!(targetPage.getContentBundle().hasInstance(GlobalizationHelper.
|
||||
getNegotiatedLocale().getLanguage(),
|
||||
false))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
navElem =
|
||||
navList.newChildElement("nav:category",
|
||||
"http://ccm.redhat.com/navigation");
|
||||
|
|
|
|||
|
|
@ -236,6 +236,6 @@ public class PublicPersonalProfileCreate extends PageCreate {
|
|||
String.format("version = '%s'", ContentItem.DRAFT));
|
||||
}
|
||||
|
||||
return profileUrl;
|
||||
return GenericPerson.urlSave(profileUrl).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
|||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ReusableImageAsset;
|
||||
import com.arsdigita.cms.contentassets.ItemImageAttachment;
|
||||
|
|
@ -162,7 +163,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
|
||||
final Session session = SessionManager.getSession();
|
||||
|
||||
DataCollection profiles =
|
||||
/*DataCollection profiles =
|
||||
session.retrieve(
|
||||
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||
|
|
@ -173,6 +174,19 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
} else {
|
||||
profiles.addFilter(String.format("version = '%s'",
|
||||
ContentItem.LIVE));
|
||||
}*/
|
||||
|
||||
DataCollection profiles = getProfiles(session,
|
||||
profileOwner,
|
||||
preview,
|
||||
GlobalizationHelper.
|
||||
getNegotiatedLocale().getLanguage());
|
||||
|
||||
if (profiles.isEmpty()) {
|
||||
profiles = getProfiles(session,
|
||||
profileOwner,
|
||||
preview,
|
||||
GlobalizationHelper.LANG_INDEPENDENT);
|
||||
}
|
||||
|
||||
if (profiles.size() == 0) {
|
||||
|
|
@ -207,7 +221,8 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
profile);
|
||||
|
||||
if (!canEdit) {
|
||||
throw new AccessDeniedException("user " + Kernel.
|
||||
throw new AccessDeniedException("user "
|
||||
+ Kernel.
|
||||
getContext().getParty().getOID()
|
||||
+ " doesn't have the "
|
||||
+ com.arsdigita.cms.SecurityManager.EDIT_ITEM
|
||||
|
|
@ -392,8 +407,47 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
(RelatedLink) DomainObjectFactory.
|
||||
newInstance(links.getDataObject());
|
||||
links.close();
|
||||
final ContentItem item =
|
||||
ContentItem item =
|
||||
link.getTargetItem();
|
||||
|
||||
if (item instanceof ContentPage) {
|
||||
ContentPage contentPage =
|
||||
(ContentPage) item;
|
||||
logger.error("contentPage.getContentBundle().hasInstance(GlobalizationHelper.getNegotiatedLocale().getLanguage()) = "
|
||||
+ contentPage.
|
||||
getContentBundle().
|
||||
hasInstance(GlobalizationHelper.
|
||||
getNegotiatedLocale().
|
||||
getLanguage()));
|
||||
if (contentPage.getContentBundle().
|
||||
hasInstance(GlobalizationHelper.
|
||||
getNegotiatedLocale().
|
||||
getLanguage())) {
|
||||
contentPage =
|
||||
(ContentPage) contentPage.
|
||||
getContentBundle().
|
||||
getInstance(GlobalizationHelper.
|
||||
getNegotiatedLocale().
|
||||
getLanguage());
|
||||
item = (ContentItem) contentPage;
|
||||
} else {
|
||||
logger.error(
|
||||
String.format(
|
||||
"Item '%s' not found in a suitable language variant. Negotiated langauge: %s, langugage independent items allowed is %s, language independent code is %s ",
|
||||
itemPath,
|
||||
GlobalizationHelper.
|
||||
getNegotiatedLocale().
|
||||
getLanguage(),
|
||||
Kernel.getConfig().
|
||||
languageIndependentItems(),
|
||||
GlobalizationHelper.LANG_INDEPENDENT));
|
||||
response.setStatus(
|
||||
HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final Element contentPanelElem = root.
|
||||
newChildElement("cms:contentPanel",
|
||||
CMS.CMS_XML_NS);
|
||||
|
|
@ -415,10 +469,42 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
|
||||
final OID itemOid = OID.valueOf(itemPath);
|
||||
try {
|
||||
final ContentItem item =
|
||||
ContentItem item =
|
||||
(ContentItem) DomainObjectFactory.
|
||||
newInstance(itemOid);
|
||||
|
||||
if (item instanceof ContentPage) {
|
||||
ContentPage contentPage = (ContentPage) item;
|
||||
logger.error("contentPage.getContentBundle().hasInstance(GlobalizationHelper.getNegotiatedLocale().getLanguage()) = "
|
||||
+ contentPage.getContentBundle().
|
||||
hasInstance(GlobalizationHelper.
|
||||
getNegotiatedLocale().getLanguage()));
|
||||
if (contentPage.getContentBundle().
|
||||
hasInstance(GlobalizationHelper.
|
||||
getNegotiatedLocale().getLanguage())) {
|
||||
contentPage = (ContentPage) contentPage.
|
||||
getContentBundle().getInstance(GlobalizationHelper.
|
||||
getNegotiatedLocale().
|
||||
getLanguage());
|
||||
item = (ContentItem) contentPage;
|
||||
} else {
|
||||
logger.error(
|
||||
String.format(
|
||||
"Item '%s' not found in a suitable language variant. Negotiated langauge: %s, langugage independent items allowed is %s, language independent code is %s ",
|
||||
itemPath,
|
||||
GlobalizationHelper.
|
||||
getNegotiatedLocale().
|
||||
getLanguage(),
|
||||
Kernel.getConfig().
|
||||
languageIndependentItems(),
|
||||
GlobalizationHelper.LANG_INDEPENDENT));
|
||||
response.setStatus(
|
||||
HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final Element contentPanelElem = root.
|
||||
newChildElement("cms:contentPanel",
|
||||
CMS.CMS_XML_NS);
|
||||
|
|
@ -608,4 +694,26 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
presentationManager.servePage(document, request, response);
|
||||
|
||||
}
|
||||
|
||||
private DataCollection getProfiles(final Session session,
|
||||
final String profileOwner,
|
||||
final boolean preview,
|
||||
final String language) {
|
||||
DataCollection profiles =
|
||||
session.retrieve(
|
||||
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||
profileOwner));
|
||||
if (preview) {
|
||||
profiles.addFilter(String.format("version = '%s'",
|
||||
ContentItem.DRAFT));
|
||||
} else {
|
||||
profiles.addFilter(String.format("version = '%s'",
|
||||
ContentItem.LIVE));
|
||||
}
|
||||
|
||||
profiles.addFilter(String.format("language = '%s'", language));
|
||||
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ public class GenericPerson extends ContentPage implements
|
|||
}
|
||||
|
||||
// Replace all special chars that are not yet replaced with a dash
|
||||
return out.replaceAll("[^A-Za-z0-9-]", "_");
|
||||
return out.replaceAll("[^A-Za-z0-9-]", "_").toLowerCase();
|
||||
}
|
||||
|
||||
return in;
|
||||
|
|
|
|||
Loading…
Reference in New Issue