/** * Performs the exit editor action and deletes the temporary file.<p> * * @see org.opencms.workplace.editors.CmsEditor#actionExit() */ @Override public void actionExit() throws IOException, JspException, ServletException { if (getAction() == ACTION_CANCEL) { // save and exit was canceled return; } // clear temporary file and unlock resource, if in directedit mode actionClear(false); // close the editor actionClose(); }
/** * Builds the html for the font face select box of a WYSIWYG editor.<p> * * @param attributes optional attributes for the <select> tag * @return the html for the font face select box */ public String buildSelectFonts(String attributes) { List<String> names = new ArrayList<String>(); for (int i = 0; i < CmsDefaultPageEditor.SELECTBOX_FONTS.length; i++) { String value = CmsDefaultPageEditor.SELECTBOX_FONTS[i]; names.add(value); } return buildSelect(attributes, names, names, -1, false); }
/** * Builds the html String for the element language selector.<p> * * @param attributes optional attributes for the <select> tag * @return the html for the element language selectbox */ public String buildSelectElementLanguage(String attributes) { return buildSelectElementLanguage(attributes, getParamTempfile(), getElementLocale()); }
/** * Builds the html String for the element language selector.<p> * * @param attributes optional attributes for the <select> tag * @return the html for the element language selectbox */ public String buildSelectElementLanguage(String attributes) { return buildSelectElementLanguage(attributes, getParamResource(), getElementLocale()); }
protected void initContent() { if (CmsStringUtil.isNotEmpty(getParamContent())) { if (CmsStringUtil.isNotEmpty(getParamElementname()) && getParamElementname().equals(getParamOldelementname())) { if (CmsStringUtil.isNotEmpty(getParamElementlanguage()) && getParamElementlanguage().equals(getParamOldelementlanguage())) { return; getCms().getRequestContext().setAttribute(CmsRequestContext.ATTRIBUTE_EDITOR, Boolean.TRUE); if (m_page.hasValue(getParamElementname(), getElementLocale())) { elementData = m_page.getStringValue(getCms(), getParamElementname(), getElementLocale()); } else { if (Boolean.valueOf(getParamDirectedit()).booleanValue()) { m_page.addValue(getParamElementname(), getElementLocale()); setParamContent(elementData);
/** * @see org.opencms.workplace.editors.CmsEditor#actionSave() */ @Override public void actionSave() throws JspException { try { // save content to temporary file performSaveContent(getParamElementname(), getElementLocale()); // copy the temporary file content back to the original file commitTempFile(); // set the modified parameter setParamModified(Boolean.TRUE.toString()); } catch (CmsException e) { showErrorPage(e); } if (getAction() != ACTION_CANCEL) { // save successful, set save action setAction(ACTION_SAVE); } }
Locale loc = getElementLocale(); m_page.removeLocale(loc); m_file = getCms().writeFile(m_file); List<Locale> locales = m_page.getLocales(); if (locales.size() > 0) { setParamElementlanguage(newLoc.toString()); m_elementLocale = newLoc; } else { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_GET_LOCALES_1, getParamResource())); initContent(); } catch (CmsXmlException e) { showErrorPage(e); } catch (CmsException e) {
/** * @see org.opencms.workplace.editors.CmsEditor#actionClear(boolean) */ @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); } } } }
List elementList = getElementList(); List options = new ArrayList(elementList.size()); List values = new ArrayList(elementList.size()); String elementName = getParamElementname(); if (CmsStringUtil.isEmpty(elementName)) { elementName = getParamOldelementname(); if ((!m_page.hasValue(element.getName(), getElementLocale()) && element.isMandantory()) || m_page.isEnabled(element.getName(), getElementLocale())) { return buildSelect(attributes, options, values, currentIndex, false);
String content = prepareContent(true); if (EDITOR_CLEANUP.equals(getParamAction())) { if ((contentConversion == null) || (contentConversion.equals(CmsHtmlConverter.PARAM_DISABLED))) { m_page.setStringValue(getCms(), body, locale, content); m_file = getCms().writeFile(m_file); m_page = CmsXmlPageFactory.unmarshal(getCms(), m_file); if (m_page.hasValue(body, locale)) { getCms().getRequestContext().setAttribute(CmsRequestContext.ATTRIBUTE_EDITOR, Boolean.TRUE); content = m_page.getStringValue(getCms(), body, locale); if (content == null) { content = ""; setParamContent(content); prepareContent(false); m_page.setEnabled(body, locale, enabled);
/** * Returns the list of active elements of the page.<p> * * @return the list of active elements of the page */ protected List<CmsDialogElement> getElementList() { if (m_elementList == null) { m_elementList = CmsDialogElements.computeElements(getCms(), m_page, getParamTempfile(), getElementLocale()); } return m_elementList; }
/** * Performs a configurable action performed by the editor.<p> * * The default action is: save resource, clear temporary files and publish the resource directly.<p> * * @throws IOException if a forward fails * @throws JspException if including a JSP fails * @throws ServletException if a forward fails */ public void actionDirectEdit() throws IOException, JspException, ServletException { // get the action class from the OpenCms runtime property I_CmsEditorActionHandler actionClass = OpenCms.getWorkplaceManager().getEditorActionHandler(); if (actionClass == null) { // error getting the action class, save content and exit the editor actionSave(); actionExit(); } else { actionClass.editorAction(this, getJsp()); } }
while (i.hasNext()) { I_CmsEditorCssHandler cssHandler = i.next(); if (cssHandler.matches(getCms(), getParamTempfile())) { m_uriStyleSheet = cssHandler.getUriStyleSheet(getCms(), getParamTempfile()); break; String currentTemplate = getUriTemplate(); m_uriStyleSheet = getCms().readPropertyObject( currentTemplate, CmsPropertyDefinition.PROPERTY_TEMPLATE,
Locale defaultLocale = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getCms().getSitePath(m_file)).get( 0); getCms().writeFile(m_file); } catch (CmsException e) { showErrorPage(this, e); } catch (JspException exc) { setParamElementlanguage(defaultLocale.toString()); } else { setParamElementlanguage(defaultLocale.toString()); } else { setParamElementlanguage(locales.get(0).toString());
/** * Returns the OpenCms VFS uri of the template of the current page.<p> * * @return the OpenCms VFS uri of the template of the current page */ public String getUriTemplate() { String result = ""; try { result = getCms().readPropertyObject(getParamTempfile(), CmsPropertyDefinition.PROPERTY_TEMPLATE, true).getValue( ""); } catch (CmsException e) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_READ_TEMPLATE_PROP_FAILED_0), e); } return result; }
protected void initContent() { if (CmsStringUtil.isNotEmpty(getParamContent())) { if (CmsStringUtil.isNotEmpty(getParamElementname()) && getParamElementname().equals(getParamOldelementname())) { if (CmsStringUtil.isNotEmpty(getParamElementlanguage()) && getParamElementlanguage().equals(getParamOldelementlanguage())) { return; getCms().getRequestContext().setAttribute(CmsRequestContext.ATTRIBUTE_EDITOR, Boolean.TRUE); if (m_page.hasValue(getParamElementname(), getElementLocale())) { elementData = m_page.getStringValue(getCms(), getParamElementname(), getElementLocale()); } else { if (Boolean.valueOf(getParamDirectedit()).booleanValue()) { m_page.addValue(getParamElementname(), getElementLocale()); setParamContent(elementData);
/** * @see org.opencms.workplace.editors.CmsEditor#actionSave() */ @Override public void actionSave() throws JspException { try { // save content to temporary file performSaveContent(getParamElementname(), getElementLocale()); // copy the temporary file content back to the original file commitTempFile(); // set the modified parameter setParamModified(Boolean.TRUE.toString()); } catch (CmsException e) { showErrorPage(e); } if (getAction() != ACTION_CANCEL) { // save successful, set save action setAction(ACTION_SAVE); } }
Locale loc = getElementLocale(); m_page.removeLocale(loc); m_file = getCms().writeFile(m_file); List locales = m_page.getLocales(); if (locales.size() > 0) { setParamElementlanguage(newLoc.toString()); m_elementLocale = newLoc; } else { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_GET_LOCALES_1, getParamResource())); initContent(); } catch (CmsXmlException e) { showErrorPage(e); } catch (CmsException e) {
/** * @see org.opencms.workplace.editors.CmsEditor#actionClear(boolean) */ @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); } } } }
List<CmsDialogElement> elementList = getElementList(); List<String> options = new ArrayList<String>(elementList.size()); List<String> values = new ArrayList<String>(elementList.size()); String elementName = getParamElementname(); if (CmsStringUtil.isEmpty(elementName)) { elementName = getParamOldelementname(); if ((!m_page.hasValue(element.getName(), getElementLocale()) && element.isMandantory()) || m_page.isEnabled(element.getName(), getElementLocale())) { return buildSelect(attributes, options, values, currentIndex, false);