/** * @see org.opencms.widgets.I_CmsWidget#getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { if (param != null) { return param.getStringValue(cms); } return null; }
/** * @see org.opencms.widgets.I_CmsWidget#getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { if (param != null) { return param.getStringValue(cms); } return null; }
/** * Determine value to show in editor.<p> * @param cms an initialized instance of a CmsObject * @param param the widget parameter to generate the widget for * * @return value to show in editor */ private String getValue(CmsObject cms, I_CmsWidgetParameter param) { String value = m_messages.key(m_bundleKey); if ((CmsStringUtil.isNotEmptyOrWhitespaceOnly(param.getStringValue(cms)) && !value.equals(param.getStringValue(cms))) || value.startsWith(CmsMessages.UNKNOWN_KEY_EXTENSION)) { // saved value is provided and different from localized value in bundle or no value found in bundle, use it value = param.getStringValue(cms); // replace OpenCms macro syntax with message bundle arguments Matcher matcher = PATTERN_MACRO.matcher(value); while (matcher.matches()) { int startIndex = matcher.start(1); int endIndex = matcher.end(3); String number = matcher.group(2); value = value.substring(0, startIndex) + "{" + number + "}" + value.substring(endIndex); matcher = PATTERN_MACRO.matcher(value); } } return value; }
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); StringBuffer result = new StringBuffer(16); result.append("<td class=\"xmlTd\">"); result.append("<input class=\"xmlInput textInput"); if (param.hasError()) { result.append(" xmlInputError"); } result.append("\""); result.append(" name=\""); result.append(id); result.append("\" id=\""); result.append(id); result.append("\" value=\""); result.append(CmsEncoder.escapeXml(param.getStringValue(cms))); result.append("\">"); result.append("</td>"); return result.toString(); }
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); StringBuffer result = new StringBuffer(16); result.append("<td class=\"xmlTd\"><input type=\"password\" class=\"xmlInput textInput"); if (param.hasError()) { result.append(" xmlInputError"); } result.append("\" name=\""); result.append(id); result.append("\" id=\""); result.append(id); result.append("\" value=\""); result.append(CmsEncoder.escapeXml(param.getStringValue(cms))); result.append("\">"); result.append("</td>"); return result.toString(); }
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); StringBuffer result = new StringBuffer(16); result.append("<td class=\"xmlTd\"><input type=\"password\" class=\"xmlInput textInput"); if (param.hasError()) { result.append(" xmlInputError"); } result.append("\" name=\""); result.append(id); result.append("\" id=\""); result.append(id); result.append("\" value=\""); result.append(CmsEncoder.escapeXml(param.getStringValue(cms))); result.append("\">"); result.append("</td>"); return result.toString(); }
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); StringBuffer result = new StringBuffer(16); result.append("<td class=\"xmlTd\">"); result.append("<input class=\"xmlInput textInput"); if (param.hasError()) { result.append(" xmlInputError"); } result.append("\""); result.append(" name=\""); result.append(id); result.append("\" id=\""); result.append(id); result.append("\" value=\""); result.append(CmsEncoder.escapeXml(param.getStringValue(cms))); result.append("\">"); result.append("</td>"); return result.toString(); }
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); StringBuffer result = new StringBuffer(16); int rows = DEFAULT_ROWS_NUMBER; try { rows = new Integer(getConfiguration()).intValue(); } catch (Exception e) { // ignore } result.append("<td class=\"xmlTd\">"); result.append("<textarea class=\"xmlInput maxwidth"); if (param.hasError()) { result.append(" xmlInputError"); } result.append("\" name=\""); result.append(id); result.append("\" rows=\""); result.append(rows); result.append("\" cols=\"60\" style=\"overflow:auto;\">"); result.append(CmsEncoder.escapeXml(param.getStringValue(cms))); result.append("</textarea>"); result.append("</td>"); return result.toString(); }
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); StringBuffer result = new StringBuffer(16); int rows = DEFAULT_ROWS_NUMBER; try { rows = new Integer(getConfiguration()).intValue(); } catch (Exception e) { // ignore } result.append("<td class=\"xmlTd\">"); result.append("<textarea class=\"xmlInput maxwidth"); if (param.hasError()) { result.append(" xmlInputError"); } result.append("\" name=\""); result.append(id); result.append("\" rows=\""); result.append(rows); result.append("\" cols=\"60\" style=\"overflow:auto;\">"); result.append(CmsEncoder.escapeXml(param.getStringValue(cms))); result.append("</textarea>"); result.append("</td>"); return result.toString(); }
result.append(param.getStringValue(cms)); result.append("\" name=\""); result.append(id);
/** * Returns the boolean value of the given widget parameter.<p> * * @param cms an initialized instance of a CmsObject * @param value the XML content value to get the boolean value of * * @return the boolean value of the given widget parameter */ public static boolean getBooleanValue(CmsObject cms, I_CmsWidgetParameter value) { boolean result; if (value instanceof CmsXmlBooleanValue) { // this is a "native" boolean type result = ((CmsXmlBooleanValue)value).getBooleanValue(); } else { // get the boolean value from the String value result = getBooleanValue(value.getStringValue(cms)); } return result; }
/** * Returns the currently selected values of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is used.<p> * * @param cms the current users OpenCms context * @param param the widget parameter of this dialog * * @return a list of the currently selected values of the select widget */ protected List<String> getSelectedValues(CmsObject cms, I_CmsWidgetParameter param) { List<String> values = new ArrayList<String>(); String paramValue = param.getStringValue(cms); if (CmsStringUtil.isEmpty(paramValue)) { Iterator<CmsSelectWidgetOption> itOptions = CmsSelectWidgetOption.getDefaultOptions( m_selectOptions).iterator(); while (itOptions.hasNext()) { CmsSelectWidgetOption option = itOptions.next(); values.add(option.getValue()); } } else { values.addAll(CmsStringUtil.splitAsList(paramValue, ',', true)); } return values; }
/** * Returns the boolean value of the given widget parameter.<p> * * @param cms an initialized instance of a CmsObject * @param value the XML content value to get the boolean value of * * @return the boolean value of the given widget parameter */ public static boolean getBooleanValue(CmsObject cms, I_CmsWidgetParameter value) { boolean result; if (value instanceof CmsXmlBooleanValue) { // this is a "native" boolean type result = ((CmsXmlBooleanValue)value).getBooleanValue(); } else { // get the boolean value from the String value result = getBooleanValue(value.getStringValue(cms)); } return result; }
/** * Returns the currently selected values of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is used.<p> * * @param cms the current users OpenCms context * @param param the widget parameter of this dialog * * @return a list of the currently selected values of the select widget */ protected List getSelectedValues(CmsObject cms, I_CmsWidgetParameter param) { List values = new ArrayList(); String paramValue = param.getStringValue(cms); if (CmsStringUtil.isEmpty(paramValue)) { Iterator itOptions = CmsSelectWidgetOption.getDefaultOptions(m_selectOptions).iterator(); while (itOptions.hasNext()) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)itOptions.next(); values.add(option.getValue()); } } else { values.addAll(CmsStringUtil.splitAsList(paramValue, ',', true)); } return values; }
/** * Returns the currently selected value of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is returned.<p> * * @param cms the current users OpenCms context * @param param the widget parameter of this dialog * * @return the currently selected value of the select widget */ protected String getSelectedValue(CmsObject cms, I_CmsWidgetParameter param) { String paramValue = param.getStringValue(cms); if (CmsStringUtil.isEmpty(paramValue)) { CmsSelectWidgetOption option = CmsSelectWidgetOption.getDefaultOption(m_selectOptions); if (option != null) { paramValue = option.getValue(); } } return paramValue; }
/** * @see org.opencms.widgets.A_CmsWidget#getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ @Override public String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String result = param.getStringValue(cms); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(result) && !"0".equals(result)) { try { result = getCalendarLocalizedTime( widgetDialog.getLocale(), widgetDialog.getMessages(), Long.parseLong(result)); } catch (NumberFormatException e) { if (!CmsMacroResolver.isMacro(result, CmsMacroResolver.KEY_CURRENT_TIME)) { // neither long nor macro, show empty value result = ""; } } } else { result = ""; } return result; }
/** * @see org.opencms.widgets.A_CmsWidget#getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ @Override public String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String result = param.getStringValue(cms); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(result) && !"0".equals(result)) { try { result = getCalendarLocalizedTime( widgetDialog.getLocale(), widgetDialog.getMessages(), Long.parseLong(result)); } catch (NumberFormatException e) { if (!CmsMacroResolver.isMacro(result, CmsMacroResolver.KEY_CURRENT_TIME)) { // neither long nor macro, show empty value result = ""; } } } else { result = ""; } return result; }
/** * Returns the currently selected value of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is returned.<p> * * @param cms the current users OpenCms context * @param param the widget parameter of this dialog * * @return the currently selected value of the select widget */ protected String getSelectedValue(CmsObject cms, I_CmsWidgetParameter param) { String paramValue = param.getStringValue(cms); if (CmsStringUtil.isEmpty(paramValue)) { CmsSelectWidgetOption option = CmsSelectWidgetOption.getDefaultOption(m_selectOptions); if (option != null) { paramValue = option.getValue(); } } return paramValue; }
/** * @see org.opencms.widgets.A_CmsWidget#setEditorValue(org.opencms.file.CmsObject, java.util.Map, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ @Override public void setEditorValue( CmsObject cms, Map formParameters, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { super.setEditorValue(cms, formParameters, widgetDialog, param); String id = param.getStringValue(cms); if (CmsStringUtil.isEmptyOrWhitespaceOnly(id)) { return; } try { CmsCategory cat = CmsCategoryService.getInstance().getCategory(cms, cms.readResource(new CmsUUID(id))); if (cat.getPath().startsWith(getStartingCategory(cms, cms.getSitePath(getResource(cms, param))))) { param.setStringValue(cms, cat.getRootPath()); } else { param.setStringValue(cms, ""); } } catch (CmsException e) { // invalid value param.setStringValue(cms, ""); } }
String id = param.getStringValue(cms); if (CmsStringUtil.isEmptyOrWhitespaceOnly(id)) { return;