/** * Returns the substituted value for the given key and arguments from the configuration file.<p> * * @param key the key to get the value for * @param args the arguments that should be substituted * @return the substituted value for the given key and arguments */ protected String getConfigValue(String key, Object[] args) { String value = getConfigValue(key); CmsMacroResolver resolver = CmsMacroResolver.newInstance(); for (int i = 0; i < args.length; i++) { resolver.addMacro(String.valueOf(i), args[i].toString()); } return resolver.resolveMacros(value); }
/** * Returns the substituted value for the given key and arguments from the configuration file.<p> * * @param key the key to get the value for * @param args the arguments that should be substituted * @return the substituted value for the given key and arguments */ protected String getConfigValue(String key, Object[] args) { String value = getConfigValue(key); CmsMacroResolver resolver = CmsMacroResolver.newInstance(); for (int i = 0; i < args.length; i++) { resolver.addMacro(String.valueOf(i), args[i].toString()); } return resolver.resolveMacros(value); }
/** * @see org.opencms.xml.content.I_CmsXmlContentHandler#getPreview(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, java.lang.String) */ public String getPreview(CmsObject cms, CmsXmlContent content, String resourcename) { CmsMacroResolver resolver = CmsMacroResolver.newInstance().setCmsObject(cms); resolver.addMacro(MACRO_PREVIEW_TEMPFILE, resourcename); return resolver.resolveMacros(m_previewLocation); }
/** * @see org.opencms.xml.content.I_CmsXmlContentHandler#getPreview(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, java.lang.String) */ public String getPreview(CmsObject cms, CmsXmlContent content, String resourcename) { CmsMacroResolver resolver = CmsMacroResolver.newInstance().setCmsObject(cms); resolver.addMacro(MACRO_PREVIEW_TEMPFILE, resourcename); return resolver.resolveMacros(m_previewLocation); }
/** * Replaces the macros in the given message.<p> * * @param msg the message in which the macros are replaced * @param contentLocale the locale of the content that is currently decorated * * @return the message with the macros replaced */ private String replaceMacros(String msg, String contentLocale) { CmsMacroResolver resolver = CmsMacroResolver.newInstance(); resolver.addMacro(MACRO_DECORATION, m_decoration); resolver.addMacro(MACRO_DECORATIONKEY, m_decorationKey); if (m_locale != null) { resolver.addMacro(MACRO_LOCALE, m_locale.toString()); if (!contentLocale.equals(m_locale.toString())) { resolver.addMacro(MACRO_LANGUAGE, "lang=\"" + m_locale.toString() + "\""); } } return resolver.resolveMacros(msg); }
/** * Replaces the macros in the given message.<p> * * @param msg the message in which the macros are replaced * @param contentLocale the locale of the content that is currently decorated * * @return the message with the macros replaced */ private String replaceMacros(String msg, String contentLocale) { CmsMacroResolver resolver = CmsMacroResolver.newInstance(); resolver.addMacro(MACRO_DECORATION, m_decoration); resolver.addMacro(MACRO_DECORATIONKEY, m_decorationKey); if (m_locale != null) { resolver.addMacro(MACRO_LOCALE, m_locale.toString()); if (!contentLocale.equals(m_locale.toString())) { resolver.addMacro(MACRO_LANGUAGE, "lang=\"" + m_locale.toString() + "\""); } } return resolver.resolveMacros(msg); }
/** * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getHelpText(java.util.Locale) */ public String getHelpText(Locale locale) { return CmsMacroResolver.newInstance().setMessages( OpenCms.getWorkplaceManager().getMessages(locale)).resolveMacros(m_toolHandler.getHelpText()); }
/** * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getName(java.util.Locale) */ public String getName(Locale locale) { return CmsMacroResolver.newInstance().setMessages( OpenCms.getWorkplaceManager().getMessages(locale)).resolveMacros(m_toolHandler.getName()); }
/** * Replaces the macros in the given message.<p> * * @param msg the message in which the macros are replaced * @param recipient the recipient in the message * * @return the message with the macros replaced */ private String replaceMacros(String msg, I_CmsNewsletterRecipient recipient) { CmsMacroResolver resolver = CmsMacroResolver.newInstance(); resolver.addMacro(MACRO_USER_FIRSTNAME, recipient.getFirstname()); resolver.addMacro(MACRO_USER_LASTNAME, recipient.getLastname()); resolver.addMacro(MACRO_USER_FULLNAME, recipient.getFullName()); resolver.addMacro(MACRO_USER_EMAIL, recipient.getEmail()); resolver.addMacro( MACRO_SEND_DATE, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis()))); return resolver.resolveMacros(msg); } }
/** * Returns the parameters of the collector with resolved macros.<p> * * @return the parameters of the collector with resolved macros */ public String getParameter() { Locale locale = getRequestContext().getLocale(); String params = m_content.getStringValue(getCmsObject(), NODE_PARAMETER, locale); List links = m_content.getValues(NODE_LINKS, locale); CmsMacroResolver macroResolver = CmsMacroResolver.newInstance(); macroResolver.setKeepEmptyMacros(true); for (int i = 0; i < links.size(); i++) { I_CmsXmlContentValue xmlValue = (I_CmsXmlContentValue)links.get(i); String value = xmlValue.getStringValue(getCmsObject()); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) { StringBuffer macro = new StringBuffer(10); macro.append(MACRO_LINK_PREFIX).append(i + 1); macroResolver.addMacro(macro.toString(), getRequestContext().removeSiteRoot(value)); } } return macroResolver.resolveMacros(params); }
/** * Replaces the macros in the given message.<p> * * @param msg the message in which the macros are replaced * @param recipient the recipient in the message * * @return the message with the macros replaced */ private String replaceMacros(String msg, I_CmsNewsletterRecipient recipient) { CmsMacroResolver resolver = CmsMacroResolver.newInstance(); resolver.addMacro(MACRO_USER_FIRSTNAME, recipient.getFirstname()); resolver.addMacro(MACRO_USER_LASTNAME, recipient.getLastname()); resolver.addMacro(MACRO_USER_FULLNAME, recipient.getFullName()); resolver.addMacro(MACRO_USER_EMAIL, recipient.getEmail()); resolver.addMacro( MACRO_SEND_DATE, DateFormat.getDateTimeInstance().format(new Date(System.currentTimeMillis()))); return resolver.resolveMacros(msg); } }
/** * Returns the current used macro resolver instance.<p> * * @return the macro resolver */ public CmsMacroResolver getMacroResolver() { if (m_macroResolver == null) { // create a new macro resolver "with everything we got" m_macroResolver = CmsMacroResolver.newInstance() // initialize resolver with the objects available .setCmsObject(m_cms).setMessages(getMessages()).setJspPageContext( (m_jsp == null) ? null : m_jsp.getJspContext()); } return m_macroResolver; }
/** * Returns the parameters of the collector with resolved macros.<p> * * @return the parameters of the collector with resolved macros */ public String getParameter() { Locale locale = getRequestContext().getLocale(); String params = m_content.getStringValue(getCmsObject(), NODE_PARAMETER, locale); List<I_CmsXmlContentValue> links = m_content.getValues(NODE_LINKS, locale); CmsMacroResolver macroResolver = CmsMacroResolver.newInstance().setCmsObject(getCmsObject()); macroResolver.setKeepEmptyMacros(true); for (int i = 0; i < links.size(); i++) { I_CmsXmlContentValue xmlValue = links.get(i); String value = xmlValue.getStringValue(getCmsObject()); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) { StringBuffer macro = new StringBuffer(10); macro.append(MACRO_LINK_PREFIX).append(i + 1); macroResolver.addMacro(macro.toString(), getRequestContext().removeSiteRoot(value)); } } return macroResolver.resolveMacros(params); }
/** * Returns the current used macro resolver instance.<p> * * @return the macro resolver */ public CmsMacroResolver getMacroResolver() { if (m_macroResolver == null) { // create a new macro resolver "with everything we got" m_macroResolver = CmsMacroResolver.newInstance() // initialize resolver with the objects available .setCmsObject(m_cms).setMessages(getMessages()).setJspPageContext( (m_jsp == null) ? null : m_jsp.getJspContext()); m_macroResolver.setParameterMap(m_parameterMap); } return m_macroResolver; }
/** * Substitutes the ${CONTEXT_NAME} and ${SERVLET_NAME} in a path with the real values.<p> * * @param path the path to substitute * @return path with real context values */ protected String insertContextStrings(String path) { // create a new macro resolver CmsMacroResolver resolver = CmsMacroResolver.newInstance(); // add special mappings for macros resolver.addMacro("CONTEXT_NAME", OpenCms.getSystemInfo().getContextPath()); resolver.addMacro("SERVLET_NAME", OpenCms.getSystemInfo().getServletPath()); // resolve the macros return resolver.resolveMacros(path); }
/** * Substitutes the ${CONTEXT_NAME} and ${SERVLET_NAME} in a path with the real values.<p> * * @param path the path to substitute * @return path with real context values */ protected String insertContextStrings(String path) { // create a new macro resolver CmsMacroResolver resolver = CmsMacroResolver.newInstance(); // add special mappings for macros resolver.addMacro("CONTEXT_NAME", OpenCms.getSystemInfo().getContextPath()); resolver.addMacro("SERVLET_NAME", OpenCms.getSystemInfo().getServletPath()); // resolve the macros return resolver.resolveMacros(path); }
/** * @see org.opencms.xml.content.I_CmsXmlContentHandler#getModelFolder(org.opencms.file.CmsObject, java.lang.String) */ public String getModelFolder(CmsObject cms, String currentFolder) { String result = m_modelFolder; // store the original URI String uri = cms.getRequestContext().getUri(); try { // set URI to current folder cms.getRequestContext().setUri(currentFolder); CmsMacroResolver resolver = CmsMacroResolver.newInstance().setCmsObject(cms); // resolve eventual macros result = resolver.resolveMacros(m_modelFolder); } finally { // switch back to stored uri cms.getRequestContext().setUri(uri); } return result; }
/** * Prepares the macro resolver which is used to process the included text file.<p> * * @param params the direct edit parameters * * @return the macro resolver */ protected CmsMacroResolver prepareMacroResolverForIncludes(CmsDirectEditParams params) { String closeLink = getLink(params.getLinkForClose()); String deleteLink = getLink(params.getLinkForDelete()); String titleForNew = m_messages.key(Messages.GUI_EDITOR_TITLE_NEW_0); String skinUri = CmsWorkplace.getSkinUri(); // resolve macros in include header CmsMacroResolver resolver = CmsMacroResolver.newInstance(); resolver.addMacro("closeLink", closeLink); resolver.addMacro("deleteLink", deleteLink); resolver.addMacro("titleForNew", titleForNew); resolver.addMacro("skinUri", skinUri); return resolver; } }
/** * Returns the direct edit include HTML to insert in the page beginning.<p> t * * @param params the parameters for the direct edit includes * * @return the direct edit include HTML to insert in the page beginning */ public String getDirectEditIncludes(CmsDirectEditParams params) { String closeLink = getLink(params.getLinkForClose()); String deleteLink = getLink(params.getLinkForDelete()); String titleForNew = m_messages.key(Messages.GUI_EDITOR_TITLE_NEW_0); String skinUri = CmsWorkplace.getSkinUri(); // resolve macros in include header CmsMacroResolver resolver = CmsMacroResolver.newInstance(); resolver.addMacro("closeLink", closeLink); resolver.addMacro("deleteLink", deleteLink); resolver.addMacro("titleForNew", titleForNew); resolver.addMacro("skinUri", skinUri); return resolver.resolveMacros(m_headerInclude); }
/** * Creates a macro resolver based on the current users OpenCms context and the provided resource name.<p> * * @param cms the current OpenCms user context * @param resourcename the resource name for macros like {@link A_CmsResourceType#MACRO_RESOURCE_FOLDER_PATH} * * @return a macro resolver based on the current users OpenCms context and the provided resource name */ protected CmsMacroResolver getMacroResolver(CmsObject cms, String resourcename) { CmsMacroResolver result = CmsMacroResolver.newInstance().setCmsObject(cms); if (isFolder() && (!CmsResource.isFolder(resourcename))) { // ensure folder ends with "/" so resourcename = resourcename.concat("/"); } // add special mappings for macros in default properties result.addMacro(MACRO_RESOURCE_ROOT_PATH, cms.getRequestContext().addSiteRoot(resourcename)); result.addMacro(MACRO_RESOURCE_SITE_PATH, resourcename); result.addMacro(MACRO_RESOURCE_FOLDER_PATH, CmsResource.getFolderPath(resourcename)); result.addMacro(MACRO_RESOURCE_FOLDER_PATH_TOUCH, CmsResource.getFolderPath(resourcename)); result.addMacro(MACRO_RESOURCE_PARENT_PATH, CmsResource.getParentFolder(resourcename)); result.addMacro(MACRO_RESOURCE_NAME, CmsResource.getName(resourcename)); return result; }