📄 jahiabigtextfield.java
字号:
// JahiaBigTextField// YG 17.07.2001package org.jahia.data.fields;import org.apache.regexp.*; // Regular Expressionimport java.util.*; // Vector, Calendarimport org.jahia.utils.*;import org.jahia.data.*;import org.jahia.services.files.*; // Jahia Files Servicesimport org.jahia.registries.*; // ServicesRegistryimport org.jahia.sharing.*; // JahiaDataSourceManagerimport org.jahia.params.*; // ParamBeanimport org.jahia.services.pages.JahiaPage;import org.jahia.services.pages.JahiaPageDefinition;import org.jahia.exceptions.JahiaException;import org.jahia.registries.*; // Registriespublic class JahiaBigTextField extends JahiaField{ /*** * constructor * YG 17.07.2001 * */ public JahiaBigTextField(Integer ID, Integer jahiaID, Integer pageID, Integer ctnid, Integer fieldDefID, Integer fieldType, Integer connectType, String fieldValue, Integer rank, Integer aclID ) { super(ID, jahiaID, pageID, ctnid, fieldDefID, fieldType, connectType, fieldValue, rank, aclID); } // end constructor /* public String getValue() { System.out.println("------ BIG TEXT . getValue"); switch (this.getConnectType()) { default : return super.getValue(); } } */ public void load(int loadFlag, ParamBean jParams) throws JahiaException { JahiaConsole.println("JahiaBigTextField.load", "Loading big text field..."); JahiaFieldDefinition theDef = JahiaFieldDefinitionsRegistry. getInstance().getDefinition( this.getFieldDefID() ); int pageDefID = ServicesRegistry.getInstance().getJahiaPageService(). lookupPage (this.getPageID(), jParams). getPageTemplateID(); if ((loadFlag & LoadFlags.BIGTEXT) != 0) { switch (this.getConnectType()) { case (ConnectionTypes.LOCAL) : this.setValue((this.getTextFileService()).loadContents( this.getJahiaID(), this.getPageID(), this.getID(), theDef.getDefaultValue(pageDefID) )); if (!this.getValue().equals("<empty>")) { this.setRawValue(this.getValue()); this.setValue(FormDataManager.getInstance(). decode(this.getValue())); } break; // JB 02.08.2001 - Add HTMLEditor Types case (ConnectionTypes.HTMLEDITOR) : this.setValue((this.getTextFileService()).loadContents( this.getJahiaID(), this.getPageID(), this.getID(), theDef.getDefaultValue(pageDefID) )); if (!this.getValue().equals("<empty>")) { this.setRawValue(this.getValue()); this.setValue(FormDataManager.getInstance(). decode(this.getValue())); } break; case (ConnectionTypes.HTMLEDITORAX) : this.setValue((this.getTextFileService()).loadContents( this.getJahiaID(), this.getPageID(), this.getID(), theDef.getDefaultValue(pageDefID) )); if (!this.getValue().equals("<empty>")) { this.setRawValue(this.getValue()); this.setValue(FormDataManager.getInstance(). decode(this.getValue())); } break; case (ConnectionTypes.DATASOURCE) : if ((loadFlag & LoadFlags.DATASOURCE) != 0) { this.setValue( JahiaDataSourceManager. getInstance().fields().getInstance(). getRemoteFieldValue( this.getValue() ) ); } break; } } } public void save(ParamBean jParams) throws JahiaException { String tmpVal = "<text>"; switch (this.getConnectType()) { case (ConnectionTypes.LOCAL) : tmpVal = (this.getTextFileService()).saveContents( this.getJahiaID(), this.getPageID(), this.getID(), this.getValue() ); break; // JB 02.08.2001 - Add HTMLEditor Types case (ConnectionTypes.HTMLEDITOR) : tmpVal = (this.getTextFileService()).saveContents( this.getJahiaID(), this.getPageID(), this.getID(), this.getValue() ); break; case (ConnectionTypes.HTMLEDITORAX) : tmpVal = (this.getTextFileService()).saveContents( this.getJahiaID(), this.getPageID(), this.getID(), this.getValue() ); break; case (ConnectionTypes.DATASOURCE) : tmpVal = this.getValue(); break; } } public void delete(ParamBean jParams) throws JahiaException { if (this.getConnectType() == ConnectionTypes.LOCAL) { //String fileName = this.getValue(); String fileName = (this.getTextFileService()).getFileName( this.getJahiaID(), this.getPageID(), this.getID() ); FileUtils.getInstance().deleteFile( fileName ); } // JB 02.08.2001 - Add HTMLEditor Types if (this.getConnectType() == ConnectionTypes.HTMLEDITOR) { String fileName = (this.getTextFileService()).getFileName( this.getJahiaID(), this.getPageID(), this.getID() ); FileUtils.getInstance().deleteFile( fileName ); } if (this.getConnectType() == ConnectionTypes.HTMLEDITORAX) { String fileName = (this.getTextFileService()).getFileName( this.getJahiaID(), this.getPageID(), this.getID() ); FileUtils.getInstance().deleteFile( fileName ); } } /** * Returns an hashtable of indexable attributes , pairs [attribute name/value]. * Returned pairs: * none * * @return Hashtable a map of indexable attributes , pairs [attribute name/value] */ public Hashtable getIndexableAttributes(){ Hashtable hash = new Hashtable(); return hash; } public String getEngineName() { return "org.jahia.engines.shared.BigText_Field"; } public String getFieldContent4Ranking() { String fieldInfo = this.getValue(); fieldInfo = JahiaTools.html2text(fieldInfo); try { fieldInfo = (new RE("<(.*?)>")).subst(fieldInfo,""); } catch (RESyntaxException re) { JahiaConsole.println("JahiaBigTextField.getFieldContent4Ranking",re.toString()); } catch (Throwable t) { JahiaConsole.println("JahiaBigTextField.getFieldContent4Ranking",t.toString()); } if (fieldInfo.length() > 30) { fieldInfo = fieldInfo.substring(0,30) +" ..."; } fieldInfo = JahiaTools.text2html(fieldInfo); return fieldInfo; } public String getIconNameOff() { return "bigtext"; } public String getIconNameOn() { return "bigtext_on"; } public JahiaField cloneField(int newctnid, int newPageID, int clonedAclID, boolean childrenCloned) throws JahiaException { JahiaField clonedField = ServicesRegistry.getInstance().getJahiaFieldService(). createJahiaField(0, this.getJahiaID(), newPageID, newctnid, this.getFieldDefID(), this.getType(), this.getConnectType(), this.getValue(), this.getRank(), clonedAclID ); //toDebug("cloneField(): value = "+this.getValue()); if (clonedField == null) { throw new JahiaException ("Could not clone field.", "Could not instanciate a new JahiaField object.", JahiaException.PAGE_ERROR, JahiaException.CRITICAL); } clonedField.setRawValue(this.getRawValue()); clonedField.setObject( this.getObject() ); clonedField.setProperties( (Hashtable)(this.getProperties()).clone() ); return clonedField; } public Object clone() { Object objItem = this.getObject(); JahiaBigTextField bt = new JahiaBigTextField (new Integer(ID), new Integer(jahiaID), new Integer(pageID), new Integer(ctnid), new Integer(fieldDefID), new Integer(fieldType), new Integer(connectType), fieldValue, new Integer(rank), new Integer(aclID) ); bt.setObject(objItem); return bt; } /** * Method getTextFileService * @author NK * @return a JahiaTextFileService instance */ private JahiaTextFileService getTextFileService(){ return ServicesRegistry.getInstance().getJahiaTextFileService(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -