1 31 32 package org.opencms.frontend.templateone; 33 34 import org.opencms.file.CmsProperty; 35 import org.opencms.file.CmsPropertyDefinition; 36 import org.opencms.file.CmsResource; 37 import org.opencms.file.CmsResourceFilter; 38 import org.opencms.file.types.CmsResourceTypeBinary; 39 import org.opencms.file.types.CmsResourceTypeImage; 40 import org.opencms.file.types.CmsResourceTypePlain; 41 import org.opencms.file.types.CmsResourceTypeXmlPage; 42 import org.opencms.frontend.templateone.modules.CmsLayoutXmlContentHandler; 43 import org.opencms.i18n.CmsEncoder; 44 import org.opencms.i18n.CmsMessages; 45 import org.opencms.jsp.CmsJspActionElement; 46 import org.opencms.jsp.util.CmsTemplateContentListItem; 47 import org.opencms.main.CmsException; 48 import org.opencms.main.CmsLog; 49 import org.opencms.main.OpenCms; 50 import org.opencms.util.CmsStringUtil; 51 import org.opencms.workplace.CmsDialogSelector; 52 import org.opencms.workplace.CmsWorkplace; 53 import org.opencms.workplace.I_CmsDialogHandler; 54 import org.opencms.workplace.commons.CmsPropertyCustom; 55 import org.opencms.workplace.explorer.CmsExplorerTypeSettings; 56 57 import java.util.ArrayList ; 58 import java.util.Iterator ; 59 import java.util.List ; 60 61 import javax.servlet.http.HttpServletRequest ; 62 import javax.servlet.http.HttpServletResponse ; 63 import javax.servlet.jsp.JspException ; 64 import javax.servlet.jsp.PageContext ; 65 66 import org.apache.commons.logging.Log; 67 68 79 public class CmsPropertyTemplateOne extends CmsPropertyCustom implements I_CmsDialogHandler { 80 81 86 private static final String [] ALL_PROPERTIES = { 87 88 CmsTemplateNavigation.PROPERTY_HEADNAV_USE, 89 CmsTemplateBean.PROPERTY_SHOWHEADIMAGE, 90 CmsTemplateBean.PROPERTY_HEAD_IMGURI, 91 CmsTemplateBean.PROPERTY_HEAD_IMGLINK, 92 CmsTemplateBean.PROPERTY_HEAD_ELEMENTURI, 93 CmsTemplateBean.PROPERTY_SHOW_HEADNAV, 94 CmsTemplateBean.PROPERTY_SHOW_NAVLEFT, 95 CmsTemplateBean.PROPERTY_NAVLEFT_ELEMENTURI, 96 CmsTemplateBean.PROPERTY_SIDE_URI, 97 CmsTemplateBean.PROPERTY_CONFIGPATH, 98 CmsTemplateBean.PROPERTY_LAYOUT_CENTER, 99 CmsTemplateBean.PROPERTY_LAYOUT_RIGHT}; 100 101 106 private static final String [] DEFAULT_PROPERTIES = { 107 108 CmsPropertyDefinition.PROPERTY_TITLE, CmsPropertyDefinition.PROPERTY_DESCRIPTION}; 109 110 111 private static final String ENABLE = "enable"; 112 113 114 private static final String INDIVIDUAL = "individual"; 115 116 117 private static final String KEY_PREFIX = "templateonedialog."; 118 119 120 private static final Log LOG = CmsLog.getLog(CmsPropertyTemplateOne.class); 121 122 123 private static final String MODULE_PATH = "/system/modules/org.opencms.frontend.templateone/"; 124 125 126 private static final String PARAM_DEFAULT = ""; 127 128 129 private static final String PARAM_FALSE = CmsStringUtil.FALSE; 130 131 132 private static final String PARAM_TRUE = CmsStringUtil.TRUE; 133 134 135 private static final String TEMPLATE_ONE = "/system/modules/org.opencms.frontend.templateone/templates/main"; 136 137 138 private static final String VFS_PATH_CONFIGFILES = CmsWorkplace.VFS_PATH_SYSTEM + "shared/templateone/"; 139 140 141 private static final String VFS_PATH_CONFIGFILES_CENTER = VFS_PATH_CONFIGFILES + "center/"; 142 143 144 private static final String VFS_PATH_CONFIGFILES_RIGHT = VFS_PATH_CONFIGFILES + "right/"; 145 146 151 public CmsPropertyTemplateOne() { 152 153 super(null); 154 } 155 156 161 public CmsPropertyTemplateOne(CmsJspActionElement jsp) { 162 163 super(jsp); 164 } 165 166 173 public CmsPropertyTemplateOne(PageContext context, HttpServletRequest req, HttpServletResponse res) { 174 175 super(new CmsJspActionElement(context, req, res)); 176 } 177 178 184 public void actionEdit(HttpServletRequest request) throws JspException { 185 186 getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); 188 try { 189 if (isEditable()) { 191 performEditOperation(request); 192 } 193 } catch (Throwable e) { 194 includeErrorpage(this, e); 196 } 197 } 198 199 208 public String buildCheckBox(String propertyName, String propertyValue, String propertyText) { 209 210 StringBuffer checkbox = new StringBuffer (); 211 checkbox.append(buildTableRowStart(key(propertyText))); 212 String checked = ""; 213 if (getActiveProperties().containsKey(propertyName)) { 214 CmsProperty currentProperty = (CmsProperty)getActiveProperties().get(propertyName); 216 217 String propValue = currentProperty.getValue(); 218 if (propValue != null) { 219 propValue = propValue.trim(); 220 } 221 propValue = CmsEncoder.escapeXml(propValue); 222 if (propertyValue.equals(propValue)) { 223 checked = " checked=\"checked\""; 224 } 225 } else { 226 if (propertyValue.equals(PARAM_DEFAULT)) { 228 checked = " checked=\"checked\""; 229 } 230 } 231 checkbox.append("<input type=\"checkbox\" name=\""); 232 checkbox.append(PREFIX_VALUE); 233 checkbox.append(propertyName); 234 checkbox.append("\" value=\""); 235 checkbox.append(propertyValue); 236 checkbox.append("\""); 237 checkbox.append(checked); 238 checkbox.append(">"); 239 checkbox.append(buildTableRowEnd()); 240 241 return checkbox.toString(); 242 } 243 244 249 public String buildEditForm() { 250 251 CmsMessages messages = Messages.get().getBundle(getLocale()); 252 StringBuffer result = new StringBuffer (); 253 254 boolean editable = isEditable(); 256 257 result.append("<table border=\"0\">\n"); 259 result.append("<tr>\n"); 260 result.append("\t<td class=\"textbold\">"); 261 result.append(messages.key(Messages.GUI_INPUT_PROPERTY_0)); 262 result.append("</td>\n"); 263 result.append("\t<td class=\"textbold maxwidth\">"); 264 result.append(messages.key(Messages.GUI_LABEL_VALUE_0)); 265 result.append("</td>\n"); 266 result.append("\t<td class=\"textbold\" style=\"white-space: nowrap;\">"); 267 result.append(messages.key(Messages.GUI_USED_PROPERTY_0)); 268 result.append("</td>\n"); 269 result.append("</tr>\n"); 270 result.append("<tr><td colspan=\"3\"><span style=\"height: 6px;\"></span></td></tr>\n"); 271 272 for (int i = 0; i < DEFAULT_PROPERTIES.length; i++) { 274 result.append(buildPropertyEntry(DEFAULT_PROPERTIES[i], key(KEY_PREFIX + DEFAULT_PROPERTIES[i]), editable)); 275 } 276 277 result.append(buildNavigationProperties(editable)); 279 280 result.append(buildCheckBox(CmsTemplateNavigation.PROPERTY_HEADNAV_USE, PARAM_TRUE, KEY_PREFIX 282 + CmsTemplateNavigation.PROPERTY_HEADNAV_USE)); 283 284 result.append(buildRadioButtons( 286 CmsTemplateBean.PROPERTY_SHOWHEADIMAGE, 287 INDIVIDUAL, 288 "toggleHeadImageProperties", 289 editable)); 290 291 result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_HEAD_IMGURI, KEY_PREFIX 293 + CmsTemplateBean.PROPERTY_HEAD_IMGURI, editable, messages)); 294 result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_HEAD_IMGLINK, KEY_PREFIX 296 + CmsTemplateBean.PROPERTY_HEAD_IMGLINK, editable, messages)); 297 298 result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_HEAD_ELEMENTURI, KEY_PREFIX 300 + CmsTemplateBean.PROPERTY_HEAD_ELEMENTURI, editable, messages)); 301 302 result.append(buildRadioButtons(CmsTemplateBean.PROPERTY_SHOW_HEADNAV, ENABLE, null, editable)); 304 305 result.append(buildRadioButtons(CmsTemplateBean.PROPERTY_SHOW_NAVLEFT, ENABLE, null, editable)); 307 308 result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_NAVLEFT_ELEMENTURI, KEY_PREFIX 310 + CmsTemplateBean.PROPERTY_NAVLEFT_ELEMENTURI, editable, messages)); 311 result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_SIDE_URI, KEY_PREFIX 313 + CmsTemplateBean.PROPERTY_SIDE_URI, editable, messages)); 314 315 result.append(buildPropertySelectbox( 317 CmsTemplateContentListItem.DISPLAYAREA_CENTER, 318 CmsTemplateBean.PROPERTY_LAYOUT_CENTER, 319 KEY_PREFIX + CmsTemplateBean.PROPERTY_LAYOUT_CENTER, 320 editable)); 321 result.append(buildPropertySelectbox( 323 CmsTemplateContentListItem.DISPLAYAREA_RIGHT, 324 CmsTemplateBean.PROPERTY_LAYOUT_RIGHT, 325 KEY_PREFIX + CmsTemplateBean.PROPERTY_LAYOUT_RIGHT, 326 editable)); 327 328 result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_CONFIGPATH, KEY_PREFIX 330 + CmsTemplateBean.PROPERTY_CONFIGPATH, editable, messages)); 331 332 result.append("</table>"); 333 334 return result.toString(); 335 } 336 337 349 public String buildSetFormValues() { 350 351 StringBuffer result = new StringBuffer (1024); 352 for (int i = 0; i < DEFAULT_PROPERTIES.length; i++) { 354 String curProperty = DEFAULT_PROPERTIES[i]; 355 String shownValue = ""; 357 try { 358 shownValue = getCms().readPropertyObject(getParamResource(), curProperty, false).getValue(); 359 } catch (CmsException e) { 360 e.printStackTrace(); 361 } 362 if (!CmsStringUtil.isEmpty(shownValue)) { 363 result.append("\tdocument.getElementById(\""); 365 result.append(PREFIX_VALUE); 366 result.append(curProperty); 367 result.append("\").value = \""); 368 result.append(CmsStringUtil.escapeJavaScript(shownValue)); 369 result.append("\";\n"); 370 } 371 } 372 373 return result.toString(); 374 } 375 376 383 public String getDefault(String propertydef) { 384 385 try { 386 String parentFolder = CmsResource.getParentFolder(getParamResource()); 387 CmsProperty property = getCms().readPropertyObject(parentFolder, propertydef, true); 388 String propertyValue = property.getValue(); 389 if (!CmsStringUtil.isEmpty(propertyValue)) { 390 return property.getValue(); 391 } 392 } catch (CmsException e) { 393 if (LOG.isErrorEnabled()) { 394 LOG.error(e); 395 } 396 } 397 398 return ""; 399 } 400 401 404 public String getDialogHandler() { 405 406 return CmsDialogSelector.DIALOG_PROPERTY; 407 } 408 409 412 public String getDialogUri(String resource, CmsJspActionElement jsp) { 413 414 try { 415 String templateOneDialog = MODULE_PATH + "dialogs/property.jsp"; 416 boolean dialogPresent = jsp.getCmsObject().existsResource(templateOneDialog); 417 418 CmsResource res = jsp.getCmsObject().readResource(resource, CmsResourceFilter.ALL); 419 String template = jsp.getCmsObject().readPropertyObject(res, CmsPropertyDefinition.PROPERTY_TEMPLATE, true).getValue( 420 ""); 421 if (!res.isFolder() 422 && res.getTypeId() != CmsResourceTypeBinary.getStaticTypeId() 423 && res.getTypeId() != CmsResourceTypePlain.getStaticTypeId() 424 && res.getTypeId() != CmsResourceTypeImage.getStaticTypeId()) { 425 if (dialogPresent && TEMPLATE_ONE.equals(template)) { 427 return templateOneDialog; 429 } else if (res.getTypeId() == CmsResourceTypeXmlPage.getStaticTypeId()) { 430 return PATH_WORKPLACE + "editors/dialogs/property.jsp"; 432 } 433 } 434 if (dialogPresent 435 && res.isFolder() 436 && TEMPLATE_ONE.equals(template) 437 && !res.getRootPath().startsWith(CmsResource.VFS_FOLDER_SYSTEM)) { 438 return templateOneDialog; 440 } 441 String resTypeName = OpenCms.getResourceManager().getResourceType(res.getTypeId()).getTypeName(); 442 CmsExplorerTypeSettings settings = getSettingsForType(resTypeName); 444 if (settings.isPropertiesEnabled()) { 445 return URI_PROPERTY_CUSTOM_DIALOG; 447 } 448 } catch (CmsException e) { 449 if (LOG.isErrorEnabled()) { 451 LOG.error(e); 452 } 453 } 454 return URI_PROPERTY_DIALOG; 455 } 456 457 464 protected boolean performEditOperation(HttpServletRequest request) throws CmsException { 465 466 boolean useTempfileProject = Boolean.valueOf(getParamUsetempfileproject()).booleanValue(); 467 try { 468 if (useTempfileProject) { 469 switchToTempProject(); 470 } 471 for (int i = 0; i < DEFAULT_PROPERTIES.length; i++) { 473 String curProperty = DEFAULT_PROPERTIES[i]; 474 String paramValue = request.getParameter(PREFIX_VALUE + curProperty); 475 String oldValue = request.getParameter(PREFIX_HIDDEN + curProperty); 476 writeProperty(curProperty, paramValue, oldValue); 477 } 478 479 for (int i = 0; i < ALL_PROPERTIES.length; i++) { 481 String curProperty = ALL_PROPERTIES[i]; 482 String paramValue = request.getParameter(PREFIX_VALUE + curProperty); 483 String oldValue = request.getParameter(PREFIX_HIDDEN + curProperty); 484 writeProperty(curProperty, paramValue, oldValue); 485 } 486 487 489 String paramValue = request.getParameter("enablenav"); 491 String oldValue = null; 492 if (Boolean.valueOf(paramValue).booleanValue()) { 493 paramValue = request.getParameter("navpos"); 495 if (!"-1".equals(paramValue)) { 496 oldValue = request.getParameter(PREFIX_HIDDEN + CmsPropertyDefinition.PROPERTY_NAVPOS); 498 writeProperty(CmsPropertyDefinition.PROPERTY_NAVPOS, paramValue, oldValue); 499 } 500 paramValue = request.getParameter(PREFIX_VALUE + CmsPropertyDefinition.PROPERTY_NAVTEXT); 501 oldValue = request.getParameter(PREFIX_HIDDEN + CmsPropertyDefinition.PROPERTY_NAVTEXT); 502 writeProperty(CmsPropertyDefinition.PROPERTY_NAVTEXT, paramValue, oldValue); 503 } else { 504 writeProperty(CmsPropertyDefinition.PROPERTY_NAVPOS, null, null); 506 writeProperty(CmsPropertyDefinition.PROPERTY_NAVTEXT, null, null); 507 } 508 } finally { 509 if (useTempfileProject) { 510 switchToCurrentProject(); 511 } 512 } 513 return true; 514 } 515 516 527 private StringBuffer buildPropertyRadioEntry( 528 String propertyName, 529 String propertyValue, 530 String propertyText, 531 String JSToggleFunction, 532 boolean editable) { 533 534 String disabled = ""; 535 if (!editable) { 536 disabled = " disabled=\"disabled\""; 537 } 538 StringBuffer result = new StringBuffer (256); 539 String checked = ""; 542 if (getActiveProperties().containsKey(propertyName)) { 543 CmsProperty currentProperty = (CmsProperty)getActiveProperties().get(propertyName); 545 546 String propValue = currentProperty.getValue(); 547 if (propValue != null) { 548 propValue = propValue.trim(); 549 } 550 propValue = CmsEncoder.escapeXml(propValue); 551 if (propertyValue.equals(propValue)) { 552 checked = " checked=\"checked\""; 553 } 554 } else { 555 if (propertyValue.equals(PARAM_DEFAULT)) { 557 checked = " checked=\"checked\""; 558 } 559 } 560 String onclick = ""; 562 if (JSToggleFunction != null) { 563 onclick = "onclick=\"" + JSToggleFunction + "();\" "; 564 } 565 result.append("<input "); 566 result.append(onclick); 567 result.append("type=\"radio\" "); 568 result.append("name=\""); 569 result.append(PREFIX_VALUE); 570 result.append(propertyName); 571 result.append("\" value=\""); 572 result.append(propertyValue); 573 result.append("\""); 574 result.append(checked); 575 result.append(disabled); 576 result.append(">"); 577 result.append(" "); 578 result.append(propertyText); 579 580 return result; 581 } 582 583 593 private StringBuffer buildPropertySearchEntry( 594 String propertyName, 595 String propertyTitle, 596 boolean editable, 597 CmsMessages messages) { 598 599 StringBuffer result = new StringBuffer (256); 600 result.append(buildTableRowStart(key(propertyTitle))); 601 String disabled = ""; 602 if (!editable) { 603 disabled = " disabled=\"disabled\""; 604 } 605 String propValue = ""; 606 CmsProperty currentProperty = (CmsProperty)getActiveProperties().get(propertyName); 608 if (currentProperty != null) { 609 propValue = currentProperty.getValue(); 610 if (CmsStringUtil.isEmpty(propValue)) { 611 if (CmsTemplateBean.PROPERTY_HEAD_IMGURI.equals(propertyName) 612 || CmsTemplateBean.PROPERTY_HEAD_IMGLINK.equals(propertyName)) { 613 String tmp = getDefault(propertyName); 614 if (!CmsStringUtil.isEmpty(tmp)) { 615 propValue = tmp; 616 } 617 } 618 } else { 619 propValue = propValue.trim(); 620 } 621 } 622 623 propValue = CmsEncoder.escapeXml(propValue); 624 result.append("<input type=\"text\" style=\"width: 99%\" class=\"maxwidth\" "); 625 result.append("name=\""); 626 result.append(PREFIX_VALUE); 627 result.append(propertyName); 628 result.append("\" id=\""); 629 result.append(PREFIX_VALUE); 630 result.append(propertyName); 631 result.append("\" value=\""); 632 result.append(propValue); 633 result.append("\""); 634 result.append(disabled); 635 result.append(">"); 636 result.append("<input type=\"hidden\" name=\""); 637 result.append(PREFIX_HIDDEN); 638 result.append(propertyName); 639 result.append("\" id=\""); 640 result.append(PREFIX_HIDDEN); 641 result.append(propertyName); 642 result.append("\" value=\""); 643 result.append(propValue); 644 result.append("\">"); 645 result.append("</td>\n"); 646 result.append("<td>"); 647 result.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"); 648 result.append("\t<tr>\n"); 649 result.append("<td> </td>"); 650 result.append("<td><a HREF=\"#\" onclick=\"javascript:top.openTreeWin('copy', true, 'main', '"); 651 result.append(PREFIX_VALUE); 652 result.append(propertyName); 653 result.append("', document);\" class=\"button\" title=\""); 654 result.append(messages.key(Messages.GUI_BUTTON_SEARCH_0)); 655 result.append("\"><img class=\"button\" SRC=\""); 656 result.append(getSkinUri()); 657 result.append("/buttons/folder.png\" border=\"0\"></a></td>"); 658 result.append("</tr>\n"); 659 result.append("</table>\n"); 660 result.append("</td>\n"); 661 result.append("</tr>"); 662 663 return result; 664 } 665 666 676 private StringBuffer buildPropertySelectbox( 677 String listType, 678 String propertyName, 679 String propertyTitle, 680 boolean editable) { 681 682 StringBuffer result = new StringBuffer (128); 683 result.append(buildTableRowStart(key(propertyTitle))); 684 String disabled = ""; 685 if (!editable) { 686 disabled = " disabled=\"disabled\""; 687 } 688 String propValue = ""; 689 CmsProperty currentProperty = (CmsProperty)getActiveProperties().get(propertyName); 691 String inheritedValue = ""; 692 if (currentProperty != null) { 693 propValue = currentProperty.getValue(); 695 inheritedValue = getDefault(propertyName); 696 } else { 697 propValue = getDefault(propertyName); 699 if (CmsStringUtil.isEmptyOrWhitespaceOnly(propValue)) { 700 propValue = ""; 701 } 702 inheritedValue = propValue; 703 } 704 705 List resources = getConfigurationFiles(listType); 706 List options = new ArrayList (resources.size() + 1); 707 List values = new ArrayList (resources.size() + 1); 708 int selectedIndex = 0; 709 710 options.add(key(KEY_PREFIX + "nolayout")); 712 if ("".equals(propValue) 713 || ("".equals(inheritedValue)) 714 || (CmsTemplateBean.PROPERTY_VALUE_NONE.equals(inheritedValue))) { 715 values.add(""); 717 } else { 718 values.add(CmsTemplateBean.PROPERTY_VALUE_NONE); 719 } 720 721 for (int i = 0; i < resources.size(); i++) { 722 CmsResource res = (CmsResource)resources.get(i); 724 String path = getCms().getSitePath(res); 725 String description = ""; 727 try { 728 description = getCms().readPropertyObject(path, CmsPropertyDefinition.PROPERTY_DESCRIPTION, false).getValue( 729 null); 730 if (CmsStringUtil.isEmpty(description)) { 731 description = getCms().readPropertyObject(path, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue( 732 path); 733 } 734 } catch (CmsException e) { 735 if (LOG.isErrorEnabled()) { 737 LOG.error(e); 738 } 739 } 740 String localized = key(description); 742 if (localized.startsWith(CmsMessages.UNKNOWN_KEY_EXTENSION)) { 743 localized = description; 744 } 745 options.add(localized); 746 if (path.equals(propValue)) { 748 selectedIndex = i + 1; 749 } 750 if (path.equals(inheritedValue)) { 752 path = ""; 754 } 755 values.add(path); 756 } 757 StringBuffer attrs = new StringBuffer (4); 759 attrs.append("name=\"").append(PREFIX_VALUE).append(propertyName).append("\""); 760 attrs.append(" class=\"maxwidth\""); 761 attrs.append(disabled); 762 result.append(buildSelect(attrs.toString(), options, values, selectedIndex)); 764 765 result.append("<input type=\"hidden\" name=\""); 767 result.append(PREFIX_HIDDEN); 768 result.append(propertyName); 769 result.append("\" id=\""); 770 result.append(PREFIX_HIDDEN); 771 result.append(propertyName); 772 result.append("\" value=\""); 773 result.append(propValue); 774 result.append("\">"); 775 result.append("</td>\n"); 776 result.append("</tr>"); 777 778 return result; 779 } 780 781 798 private StringBuffer buildRadioButtons(String propertyName, String mode, String JSToggleFunction, boolean editable) { 799 800 StringBuffer result = new StringBuffer (256); 801 result.append(buildTableRowStart(key(KEY_PREFIX + propertyName), 2)); 803 result.append("\t<table border=\"0\">\n"); 804 result.append("\t<tr>\n"); 805 result.append("\t<td>\n"); 806 result.append(buildPropertyRadioEntry( 807 propertyName, 808 PARAM_DEFAULT, 809 key(KEY_PREFIX + "radio.default"), 810 JSToggleFunction, 811 editable)); 812 result.append("</td>\n"); 813 result.append("\t<td>\n"); 814 result.append(buildPropertyRadioEntry( 815 propertyName, 816 PARAM_TRUE, 817 key(KEY_PREFIX + "radio." + mode), 818 JSToggleFunction, 819 editable)); 820 result.append("</td>\n"); 821 result.append("\t<td>\n"); 822 result.append(buildPropertyRadioEntry( 823 propertyName, 824 PARAM_FALSE, 825 key(KEY_PREFIX + "radio.disable"), 826 JSToggleFunction, 827 editable)); 828 result.append("</td>\n"); 829 result.append("</tr>\n"); 830 result.append("</table>\n"); 831 result.append(buildTableRowEnd()); 832 833 return result; 834 } 835 836 845 private StringBuffer buildTableRowStart(String propertyName, int colspan) { 846 847 StringBuffer result = new StringBuffer (96); 848 result.append("<tr>\n"); 849 result.append("\t<td style=\"white-space: nowrap;\" unselectable=\"on\">"); 850 result.append(propertyName); 851 result.append("</td>\n"); 852 result.append("\t<td class=\"maxwidth\" colspan=\""); 853 result.append(String.valueOf(colspan)); 854 result.append("\">"); 855 856 return result; 857 } 858 859 865 private List getConfigurationFiles(String listType) { 866 867 List result = new ArrayList (); 868 String configFolder; 869 if (listType.equals(CmsTemplateContentListItem.DISPLAYAREA_CENTER)) { 870 configFolder = VFS_PATH_CONFIGFILES_CENTER; 871 } else { 872 configFolder = VFS_PATH_CONFIGFILES_RIGHT; 873 } 874 try { 875 result = getCms().readResources(configFolder, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED); 877 878 String configPath = getCms().readPropertyObject( 880 getParamResource(), 881 CmsTemplateBean.PROPERTY_CONFIGPATH, 882 true).getValue(); 883 if (CmsStringUtil.isNotEmpty(configPath)) { 884 int type = OpenCms.getResourceManager().getResourceType(CmsLayoutXmlContentHandler.CONFIG_RESTYPE_NAME).getTypeId(); 885 CmsResourceFilter filter = CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(type); 886 Iterator i = getCms().readResources(configPath, filter, false).iterator(); 887 while (i.hasNext()) { 888 CmsResource res = (CmsResource)i.next(); 889 String column = getCms().readPropertyObject( 891 getCms().getSitePath(res), 892 CmsLayoutXmlContentHandler.PROPERTY_LAYOUT_COLUMN, 893 false).getValue(); 894 if (listType.equals(column)) { 895 result.add(res); 897 } 898 } 899 } 900 } catch (CmsException e) { 901 if (LOG.isErrorEnabled()) { 903 LOG.error(e); 904 } 905 } 906 return result; 907 } 908 } | Popular Tags |