/** * Builds the HTML String for the element language selector.<p> * * This method has to use the resource request parameter because the temporary file is * not available in the upper button frame.<p> * * @param attributes optional attributes for the <select> tag * @return the HTML for the element language select box */ public String buildSelectElementLanguage(String attributes) { return buildSelectElementLanguage(attributes, getParamResource(), getElementLocale()); }
/** * Builds the html String for the element language selector.<p> * * This method has to use the resource request parameter because the temporary file is * not available in the upper button frame.<p> * * @param attributes optional attributes for the <select> tag * @return the html for the element language select box */ public String buildSelectElementLanguage(String attributes) { return buildSelectElementLanguage(attributes, getParamResource(), getElementLocale()); }
/** * Determines if the element language selector is shown dependent on the available Locales.<p> * * @return true, if more than one Locale is available, otherwise false */ public boolean showElementLanguageSelector() { List locales = OpenCms.getLocaleManager().getAvailableLocales(getCms(), getParamResource()); if ((locales == null) || (locales.size() < 2)) { // for less than two available locales, do not create language selector return false; } return true; }
/** * Determines if the element language selector is shown dependent on the available Locales.<p> * * @return true, if more than one Locale is available, otherwise false */ public boolean showElementLanguageSelector() { List<Locale> locales = OpenCms.getLocaleManager().getAvailableLocales(getCms(), getParamResource()); if ((locales == null) || (locales.size() < 2)) { // for less than two available locales, do not create language selector return false; } return true; }
/** * Initializes the element language for the first call of the editor.<p> */ protected void initElementLanguage() { // get the default locale for the resource List<Locale> locales = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getParamResource()); Locale locale = locales.get(0); locale = ensureLocale(locale); setParamElementlanguage(locale.toString()); }
/** * Deletes the temporary file and unlocks the edited resource when in direct edit mode.<p> * * @param forceUnlock if true, the resource will be unlocked anyway */ @Override public void actionClear(boolean forceUnlock) { // delete the temporary file deleteTempFile(); boolean directEditMode = Boolean.valueOf(getParamDirectedit()).booleanValue(); boolean modified = Boolean.valueOf(getParamModified()).booleanValue(); if (directEditMode || forceUnlock || !modified) { // unlock the resource when in direct edit mode, force unlock is true or resource was not modified try { getCms().unlockResource(getParamResource()); } catch (CmsException e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e.getLocalizedMessage(), e); } } } }
/** * Deletes the temporary file and unlocks the edited resource when in direct edit mode.<p> * * @param forceUnlock if true, the resource will be unlocked anyway */ @Override public void actionClear(boolean forceUnlock) { // delete the temporary file deleteTempFile(); boolean directEditMode = Boolean.valueOf(getParamDirectedit()).booleanValue(); boolean modified = Boolean.valueOf(getParamModified()).booleanValue(); if (directEditMode || forceUnlock || !modified) { // unlock the resource when in direct edit mode, force unlock is true or resource was not modified try { getCms().unlockResource(getParamResource()); } catch (CmsException e) { // should usually never happen if (LOG.isInfoEnabled()) { LOG.info(e.getLocalizedMessage(), e); } } } }
/** * Returns true if the preview is available for the edited xml content.<p> * * This method has to use the resource request parameter and read the file from vfs because the temporary file is * not available in the upper button frame.<p> * * @return true if the preview is enabled, otherwise false */ public boolean isPreviewEnabled() { try { // read the original file because temporary file is not created when opening button frame CmsFile file = getCms().readFile(getParamResource(), CmsResourceFilter.ALL); CmsXmlContent content = CmsXmlContentFactory.unmarshal(getCloneCms(), file); return content.getHandler().getPreview(getCms(), m_content, getParamResource()) != null; } catch (Exception e) { // error reading or unmarshalling, no preview available return false; } }
} else { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_GET_LOCALES_1, getParamResource()));
} else { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_GET_LOCALES_1, getParamResource()));
/** * @see org.opencms.workplace.editors.CmsEditor#commitTempFile() */ @Override protected void commitTempFile() throws CmsException { super.commitTempFile(); m_file = getCloneCms().readFile(getParamResource()); m_content = CmsXmlContentFactory.unmarshal(getCloneCms(), m_file); }
/** * @see org.opencms.workplace.editors.CmsEditor#commitTempFile() */ @Override protected void commitTempFile() throws CmsException { super.commitTempFile(); m_file = getCloneCms().readFile(getParamResource()); m_content = CmsXmlContentFactory.unmarshal(getCloneCms(), m_file); }
/** * Initializes the element language for the first call of the editor.<p> */ protected void initElementLanguage() { // get the default locale for the resource List locales = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getParamResource()); Locale locale = (Locale)locales.get(0); if (m_content != null) { // to copy anything we need at least one locale if ((locales.size() > 1) && (m_content.getLocales().size() > 0) && !m_content.hasLocale(locale)) { // required locale not available, check if an existing default locale should be copied as "template" try { // a list of possible default locales has been set as property, try to find a match m_content.copyLocale(locales, locale); writeContent(); } catch (CmsException e) { // no match was found for the required locale } } if (!m_content.hasLocale(locale)) { // value may have changed because of the copy operation locale = m_content.getLocales().get(0); } } setParamElementlanguage(locale.toString()); }
/** * Returns true if the preview is available for the edited xml content.<p> * * This method has to use the resource request parameter and read the file from vfs because the temporary file is * not available in the upper button frame.<p> * * @return true if the preview is enabled, otherwise false */ public boolean isPreviewEnabled() { try { // read the original file because temporary file is not created when opening button frame CmsFile file = getCms().readFile(getParamResource(), CmsResourceFilter.ALL); CmsXmlContent content = CmsXmlContentFactory.unmarshal(getCloneCms(), file); return content.getContentDefinition().getContentHandler().getPreview( getCms(), m_content, getParamResource()) != null; } catch (Exception e) { // error reading or unmarshalling, no preview available return false; } }
/** * Writes the xml content to the vfs and re-initializes the member variables.<p> * * @throws CmsException if writing the file fails */ private void writeContent() throws CmsException { String decodedContent = m_content.toString(); try { m_file.setContents(decodedContent.getBytes(getFileEncoding())); } catch (UnsupportedEncodingException e) { throw new CmsException(Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()), e); } // the file content might have been modified during the write operation m_file = getCloneCms().writeFile(m_file); m_content = CmsXmlContentFactory.unmarshal(getCloneCms(), m_file); } }
List<Locale> locales = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getParamResource()); if (locales.size() > 1) {
List<Locale> locales = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getParamResource()); if (m_content != null) { if (!m_content.hasLocale(locale)) {
List locales = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getParamResource()); if (locales.size() > 1) {
/** * Writes the xml content to the vfs and re-initializes the member variables.<p> * * @throws CmsException if writing the file fails */ private void writeContent() throws CmsException { String decodedContent = m_content.toString(); try { m_file.setContents(decodedContent.getBytes(getFileEncoding())); } catch (UnsupportedEncodingException e) { throw new CmsException(Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()), e); } // the file content might have been modified during the write operation CmsObject cloneCms = getCloneCms(); CmsUUID tempProjectId = OpenCms.getWorkplaceManager().getTempFileProjectId(); cloneCms.getRequestContext().setCurrentProject(getCms().readProject(tempProjectId)); m_file = cloneCms.writeFile(m_file); m_content = CmsXmlContentFactory.unmarshal(cloneCms, m_file); } }
m_paramNewLink, getElementLocale(), getParamResource(), getParamModelFile(), getParamMode(),