📄 htmltoolbox.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////// HTMLToolBox// EV 15.12.2000// NK 14.05.2001 Prefix each popup window's name with the session id// to resolve session conflict beetween different sites// opened in different explorer// NK 22.05.2001 Container and field update popup's names are composed with their id too !!!// This is needed when to close and reopen the update popup with data. ( resolv refresh problem with JahiaOpenWindow() javascript function )//package org.jahia.gui;import java.util.*; // Vectorimport org.jahia.utils.*; // JahiaConsoleimport org.jahia.params.*; // ParamBeanimport org.jahia.data.fields.*; // JahiaFieldimport org.jahia.data.containers.*; // JahiaContainerimport org.jahia.services.pages.*; // JahiaPagesimport org.jahia.exceptions.JahiaException;import org.jahia.engines.copytree.*;public class HTMLToolBox { private static final String CLASS_NAME = HTMLToolBox.class.getName(); private static final int JS_WINDOW_WIDTH = 640; private static final int JS_WINDOW_HEIGHT = 480; private ParamBean jParams; private GuiBean gui; /*** * constructor * EV 15.12.2000 * */ public HTMLToolBox( GuiBean gui, ParamBean jParams ) { this.gui = gui; this.jParams = jParams; } // end constructor private static String previousSessionID = ""; private static String previousCleanSessionID = ""; /** * Utility method to clean session ID to be used in javascript code mostly * Basically what it does is removed all non alpha numeric characters in the * session ID. This uses a unicode method so it WILL allow unicode allowed * alpha numeric character which might NOT work with Javascript flawlessly. * * This method also uses a very simple "cache" system that allows us not * to have to parse the whole string if called repeteadly with the same * session ID. * @param sessionID the session ID to test for non alpha numeric characters * @return the "cleaned" session ID. */ public static String cleanSessionID(String sessionID) { if (sessionID.equals(previousSessionID)) { return previousCleanSessionID; } StringBuffer result = new StringBuffer(); for (int i=0; i < sessionID.length(); i++) { char curChar = sessionID.charAt(i); if (Character.isLetterOrDigit(curChar)) { result.append(curChar); } } previousSessionID = sessionID; previousCleanSessionID = result.toString(); return result.toString(); } // drawLoginLauncher public String drawLoginLauncher() throws JahiaException { return (gui.drawPopupLoginUrl().equals("")) ? "" : "OpenJahiaWindow('" + gui.drawPopupLoginUrl() + "','Login',260,300)"; } public String drawLoginLauncher( int destinationPageID) throws JahiaException { return (gui.drawPopupLoginUrl( destinationPageID ).equals("")) ? "" : "OpenJahiaWindow('" + gui.drawPopupLoginUrl( destinationPageID ) + "','Login',260,300)"; } // drawLogoutLauncher public String drawLogoutLauncher() throws JahiaException { return gui.drawLogoutUrl(); } public String drawLogoutLauncher( int destinationPageID ) throws JahiaException { return gui.drawLogoutUrl(); } // drawUpdateFieldLauncher public String drawUpdateFieldLauncher( JahiaField theField ) throws JahiaException { StringBuffer name = new StringBuffer("updateField_"); if ( theField != null ){ name.append(theField.getID()); } name.append(cleanSessionID(jParams.getSessionID())); return drawLauncher( gui.drawUpdateFieldUrl(theField) , name.toString() ); } // drawAddContainerLauncher public String drawAddContainerLauncher( JahiaContainerList theContainerList ) throws JahiaException { return drawAddContainerLauncher ( theContainerList, JS_WINDOW_WIDTH, JS_WINDOW_HEIGHT); } // drawAddContainerLauncher public String drawAddContainerLauncher( JahiaContainerList theContainerList, int width, int height ) throws JahiaException { StringBuffer name = new StringBuffer("addContainer_"); if ( theContainerList != null ){ name.append(theContainerList.getID()); } name.append(cleanSessionID(jParams.getSessionID())); return (gui.drawAddContainerUrl(theContainerList).equals("")) ? "" : "OpenJahiaScrollableWindow('" + gui.drawAddContainerUrl(theContainerList) + "','" + name.toString() + "'," + width + "," + height + ")"; } public String drawAddContainerLauncher( JahiaContainerList theContainerList, boolean scrollable ) throws JahiaException { if ( scrollable = true ) { StringBuffer name = new StringBuffer("addContainer_"); if ( theContainerList != null ){ name.append(theContainerList.getID()); } name.append(cleanSessionID(jParams.getSessionID())); return (gui.drawAddContainerUrl(theContainerList).equals("")) ? "" : "OpenJahiaScrollableWindow('" + gui.drawAddContainerUrl(theContainerList) + "','" + name.toString() + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT +")"; } else { return drawAddContainerLauncher(theContainerList); } } // drawUpdateContainerLauncher public String drawUpdateContainerLauncher( JahiaContainer theContainer ) throws JahiaException { return drawUpdateContainerLauncher(theContainer, JS_WINDOW_WIDTH, JS_WINDOW_HEIGHT); } // drawUpdateContainerLauncher public String drawUpdateContainerLauncher( JahiaContainer theContainer, int width, int height ) throws JahiaException { StringBuffer name = new StringBuffer("updateContainer_"); if ( theContainer != null ){ name.append(theContainer.getID()); } name.append(cleanSessionID(jParams.getSessionID())); return (gui.drawUpdateContainerUrl(theContainer).equals("")) ? "" : "OpenJahiaScrollableWindow('" + gui.drawUpdateContainerUrl(theContainer) + "','" + name.toString() + "'," + width + "," + height + ")"; } public String drawUpdateContainerLauncher( JahiaContainer theContainer, boolean scrollable ) throws JahiaException { if ( scrollable = true ) { StringBuffer name = new StringBuffer("updateContainer_"); if ( theContainer != null ){ name.append(theContainer.getID()); } name.append(cleanSessionID(jParams.getSessionID())); return (gui.drawUpdateContainerUrl(theContainer).equals("")) ? "" : "OpenJahiaScrollableWindow('" + gui.drawUpdateContainerUrl(theContainer) + "','" + name.toString() + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT +")"; } else { return drawUpdateContainerLauncher(theContainer); } } // drawDeleteContainerLauncher public String drawDeleteContainerLauncher( JahiaContainer theContainer ) throws JahiaException { StringBuffer name = new StringBuffer("deleteContainer_"); if ( theContainer != null ){ name.append(theContainer.getID()); } name.append(cleanSessionID(jParams.getSessionID())); return (gui.drawDeleteContainerUrl(theContainer).equals("")) ? "" : "OpenJahiaScrollableWindow('" + gui.drawDeleteContainerUrl(theContainer) + "','" + name.toString() + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT +")"; } // drawContainerListPropertiesLauncher public String drawContainerListPropertiesLauncher( JahiaContainerList theContainerList ) throws JahiaException { StringBuffer name = new StringBuffer("containerListProperties_"); if ( theContainerList != null ){ name.append(theContainerList.getID()); } name.append(cleanSessionID(jParams.getSessionID())); String out = (gui.drawContainerListPropertiesUrl( theContainerList ).equals("")) ? "" : "OpenJahiaWindow('" + gui.drawContainerListPropertiesUrl( theContainerList ) + "','" + name.toString() + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT +")"; if (!theContainerList.getContainers().hasMoreElements()) { out = ""; } return out; } // drawPagePropertiesLauncher public String drawPagePropertiesLauncher() throws JahiaException { StringBuffer name = new StringBuffer("pageProperties_"); if ( jParams.getPage() != null ){ name.append(jParams.getPage().getID()); } name.append(cleanSessionID(jParams.getSessionID())); return (gui.drawPagePropertiesUrl().equals("")) ? "" : "OpenJahiaWindow('" + gui.drawPagePropertiesUrl() + "','" + name.toString() + "'," + JS_WINDOW_WIDTH + "," + JS_WINDOW_HEIGHT +")"; } // drawUpdateTemplateLauncher public String drawUpdateTemplateLauncher( JahiaPageDefinition theTemplate ) throws JahiaException { StringBuffer name = new StringBuffer("updateTemplate_"); if ( theTemplate != null ){ name.append(theTemplate.getID()); } name.append(cleanSessionID(jParams.getSessionID())); return drawLauncher( gui.drawUpdateTemplateUrl(theTemplate) , name.toString() ); } /** * Call the Draw the drawCopyTreeLauncher with CopyTree_Engine.CHOOSE_OPERATION * as operation . * Display the page chooser GUI * * @param String unique name of the launcher of this engine * @param int initialSourcePage, the initial page to be selected. * @author NK */ public String drawChoosePageTreeLauncher(String engineLauncherName, int initialSourcePage) throws JahiaException { return drawCopyTreeLauncher(CopyTree_Engine.CHOOSE_OPERATION,engineLauncherName,initialSourcePage); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -