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.
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 ?
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';
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.
You must be logged in to post messages in this topic!