📄 bigtext_field.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .////// BigText_Field// EV 14.01.20001//// handleField( mode, jParams )//package org.jahia.engines.shared;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;import org.jahia.exceptions.*; // JahiaExceptionimport org.jahia.utils.*; // JahiaConsoleimport org.jahia.data.*; // JahiaData, ConnectionTypesimport org.jahia.params.*; // ParamBeanimport org.jahia.engines.*; // JahiaEngine interfaceimport org.jahia.data.containers.*;import org.jahia.data.fields.*; // JahiaField, FieldTypesimport org.jahia.registries.*; // ServicesRegistryimport org.jahia.services.acl.*;public class BigText_Field{ private static BigText_Field theObject = null; private static final String JSP_FILE = "/jsp/jahia/engines/shared/bigtext_field.jsp"; /*** * getInstance * AK 19.12.2000 * */ public static synchronized BigText_Field getInstance() { if (theObject == null) { theObject = new BigText_Field(); } return theObject; } // end getInstance /*** * handles the field actions * * @param jParams a ParamBean object * @param mode the mode, according to JahiaEngine * @return true if everything went okay, false if not * @see org.jahia.engines.JahiaEngine * */ public boolean handleField( ParamBean jParams, Integer modeInt, HashMap engineMap ) throws JahiaException { int mode = modeInt.intValue(); JahiaField theField = (JahiaField) engineMap.get( "theField" ); // SB 25.07.2001 : commented out Eric's code if (engineMap.get(theField.getDefinition().getName() + "_rawData") == null) { theField.setValue( theField.getRawValue() ); engineMap.put(theField.getDefinition().getName() + "_rawData", Boolean.TRUE ); } switch (mode) { case (JahiaEngine.LOAD_MODE) : return composeEngineMap( jParams, engineMap, theField ); case (JahiaEngine.UPDATE_MODE) : return getFormData( jParams, engineMap, theField ); case (JahiaEngine.SAVE_MODE) : return saveData( jParams, engineMap, theField ); } return false; } // end handleField /*** * gets POST data from the form and saves it in session * * @param jParams a ParamBean object * @param engineMap the engine hashmap * @param theField the field we are working on * @return true if everything went okay, false if not * */ private boolean getFormData( ParamBean jParams, HashMap engineMap, JahiaField theField ) throws JahiaException { boolean out = true; String sConnectType = jParams.getRequest().getParameter("connectType"); int connectType = sConnectType != null ? Integer.parseInt(sConnectType) : theField.getConnectType(); String fieldValue = jParams.getRequest().getParameter( "_" + new Integer(theField.getID()).toString() ); if (fieldValue != null) { fieldValue = JahiaTools.replacePattern(fieldValue,"|","|"); if (FormDataManager.getInstance().checkIntegrity(fieldValue)) { fieldValue = FormDataManager.getInstance().encode( fieldValue ); } else { out = false; } } else { fieldValue = theField.getValue(); } if (connectType == ConnectionTypes.HTMLEDITORAX) { if ((theField.getConnectType() == ConnectionTypes.LOCAL) || (theField.getConnectType() == ConnectionTypes.HTMLEDITOR) ) { // we replace carriage returns by BRs for the ActiveX HTML editor // so that it understands them. if (!fieldValue.toLowerCase().startsWith("<html>")) { fieldValue = JahiaTools.replacePattern(fieldValue, "\n", "<br>"); } } } else if (connectType == ConnectionTypes.LOCAL) { if ((theField.getConnectType() == ConnectionTypes.HTMLEDITORAX) || (theField.getConnectType() == ConnectionTypes.HTMLEDITOR) ) { if (fieldValue.toLowerCase().startsWith("<html>")) { fieldValue = JahiaTools.replacePattern(fieldValue, "<br>", "<br>\n"); fieldValue = JahiaTools.replacePattern(fieldValue, "<BR>", "<br>\n"); } } } switch(connectType) { case ConnectionTypes.LOCAL : theField.setValue( fieldValue ); theField.setObject(null); break; // JB 02.08.2001 - Add HTMLEditor Types case ConnectionTypes.HTMLEDITOR : theField.setValue( fieldValue ); theField.setObject(null); break; case ConnectionTypes.HTMLEDITORAX : theField.setValue( fieldValue ); theField.setObject(null); break; default : break; } theField.setConnectType(connectType); return out; } // end getFormData /*** * saves data in datasource * * @param jParams a ParamBean object * @param engineMap the engine hashmap * @param theField the field we are working on * @return true if everything went okay, false if not * */ private boolean saveData( ParamBean jParams, HashMap engineMap, JahiaField theField ) throws JahiaException { // 0 for parentAclID in saveField, because field already exists // -> field already has an aclID // -> no need to create a new one ServicesRegistry.getInstance().getJahiaFieldService().saveField( theField, 0, jParams ); return true; } // end saveData /*** * composes engine hash map * * @param jParams a ParamBean object * @param engineMap the engine hashmap * @param theField the field we are working on * @return true if everything went okay, false if not * */ private boolean composeEngineMap( ParamBean jParams, HashMap engineMap, JahiaField theField ) throws JahiaException { boolean editable = false; JahiaContainer theContainer = (JahiaContainer)engineMap.get("theContainer"); if ( theContainer == null ){ // in case of a field , not a field in a container editable = true; } else if ( theContainer.getListID()!=0 ){ JahiaBaseACL acl = JahiaEngineTools.getCtnListFieldACL((HashMap)engineMap.get("ctnListFieldAcls"), theField.getID()); if ( acl != null ){ editable = acl.getPermission(jParams.getUser(),JahiaBaseACL.WRITE_RIGHTS, jParams.getSiteID()); } } else { editable = true; } String output = ""; if ( editable ){ if (theField.getConnectType() == ConnectionTypes.LOCAL) { theField.setValue( FormDataManager.getInstance().formDecode(theField.getValue()) ); } // JB 02.08.2001 - Add HTMLEditor Types if (theField.getConnectType() == ConnectionTypes.HTMLEDITOR) { theField.setValue( FormDataManager.getInstance().formDecode(theField.getValue()) ); } if (theField.getConnectType() == ConnectionTypes.HTMLEDITORAX) { theField.setValue( FormDataManager.getInstance().formDecode(theField.getValue()) ); } output = ServicesRegistry.getInstance().getJahiaFetcherService().fetchServlet( jParams, JSP_FILE ); } else { output = ServicesRegistry.getInstance().getJahiaFetcherService().fetchServlet( jParams, JahiaEngine.NOT_EDITABLE_FIELD ); } engineMap.put( "fieldForm", output ); return true; } // end composeEngineMap} // end BigText_Field
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -