📄 cmsadministration.java
字号:
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "selected template section is: "
+ ((templateSelector == null) ? "<default>" : templateSelector));
}
I_CmsSession session = cms.getRequestContext().getSession(true);
CmsXmlWpTemplateFile templateDocument = new CmsXmlWpTemplateFile(cms, templateFile);
CmsXmlLanguageFile lang = templateDocument.getLanguageFile();
String navPos = (String)session.getValue(C_SESSION_ADMIN_POS);
templateDocument.setData("emptyPic", (String)resourcesUri(cms, "empty.gif", null, null));
CmsXmlWpConfigFile confFile = new CmsXmlWpConfigFile(cms);
String sendBy = (String)parameters.get("sender");
if(sendBy == null) {
if(navPos == null) {
sendBy = confFile.getWorkplaceAdministrationPath();
}
else {
if(!navPos.endsWith("/")) {
navPos = navPos.substring(0, navPos.indexOf("/") + 1);
}
sendBy = navPos;
}
}
Vector iconVector = new Vector();
if(sendBy.endsWith("/administration/")) {
// we must serch for administrationPoints in AdminPath and in system/modules/..
sendBy = confFile.getWorkplaceAdministrationPath();
iconVector = cms.getSubFolders(sendBy);
Vector modules = new Vector();
modules = cms.getSubFolders(I_CmsWpConstants.C_VFS_PATH_MODULES);
for(int i = 0;i < modules.size();i++) {
Vector moduleAdminPoints = new Vector();
moduleAdminPoints = cms.getSubFolders(((CmsFolder)modules.elementAt(i)).getAbsolutePath() + "administration/");
for(int j = 0;j < moduleAdminPoints.size();j++) {
iconVector.addElement(moduleAdminPoints.elementAt(j));
}
}
}
else {
iconVector = cms.getSubFolders(sendBy);
}
session.putValue(C_SESSION_ADMIN_POS, sendBy);
Vector iconVector2 = cms.getFilesInFolder(sendBy);
int numFolders = iconVector.size();
if(numFolders > 0) {
String iconNames[] = new String[numFolders];
int index[] = new int[numFolders];
String folderTitles[] = new String[numFolders];
String folderLangKeys[] = new String[numFolders];
String folderPos[] = new String[numFolders];
String folderVisible[] = new String[numFolders];
String folderActiv[] = new String[numFolders];
String accessVisible[] = new String[numFolders];
for(int i = 0;i < numFolders;i++) {
CmsResource aktIcon = (CmsResource)iconVector.elementAt(i);
try {
Map propertyinfos = cms.readProperties(aktIcon.getAbsolutePath());
iconNames[i] = aktIcon.getAbsolutePath();
index[i] = i;
folderLangKeys[i] = getStringValue((String)propertyinfos.get(C_PROPERTY_NAVTEXT));
folderTitles[i] = getStringValue((String)propertyinfos.get(C_PROPERTY_TITLE));
folderPos[i] = getStringValue((String)propertyinfos.get(C_PROPERTY_NAVPOS));
if(folderPos[i].equals("")) {
folderPos[i] = "101";
}
folderVisible[i] = getStringValue((String)propertyinfos.get(C_PROPERTY_VISIBLE));
folderActiv[i] = getStringValue((String)propertyinfos.get(C_PROPERTY_ACTIV));
accessVisible[i] = new Boolean(checkVisible(cms, aktIcon)).toString();
} catch(CmsException e){
if(e.getType() != CmsException.C_NO_ACCESS &&
e.getType() != CmsException.C_ACCESS_DENIED){
throw e;
}
} catch(Exception exc) {
throw new CmsException("[" + this.getClass().getName() + "] "
+ exc.getMessage(), CmsException.C_SQL_ERROR, exc);
}
} // end of for
sort(iconNames, index, folderPos, numFolders);
String completeTable = "";
int element = 0;
int zeile = 0;
while(element < numFolders) {
String completeRow = "";
//while((element < numFolders) && (element < (zeile + 1) * C_ELEMENT_PER_ROW)) {
while((element < numFolders)) {
int pos = index[element];
if(iconNames[element] != null){
completeRow += generateIcon(cms, templateDocument, parameters, lang, folderTitles[pos],
iconNames[element], folderLangKeys[pos], folderActiv[pos], folderVisible[pos],
accessVisible[pos]);
}
element++;
}
templateDocument.setData("entrys", completeRow);
completeTable += templateDocument.getProcessedDataValue("list_row");
zeile++;
} // of while
templateDocument.setData("iconTable", completeTable);
}
else {
// no Folders, just a real page
try {
cms.getRequestContext().getResponse().sendCmsRedirect(sendBy
+ "index.html?initial=true");
}
catch(Exception e) {
throw new CmsException("Redirect fails :" + ((CmsFile)iconVector2.elementAt(0)).getAbsolutePath(),
CmsException.C_UNKNOWN_EXCEPTION, e);
}
return null;
}
return startProcessing(cms, templateDocument, elementName, parameters, templateSelector);
}
/**
* returns the String or "" if it is null.
* Creation date: (29.10.00 16:05:38)
* @return java.lang.String
* @param param java.lang.String
*/
private String getStringValue(String param) {
if(param == null) {
return "";
}
return param;
}
/**
* Indicates if the results of this class are cacheable.
*
* @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.
* @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
*/
public boolean isCacheable(CmsObject cms, String templateFile, String elementName,
Hashtable parameters, String templateSelector) {
return false;
}
/**
* Sorts a set of arrays containing navigation information depending on
* their navigation positions.
* @param filenames Array of filenames
* @param index Array of associate Strings
* @param positions Array of navpostions
*/
private void sort(String[] filenames, int[] index, String[] positions, int max) {
// Sorting algorithm
// This method uses an bubble sort, so replace this with something more
// efficient
try {
for(int i = max - 1;i > 0;i--) {
for(int j = 0;j < i;j++) {
float a = new Float(positions[j]).floatValue();
float b = new Float(positions[j + 1]).floatValue();
if(a > b) {
String tempfilename = filenames[j];
int tempindex = index[j];
String tempposition = positions[j];
filenames[j] = filenames[j + 1];
index[j] = index[j + 1];
positions[j] = positions[j + 1];
filenames[j + 1] = tempfilename;
index[j + 1] = tempindex;
positions[j + 1] = tempposition;
}
}
}
}
catch(Exception e) {
if(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging()){
A_OpenCms.log(I_CmsLogChannels.C_OPENCMS_DEBUG,
"cmsAdministration.sort : adminpoints unsorted cause I cant get a valid floatvalue \n" + e.toString());
}
}
} // of sort
/**
* Check if this resource should be displayed in the administrationview.
* @param cms The CmsObject
* @param resource The resource to be checked.
* @return True or false.
* @throws CmsException if something goes wrong.
*/
private boolean checkVisible(CmsObject cms, CmsResource resource) throws CmsException {
boolean access = false;
int accessflags = resource.getAccessFlags();
// First check if the user may have access by one of his groups.
boolean groupAccess = false;
Enumeration allGroups = cms.getGroupsOfUser(cms.getRequestContext().currentUser().getName()).elements();
while((!groupAccess) && allGroups.hasMoreElements()) {
CmsGroup nextGroup = (CmsGroup)allGroups.nextElement();
if(nextGroup.getName().equals(C_GROUP_ADMIN)){
return true;
}
groupAccess = cms.readGroup(resource).equals(nextGroup);
}
if(groupAccess && (accessflags & C_ACCESS_GROUP_VISIBLE) == C_ACCESS_GROUP_VISIBLE) {
return true;
}
// is the resource owned by this user?
if(resource.getOwnerId() == cms.getRequestContext().currentUser().getId()) {
if( (accessflags & C_ACCESS_OWNER_VISIBLE) == C_ACCESS_OWNER_VISIBLE ) {
return true ;
}
}
if ((accessflags & C_ACCESS_PUBLIC_VISIBLE) == C_ACCESS_PUBLIC_VISIBLE){
return true;
}
return access;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -