public static void getJavaScript( String fieldNameFunction, String fieldName, String language, PrintWriter out) { out.println("var galleryFileWindow=window;"); out.println("function openGalleryFileManager" + fieldNameFunction + "(){"); out.println( "index = document.getElementById(\"galleryFile_" + fieldName + "\").selectedIndex;"); out.println( "var componentId = document.getElementById(\"galleryFile_" + fieldName + "\").options[index].value;"); out.println("if (index != 0){ "); out.println( "url = \"" + URLUtil.getApplicationURL() + "/gallery/jsp/wysiwygBrowser.jsp?ComponentId=\"+componentId+\"&Language=" + language + "&FieldName=" + fieldNameFunction + "\";"); out.println("windowName = \"GalleryFileWindow\";"); out.println("width = \"750\";"); out.println("height = \"580\";"); out.println("windowParams = \"scrollbars=1,directories=0,menubar=0,toolbar=0, alwaysRaised\";"); out.println("if (!galleryFileWindow.closed && galleryFileWindow.name==windowName)"); out.println("galleryFileWindow.close();"); out.println("galleryFileWindow = SP_openWindow(url, windowName, width, height, windowParams);"); out.println("}}"); }
public String getUserAutoRedirectURL(final String userId, final String target) { String encodedTarget = URLUtil.encodeURL(target); try { final UserDetail ud = UserDetail.getById(userId); final Domain dom = ud.getDomain(); String url; if (URLUtil.isPermalink(target)) { url = dom.getSilverpeasServerURL() + getApplicationURL() + target; } else { url = getUserAutoRedirectURL(dom) + encodedTarget; } return url; } catch (final Exception e) { SilverLogger.getLogger(this) .error( "Error while getting user auto redirect url {0} for user {1}", new String[] {target, userId}, e); return "ErrorGettingDomainServer" + encodedTarget; } }
/** @return the export array pane URL */ protected String getExportUrl() { if (StringUtil.isDefined(getExportDataURL())) { return getExportDataURL(); } StringBuilder exportUrl = new StringBuilder(); String contextPath = URLUtil.getApplicationURL(); exportUrl.append(contextPath).append(EXPORT_URL_SERVLET_MAPPING); exportUrl.append("?type=ArrayPane&name="); // Change the name parameter if you want to export 2 arrays which are displayed in the same page exportUrl.append("Silverpeas_arraypane"); return exportUrl.toString(); }
@Override public String getDestination(String objectId, HttpServletRequest req, HttpServletResponse res) throws Exception { MainSessionController mainSessionCtrl = util.getMainSessionController(req); String language = I18NHelper.defaultLanguage; if (mainSessionCtrl != null) { language = mainSessionCtrl.getFavoriteLanguage(); } SimpleDocumentPK pk = new SimpleDocumentPK(objectId); if (StringUtil.isLong(objectId)) { pk.setOldSilverpeasId(Long.parseLong(objectId)); } SimpleDocument attachment = AttachmentServiceProvider.getAttachmentService().searchDocumentById(pk, language); if (attachment == null) { return null; } String componentId = attachment.getInstanceId(); String foreignId = attachment.getForeignId(); if (isUserLogin(req) && isUserAllowed(req, componentId)) { boolean isAccessAuthorized = true; if (componentId.startsWith("kmelia")) { try { ComponentAuthorization security = (ComponentAuthorization) Class.forName(KMELIA_SECURITY_CLASS).newInstance(); isAccessAuthorized = security.isAccessAuthorized(componentId, getUserId(req), foreignId); } catch (Exception e) { SilverTrace.error( "util", "GoToFile.doPost", "root.EX_CLASS_NOT_INITIALIZED", "org.silverpeas.components.kmelia.KmeliaAuthorization", e); return null; } } if (isAccessAuthorized) { res.setCharacterEncoding(CharEncoding.UTF_8); res.setContentType("text/html; charset=utf-8"); String fileName = ClientBrowserUtil.rfc2047EncodeFilename(req, attachment.getFilename()); res.setHeader("Content-Disposition", "inline; filename=\"" + fileName + "\""); return URLUtil.getFullApplicationURL(req) + encodeFilename(attachment.getAttachmentURL()); } } return "ComponentId=" + componentId + "&AttachmentId=" + objectId + "&Mapping=File&ForeignId=" + foreignId; }
private String printScript() { String context = URLUtil.getApplicationURL(); StringBuilder script = new StringBuilder(); script.append("<script type=\"text/javascript\">"); script.append("function goSpace(spaceId) {"); String mainFrame = "/admin/jsp/MainFrameSilverpeasV5.jsp"; if (look != null && StringUtil.isDefined(look.getMainFrame())) { mainFrame = look.getMainFrame(); if (!mainFrame.startsWith("/")) { mainFrame = "/admin/jsp/" + mainFrame; } } script .append(" top.location = \"") .append(context) .append(mainFrame) .append("?RedirectToSpaceId=\"+spaceId;"); script.append("}"); script.append("</script>"); return script.toString(); }
private String printBreadCrumb() { StringBuilder result = new StringBuilder(); String information = getExtraInformation(); String path = getPath(); // print javascript to go to spaces in displayed path result.append(printScript()); if (!StringUtil.isDefined(getSpaceJavascriptCallback())) { setSpaceJavascriptCallback("goSpace"); } result.append("<div id=\"breadCrumb\">"); boolean emptyBreadCrumb = true; // Display spaces path from root to component String language = (getMainSessionController() == null) ? "" : getMainSessionController().getFavoriteLanguage(); if (StringUtil.isDefined(getComponentId()) || StringUtil.isDefined(getSpaceId())) { List<SpaceInst> spaces; OrganizationController organizationController = OrganizationControllerProvider.getOrganisationController(); if (StringUtil.isDefined(getComponentId())) { spaces = organizationController.getSpacePathToComponent(getComponentId()); } else { spaces = organizationController.getSpacePath(getSpaceId()); } boolean firstSpace = true; for (SpaceInst spaceInst : spaces) { String spaceId = spaceInst.getId(); if (!spaceId.startsWith("WA")) { spaceId = "WA" + spaceId; } String href = "javascript:" + getSpaceJavascriptCallback() + "('" + spaceId + "')"; if (!isClickable()) { href = "#"; } if (!firstSpace) { result.append(CONNECTOR); } result.append("<a href=\"").append(href).append("\""); result.append(" class=\"space\""); result.append(" id=\"space").append(spaceId).append("\""); result.append(">"); result.append(Encode.forHtml(spaceInst.getName(language))); result.append("</a>"); firstSpace = false; emptyBreadCrumb = false; } if (StringUtil.isDefined(getComponentId())) { // Display component's label ComponentInstLight componentInstLight = organizationController.getComponentInstLight(getComponentId()); if (componentInstLight != null) { result.append(CONNECTOR); result.append("<a href=\""); if (!isClickable()) { result.append("#"); } else if (StringUtil.isDefined(getComponentJavascriptCallback())) { result .append("javascript:") .append(getComponentJavascriptCallback()) .append("('") .append(getComponentId()) .append("')"); } else { result .append(URLUtil.getApplicationURL()) .append(URLUtil.getURL(getSpaceId(), getComponentId())); if (ignoreComponentLink()) { result.append("Main"); } else { result.append(getComponentLink()); } } result.append("\""); result.append(" class=\"component\""); result.append(" id=\"bc_").append(componentInstLight.getId()).append("\""); result.append(">"); result.append(Encode.forHtml(componentInstLight.getLabel(language))); result.append("</a>"); emptyBreadCrumb = false; } } } else { if (getDomainName() != null) { result.append(getDomainName()); emptyBreadCrumb = false; } if (getComponentName() != null) { if (getDomainName() != null) { result.append(CONNECTOR); } if (getComponentLink() != null) { result .append("<a href=\"") .append(getComponentLink()) .append("\">") .append(getComponentName()) .append("</a>"); } else { result.append(getComponentName()); } emptyBreadCrumb = false; } } // Display path List<BrowseBarElement> elements = getElements(); if (!elements.isEmpty()) { for (BrowseBarElement element : elements) { if (!emptyBreadCrumb) { result.append(CONNECTOR); } result.append("<a href=\"").append(element.getLink()).append("\""); result.append(" class=\"element\""); if (StringUtil.isDefined(element.getId())) { result.append(" id=\"").append(element.getId()).append("\""); } result.append(">"); result.append(EncodeHelper.javaStringToHtmlString(element.getLabel())); result.append("</a>"); emptyBreadCrumb = false; } } else if (StringUtil.isDefined(path)) { if (!emptyBreadCrumb) { result.append(CONNECTOR); } result.append("<span class=\"path\">"); result.append(path); result.append("</span>"); } // Display extra information if (StringUtil.isDefined(information)) { if (!emptyBreadCrumb) { result.append(CONNECTOR); } result.append("<span class=\"information\">"); result.append(information); result.append("</span>"); } result.append("</div>"); return result.toString(); }
public String getLoginHomePage() { return getSettings("loginHomepage", URLUtil.getApplicationURL() + "/look/jsp/Main.jsp"); }
public String getApplicationURL() { return URLUtil.getApplicationURL(); }