📄 a_cmschannelbackoffice.java
字号:
/**
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001 The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.opencms.defaults;
import org.opencms.db.CmsDbUtil;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsRequestContext;
import org.opencms.main.CmsException;
import org.opencms.main.OpenCms;
import com.opencms.core.I_CmsSession;
import com.opencms.defaults.master.CmsMasterContent;
import com.opencms.defaults.master.CmsMasterMedia;
import com.opencms.legacy.CmsXmlTemplateLoader;
import com.opencms.template.A_CmsXmlContent;
import com.opencms.template.CmsXmlTemplateFile;
import com.opencms.workplace.CmsXmlLanguageFile;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
/**
* Backoffice class with channel functionality
* @author Michael Dernen
*
* @deprecated Will not be supported past the OpenCms 6 release.
*/
public abstract class A_CmsChannelBackoffice extends A_CmsBackoffice {
/**
* UserMethod creates a selectBox for selected channels
*
* @param cms CmsObject Object for accessing system resources
* @param lang CmsXmlLanguageFile the language file
* @param values Vector for the values in the selectBox
* @param names Vector for the names in the selectBox
* @param parameters Hashtable with all template class parameters.
* @return Integer selected Index Value of selectBox
* @throws CmsException in case of unrecoverable errors
*/
public Integer getSelectedChannels(CmsObject cms, CmsXmlLanguageFile lang, Vector values, Vector names, Hashtable parameters)
throws CmsException {
int retValue = -1;
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
CmsMasterContent cd = (CmsMasterContent)session.getValue(getContentDefinitionClass().getName());
Vector channels = cd.getSelectedChannels();
int size = channels.size();
for (int i=0; i < size; i++) {
values.add(channels.elementAt(i));
names.add(channels.elementAt(i));
}
return new Integer(retValue);
}
/**
* UserMethod creates a selectBox for available channels
*
* @param cms CmsObject Object for accessing system resources
* @param lang CmsXmlLanguageFile
* @param values Vector for the values in the selectBox
* @param names Vector for the names in the selectBox
* @param parameters Hashtable with all template class parameters.
* @return Integer selected Index Value of selectBox
* @throws org.opencms.main.CmsException in case of unrecoverable errors
*/
public Integer getAvailableChannels(CmsObject cms, CmsXmlLanguageFile lang, Vector values, Vector names, Hashtable parameters)
throws CmsException {
int retValue = -1;
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
CmsMasterContent cd = (CmsMasterContent)session.getValue(getContentDefinitionClass().getName());
Vector channels = cd.getAvailableChannels(cms);
int size = channels.size();
for (int i=0; i < size; i++) {
values.add(channels.elementAt(i));
names.add(channels.elementAt(i));
}
return new Integer(retValue);
}
/**
* UserMethod creates a selectBox for selected channels
*
* @param cms CmsObject Object for accessing system resources
* @param lang CmsXmlLanguageFile
* @param values Vector for the values in the selectBox
* @param names Vector for the names in the selectBox
* @param parameters Hashtable with all template class parameters.
* @return Integer selected Index Value of selectBox
* @throws org.opencms.main.CmsException in case of unrecoverable errors
*/
public Integer getMediaPosition(CmsObject cms, CmsXmlLanguageFile lang, Vector values, Vector names, Hashtable parameters)
throws CmsException {
//get session
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
//selected media content definition
//media_position
String media_position = null;
int media_positionInt=0;
//content of the select box
String selectBoxContent="";
//flag
boolean flag=false;
try {
//get the content
selectBoxContent=selectBoxContent(cms);
} catch (Exception e) {
e.printStackTrace(System.err);
}
StringTokenizer t = new StringTokenizer(selectBoxContent, ";");
while (t.hasMoreElements()) {
String s=t.nextToken();
if (s!=null && !s.equals("")) {
int z=s.indexOf(":");
values.add(s.substring(0, z));
String name=s.substring(z+1);
names.add(name);
//if there is a 0 as position don't
if (name.equals("0")) {
flag=true;
}
}
}
//try to get the medias from session
try {
media_position=(String)session.getValue("media_position");
media_positionInt=Integer.parseInt(media_position);
if (!flag) {
media_positionInt=Integer.parseInt(media_position)-1;
}
} catch (Exception e) {
media_positionInt=0;
}
return new Integer(media_positionInt);
}
/**
* get the complete page to edit,delete and upload files and pictures
* <P>
* This method can be called using <code><METHOD name="getTitle"></code>
* in the template file.
*
* @param cms CmsObject Object for accessing system resources.
* @param tagcontent Unused in this special case of a user method. Can be ignored.
* @param doc Reference to the A_CmsXmlContent object of the initiating XLM document.
* @param userObject Hashtable with parameters.
* @return String or byte[] with the content of this subelement.
* @throws CmsException if something goes wrong
*/
public Object getContentMedia(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) throws CmsException {
//return value
String content="";
String row="";
//get the template
CmsXmlTemplateFile templateFile = (CmsXmlTemplateFile) doc;
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
CmsMasterContent masterCD = (CmsMasterContent)session.getValue(getContentDefinitionClass().getName());
//get the parameter
Hashtable parameters = (Hashtable)userObject;
// get the action
String media_action = (String) parameters.get("media_action");
media_action=(media_action!=null?media_action.trim():"");
// get the media_name
String media_name = (String) parameters.get("media_name");
media_name=(media_name!=null?media_name.trim():"");
// get the alt_text
String media_title = (String) parameters.get("media_alt_text");
media_title=(media_title!=null?media_title.trim():"");
media_title = org.opencms.i18n.CmsEncoder.unescape(media_title,
cms.getRequestContext().getEncoding());
// get the pos
String pos = (String) parameters.get("pos");
pos=(pos!=null?pos.trim():"");
if (pos.equals("")) {
//if your are in the edit modus get another pos
pos = (String) parameters.get("posEdit");
pos=(pos!=null?pos.trim():"");
}
int posInt=CmsDbUtil.UNKNOWN_ID;
if (!pos.equals("")) {
try {
posInt=Integer.parseInt(pos);
} catch (Exception e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -