1 31 32 package org.opencms.workplace.help; 33 34 import org.opencms.file.CmsProject; 35 import org.opencms.file.CmsProperty; 36 import org.opencms.file.CmsPropertyDefinition; 37 import org.opencms.file.CmsResource; 38 import org.opencms.file.CmsResourceFilter; 39 import org.opencms.file.CmsVfsResourceNotFoundException; 40 import org.opencms.file.types.CmsResourceTypeXmlPage; 41 import org.opencms.i18n.CmsLocaleManager; 42 import org.opencms.jsp.CmsJspActionElement; 43 import org.opencms.jsp.CmsJspNavElement; 44 import org.opencms.main.CmsException; 45 import org.opencms.main.CmsLog; 46 import org.opencms.main.OpenCms; 47 import org.opencms.util.CmsMacroResolver; 48 import org.opencms.util.CmsPropertyUtils; 49 import org.opencms.util.CmsStringUtil; 50 import org.opencms.workplace.CmsDialog; 51 import org.opencms.workplace.CmsWorkplace; 52 import org.opencms.workplace.CmsWorkplaceSettings; 53 54 import java.io.IOException ; 55 import java.util.Iterator ; 56 import java.util.List ; 57 import java.util.Locale ; 58 import java.util.Map ; 59 60 import javax.servlet.http.HttpServletRequest ; 61 import javax.servlet.http.HttpServletResponse ; 62 import javax.servlet.jsp.PageContext ; 63 64 import org.apache.commons.collections.ExtendedProperties; 65 import org.apache.commons.logging.Log; 66 67 87 public class CmsHelpTemplateBean extends CmsDialog { 88 89 90 public static final String DEFAULT_HELPFILE = "index.html"; 91 92 93 public static final String HELPMAPPINGS_FILENAME = "mappings_" 94 + "${" 95 + CmsMacroResolver.KEY_REQUEST_LOCALE 96 + "}.properties"; 97 98 99 public static final String MODULE_NAME = "org.opencms.workplace.help"; 100 101 102 public static final String PARAM_BUILDFRAME = "buildframe"; 103 104 105 public static final String PARAM_HELPRESOURCE = "helpresource"; 106 107 108 public static final String PARAM_HOMELINK = "homelink"; 109 110 111 public static final String PARAM_WORKPLACERESOURCE = "workplaceresource"; 112 113 114 public static final String PATH_HELP = CmsWorkplace.VFS_PATH_LOCALES 115 + "${" 116 + CmsMacroResolver.KEY_REQUEST_LOCALE 117 + "}/help/"; 118 119 120 public static final String PROPERTY_VALUE_HELPSTART = "help.start"; 121 122 123 public static final String RFS_HELPMAPPINGS = "classes/" 124 + MODULE_NAME.replace('.', '/') 125 + "/" 126 + HELPMAPPINGS_FILENAME; 127 128 129 public static final String TEMPLATEPATH = CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/jsptemplates/"; 130 131 132 private static final Log LOG = CmsLog.getLog(CmsHelpTemplateBean.class); 133 134 135 private CmsProject m_offlineProject; 136 137 138 private CmsProject m_onlineProject; 139 140 141 private String m_paramBuildframe; 142 143 144 private String m_paramHelpresource; 145 146 147 private String m_paramHomelink; 148 149 150 private String m_paramWorkplaceresource; 151 152 157 public CmsHelpTemplateBean(CmsJspActionElement jsp) { 158 159 super(jsp); 160 161 try { 162 m_onlineProject = getCms().readProject(CmsProject.ONLINE_PROJECT_ID); 163 m_offlineProject = jsp.getRequestContext().currentProject(); 164 } catch (CmsException e) { 165 m_onlineProject = getCms().getRequestContext().currentProject(); 167 } 168 } 169 170 177 public CmsHelpTemplateBean(PageContext context, HttpServletRequest req, HttpServletResponse res) { 178 179 this(new CmsJspActionElement(context, req, res)); 180 } 181 182 188 public static String buildOnlineHelpJavaScript(Locale locale) { 189 190 StringBuffer result = new StringBuffer (16); 191 192 result.append("function openOnlineHelp(wpUri) {\n"); 194 result.append("\tif (wpUri == null || wpUri == \"\") {\n"); 195 result.append("\t\tif (top.body.top.body.admin_content != null && top.body.top.body.admin_content.onlineHelpUriCustom != null) {\n"); 196 result.append("\t\t\twpUri = top.body.top.body.admin_content.onlineHelpUriCustom;\n"); 197 result.append("\t\t}\n"); 198 result.append("\t\telse{\n"); 199 result.append("\t\t\tif (top.body != null && top.body.explorer_body != null) {\n"); 200 result.append("\t\t\t\t// determine currently shown explorer item\n"); 201 result.append("\t\t\t\ttry {\n"); 202 result.append("\t\t\t\t\twpUri = top.body.explorer_body.explorer_files.location.pathname;\n"); 203 result.append("\t\t\t\t} catch (e) {}\n"); 204 result.append("\t\t\t} else if (top.body != null && top.body.admin_content != null) {\n"); 205 result.append("\t\t\t\t// determine currently shown administration item\n"); 206 result.append("\t\t\t\tvar parameters = \"\";\n"); 207 result.append("\t\t\t\ttry {\n"); 208 result.append("\t\t\t\t\tparameters = decodeURIComponent(top.body.admin_content.tool_title.location.search);\n"); 209 result.append("\t\t\t\t} catch (e) {\n"); 210 result.append("\t\t\t\t\ttry {\n"); 211 result.append("\t\t\t\t\t\tparameters = decodeURIComponent(top.body.admin_content.location.search);\n"); 212 result.append("\t\t\t\t\t} catch (e) {}\n"); 213 result.append("\t\t\t\t}\n"); 214 result.append("\t\t\t\tvar pathIndex = parameters.lastIndexOf(\"path=\");\n"); 215 result.append("\t\t\t\tif (pathIndex != -1) {\n"); 216 result.append("\t\t\t\t\tparameters = parameters.substring(pathIndex + 5);\n"); 217 result.append("\t\t\t\t\tif (parameters.indexOf(\"&\") != -1) {\n"); 218 result.append("\t\t\t\t\t\tparameters = parameters.substring(0, parameters.indexOf(\"&\"));\n"); 219 result.append("\t\t\t\t\t}\n"); 220 result.append("\t\t\t\t\twpUri = parameters + \"/\";\n"); 221 result.append("\t\t\t\t} else {\n"); 222 result.append("\t\t\t\t\twpUri = \"/administration/\"\n"); 223 result.append("\t\t\t\t}\n"); 224 result.append("\t\t\t} else if(top.body != null) {\n"); 225 result.append("\t\t\t\twpUri = top.body.location.pathname;\n"); 226 result.append("\t\t\t}\n"); 227 result.append("\t\t}\n"); 228 result.append("\t}\n"); 229 result.append("\tif (wpUri==null) {\n"); 230 result.append("\t\twpUri=\"/system/workplace/\";\n"); 231 result.append("\t}\n"); 232 result.append("\twindow.open(\"../locales/"); 233 result.append(locale); 234 result.append("/help/index.html?").append(PARAM_BUILDFRAME).append("=true"); 235 result.append("&").append(PARAM_WORKPLACERESOURCE).append("=\" + wpUri, \"cmsonlinehelp\", "); 236 result.append("\"toolbar=no,location=no,directories=no,status=yes,menubar=0,scrollbars=yes,resizable=yes,width=700,height=450\");\n"); 237 result.append("}\n"); 238 239 String s = result.toString(); 240 return s; 241 } 242 243 248 public String buildHtmlHelpEnd() { 249 250 StringBuffer result = new StringBuffer (4); 251 result.append("</body>\n"); 252 result.append("</html>"); 253 return result.toString(); 254 } 255 256 263 public String buildHtmlHelpStart(String cssFile, boolean transitional) { 264 265 StringBuffer result = new StringBuffer (8); 266 if (transitional) { 267 result.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); 268 } else { 269 result.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n"); 270 } 271 result.append("<html>\n"); 272 result.append("<head>\n"); 273 result.append("\t<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8"); 274 result.append("\">\n"); 275 result.append("\t<title>"); 276 if (CmsStringUtil.isNotEmpty(getParamHelpresource())) { 277 result.append(getJsp().property( 278 CmsPropertyDefinition.PROPERTY_TITLE, 279 getParamHelpresource(), 280 key(Messages.GUI_HELP_FRAMESET_TITLE_0))); 281 } else { 282 result.append(key(Messages.GUI_HELP_FRAMESET_TITLE_0)); 283 } 284 result.append("</title>\n"); 285 result.append("\t<link rel=\"stylesheet\" type=\"text/css\" HREF=\""); 286 result.append(getStyleUri(getJsp(), cssFile)).append("\">\n"); 287 result.append("</head>\n"); 288 return result.toString(); 289 } 290 291 296 public String displayBody() { 297 298 StringBuffer result = new StringBuffer (256); 299 300 try { 302 getJsp().getRequestContext().setCurrentProject(m_onlineProject); 303 result.append(buildHtmlHelpStart("onlinehelp.css", true)); 304 result.append("<body>\n"); 305 result.append("<a name=\"top\"></a>\n"); 306 result.append("<table class=\"helpcontent\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"); 307 result.append("<tr>\n"); 308 result.append("\t<td class=\"helpnav\">\n"); 309 result.append("\t\t<a class=\"navhelphead\" HREF=\"javascript:top.body.location.href=top.head.homeLink;\">"); 310 result.append(key(Messages.GUI_HELP_NAVIGATION_HEAD_0)); 311 result.append("</a>\n"); 312 result.append(buildHtmlHelpNavigation()); 313 result.append("</td>\n"); 314 result.append("\t<td class=\"helpcontent\">\n"); 315 result.append("\t\t<h1>"); 316 result.append(getJsp().property( 317 CmsPropertyDefinition.PROPERTY_TITLE, 318 getParamHelpresource(), 319 key(Messages.GUI_HELP_FRAMESET_TITLE_0))); 320 result.append("</h1>\n"); 321 result.append(getJsp().getContent(getParamHelpresource(), "body", getLocale())); 323 try { 324 CmsProperty elements = getCms().readPropertyObject( 327 getParamHelpresource(), 328 CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS, 329 false); 330 if (!elements.isNullProperty()) { 331 try { 332 getJsp().getCmsObject().readFile(elements.getValue()); 334 String elementName = elements.getValue(); 336 boolean export = false; 338 CmsProperty exportProp = getCms().readPropertyObject( 339 elementName, 340 CmsPropertyDefinition.PROPERTY_EXPORT, 341 true); 342 343 if (!exportProp.isNullProperty()) { 344 export = Boolean.valueOf(exportProp.getValue(CmsStringUtil.FALSE)).booleanValue(); 345 } 346 if (!export) { 347 getJsp().getRequestContext().setCurrentProject(m_offlineProject); 349 } 350 result.append(getJsp().getContent(elements.getValue())); 351 352 } catch (Throwable t) { 353 CmsVfsResourceNotFoundException e2 = new CmsVfsResourceNotFoundException( 354 Messages.get().container( 355 Messages.GUI_HELP_ERR_CONTENT_APPEND_2, 356 this.getParamHelpresource(), 357 elements.getValue(), 358 CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS), 359 t); 360 throw e2; 361 } 362 } 363 } catch (CmsException e1) { 364 365 if (LOG.isErrorEnabled()) { 366 LOG.error(e1); 367 } 368 result.append("<br>\n<div class=\"dialogerror\">"); 369 result.append(e1.getMessageContainer().key(Locale.GERMAN)); 371 result.append("</div>"); 372 } 373 result.append("\t</td>\n"); 374 result.append("</tr>\n"); 375 result.append("</table>\n"); 376 result.append(buildHtmlHelpEnd()); 377 return result.toString(); 378 } finally { 379 getJsp().getRequestContext().setCurrentProject(m_offlineProject); 380 } 381 } 382 383 388 public String displayHead() { 389 390 StringBuffer result = new StringBuffer (2048); 391 392 int buttonStyle = getSettings().getUserSettings().getWorkplaceButtonStyle(); 393 394 try { 396 getJsp().getRequestContext().setCurrentProject(m_onlineProject); 397 String resourcePath = getJsp().link("/system/modules/" + MODULE_NAME + "/resources/"); 398 399 result.append(buildHtmlHelpStart("workplace.css", false)); 400 result.append("<body class=\"buttons-head\" unselectable=\"on\">\n"); 401 result.append("<script type=\"text/javascript\" SRC=\""); 402 result.append(getJsp().link("/system/modules/org.opencms.workplace.help/resources/search.js")); 403 result.append("\"></script>\n"); 404 405 result.append("<script type=\"text/javascript\">\n<!--\n"); 407 result.append("\tvar homeLink = \""); 408 result.append(getParamHomelink()); 409 result.append("\";\n\n"); 410 result.append("//-->\n</script>\n"); 411 412 414 String index = getJsp().property( 417 "search.index", 418 "/system/modules/org.opencms.workplace.help/elements/search.jsp", 419 "German online help", 420 false); 421 StringBuffer submitAction = new StringBuffer (); 422 submitAction.append("parseSearchQuery(document.forms[\'searchform\'],\'"); 423 submitAction.append( 424 Messages.get().getBundle(getLocale()).key(Messages.GUI_HELP_ERR_SEARCH_WORD_LENGTH_1, new Integer (3))).append( 425 "\');"); 426 427 result.append("<form style=\"margin: 0;\" name=\"searchform\" method=\"post\" action=\""); 428 String searchLink = getJsp().link( 429 new StringBuffer ("/system/modules/org.opencms.workplace.help/elements/search.jsp?").append( 430 CmsLocaleManager.PARAMETER_LOCALE).append("=").append(getLocale()).toString()); 431 result.append(searchLink); 432 result.append("\" target=\"body\""); 433 result.append(" onsubmit=\""); 434 result.append(submitAction.toString()); 435 result.append("\">\n"); 436 result.append(" <input type=\"hidden\" name=\"action\" value=\"search\" />\n"); 437 result.append(" <input type=\"hidden\" name=\"query\" value=\"\" />\n"); 438 result.append(" <input type=\"hidden\" name=\"index\" value=\"" + index + "\" />\n"); 439 result.append(" <input type=\"hidden\" name=\"searchPage\" value=\"1\" />\n"); 440 441 result.append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n"); 442 result.append("<tr>\n"); 443 result.append("\t<td align=\"left\">\n"); 444 445 result.append(buttonBar(HTML_START)); 447 result.append(buttonBarStartTab(0, 5)); 448 result.append(button( 449 "javascript:history.back();", 450 null, 451 "back.png", 452 org.opencms.search.Messages.GUI_HELP_BUTTON_BACK_0, 453 buttonStyle, 454 resourcePath)); 455 result.append(button( 456 "javascript:history.forward();", 457 null, 458 "next.png", 459 org.opencms.search.Messages.GUI_HELP_BUTTON_NEXT_0, 460 buttonStyle, 461 resourcePath)); 462 463 result.append(button( 464 "javascript:top.body.location.href='" + getParamHomelink() + "';", 465 null, 466 "contents.png", 467 org.opencms.search.Messages.GUI_HELP_BUTTON_CONTENTS_0, 468 buttonStyle, 469 resourcePath)); 470 result.append("<td style=\"vertical-align: top;\">"); 472 result.append("<input type=\"text\" name=\"query2\" class=\"onlineform\" style=\"width: 120px\" value=\""); 473 result.append(""); 474 result.append(" \">"); 475 result.append("</td>\n"); 476 477 result.append(button( 478 new StringBuffer ("javascript:").append(submitAction.toString()).toString(), 479 null, 480 null, 481 org.opencms.search.Messages.GUI_HELP_BUTTON_SEARCH_0, 482 2, 483 null)); 484 485 result.append(buttonBar(HTML_END)); 486 487 result.append("</td>\n"); 488 result.append("\t<td align=\"right\" width=\"100%\">\n"); 489 490 result.append(buttonBar(HTML_START)); 492 result.append(buttonBarSeparator(5, 0)); 493 result.append(button( 494 "javascript:top.close();", 495 null, 496 "close", 497 org.opencms.search.Messages.GUI_HELP_BUTTON_CLOSE_0, 498 buttonStyle, 499 resourcePath)); 500 result.append(buttonBar(HTML_END)); 501 502 result.append("\t</td>\n"); 503 result.append("\t<td> </td>\n"); 504 result.append("<td>"); 505 506 result.append("<span style=\"display: block; width: 80px; height: 22px; background-image: url(\'"); 508 result.append(getSkinUri()); 509 result.append("commons/workplace.png"); 510 result.append("\'); \"></span>"); 511 result.append("</td>"); 512 result.append("</tr>\n"); 513 result.append("</table>\n"); 514 result.append("</form>\n"); 515 result.append(buildHtmlHelpEnd()); 516 517 return result.toString(); 518 } finally { 519 getJsp().getRequestContext().setCurrentProject(m_offlineProject); 521 } 522 } 523 524 530 public String displayHelp() throws IOException { 531 532 String result = ""; 533 try { 535 getJsp().getRequestContext().setCurrentProject(m_onlineProject); 536 537 if (isBuildFrameset()) { 538 result = displayFrameset(); 540 } else { 541 StringBuffer bodyLink = new StringBuffer (8); 543 bodyLink.append(TEMPLATEPATH); 544 bodyLink.append("help_body.jsp?"); 545 bodyLink.append(CmsHelpTemplateBean.PARAM_HELPRESOURCE); 546 bodyLink.append("="); 547 bodyLink.append(getJsp().getRequestContext().getUri()); 548 bodyLink.append("&"); 549 bodyLink.append(CmsLocaleManager.PARAMETER_LOCALE); 550 bodyLink.append("="); 551 bodyLink.append(getLocale()); 552 String bodyLinkWithParams = attachRequestString(bodyLink.toString()); 554 String redirectLink = getJsp().link(bodyLinkWithParams); 555 getJsp().getResponse().sendRedirect(redirectLink); 557 } 558 return result; 559 } finally { 560 getJsp().getRequestContext().setCurrentProject(m_onlineProject); 561 } 562 } 563 564 569 public String getParamBuildframe() { 570 571 return m_paramBuildframe; 572 } 573 574 579 public String getParamHelpresource() { 580 581 if (m_paramHelpresource == null) { 582 m_paramHelpresource = resolveMacros(PATH_HELP) + DEFAULT_HELPFILE; 583 } 584 585 return m_paramHelpresource; 586 } 587 588 593 public String getParamHomelink() { 594 595 return m_paramHomelink; 596 } 597 598 603 public String getParamWorkplaceresource() { 604 605 return m_paramWorkplaceresource; 606 } 607 608 613 public void setParamBuildframe(String buildframe) { 614 615 m_paramBuildframe = buildframe; 616 } 617 618 623 public void setParamHelpresource(String helpresource) { 624 625 m_paramHelpresource = helpresource; 626 } 627 628 633 public void setParamHomelink(String homelink) { 634 635 m_paramHomelink = homelink; 636 } 637 638 643 public void setParamWorkplaceresource(String workplaceresource) { 644 645 m_paramWorkplaceresource = workplaceresource; 646 } 647 648 653 protected String buildHtmlHelpNavigation() { 654 655 StringBuffer result = new StringBuffer (512); 656 String currentUri = getParamHelpresource(); 658 if (currentUri == null || currentUri.indexOf("/workplace/locales/") == -1) { 661 currentUri = resolveMacros(PATH_HELP) + DEFAULT_HELPFILE; 664 } 665 int helpLevel = CmsResource.getPathLevel(PATH_HELP); 667 668 List navList = getJsp().getNavigation().getNavigationTreeForFolder(currentUri, helpLevel, 99); 670 Iterator i = navList.iterator(); 671 672 while (i.hasNext()) { 673 CmsJspNavElement nav = (CmsJspNavElement)i.next(); 674 int level = nav.getNavTreeLevel() - (helpLevel - 1); 676 if (nav.getResourceName().equals(currentUri) 677 || (nav.isFolderLink() && currentUri.equals(nav.getResourceName() + "index.html"))) { 678 result.append("\t\t<span class=\"navhelpcurrent\" style=\"padding-left: "); 679 result.append(level * 10); 680 result.append("px; background-position: "); 681 result.append((level - 1) * 10); 682 result.append("px 1px;\">"); 683 result.append(nav.getNavText()); 684 result.append("</span><br style=\"clear:left\">\n"); 685 } else { 686 result.append("\t\t<a class=\"navhelp\" style=\"padding-left: "); 687 result.append(level * 10); 688 result.append("px; background-position: "); 689 result.append((level - 1) * 10); 690 result.append("px 1px;\" HREF=\""); 691 if (nav.isFolderLink()) { 692 result.append(getJsp().link( 694 "/system/modules/org.opencms.workplace.help/jsptemplates/help_body.jsp?helpresource=" 695 + nav.getResourceName() 696 + "index.html&" 697 + CmsLocaleManager.PARAMETER_LOCALE 698 + "=" 699 + getLocale())); 700 } else { 701 result.append(getJsp().link( 702 "/system/modules/org.opencms.workplace.help/jsptemplates/help_body.jsp?helpresource=" 703 + nav.getResourceName() 704 + "&" 705 + CmsLocaleManager.PARAMETER_LOCALE 706 + "=" 707 + getLocale())); 708 } 710 result.append("\">"); 711 result.append(nav.getNavText()); 712 result.append("</a><br style=\"clear:left\">\n"); 713 } 714 } 715 return result.toString(); 716 } 717 718 723 protected String displayFrameset() { 724 725 StringBuffer result = new StringBuffer (8); 726 result.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n"); 727 result.append("<html>\n"); 728 result.append("<head>\n"); 729 result.append("\t<title>"); 730 result.append(key(Messages.GUI_HELP_FRAMESET_TITLE_0)); 731 result.append("</title>\n"); 732 733 result.append("<script type=\"text/javascript\">\n<!--\n"); 735 result.append("\t if (window.name == \"body\") {\n"); 736 result.append("\t\ttop.location.href = \"" + getJsp().link(getJsp().getRequestContext().getUri()) + "\";\n"); 737 result.append("\t}\n"); 738 result.append("//-->\n</script>\n"); 739 result.append("<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n"); 740 741 result.append("</head>\n\n"); 742 result.append("<frameset rows=\"24,*\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n"); 743 result.append("\t<frame name=\"head\" SRC=\""); 744 745 StringBuffer headLink = new StringBuffer (8); 746 headLink.append(TEMPLATEPATH); 747 headLink.append("help_head.jsp?"); 748 headLink.append(CmsLocaleManager.PARAMETER_LOCALE); 749 headLink.append("="); 750 headLink.append(getLocale()); 751 headLink.append("&"); 752 headLink.append(PARAM_HOMELINK); 753 headLink.append("="); 754 headLink.append(getParamHomelink()); 755 result.append(getJsp().link(attachRequestString(headLink.toString()))); 756 result.append("\" scrolling=\"no\" noresize>\n"); 757 result.append("\t<frame name=\"body\" SRC=\""); 758 StringBuffer bodyLink = new StringBuffer (8); 759 bodyLink.append(TEMPLATEPATH); 760 bodyLink.append("help_body.jsp?"); 761 bodyLink.append(CmsHelpTemplateBean.PARAM_HELPRESOURCE); 762 bodyLink.append("="); 763 bodyLink.append(getJsp().getRequestContext().getUri()); 764 bodyLink.append("&"); 765 bodyLink.append(CmsLocaleManager.PARAMETER_LOCALE); 766 bodyLink.append("="); 767 bodyLink.append(getLocale()); 768 result.append(getJsp().link(bodyLink.toString())); 769 result.append("\" scrolling=\"auto\" noresize>\n"); 770 result.append("</frameset>\n\n"); 771 result.append("<body></body>\n"); 772 result.append("</html>"); 773 774 return result.toString(); 775 } 776 777 784 protected void getMappedHelpUri() { 785 786 try { 787 getJsp().getRequestContext().setCurrentProject(m_onlineProject); 788 if (CmsStringUtil.isNotEmpty(getParamWorkplaceresource())) { 789 String helpResource = null; 791 String wpResource = getParamWorkplaceresource(); 792 if (getCms().existsResource( 793 resolveMacros(getParamWorkplaceresource()), 795 CmsResourceFilter.requireType(CmsResourceTypeXmlPage.getStaticTypeId()))) { 796 helpResource = resolveMacros(getParamWorkplaceresource()); 798 setParamHomelink(getJsp().link(helpResource)); 799 } else { 800 try { 802 803 String absolutePath = OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf( 805 resolveMacros(RFS_HELPMAPPINGS)); 806 ExtendedProperties props = CmsPropertyUtils.loadProperties(absolutePath); 807 808 if (wpResource.startsWith(OpenCms.getSystemInfo().getOpenCmsContext())) { 809 wpResource = wpResource.substring(OpenCms.getSystemInfo().getOpenCmsContext().length()); 811 } 812 while (wpResource != null && CmsStringUtil.isEmpty(helpResource)) { 814 helpResource = props.getString(wpResource, null); 815 wpResource = CmsResource.getParentFolder(wpResource); 816 } 817 } catch (IOException e) { 818 } 820 821 if (CmsStringUtil.isEmpty(helpResource)) { 822 helpResource = DEFAULT_HELPFILE; 824 } 825 helpResource = resolveMacros(PATH_HELP) + helpResource; 827 if (!getCms().existsResource(helpResource, CmsResourceFilter.IGNORE_EXPIRATION)) { 828 helpResource = resolveMacros(PATH_HELP) + DEFAULT_HELPFILE; 829 } 830 setParamHomelink(getJsp().link(resolveMacros(PATH_HELP) + DEFAULT_HELPFILE)); 831 } 832 getJsp().getRequestContext().setUri(helpResource); 834 } 835 836 } finally { 837 getJsp().getRequestContext().setCurrentProject(m_offlineProject); 838 } 839 } 840 841 844 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 845 846 fillParamValues(request); 848 849 if (isBuildFrameset()) { 851 getMappedHelpUri(); 853 } 854 } 855 856 861 protected boolean isBuildFrameset() { 862 863 return Boolean.valueOf(getParamBuildframe()).booleanValue(); 864 } 865 866 872 private String attachRequestString(String ressourceName) { 873 874 StringBuffer result = new StringBuffer (ressourceName); 875 boolean firstParam = true; 876 if (ressourceName.indexOf('?') == -1) { 877 result.append('?'); 879 } else { 880 firstParam = false; 881 } 882 Map.Entry entry; 883 Iterator it = getJsp().getRequest().getParameterMap().entrySet().iterator(); 884 String [] values = null; 885 while (it.hasNext()) { 886 if (values == null) { 887 if (!firstParam) { 889 result.append('&'); 890 } 891 } else { 892 result.append("&"); 893 } 894 entry = (Map.Entry )it.next(); 895 result.append(entry.getKey().toString()).append('='); 896 values = (String [])entry.getValue(); 897 for (int i = 0; i < values.length; i++) { 898 result.append(values[i]); 899 if (i + 1 < values.length) { 900 result.append(','); 901 } 902 } 903 } 904 return result.toString(); 905 } 906 907 } | Popular Tags |