Author: xlawrence
Date: Thu Aug 3 11:27:57 2006
New Revision: 14836
URL: https://svndev.jahia.net/websvn/listing.php?sc=1&rev=14836&repname=jahia
Log:
add posibility to put filters in definitions in order to customize the
filemanager view in the engine. For example, if we have a filefield in a
template for an image, we may want to allow only images files to be displayed
in the engine. We can now do that by specifying a value in the definition. This
value could be something like "*.gif,*.jpg"
Modified:
trunk/core/src/java/org/jahia/ajax/webdav/DAVAbstractAction.java
trunk/core/src/java/org/jahia/data/files/JahiaFile.java
trunk/core/src/java/org/jahia/data/files/JahiaFileField.java
trunk/core/src/webapp/WEB-INF/var/shared_templates/corporate_portal_templates_v2.jar
trunk/core/src/webapp/jsp/jahia/engines/shared/embedded_filemanager.jsp
trunk/core/src/webapp/jsp/jahia/javascript/zimbra/complexTree/ComplexTree.js
Modified: trunk/core/src/java/org/jahia/ajax/webdav/DAVAbstractAction.java
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/ajax/webdav/DAVAbstractAction.java&rev=14836&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/ajax/webdav/DAVAbstractAction.java (original)
+++ trunk/core/src/java/org/jahia/ajax/webdav/DAVAbstractAction.java Thu Aug 3
11:27:57 2006
@@ -31,6 +31,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.StringTokenizer;
/**
* Abstract Class that simply holds common methods regarding WEBDAV.
@@ -47,8 +48,9 @@
private static final double MEGA_BYTE = 1024 * 1024;
protected static final String DISPLAY_PARAM = "display";
- public static final String IMAGES_ONLY = "images_Only";
public static final String DIRECTORIES_ONLY = "directories_Only";
+ public static final String IMAGES_ONLY = "images_Only";
+
// For the listView
public static final String LIST_VIEW = "listView";
public static final String ICONS_VIEW = "iconsView";
@@ -120,14 +122,37 @@
final int index = path.lastIndexOf('.');
final String extension;
if (index >= 0) {
- extension = path.substring(index + 1);
+ extension = path.substring(index + 1).toLowerCase();
logger.debug("extension: " + extension);
} else {
extension = "";
}
- if (display.indexOf(IMAGES_ONLY) > -1) {
- logger.debug("Should only display images");
- if (! imagesExtensions.contains(extension.toLowerCase())) return;
+ if (display != null && display.length() > 0 && display.indexOf(".") >
-1) {
+ if (display.indexOf(IMAGES_ONLY) > -1) {
+ logger.debug("Should only display images");
+ if (! imagesExtensions.contains(extension)) return;
+ } else {
+ final StringTokenizer tokenizer = new StringTokenizer(display,
",");
+ boolean found = false;
+ while (tokenizer.hasMoreTokens()) {
+ final String token = tokenizer.nextToken();
+ if (token.indexOf("*") >= 0) {
+ final String tmp = token.substring(token.indexOf("*")
+ 1);
+ // token contains an expression. ie '*.gif'
+ if (tmp.indexOf(extension) > -1) {
+ found = true;
+ break;
+ }
+ } else {
+ // token contains a full filename. ie 'logo.gif'
+ if (file.getPath().indexOf(token) > -1) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (! found) return;
+ }
}
item.setAttribute("title", file.getName());
item.setAttribute("dir", extension);
Modified: trunk/core/src/java/org/jahia/data/files/JahiaFile.java
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/data/files/JahiaFile.java&rev=14836&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/data/files/JahiaFile.java (original)
+++ trunk/core/src/java/org/jahia/data/files/JahiaFile.java Thu Aug 3 11:27:57
2006
@@ -29,6 +29,7 @@
import org.jahia.registries.ServicesRegistry;
import org.jahia.services.usermanager.JahiaUser;
+
import java.io.Serializable;
@@ -44,274 +45,298 @@
public static final int STATE_ACTIVE = 1;
public static final int STATE_BACKUP = 0;
- /** the file identifier **/
- private int m_FileID = -1;
- /** the filemanager identifier **/
- private int m_FilemanagerID = -1;
- /** the folder identifier **/
- private int m_FolderID = -1;
- /** the upload user identifer **/
- private String m_UploadUser = "";
- /** the page id **/
- private int m_PageID = -1;
- /** is public or not **/
- private int m_IsPublic = 1;
- /** the real name of the file **/
- private String m_RealName = "";
- /** the storage name on disk **/
- private String m_StorageName = "";
- /** the last modification date **/
- private long m_LastModifDate;
- /** the size in bytes **/
- private long m_Size = 0;
- /** the content-type **/
- private String m_Type ="";
- /** the general title (short desc) **/
- private String m_Title = "";
- /** the general desc of the file **/
- private String m_Descr ="";
- /** the download Url **/
- private String m_DownloadUrl ="#";
- /** the version id **/
+ /**
+ * the file identifier *
+ */
+ private int m_FileID = -1;
+ /**
+ * the filemanager identifier *
+ */
+ private int m_FilemanagerID = -1;
+ /**
+ * the folder identifier *
+ */
+ private int m_FolderID = -1;
+ /**
+ * the upload user identifer *
+ */
+ private String m_UploadUser = "";
+ /**
+ * the page id *
+ */
+ private int m_PageID = -1;
+ /**
+ * is public or not *
+ */
+ private int m_IsPublic = 1;
+ /**
+ * the real name of the file *
+ */
+ private String m_RealName = "";
+ /**
+ * the storage name on disk *
+ */
+ private String m_StorageName = "";
+ /**
+ * the last modification date *
+ */
+ private long m_LastModifDate;
+ /**
+ * the size in bytes *
+ */
+ private long m_Size = 0;
+ /**
+ * the content-type *
+ */
+ private String m_Type = "";
+ /**
+ * the general title (short desc) *
+ */
+ private String m_Title = "";
+ /**
+ * the general desc of the file *
+ */
+ private String m_Descr = "";
+ /**
+ * the download Url *
+ */
+ private String m_DownloadUrl = "#";
+ /**
+ * the version id *
+ */
private String m_Version = "0";
- /** the state **/
+ /**
+ * the state *
+ */
private int m_State = STATE_ACTIVE;
- /**
+ /**
* Constructor
- *
*/
- protected JahiaFile(){
- }
+ protected JahiaFile() {
+ }
- /**
- * Constructor
- *
- * @param filemanagerID
- * @param folderID
- * @param uploadUser
- * @param realName
- * @param storageName
- * @param lastModifDate
- * @param size
- * @param type
- * @param title
- * @param descr
- * @param versionID
- * @param state
- */
- public JahiaFile( int filemanagerID,
- int folderID,
- String uploadUser,
- String realName,
- String storageName,
- long lastModifDate,
- long size,
- String type,
- String title,
- String descr,
- String version,
- int state )
- {
- m_FilemanagerID = filemanagerID;
- m_FolderID = folderID;
- m_UploadUser = uploadUser;
- m_RealName = realName;
- m_StorageName = storageName;
- m_LastModifDate = lastModifDate;
- m_Size = size;
- m_Type = type;
- m_Title = title;
- m_Descr = descr;
+ /**
+ * Constructor
+ *
+ * @param filemanagerID
+ * @param folderID
+ * @param uploadUser
+ * @param realName
+ * @param storageName
+ * @param lastModifDate
+ * @param size
+ * @param type
+ * @param title
+ * @param descr
+ * @param version
+ * @param state
+ */
+ public JahiaFile(int filemanagerID,
+ int folderID,
+ String uploadUser,
+ String realName,
+ String storageName,
+ long lastModifDate,
+ long size,
+ String type,
+ String title,
+ String descr,
+ String version,
+ int state) {
+ m_FilemanagerID = filemanagerID;
+ m_FolderID = folderID;
+ m_UploadUser = uploadUser;
+ m_RealName = realName;
+ m_StorageName = storageName;
+ m_LastModifDate = lastModifDate;
+ m_Size = size;
+ m_Type = type;
+ m_Title = title;
+ m_Descr = descr;
m_Version = version;
m_State = state;
- }
+ }
- public int getFileID(){
- return m_FileID;
- }
+ public int getFileID() {
+ return m_FileID;
+ }
- public void setFileID(int id){
- m_FileID = id;
- }
+ public void setFileID(int id) {
+ m_FileID = id;
+ }
- public int getFilemanagerID(){
- return m_FilemanagerID;
- }
+ public int getFilemanagerID() {
+ return m_FilemanagerID;
+ }
- public void setFilemanagerID(int id){
- m_FilemanagerID = id;
- }
+ public void setFilemanagerID(int id) {
+ m_FilemanagerID = id;
+ }
- public int getFolderID(){
- return m_FolderID;
- }
+ public int getFolderID() {
+ return m_FolderID;
+ }
- public void setFolderID(int id){
- m_FolderID = id;
- }
+ public void setFolderID(int id) {
+ m_FolderID = id;
+ }
- public String getUploadUser(){
- return m_UploadUser;
- }
+ public String getUploadUser() {
+ return m_UploadUser;
+ }
- public void setUploadUser(String name){
- m_UploadUser = name;
- }
+ public void setUploadUser(String name) {
+ m_UploadUser = name;
+ }
- public int getPageID(){
- return m_PageID;
- }
+ public int getPageID() {
+ return m_PageID;
+ }
- public void setPageID(int id){
- m_PageID = id;
- }
+ public void setPageID(int id) {
+ m_PageID = id;
+ }
- public int getPublic(){
- return m_IsPublic;
- }
+ public int getPublic() {
+ return m_IsPublic;
+ }
- public void setPublic(int val){
- m_IsPublic = val;
- }
+ public void setPublic(int val) {
+ m_IsPublic = val;
+ }
- public String getRealName(){
- return m_RealName;
- }
+ public String getRealName() {
+ return m_RealName;
+ }
- public void setRealName(String realName){
- m_RealName = realName;
- }
+ public void setRealName(String realName) {
+ m_RealName = realName;
+ }
- public String getStorageName(){
- return m_StorageName;
- }
+ public String getStorageName() {
+ return m_StorageName;
+ }
- public void setStorageName(String storageName){
- m_StorageName = storageName;
- }
+ public void setStorageName(String storageName) {
+ m_StorageName = storageName;
+ }
- public long getLastModifDate(){
- return m_LastModifDate;
- }
+ public long getLastModifDate() {
+ return m_LastModifDate;
+ }
- public void setLastModifDate(long lastModifDate){
- m_LastModifDate = lastModifDate;
- }
+ public void setLastModifDate(long lastModifDate) {
+ m_LastModifDate = lastModifDate;
+ }
- public long getSize(){
- return m_Size;
- }
+ public long getSize() {
+ return m_Size;
+ }
- public void setSize(long size){
- m_Size = size;
- }
+ public void setSize(long size) {
+ m_Size = size;
+ }
- public String getType(){
- return m_Type;
- }
+ public String getType() {
+ return m_Type;
+ }
- public void setType(String type){
- m_Type = type;
- }
+ public void setType(String type) {
+ m_Type = type;
+ }
- public String getTitle(){
- return m_Title;
- }
+ public String getTitle() {
+ return m_Title;
+ }
- public void setTitle(String title){
- m_Title = title;
- }
+ public void setTitle(String title) {
+ m_Title = title;
+ }
- public String getDescr(){
- return m_Descr;
- }
+ public String getDescr() {
+ return m_Descr;
+ }
- public void setDescr(String descr){
- m_Descr = descr;
- }
+ public void setDescr(String descr) {
+ m_Descr = descr;
+ }
- public String getVersion(){
+ public String getVersion() {
return this.m_Version;
}
- public void setVersion(String version){
+ public void setVersion(String version) {
this.m_Version = version;
}
- public int getState(){
+ public int getState() {
return this.m_State;
}
- public void setState(int state){
+ public void setState(int state) {
this.m_State = state;
}
- public String getDownloadUrl(){
- return m_DownloadUrl;
- }
-
- public void setDownloadUrl(String dUrl){
- m_DownloadUrl = dUrl;
- }
-
-
- // Output Representation purpose
-
- public String getFormatedLastModifDate(){
+ public String getDownloadUrl() {
+ return m_DownloadUrl;
+ }
- String fmtDate = "";
- Date tmpDate = new Date();
- tmpDate.setTime(m_LastModifDate);
+ public void setDownloadUrl(String dUrl) {
+ m_DownloadUrl = dUrl;
+ }
- DateFormat dateFmt = DateFormat.getDateInstance();
+ // Output Representation purpose
- fmtDate = DateFormat.getDateInstance().format(tmpDate);
+ public String getFormatedLastModifDate() {
+ Date tmpDate = new Date();
+ tmpDate.setTime(m_LastModifDate);
- return fmtDate;
- }
+ return DateFormat.getDateInstance().format(tmpDate);
+ }
- public String getFormatedSize(){
+ public String getFormatedSize() {
- return String.valueOf(m_Size >> 10) + " Kb";
- }
+ return String.valueOf(m_Size >> 10) + " Kb";
+ }
- public boolean isImage(){
+ public boolean isImage() {
- return m_Type.startsWith("image");
+ return m_Type.startsWith("image");
- }
+ }
- public boolean isDownloadable(){
- if ( m_StorageName == null ){
- return false;
- } else {
- return (m_StorageName.trim().length()>0);
- }
- }
+ public boolean isDownloadable() {
+ if (m_StorageName == null) {
+ return false;
+ } else {
+ return (m_StorageName.trim().length() > 0);
+ }
+ }
- public String getUploadUsername(){
- if ( m_UploadUser != null && m_UploadUser.length()>0 ){
- JahiaUser user = ServicesRegistry.getInstance()
-
.getJahiaUserManagerService()
-
.lookupUser(m_UploadUser);
- if ( user != null ){
- return user.getUsername();
- }
- }
- return "";
- }
+ public String getUploadUsername() {
+ if (m_UploadUser != null && m_UploadUser.length() > 0) {
+ JahiaUser user = ServicesRegistry.getInstance()
+ .getJahiaUserManagerService()
+ .lookupUser(m_UploadUser);
+ if (user != null) {
+ return user.getUsername();
+ }
+ }
+ return "";
+ }
- public Object clone(){
+ public Object clone() throws CloneNotSupportedException {
+ super.clone();
JahiaFile file =
- new JahiaFile(this.getFilemanagerID(),
- this.getFolderID(),this.getUploadUser(),this.getRealName(),
- this.getStorageName(),this.getLastModifDate(),this.getSize(),
-
this.getType(),this.getTitle(),this.getDescr(),this.getVersion(),this.getState());
+ new JahiaFile(this.getFilemanagerID(),
+ this.getFolderID(), this.getUploadUser(),
this.getRealName(),
+ this.getStorageName(), this.getLastModifDate(),
this.getSize(),
+ this.getType(), this.getTitle(), this.getDescr(),
this.getVersion(), this.getState());
file.setFileID(this.getFileID());
return file;
}
@@ -323,9 +348,7 @@
final JahiaFile jahiaFile = (JahiaFile) o;
if (!m_RealName.equals(jahiaFile.m_RealName)) return false;
- if (!m_StorageName.equals(jahiaFile.m_StorageName)) return false;
-
- return true;
+ return m_StorageName.equals(jahiaFile.m_StorageName);
}
public int hashCode() {
Modified: trunk/core/src/java/org/jahia/data/files/JahiaFileField.java
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/data/files/JahiaFileField.java&rev=14836&repname=jahia
==============================================================================
--- trunk/core/src/java/org/jahia/data/files/JahiaFileField.java (original)
+++ trunk/core/src/java/org/jahia/data/files/JahiaFileField.java Thu Aug 3
11:27:57 2006
@@ -156,5 +156,5 @@
Properties props = (Properties)this.properties.clone();
return new JahiaFileField(file,props);
- }
+ }
}
\ No newline at end of file
Modified:
trunk/core/src/webapp/WEB-INF/var/shared_templates/corporate_portal_templates_v2.jar
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/WEB-INF/var/shared_templates/corporate_portal_templates_v2.jar&rev=14836&repname=jahia
==============================================================================
Binary files - no diff available.
Modified:
trunk/core/src/webapp/jsp/jahia/engines/shared/embedded_filemanager.jsp
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/shared/embedded_filemanager.jsp&rev=14836&repname=jahia
==============================================================================
--- trunk/core/src/webapp/jsp/jahia/engines/shared/embedded_filemanager.jsp
(original)
+++ trunk/core/src/webapp/jsp/jahia/engines/shared/embedded_filemanager.jsp Thu
Aug 3 11:27:57 2006
@@ -16,9 +16,12 @@
limitations under the License.
--%><%@ page import="org.jahia.ajax.webdav.DAVAbstractAction,
org.jahia.data.containers.JahiaContainer,
- org.jahia.engines.JahiaEngine,
- org.jahia.engines.filemanager.TableEntry,
- org.jahia.params.ParamBean" %>
+ org.jahia.data.fields.FieldsEditHelper,
+ org.jahia.data.fields.FieldsEditHelperAbstract,
+ org.jahia.data.fields.JahiaField" %>
+<%@ page import="org.jahia.engines.JahiaEngine"%>
+<%@ page import="org.jahia.engines.filemanager.TableEntry"%>
+<%@ page import="org.jahia.params.ParamBean"%>
<%@ page import="org.jahia.resourcebundle.JahiaResourceBundle"%>
<%@ page import="org.jahia.taglibs.ajax.ComplexTreeInclude"%>
<%@ page import="java.util.HashMap"%>
@@ -40,6 +43,12 @@
final boolean empty = !(filename != null && filename.length() > 0);
final JahiaContainer theEditedContainer = (JahiaContainer)
engineMap.get("theContainer");
request.getSession().setAttribute("TreeFileManager", "true");
+ final String fieldsEditCallingEngineName = (String)
engineMap.get("fieldsEditCallingEngineName");
+ final FieldsEditHelper feh = (FieldsEditHelper)
engineMap.get(fieldsEditCallingEngineName + "." +
+ FieldsEditHelperAbstract.FIELDS_EDIT_HELPER_CONTEXTID);
+
+ final JahiaField theField = feh.getSelectedField();
+ final String fieldValue = theField.getValue();
%>
<script type="text/javascript">
@@ -591,6 +600,11 @@
} else if (view.equals("2")) {
display += DAVAbstractAction.THUMBNAIL_VIEW;
}
+
+ // Extra filters
+ if (fieldValue != null && fieldValue.length() > 0) {
+ display += fieldValue;
+ }
%>
<ajax:complexTreeInclude divID="tree1"
Modified:
trunk/core/src/webapp/jsp/jahia/javascript/zimbra/complexTree/ComplexTree.js
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/javascript/zimbra/complexTree/ComplexTree.js&rev=14836&repname=jahia
==============================================================================
---
trunk/core/src/webapp/jsp/jahia/javascript/zimbra/complexTree/ComplexTree.js
(original)
+++
trunk/core/src/webapp/jsp/jahia/javascript/zimbra/complexTree/ComplexTree.js
Thu Aug 3 11:27:57 2006
@@ -474,7 +474,7 @@
xmlDoc.set("key", source._key);
if (this._props.CURRENT_STYLE ==
ComplexTreeProperties.FILEMANAGER_STYLE)
- jahiaCommand.invoke(xmlDoc, this._props.EXPAND_SERVER_URL
+ "&display=directories");
+ jahiaCommand.invoke(xmlDoc, this._props.EXPAND_SERVER_URL
+ "&display=directories_Only");
else
jahiaCommand.invoke(xmlDoc, this._props.EXPAND_SERVER_URL);
delete jahiaCommand;
@@ -540,7 +540,7 @@
var xmlDoc = AjxXmlDoc.createRoot("GetDirContent");
xmlDoc.set("key", item._key);
- var reg = new RegExp("(&display=directories)", "g");
+ var reg = new RegExp("(&display=directories_Only)", "g");
jahiaCommand.invoke(xmlDoc, this._props.EXPAND_SERVER_URL.replace(reg,
"&display="));
delete reg;
updateMenuBarAfterSelect(item._key);
@@ -583,7 +583,7 @@
var xmlDoc = AjxXmlDoc.createRoot("GetDirContent");
xmlDoc.set("key", item._key);
- var reg = new RegExp("(&display=directories)", "g");
+ var reg = new RegExp("(&display=directories_Only)", "g");
jahiaCommand.invoke(xmlDoc, this._props.EXPAND_SERVER_URL.replace(reg,
"&display="));
updateMenuBarAfterSelect(item._key);
delete jahiaCommand;