/** * Get the list of contents by relationship if exists. * * @param structure The content structure * @param contentlet The content * @param parametersOptions The macro form options parameters * @return Map<Relationship,List<Contentlet>> * @throws DotSecurityException */ private static Map<Relationship, List<Contentlet>> getRelationships( Structure structure, Contentlet contentlet, String parametersOptions, User user) throws DotDataException, DotSecurityException { LanguageAPI lAPI = APILocator.getLanguageAPI(); Map<Relationship, List<Contentlet>> contentRelationships = new HashMap<Relationship, List<Contentlet>>(); if (contentlet == null) return contentRelationships; List<Relationship> rels = RelationshipFactory.getAllRelationshipsByStructure(contentlet.getStructure()); for (Relationship rel : rels) { String[] opt = parametersOptions.split(";"); for (String text : opt) { if (text.indexOf(rel.getRelationTypeValue()) != -1) { String[] identArray = text.substring(text.indexOf("=") + 1) .replaceAll("\\[", "") .replaceAll("\\]", "") .split(","); List<Contentlet> cons = conAPI.findContentletsByIdentifiers( identArray, true, lAPI.getDefaultLanguage().getId(), user, true); if (cons.size() > 0) { contentRelationships.put(rel, cons); } } } } return contentRelationships; }
public boolean getBoolean(String key, String languageId) { boolean value = false; try { Language lang = langAPI.getLanguage(languageId); value = langAPI.getBooleanKey(lang, key); } catch (Exception e) { Logger.error(this, e.toString()); } return value; }
public float getFloat(String key, String languageId) { float value = 0; try { Language lang = langAPI.getLanguage(languageId); value = langAPI.getFloatKey(lang, key); } catch (Exception e) { Logger.error(this, e.toString()); } return value; }
public String get(String key, List args) { String language = null; if (language == null) language = (String) request.getSession().getAttribute(com.dotmarketing.util.WebKeys.HTMLPAGE_LANGUAGE); if (language == null) language = String.valueOf(langAPI.getDefaultLanguage().getId()); try { key = key.replace(" ", "\\ "); MessagesTools resources = new MessagesTools(); resources.init(ctx); } catch (Exception e) { Logger.error(this, e.toString()); } String value = null; try { MessagesTools resources = new MessagesTools(); resources.init(ctx); value = resources.get(key, args); } catch (Exception e) { Logger.error(this, e.toString()); } return (value == null) ? "" : value; }
public String get(String key, String languageId) { String value = null; try { Language lang = langAPI.getLanguage(languageId); value = langAPI.getStringKey(lang, key); if ((!UtilMethods.isSet(value) || value.equals(key)) && Config.getBooleanProperty("DEFAULT_CONTENT_TO_DEFAULT_LANGUAGE")) { lang = langAPI.getDefaultLanguage(); value = langAPI.getStringKey(lang, key); } } catch (Exception e) { Logger.error(this, e.toString()); } return (value == null) ? "" : value; }
/** * Create a new content, setting the content values with the specified list of param values * * @param structureName The content structure name * @param parametersName The fields names * @param values The fields values * @return Contentlet * @throws DotDataException */ private static Contentlet setAllFields( String structureName, List<String> parametersName, List<String[]> values) throws DotDataException { LanguageAPI lAPI = APILocator.getLanguageAPI(); Structure st = StructureCache.getStructureByName(structureName); Contentlet contentlet = new Contentlet(); contentlet.setStructureInode(st.getInode()); contentlet.setLanguageId(lAPI.getDefaultLanguage().getId()); for (int i = 0; i < parametersName.size(); i++) { String fieldname = parametersName.get(i); String[] fieldValue = values.get(i); setField(st, contentlet, fieldname, fieldValue); } return contentlet; }
public float getFloat(String key) { String language = null; if (language == null) language = (String) request.getSession().getAttribute(com.dotmarketing.util.WebKeys.HTMLPAGE_LANGUAGE); if (language == null) language = String.valueOf(langAPI.getDefaultLanguage().getId()); return getFloat(key, language); }
public boolean getBoolean(String key) { String language = null; if (language == null) language = request.getParameter("languageId"); if (language == null) language = (String) request.getSession().getAttribute(com.dotmarketing.util.WebKeys.HTMLPAGE_LANGUAGE); if (language == null) language = String.valueOf(langAPI.getDefaultLanguage().getId()); return getBoolean(key, language); }
public String getFromSessionLanguage(String key) throws LanguageException { String language = null; if (language == null) language = request.getParameter("languageId"); if (language == null) language = (String) request.getSession().getAttribute(com.dotmarketing.util.WebKeys.HTMLPAGE_LANGUAGE); if (language == null) language = String.valueOf(langAPI.getDefaultLanguage().getId()); Language lang = APILocator.getLanguageAPI().getLanguage(language); return LanguageUtil.get(LanguageUtil.getLocale(lang.getLanguageCode()), key); }
public static ClickstreamRequest getClickstreamRequest( HttpServletRequest request, Date timestamp) { HttpSession session = request.getSession(); long languageId = langAPI.getDefaultLanguage().getId(); if (session.getAttribute(WebKeys.HTMLPAGE_LANGUAGE) != null) { languageId = Long.parseLong(session.getAttribute(WebKeys.HTMLPAGE_LANGUAGE).toString()); } String uri = request.getRequestURI(); if (request.getAttribute(WebKeys.CLICKSTREAM_URI_OVERRIDE) != null) { uri = (String) request.getAttribute(WebKeys.CLICKSTREAM_URI_OVERRIDE); } HostWebAPI hostWebAPI = WebAPILocator.getHostWebAPI(); Host host = null; try { host = hostWebAPI.getCurrentHost(request); } catch (PortalException e) { Logger.error( ClickstreamRequestFactory.class, "Unable to retrieve current request host for URI " + uri); } catch (SystemException e) { Logger.error( ClickstreamRequestFactory.class, "Unable to retrieve current request host for URI " + uri); } catch (DotDataException e) { Logger.error( ClickstreamRequestFactory.class, "Unable to retrieve current request host for URI " + uri); } catch (DotSecurityException e) { Logger.error( ClickstreamRequestFactory.class, "Unable to retrieve current request host for URI " + uri); } String hostIdentifier = host.getIdentifier(); ClickstreamRequest cr = new ClickstreamRequest(); cr.setProtocol(request.getProtocol()); cr.setServerName(request.getServerName()); cr.setServerPort(request.getServerPort()); cr.setQueryString(request.getQueryString()); cr.setRemoteUser(request.getRemoteUser()); cr.setRequestURI(uri); cr.setLanguageId(languageId); cr.setTimestamp(timestamp); cr.setHostId(hostIdentifier); return cr; }
/** * Get the list of availables languages * * @return List<Language> */ public static List<Language> getLanguages() { return langAPI.getLanguages(); }
/** * Get the default language * * @return Language */ public static Language getDefaultLanguage() { return langAPI.getDefaultLanguage(); }
/** * Get Language by language code * * @param langId * @return Language */ public static Language getLanguage(String langId) { return langAPI.getLanguage(langId); }
/** * Get Language by language code and country code * * @param languageCode * @param countryCode * @return Language */ public static Language getLanguage(String languageCode, String countryCode) { return langAPI.getLanguage(languageCode, countryCode); }