Webdav: how to define a class should be seen as a folder ?

Author Message

Xavier Dutoit

Sunday 13 March 2005 6:49:14 am

Hello,

Where is the setup to be able to "see" a class as a folder ?
I couldn't find any information on that and I have strange behavior (?related):

a new class "report" is seen as an image (with a .jpg added at the end) and if a folder contains an object of the class article, my web browser (IE6) displays an error message.

Any idea where is the setting ?

Thanks in advance,

Xavier

http://www.sydesy.com

Bård Farstad

Monday 14 March 2005 5:15:40 am

Xavier,

the current WebDAV implementation does this automatically. If there is an image attribute then this is used and the object is represented as such.

Don't think there is much that needs to be changed for this. Just a webdav.ini setting and disable the automatic checking for this. This would be a great issue to get solved during the hackfest.

--bård

Documentation: http://ez.no/doc

Xavier Dutoit

Monday 14 March 2005 5:48:34 am

Bård,

Tricky feature indeed, well spoted ;)

IMHO, it would make more sense to check first if the class is a container, then if it has an image attribute.

The logic:
1) if you can contain children object, then display it as folder,
2) if it has an image attribute, then display it as image (with the extension)
3) else use the standard icon.

I'm not sure I can make it on friday, could you give me a hint of where to find the code that manage the folder+image trick so I can try to modify it and send you the patch ?

Xavier

http://www.sydesy.com

Bård Farstad

Monday 14 March 2005 6:29:49 am

Xavier, I agree. That would be a better implementation.

Do you have time to look at the sources and make a small patch, then we can get this into 3.6?

--bård

Documentation: http://ez.no/doc

Norman Leutner

Wednesday 23 March 2005 2:07:25 am

Would be nice, if you could send me that patch too.
I´m currently having the same problem with my topics, which contain a image attribute.

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Xavier Dutoit

Tuesday 29 March 2005 3:04:38 am

Ok, have a look at the new param in webdav.ini (diff output) :

+# List of classes that should be seen as a folder.
+# by default, if a class contains an image attribute it is seen as an image
+# if a container class doesn't contains an image attribute it is also seen as an image
+FolderClasses[]=folder
+FolderClasses[]=article
+#FolderClasses[]=your_custom_class

and modify kernel/classes/webdav/ezwebdavcontentserver.php

     /*!
+      Check if the object has to be seen as a folder
+    */
+    function objectAsFolder ( &$object, &$class )
+    {
+        $webdavINI =& eZINI::instance( WEBDAV_INI_FILE );
+        $classIdentifier = $class->attribute( 'identifier' );
+        if ( $webdavINI->hasGroup( 'GeneralSettings' ) &&  $webdavINI->hasVariable( 'GeneralSettings', 'FolderClasses' ) )
+        {
+            $folderClasses = $webdavINI->variable( 'GeneralSettings', 'FolderClasses' );
+            foreach ( $folderClasses as $folderClass)
+            {
+                if ($folderClass == $classIdentifier)
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /*!
       Gathers information about a given node (specified as parameter).
     */
     function fetchNodeInfo( &$node )
@@ -1429,7 +1451,9 @@
         include_once( 'kernel/classes/ezcontentupload.php' );
         $upload = new eZContentUpload();
         $info = $upload->objectFileInfo( $object );
-        if ( $info )
+        $class =& $object->contentClass();
+        
+        if (!$this->objectAsFolder ( $object,$class ) && $info )
         {
             $filePath = $info['filepath'];
             $entry["mimetype"] = false;
@@ -1470,7 +1494,6 @@
         {
             // Here we only show items as folders if they have
             // is_container set to true, otherwise it's an unknown binary file
-            $class =& $object->contentClass();
             if ( !$class->attribute( 'is_container' ) )
             {
                 $entry['mimetype'] = 'application/octet-stream';

http://www.sydesy.com

Oree Eyo

Monday 18 July 2005 3:49:39 am

Is it the only way to make ezwebdav to show a class as a folder????
Sounds strange.
In the content folder I see nothing. but when I upload the file is getting into the system. as a File object.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.