1 31 32 package org.opencms.frontend.templateone; 33 34 import org.opencms.file.CmsFile; 35 import org.opencms.file.CmsFolder; 36 import org.opencms.file.CmsObject; 37 import org.opencms.file.CmsPropertyDefinition; 38 import org.opencms.file.CmsResource; 39 import org.opencms.file.CmsResourceFilter; 40 import org.opencms.i18n.CmsMessages; 41 import org.opencms.jsp.util.CmsTemplateContentListItem; 42 import org.opencms.loader.CmsLoaderException; 43 import org.opencms.main.CmsException; 44 import org.opencms.main.CmsLog; 45 import org.opencms.main.OpenCms; 46 import org.opencms.util.CmsStringUtil; 47 import org.opencms.workplace.CmsWorkplace; 48 import org.opencms.xml.content.CmsXmlContent; 49 import org.opencms.xml.content.CmsXmlContentFactory; 50 51 import java.io.IOException ; 52 import java.util.ArrayList ; 53 import java.util.Collections ; 54 import java.util.HashMap ; 55 import java.util.List ; 56 import java.util.Locale ; 57 import java.util.Map ; 58 59 import javax.servlet.http.HttpServletRequest ; 60 import javax.servlet.http.HttpServletResponse ; 61 import javax.servlet.jsp.JspException ; 62 import javax.servlet.jsp.JspWriter ; 63 import javax.servlet.jsp.PageContext ; 64 65 import org.apache.commons.logging.Log; 66 67 76 public class CmsTemplateBean extends CmsTemplateBase { 77 78 79 public static final String FILE_CONFIG_COMMON = "configuration_common"; 80 81 82 public static final String FILE_CSS = "style.css"; 83 84 85 public static final String FILE_CSS_ACCESSIBLE = "style_accessible.css"; 86 87 88 public static final String FILE_LINKS_HEAD = "configuration_links"; 89 90 91 public static final String FOLDER_ELEMENTS = "../elements/"; 92 93 94 public static final String MESSAGE_BUNDLE = "templateone"; 95 96 97 public static final String MODULE_NAME = "org.opencms.frontend.templateone"; 98 99 100 public static final String PARAM_ACCESSIBLE = "accessible"; 101 102 103 public static final String PARAM_COMMON = "common"; 104 105 106 public static final String PARAM_HELPURI = "helpuri"; 107 108 109 public static final String PARAM_LAYOUT = "layout"; 110 111 112 public static final String PARAM_LOGINURI = "loginuri"; 113 114 115 public static final String PARAM_PART = "part"; 116 117 118 public static final String PARAM_PRINT = "print"; 119 120 121 public static final String PARAM_SITE = "site"; 122 123 124 public static final String PARAM_URI = "uri"; 125 126 127 public static final String PROPERTY_CONFIGPATH = "style_main_configpath"; 128 129 130 public static final String PROPERTY_EXTENSIONMODULE = "style_main_extensionmodule"; 131 132 133 public static final String PROPERTY_HEAD_DEFAULTLINK = "style_head_links_defaultlink"; 134 135 136 public static final String PROPERTY_HEAD_ELEMENTURI = "style_head_elementuri"; 137 138 139 public static final String PROPERTY_HEAD_IMGHEIGHT = "style_head_img_height"; 140 141 142 public static final String PROPERTY_HEAD_IMGLINK = "style_head_img_link"; 143 144 145 public static final String PROPERTY_HEAD_IMGURI = "style_head_img_uri"; 146 147 148 public static final String PROPERTY_LAYOUT_CENTER = "layout.center"; 149 150 151 public static final String PROPERTY_LAYOUT_RIGHT = "layout.right"; 152 153 154 public static final String PROPERTY_NAVLEFT_ELEMENTURI = "style_navleft_element_uri"; 155 156 157 public static final String PROPERTY_RESOURCEPATH = "style_main_resourcepath"; 158 159 160 public static final String PROPERTY_SHOW_HEADNAV = "style_show_head_nav"; 161 162 163 public static final String PROPERTY_SHOW_NAVLEFT = "style_show_navleft"; 164 165 166 public static final String PROPERTY_SHOWHEADIMAGE = "style_show_head_img"; 167 168 169 public static final String PROPERTY_SHOWHEADLINKS = "style_show_head_links"; 170 171 172 public static final String PROPERTY_SIDE_URI = "style_side_uri"; 173 174 175 public static final String PROPERTY_STARTFOLDER = "style_main_startfolder"; 176 177 178 public static final String PROPERTY_VALUE_NONE = CmsTemplateContentListItem.PROPERTY_VALUE_NONE; 179 180 181 public static final String RESOURCE_TYPE_MICROSITE_NAME = "microsite"; 182 183 184 private static final Log LOG = CmsLog.getLog(CmsTemplateBean.class); 185 186 187 private CmsXmlContent m_globalConfiguration; 188 189 190 private String m_layout; 191 192 193 private Map m_listDefaults; 194 195 196 private CmsMessages m_messages; 197 198 199 private Map m_properties; 200 201 202 private String m_resPath; 203 204 205 private boolean m_showAccessibleVersion; 206 207 208 private boolean m_showHeadNavigation; 209 210 211 private boolean m_showPrintVersion; 212 213 214 private String m_startFolder; 215 216 219 public CmsTemplateBean() { 220 221 super(); 222 } 223 224 233 public CmsTemplateBean(PageContext context, HttpServletRequest req, HttpServletResponse res) { 234 235 super(); 236 init(context, req, res); 237 } 238 239 246 protected static CmsXmlContent getConfigurationFile(String fileName, CmsObject cms) { 247 248 CmsXmlContent configuration = null; 249 try { 250 CmsFile configFile = cms.readFile(fileName, CmsResourceFilter.IGNORE_EXPIRATION); 251 configuration = CmsXmlContentFactory.unmarshal(cms, configFile); 252 } catch (Exception e) { 253 if (LOG.isInfoEnabled()) { 255 LOG.info(Messages.get().getBundle().key( 256 Messages.LOG_XMLCONTEN_CONFIG_NOT_FOUND_2, 257 fileName, 258 cms.getRequestContext().getUri())); 259 } 260 } 261 return configuration; 262 } 263 264 270 public void buildHtmlBodyEnd() throws IOException , JspException { 271 272 m_properties.put(PARAM_LAYOUT, getLayout()); 273 JspWriter out = getJspContext().getOut(); 275 String elementName = FOLDER_ELEMENTS + "body_end.jsp"; 276 out.print(getTemplateParts().includePart(elementName, "1", getLayout(), this)); 277 if (!showPrintVersion()) { 278 include(getExtensionModuleFileUri("elements/info_side.jsp"), null, m_properties); 280 } 281 282 out.print(getTemplateParts().includePart(elementName, "2", getLayout(), this)); 284 285 if (!showPrintVersion()) { 286 getProperties().put(PARAM_HELPURI, getConfigurationValue("help.uri", PROPERTY_VALUE_NONE)); 288 getProperties().put(PARAM_LOGINURI, getConfigurationValue("login.uri", PROPERTY_VALUE_NONE)); 289 include(FOLDER_ELEMENTS + "foot_links.jsp", null, m_properties); 290 boolean showMenus = Boolean.valueOf(getConfigurationValue("headnav.menus", CmsStringUtil.TRUE)).booleanValue(); 291 if (showHeadNavigation() && showMenus) { 292 if (getProperties().get(CmsTemplateNavigation.PARAM_HEADNAV_MENUDEPTH) == null) { 294 getProperties().put(PARAM_SITE, getRequestContext().getSiteRoot()); 295 getProperties().put(CmsTemplateNavigation.PARAM_STARTFOLDER, getStartFolder()); 296 getProperties().put(CmsTemplateNavigation.PARAM_HEADNAV_FOLDER, getNavigationStartFolder()); 297 getProperties().put( 298 CmsTemplateNavigation.PARAM_HEADNAV_MENUDEPTH, 299 getConfigurationValue("headnav.menudepth", "1")); 300 getProperties().put( 301 CmsTemplateNavigation.PARAM_SHOWMENUS, 302 getConfigurationValue("headnav.menus", CmsStringUtil.TRUE)); 303 getProperties().put( 304 CmsTemplateNavigation.PARAM_HEADNAV_MANUAL, 305 getConfigurationValue("headnav.manual", CmsStringUtil.FALSE)); 306 } 307 include(FOLDER_ELEMENTS + "nav_head_menus.jsp", null, m_properties); 308 } 309 } else { 310 m_properties.put(CmsTemplateBean.PARAM_URI, getRequestContext().getUri()); 312 include(CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/pages/imprint.html", "content", m_properties); 313 } 314 315 out.print(getTemplateParts().includePart(elementName, "3", getLayout(), this)); 317 } 318 319 326 public String getAreaName() { 327 328 String name = getConfigurationValue("area.name", null); 329 if (name == null) { 330 String startFolder = getStartFolder(); 331 name = property(CmsPropertyDefinition.PROPERTY_TITLE, startFolder, CmsResource.getName(startFolder)); 332 } 333 return name; 334 } 335 336 341 public String getConfigPath() { 342 343 return property(PROPERTY_CONFIGPATH, "search", "/"); 344 } 345 346 351 public CmsXmlContent getConfiguration() { 352 353 if (m_globalConfiguration == null) { 354 m_globalConfiguration = getConfigurationFile(getConfigPath() + FILE_CONFIG_COMMON, getCmsObject()); 355 } 356 return m_globalConfiguration; 357 } 358 359 365 public String getConfigurationValue(String key) { 366 367 return getConfigurationValue(key, null); 368 } 369 370 379 public String getConfigurationValue(String key, String defaultValue) { 380 381 String value = null; 382 try { 383 value = getConfiguration().getStringValue(null, key, getRequestContext().getLocale()); 384 } catch (Exception e) { 385 if (LOG.isDebugEnabled()) { 387 LOG.debug(e.getMessage(), e); 388 } 389 } 390 if (CmsStringUtil.isEmpty(value)) { 391 value = defaultValue; 392 } 393 return value; 394 } 395 396 402 public String getDescription(String defaultValue) { 403 404 if (defaultValue == null) { 405 defaultValue = ""; 406 } 407 return property(CmsPropertyDefinition.PROPERTY_DESCRIPTION, "search", defaultValue); 408 } 409 410 415 public String getEncoding() { 416 417 return property( 418 CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, 419 "search", 420 OpenCms.getSystemInfo().getDefaultEncoding()); 421 } 422 423 431 public String getExtensionModuleFileUri(String relFilePath) { 432 433 String configModule = property( 434 PROPERTY_EXTENSIONMODULE, 435 CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME, 436 PROPERTY_VALUE_NONE); 437 if (LOG.isDebugEnabled()) { 438 LOG.debug(Messages.get().getBundle().key(Messages.LOG_EXT_MODULE_PROP_VALUE_1, configModule)); 439 } 440 if (!PROPERTY_VALUE_NONE.equals(configModule)) { 441 String fileName = CmsWorkplace.VFS_PATH_MODULES + configModule + "/" + relFilePath; 443 try { 444 getCmsObject().readResource(fileName); 445 return fileName; 446 } catch (CmsException e) { 447 if (LOG.isDebugEnabled()) { 449 LOG.debug(Messages.get().getBundle().key(Messages.LOG_EXT_MODULE_FILE_NOT_FOUND_1, fileName)); 450 } 451 } 452 } 453 return CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/" + relFilePath; 454 } 455 456 461 public String getHeadElementUri() { 462 463 String elemUri = (String )getProperties().get(PROPERTY_HEAD_ELEMENTURI); 464 if (CmsStringUtil.isEmptyOrWhitespaceOnly(elemUri)) { 465 elemUri = PROPERTY_VALUE_NONE; 466 } 467 return elemUri; 468 } 469 470 475 public List getHeadLinks() { 476 477 List links = new ArrayList (10); 478 String configFile = getConfigPath() + FILE_LINKS_HEAD; 480 CmsXmlContent configuration = getConfigurationFile(configFile, getCmsObject()); 481 boolean showMainLink = true; 483 if (configuration != null) { 484 Locale locale = getRequestContext().getLocale(); 486 int count = configuration.getIndexCount("Headlink", locale); 487 for (int i = 1; i <= count; i++) { 488 String prefix = "Headlink[" + i + "]"; 489 try { 490 String url = configuration.getStringValue(null, prefix + "/link.url", locale); 491 String text = configuration.getStringValue(null, prefix + "/link.text", locale); 492 String target = configuration.getStringValue(null, prefix + "/link.target", locale); 493 if (CmsStringUtil.isEmpty(url) || CmsStringUtil.isEmpty(text)) { 494 break; 496 } 497 if (url.startsWith("/")) { 498 url = link(url); 500 } 501 CmsTemplateLink link = new CmsTemplateLink(url, text, target, i); 502 links.add(link); 503 } catch (Exception e) { 504 if (LOG.isDebugEnabled()) { 506 LOG.debug(e.getMessage(), e); 507 } 508 } 509 if (i == 10) { 510 showMainLink = false; 512 } 513 } 514 } 515 if (showMainLink) { 516 String defaultLink = (String )m_properties.get(PROPERTY_HEAD_DEFAULTLINK); 518 if (defaultLink != null && !PROPERTY_VALUE_NONE.equals(defaultLink)) { 519 String url = defaultLink; 520 String text = defaultLink; 521 String target = ""; 522 int sepIndex = defaultLink.indexOf("|"); 523 try { 524 if (sepIndex != -1) { 525 url = defaultLink.substring(0, sepIndex); 526 text = defaultLink.substring(sepIndex + 1); 527 sepIndex = text.indexOf("|"); 528 if (sepIndex != -1) { 529 target = text.substring(sepIndex + 1); 530 text = text.substring(0, sepIndex); 531 } 532 } 533 if (url.startsWith("/")) { 534 url = link(url); 535 } 536 text = keyDefault(text, text); 538 } catch (Exception e) { 539 if (LOG.isErrorEnabled()) { 541 LOG.error(e); 542 } 543 } 544 545 CmsTemplateLink link = new CmsTemplateLink(url, text, target, 0); 546 links.add(link); 547 Collections.sort(links); 549 } 550 } 551 return links; 552 } 553 554 560 public String getKeywords(String defaultValue) { 561 562 if (defaultValue == null) { 563 defaultValue = ""; 564 } 565 return property(CmsPropertyDefinition.PROPERTY_KEYWORDS, "search", defaultValue); 566 } 567 568 573 public String getLayout() { 574 575 return m_layout; 576 } 577 578 583 public String getLeftNavigationElementUri() { 584 585 return property(PROPERTY_NAVLEFT_ELEMENTURI, "search", PROPERTY_VALUE_NONE); 586 } 587 588 593 public String getNavigationStartFolder() { 594 595 String startFolder = getConfigurationValue("navigation.startfolder", null); 596 if (startFolder == null) { 597 return getStartFolder(); 598 } else { 599 startFolder = getRequestContext().removeSiteRoot(startFolder); 600 } 601 return startFolder; 602 } 603 604 609 public Map getProperties() { 610 611 return m_properties; 612 } 613 614 619 public String getResourcePath() { 620 621 if (m_resPath == null) { 622 m_resPath = property(PROPERTY_RESOURCEPATH, "search", "na"); 624 if ("na".equals(m_resPath)) { 625 m_resPath = CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/resources/"; 627 } 628 m_resPath = link(m_resPath); 629 } 630 return m_resPath; 631 } 632 633 640 public String getSearchIndexName() { 641 642 String currentSite = getRequestContext().getSiteRoot(); 643 if (currentSite.indexOf("sites/default") == -1) { 644 return currentSite; 646 } else { 647 return getRequestContext().currentProject().getName() + " project (VFS)"; 649 } 650 } 651 652 657 public String getStartFolder() { 658 659 if (m_startFolder == null) { 660 int folderTypeId = -1; 662 try { 663 folderTypeId = OpenCms.getResourceManager().getResourceType(RESOURCE_TYPE_MICROSITE_NAME).getTypeId(); 664 } catch (CmsLoaderException e) { 665 if (LOG.isErrorEnabled()) { 667 LOG.error(Messages.get().getBundle().key(Messages.LOG_MICROSITE_FOLDER_NOT_FOUND_0)); 668 } 669 } 670 m_startFolder = "/"; 671 try { 672 CmsFolder startFolder = getCmsObject().readAncestor(getRequestContext().getUri(), folderTypeId); 673 if (startFolder != null) { 674 m_startFolder = getCmsObject().getRequestContext().removeSiteRoot(startFolder.getRootPath()); 675 } 676 } catch (CmsException e) { 677 if (LOG.isErrorEnabled()) { 679 LOG.error(Messages.get().getBundle().key(Messages.LOG_MICROSITE_READ_START_FOLDER_0)); 680 } 681 } 682 } 683 return m_startFolder; 684 } 685 686 691 public String getStyleSheetConfigUri() { 692 693 String confUri = property(CmsTemplateStyleSheet.PROPERTY_CONFIGFILE, "search", ""); 694 if ("".equals(confUri)) { 695 confUri = getConfigPath() + CmsTemplateStyleSheet.FILENAME_CONFIGFILE; 697 } 698 return confUri; 699 } 700 701 706 public String getStyleSheetUri() { 707 708 String fileName = FILE_CSS; 709 if (showAccessibleVersion()) { 710 fileName = FILE_CSS_ACCESSIBLE; 712 } 713 return link(CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/resources/" + fileName); 715 } 716 717 727 public String getStyleSheetUri(String resPath, String config, String site, Locale locale) { 728 729 StringBuffer result = new StringBuffer (16); 730 731 result.append(CmsWorkplace.VFS_PATH_MODULES); 733 result.append(MODULE_NAME); 734 result.append("/resources/"); 735 736 if (showAccessibleVersion()) { 737 result.append(FILE_CSS_ACCESSIBLE); 739 } else { 740 result.append(FILE_CSS); 742 } 743 744 result.append("?respath="); 746 result.append(resPath); 747 result.append("&config="); 748 result.append(config); 749 result.append("&site="); 750 result.append(site); 751 result.append("&__locale="); 752 result.append(locale); 753 754 return link(result.toString()); 756 } 757 758 765 public CmsTemplateParts getTemplateParts() { 766 767 return CmsTemplateParts.getInstance(); 768 } 769 770 776 public String getTitle(String defaultValue) { 777 778 if (defaultValue == null) { 779 defaultValue = ""; 780 } 781 return property(CmsPropertyDefinition.PROPERTY_TITLE, "search", defaultValue); 782 } 783 784 794 public void includeElements() throws IOException , JspException { 795 796 boolean elementsPresent = template("text1,text2,text3,text4,text5,text6,text7,text8", false); 798 799 String configFile = (String )getProperties().get(PROPERTY_LAYOUT_CENTER); 801 List contents = new ArrayList (); 802 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(configFile) && !PROPERTY_VALUE_NONE.equals(configFile)) { 803 contents = getContentListItems(configFile, CmsTemplateContentListItem.DISPLAYAREA_CENTER); 805 } 806 int size = contents.size(); 808 boolean showPageLinks = true; 809 if (size > 1) { 810 showPageLinks = false; 812 } 813 814 if (elementsPresent || size > 0) { 815 JspWriter out = getJspContext().getOut(); 817 String elementName = FOLDER_ELEMENTS + "elements.jsp"; 818 out.print(getTemplateParts().includePart(elementName, "start", getLayout(), this)); 820 821 int startPoint = 3 - size; 823 int listIndex = 0; 824 for (int i = 0; i < 4; i++) { 825 int elementIndex = (i * 2) + 1; 826 includeContentRow("text" + (elementIndex), "text" + (elementIndex + 1), out); 828 if ((listIndex < size) && (i >= startPoint)) { 829 CmsTemplateContentListItem item = (CmsTemplateContentListItem)contents.get(listIndex); 831 out.print(getTemplateParts().includePart(elementName, "column_start", getLayout(), this)); 832 out.print(getTemplateParts().includePart(elementName, "element_start_1", getLayout(), this)); 833 item.includeListItem(this, showPageLinks); 834 out.print(getTemplateParts().includePart(elementName, "element_end", getLayout(), this)); 835 out.print(getTemplateParts().includePart(elementName, "column_end", getLayout(), this)); 836 listIndex++; 837 } 838 } 839 out.print(getTemplateParts().includePart(elementName, "end", getLayout(), this)); 841 } 842 } 843 844 851 public void includePopup(String element, String title) throws JspException { 852 853 Map properties = new HashMap (); 854 if ("popuphead".equals(element)) { 855 properties.put("stylesheeturi", getStyleSheetUri()); 857 properties.put("resourcepath", getResourcePath()); 858 properties.put("title", title); 859 properties.put(CmsTemplateStyleSheet.PARAM_CONFIGFILE, getStyleSheetConfigUri()); 860 } 861 include(CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/pages/popup_includes.jsp", element, properties); 863 } 864 865 870 public void includeRightLists() throws JspException { 871 872 String configFile = (String )getProperties().get(PROPERTY_LAYOUT_RIGHT); 873 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(configFile) && !PROPERTY_VALUE_NONE.equals(configFile)) { 874 List contents = getContentListItems(configFile, CmsTemplateContentListItem.DISPLAYAREA_RIGHT); 875 int size = contents.size(); 876 for (int i = 0; i < size; i++) { 877 CmsTemplateContentListItem item = (CmsTemplateContentListItem)contents.get(i); 878 item.includeListItem(this, false); 879 } 880 } 881 } 882 883 893 public void init(PageContext context, HttpServletRequest req, HttpServletResponse res) { 894 895 super.init(context, req, res); 897 String className = getClass().getName(); 898 if (className.endsWith("Bean")) { 899 m_properties = properties("search"); 901 initPageVersion(); 903 m_showHeadNavigation = !showPrintVersion() 905 && Boolean.valueOf(property(PROPERTY_SHOW_HEADNAV, "search", CmsStringUtil.TRUE)).booleanValue(); 906 } 907 } 908 909 921 public String key(String keyName) { 922 923 return messages().key(keyName); 924 } 925 926 938 public String keyDefault(String keyName, String defaultValue) { 939 940 return messages().keyDefault(keyName, defaultValue); 941 } 942 943 948 public CmsMessages messages() { 949 950 if (m_messages == null) { 951 messages(MESSAGE_BUNDLE); 952 } 953 return m_messages; 954 } 955 956 962 public CmsMessages messages(String bundleName) { 963 964 if (m_messages == null) { 965 m_messages = new CmsMessages(bundleName, getRequestContext().getLocale()); 966 } 967 return m_messages; 968 } 969 970 973 public void putNavigationProperties() { 974 975 getProperties().put(PARAM_SITE, getRequestContext().getSiteRoot()); 977 getProperties().put(PARAM_ACCESSIBLE, "" + showAccessibleVersion()); 978 getProperties().put(CmsTemplateNavigation.PARAM_RESPATH, getResourcePath()); 979 getProperties().put(CmsTemplateNavigation.PARAM_STARTFOLDER, getStartFolder()); 980 getProperties().put(CmsTemplateNavigation.PARAM_HEADNAV_FOLDER, getNavigationStartFolder()); 981 getProperties().put( 982 CmsTemplateNavigation.PARAM_HEADNAV_IMAGES, 983 getConfigurationValue("headnav.images", CmsStringUtil.FALSE)); 984 getProperties().put( 985 CmsTemplateNavigation.PARAM_HEADNAV_MANUAL, 986 getConfigurationValue("headnav.manual", CmsStringUtil.FALSE)); 987 getProperties().put( 988 CmsTemplateNavigation.PARAM_HEADNAV_MARKCURRENT, 989 getConfigurationValue("headnav.markcurrent", CmsStringUtil.FALSE)); 990 getProperties().put( 991 CmsTemplateNavigation.PARAM_HEADNAV_MENUDEPTH, 992 getConfigurationValue("headnav.menudepth", "1")); 993 getProperties().put( 994 CmsTemplateNavigation.PARAM_HEADNAV_MENUCLICK, 995 getConfigurationValue("headnav.menuclick", CmsStringUtil.FALSE)); 996 getProperties().put( 997 CmsTemplateNavigation.PARAM_SHOWMENUS, 998 getConfigurationValue("headnav.menus", CmsStringUtil.TRUE)); 999 getProperties().put( 1000 CmsTemplateNavigation.PARAM_NAVLEFT_SHOWSELECTED, 1001 getConfigurationValue("navleft.showselected", CmsStringUtil.FALSE)); 1002 getProperties().put(CmsTemplateNavigation.PARAM_NAVLEFT_SHOWTREE, "" + showLeftNavigation()); 1003 getProperties().put(CmsTemplateNavigation.PARAM_NAVLEFT_ELEMENTURI, getLeftNavigationElementUri()); 1004 } 1005 1006 1011 public void setLayout(String layout) { 1012 1013 m_layout = layout; 1014 } 1015 1016 1021 public boolean showAccessibleVersion() { 1022 1023 return m_showAccessibleVersion; 1024 } 1025 1026 1031 public boolean showHeadImage() { 1032 1033 return Boolean.valueOf(property(PROPERTY_SHOWHEADIMAGE, "search", CmsStringUtil.TRUE)).booleanValue(); 1034 } 1035 1036 1041 public boolean showHeadLinks() { 1042 1043 return Boolean.valueOf(property(PROPERTY_SHOWHEADLINKS, "search", CmsStringUtil.TRUE)).booleanValue(); 1044 } 1045 1046 1051 public boolean showHeadNavigation() { 1052 1053 return m_showHeadNavigation; 1054 } 1055 1056 1061 public boolean showLeftNavigation() { 1062 1063 return Boolean.valueOf(property(PROPERTY_SHOW_NAVLEFT, "search", CmsStringUtil.TRUE)).booleanValue(); 1064 } 1065 1066 1071 public boolean showPrintVersion() { 1072 1073 return m_showPrintVersion; 1074 } 1075 1076 1083 private List getContentListItems(String configFile, String displayArea) { 1084 1085 List result = new ArrayList (); 1086 Map properties = properties(configFile); 1088 int i = 1; 1089 boolean cont = true; 1090 do { 1091 CmsTemplateContentListItem item = CmsTemplateContentListItem.newInstance( 1093 getListDefaults(), 1094 properties, 1095 getStartFolder(), 1096 displayArea, 1097 i); 1098 if (item == null) { 1099 cont = false; 1101 } else { 1102 result.add(item); 1104 i++; 1105 } 1106 } while (cont); 1107 return result; 1108 } 1109 1110 1115 private Map getListDefaults() { 1116 1117 if (m_listDefaults == null) { 1118 CmsMessages messages = OpenCms.getWorkplaceManager().getMessages(getRequestContext().getLocale()); 1119 m_listDefaults = CmsTemplateContentListItem.getDefaultValuesFromMessages(messages); 1120 } 1121 return m_listDefaults; 1122 } 1123 1124 1137 private void includeContentRow(String elementLeft, String elementRight, JspWriter out) 1138 throws IOException , JspException { 1139 1140 if (template(elementLeft + "," + elementRight, false)) { 1141 String elementName = FOLDER_ELEMENTS + "elements.jsp"; 1143 out.print(getTemplateParts().includePart(elementName, "column_start", getLayout(), this)); 1144 1145 if (template(elementLeft, true)) { 1146 if (template(elementRight, true)) { 1148 out.print(getTemplateParts().includePart(elementName, "element_start_2", getLayout(), this)); 1150 } else { 1151 out.print(getTemplateParts().includePart(elementName, "element_start_1", getLayout(), this)); 1153 } 1154 include(null, elementLeft, true); 1155 out.print(getTemplateParts().includePart(elementName, "element_end", getLayout(), this)); 1156 } 1157 if (template(elementRight, true)) { 1158 if (template(elementLeft, true)) { 1160 out.print(getTemplateParts().includePart(elementName, "element_start_2", getLayout(), this)); 1162 } else { 1163 out.print(getTemplateParts().includePart(elementName, "element_start_1", getLayout(), this)); 1165 } 1166 include(null, elementRight, true); 1167 out.print(getTemplateParts().includePart(elementName, "element_end", getLayout(), this)); 1168 } 1169 out.print(getTemplateParts().includePart(elementName, "column_end", getLayout(), this)); 1171 } 1172 } 1173 1174 1180 private void initPageVersion() { 1181 1182 m_showPrintVersion = Boolean.valueOf(getRequest().getParameter(PARAM_PRINT)).booleanValue(); 1184 if (!showPrintVersion()) { 1185 String param = getRequest().getParameter(PARAM_ACCESSIBLE); 1187 if (CmsStringUtil.isNotEmpty(param)) { 1188 m_showAccessibleVersion = Boolean.valueOf(param).booleanValue(); 1189 } else { 1190 m_showAccessibleVersion = getConfigurationValue("layout.version", PARAM_COMMON).equals(PARAM_ACCESSIBLE); 1191 } 1192 if (showAccessibleVersion()) { 1193 setLayout(PARAM_ACCESSIBLE); 1194 } else { 1195 setLayout(PARAM_COMMON); 1196 } 1197 } else { 1198 setLayout(PARAM_PRINT); 1199 } 1200 } 1201} | Popular Tags |