📄 cmsworkplacedefault.java
字号:
/** Directory name of content internal folder. */
public static final String C_VFS_DIR_INTERNAL = "internal/";
/** Directory name of module locales path. */
public static final String C_VFS_DIR_LOCALES = "locales/";
/**
* Path to the login folder.<p>
*
* It's important to note that this does NOT end with a /
* as most other path constants do!<p>
*/
public static final String VFS_PATH_LOGIN = CmsWorkplace.VFS_PATH_SYSTEM + "login";
/** Path to content default_bodies folder. */
public static final String C_VFS_PATH_DEFAULT_BODIES = CmsCompatibleCheck.VFS_PATH_DEFAULTMODULE + CmsWorkplace.VFS_DIR_DEFAULTBODIES;
/** Path to module demo folder (deprecated since version 5.0 beta 2). */
public static final String C_VFS_PATH_MODULEDEMOS = CmsWorkplace.VFS_PATH_MODULES + "moduledemos/";
/** Path to online help pages. */
public static final String C_VFS_PATH_HELP = CmsWorkplace.VFS_PATH_WORKPLACE + "help/";
/** Path to scripts. */
public static final String C_VFS_PATH_SCRIPTS = CmsWorkplace.VFS_PATH_WORKPLACE + "scripts/";
/** Path to download gallery folder. */
public static final String C_VFS_GALLERY_DOWNLOAD = CmsWorkplace.VFS_PATH_GALLERIES + "download/";
/** Path to externallink gallery folder. */
public static final String C_VFS_GALLERY_EXTERNALLINKS = CmsWorkplace.VFS_PATH_GALLERIES + "externallinks/";
/** Path to html gallery folder. */
public static final String C_VFS_GALLERY_HTML = CmsWorkplace.VFS_PATH_GALLERIES + "htmlgalleries/";
/** Path to pics gallery folder. */
public static final String C_VFS_GALLERY_PICS = CmsWorkplace.VFS_PATH_GALLERIES + "pics/";
/** Path to content internal folder. */
public static final String C_VFS_PATH_DEFAULT_INTERNAL = CmsWorkplace.VFS_PATH_WORKPLACE + "templates/";
/** The channel tree. */
public static final String C_WP_CHANNEL_TREE = "../action/channel_tree.html";
/** The explorer file list. */
public static final String C_WP_EXPLORER_FILELIST = "../action/explorer_files.html";
/** The preferences user panel. */
public static final String C_WP_EXPLORER_PREFERENCES = "../action/preferences.html?panel=user";
/** The explorer tree. */
public static final String C_WP_EXPLORER_TREE = "../action/explorer_tree.html";
/** The folder tree. */
public static final String C_WP_FOLDER_TREE = "../action/folder_tree.html";
/** The workplace. */
public static final String C_WP_RELOAD = "../action/workplace_reload.html";
/**
* Checks a Java System property for containing the given value
* @param propertyName Name of the property
* @param value Value that should be checked
* @return <code>true</code> if the property contains the value, <code>false</code> otherwise
*/
protected boolean checkJavaProperty(String propertyName, String value) {
boolean result = false;
String prop = null;
try {
prop = System.getProperty(propertyName);
if(prop != null && prop.equals(value)) {
result = true;
}
return result;
}
catch(Exception e) {
return false;
}
}
/**
* Used by workplace icons to decide whether the icon should
* be activated or not. Icons will use this method if the attribute <code>method="doNotShow"</code>
* is defined in the <code><ICON></code> tag.
* <P>
* This method always returns <code>false</code> thus icons controlled by
* this method will never be activated.
*
* @param cms CmsObject Object for accessing system resources <em>(not used here)</em>.
* @param lang reference to the currently valid language file <em>(not used here)</em>.
* @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
* @return <code>false</code>.
*/
public Boolean doNotShow(CmsObject cms, CmsXmlLanguageFile lang, Hashtable parameters) {
return new Boolean(false);
}
/**
* Gets a reference to the default config file.
* The path to this file ist stored in <code>C_WORKPLACE_INI</code>
*
* @param cms CmsObject Object for accessing system resources.
* @return Reference to the config file.
* @throws CmsException
*/
public CmsXmlWpConfigFile getConfigFile(CmsObject cms) throws CmsException {
//if(m_configFile == null) {
m_configFile = new CmsXmlWpConfigFile(cms);
//}
return m_configFile;
}
/**
* Help method used to fill the vectors returned to
* <code>CmsSelectBox</code> with constant values.
* @param names Vector to be filled with the appropriate values in this method.
* @param values Vector to be filled with the appropriate values in this method.
* @param content String array containing the elements to be set.
* @param lang reference to the currently valid language file
*/
protected void getConstantSelectEntries(Vector names, Vector values, String[] contents,
CmsXmlLanguageFile lang) throws CmsException {
for(int i = 0;i < contents.length;i++) {
String value = contents[i];
values.addElement(value);
String s = lang.getLanguageValue("select." + value);
if ((s == null) || s.startsWith("???")) s = value;
names.addElement(s);
}
}
/**
* Gets all fonts available in the WYSIWYG editor.
*
* The given vectors <code>names</code> and <code>values</code> will
* be filled with the appropriate information to be used for building
* a select box.
*
* @param cms CmsObject Object for accessing system resources.
* @param lang reference to the currently valid language file
* @param names Vector to be filled with the appropriate values in this method.
* @param values Vector to be filled with the appropriate values in this method.
* @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
* @return Index representing the user's current workplace view in the vectors.
* @throws CmsException
*/
public Integer getFonts(CmsObject cms, CmsXmlLanguageFile lang, Vector names, Vector values,
Hashtable parameters) throws CmsException {
for(int i = 0;i < CmsDefaultPageEditor.SELECTBOX_FONTS.length; i++) {
String value = CmsDefaultPageEditor.SELECTBOX_FONTS[i];
values.addElement(value);
names.addElement(value);
}
return new Integer(0);
}
/**
* Gets the key that should be used to cache the results of
* this template class.
*
* @param cms CmsObject Object for accessing system resources
* @param templateFile Filename of the template file
* @param parameters Hashtable with all template class parameters.
* @param templateSelector template section that should be processed.
* @return key that can be used for caching
*/
public Object getKey(CmsObject cms, String templateFile, Hashtable parameters, String templateSelector) {
CmsRequestContext reqContext = cms.getRequestContext();
String result = ""
+ reqContext.currentProject().getId()
+ ":"
+ reqContext.currentUser().getName()
+ reqContext.addSiteRoot(templateFile);
Enumeration keys = parameters.keys();
// select the right language to use
String currentLanguage = null;
CmsUserSettings settings = new CmsUserSettings(cms);
currentLanguage = settings.getLocale().toString();
while(keys.hasMoreElements()) {
String key = (String)keys.nextElement();
result = result + key + parameters.get(key);
}
result = result + templateSelector + currentLanguage;
return result;
}
/**
* Get the currently valid <code>lasturl</code> parameter that can be
* used for redirecting to the previous workplace screen.
* @param cms Cms object for accessing system resources.
* @param parameters User parameters.
* @return <code>lasturl</code> parameter.
*/
protected String getLastUrl(CmsObject cms, Hashtable parameters) {
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
String lasturl = (String)parameters.get("lasturl");
// Lasturl parameter will be taken either from the parameter hashtable
// (if exists) or from the session storage.
// If neccessary, session storage will be updated.
StringBuffer encLasturl = new StringBuffer();
boolean notfirst = false;
if(lasturl != null) {
// Fine. A lasturl parameter was found in session or parameter hashtable.
// Check, if the URL parameters of the last url have to be encoded.
int asteriskIdx = lasturl.indexOf("?");
if(asteriskIdx > -1 && (asteriskIdx < (lasturl.length() - 1))) {
// In fact, there are URL parameters
encLasturl.append(lasturl.substring(0, asteriskIdx + 1));
String queryString = lasturl.substring(asteriskIdx + 1);
StringTokenizer st = new StringTokenizer(queryString, "&");
while(st.hasMoreTokens()) {
// Loop through all URL parameters
String currToken = st.nextToken();
if(currToken != null && !"".equals(currToken)) {
// Look for the "=" character to divide parameter name and value
int idx = currToken.indexOf("=");
if(notfirst) {
encLasturl.append("&");
}
else {
notfirst = true;
}
if(idx > -1) {
// A parameter name/value pair was found.
// Encode the parameter value and write back!
String key = currToken.substring(0, idx);
String value = (idx < (currToken.length() - 1)) ? currToken.substring(idx + 1) : "";
encLasturl.append(key);
encLasturl.append("=");
encLasturl.append(CmsEncoder.escape(value,
cms.getRequestContext().getEncoding()));
}
else {
// Something strange happened.
// Maybe a parameter without "=" ?
// Write back without encoding!
encLasturl.append(currToken);
}
}
}
lasturl = encLasturl.toString();
}
session.putValue("lasturl", lasturl);
}
else {
lasturl = (String)session.getValue("lasturl");
}
return lasturl;
}
/**
* Reads in the template file and starts the XML parser for the expected
* content type <class>CmsXmlWpTemplateFile</code>
*
* @param cms CmsObject Object for accessing system resources.
* @param templateFile Filename of the template file.
* @param elementName Element name of this template in our parent template.
* @param parameters Hashtable with all template class parameters.
* @param templateSelector template section that should be processed.
*/
public CmsXmlTemplateFile getOwnTemplateFile(CmsObject cms, String templateFile, String elementName,
Hashtable parameters, String templateSelector) throws CmsException {
CmsXmlWpTemplateFile xmlTemplateDocument = new CmsXmlWpTemplateFile(cms, templateFile);
return xmlTemplateDocument;
}
/**
* Checks if the current user is <strong>administrator</strong>.
* <P>
* This method is used by workplace icons to decide whether the icon should
* be activated or not. Icons will use this method if the attribute <code>method="isAdministrator"</code>
* is defined in the <code><ICON></code> tag.
*
* @param cms CmsObject Object for accessing system resources <em>(not used here)</em>.
* @param lang reference to the currently valid language file <em>(not used here)</em>.
* @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
* @return <code>true</code> if the current user is in the Administrators Group, <code>false</code> otherwise.
* @throws CmsException if there were errors while accessing project data.
*/
public Boolean isAdmin(CmsObject cms, CmsXmlLanguageFile lang, Hashtable parameters) throws CmsException {
return new Boolean(cms.isAdmin());
}
/**
* Same as above, only that this returns always 'false'.
* Can be used to quickly deactivate unwanted icons on the workplace even
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -