From: <lei...@us...> - 2008-08-27 11:46:44
|
Author: leithoff Date: Wed Aug 27 13:17:00 2008 New Revision: 25946 URL: http://www.egroupware.org/viewvc?rev=3D25946&view=3Drev Log: #add sidebox menue to filemanager, with Links to Home and root. #filemanager supports the configuration of a different startfolder (other t= han users home directory) #preferences for filemanager -define links to folders, that show in sidebox menu -specify the display characteristics in filelisting (default (all sorted), = or forced folders first) #configuration options for filemanager -you may specify how many links to folders can be configured in filemanager= s preferences YOU HAVE TO RUN Search and Register Hooks of all Applications, and you may = have to login/logout. Added: trunk/filemanager/inc/class.filemanager_hooks.inc.php trunk/filemanager/templates/default/config.tpl Modified: trunk/filemanager/inc/class.filemanager_ui.inc.php trunk/filemanager/setup/setup.inc.php Added: trunk/filemanager/inc/class.filemanager_hooks.inc.php URL: http://www.egroupware.org/viewvc/trunk/filemanager/inc/class.filemanag= er_hooks.inc.php?rev=3D25946&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/filemanager/inc/class.filemanager_hooks.inc.php (added) +++ trunk/filemanager/inc/class.filemanager_hooks.inc.php Wed Aug 27 13:17:= 00 2008 @@ -1,0 +1,158 @@ +<?php +/** + * eGroupWare - Hooks for admin, preferences and sidebox-menus + * + * @link http://www.egroupware.org + * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> + * @package filemanager + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU Gener= al Public License + * @version $Id: class.filemanager_hooks.inc.php 25002 2008-03-03 12:16:11= Z ralfbecker $ = + */ + +/** + * Class containing admin, preferences and sidebox-menus (used as hooks) + */ +class filemanager_hooks +{ + static $appname =3D 'filemanager'; + static $foldercount =3D 1; + static function sidebox_menu($args) + { + $location =3D is_array($args) ? $args['location'] : $args; + $basepath =3D '/'; + $rootpath =3D '/home'; + $homepath =3D '/home/'.$GLOBALS['egw_info']['user']['account_lid']; + //echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).")= appname=3D'$appname', location=3D'$location'</p>\n"; + $config =3D config::read(self::$appname); + if (!empty($config['max_folderlinks'])) self::$foldercount =3D (int)$con= fig['max_folderlinks']; + $file_prefs =3D &$GLOBALS['egw_info']['user']['preferences'][self::$a= ppname]; + if ($location =3D=3D 'sidebox_menu') + { + $title =3D $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '.= lang('Menu'); + $file =3D Array( + 'Home' =3D> $GLOBALS['egw']->link('/index.php',array('menuaction'=3D>s= elf::$appname.'.filemanager_ui.index','path'=3D>$homepath)), + 'Root' =3D> $GLOBALS['egw']->link('/index.php',array('menuaction'=3D>s= elf::$appname.'.filemanager_ui.index','path'=3D>$rootpath)), + # not sure if we want to offer a link to the base directory for defaul= t, this way i do that as preference + #'Base' =3D> $GLOBALS['egw']->link('/index.php',array('menuaction'=3D>= self::$appname.'.filemanager_ui.index','path'=3D>$basepath)), + ); + if (!empty($file_prefs['showbase'])) $file['Base']=3D $GLOBALS['egw']->= link('/index.php',array('menuaction'=3D>self::$appname.'.filemanager_ui.ind= ex','path'=3D>$basepath)); + if (!empty($file_prefs['startfolder'])) $file['Startfolder']=3D $GLOBAL= S['egw']->link('/index.php',array('menuaction'=3D>self::$appname.'.filemana= ger_ui.index','path'=3D>$file_prefs['startfolder'])); + for ($i=3D1; $i<=3Dself::$foldercount;$i++) { + if (!empty($file_prefs['folderlink'.$i])) { + $foldername =3D array_pop(explode("/",$file_prefs['folderlink'.$i])); + $file['Link '.$i.($foldername?": ($foldername)":'(Base)')]=3D $GLOBAL= S['egw']->link('/index.php',array( + 'menuaction'=3D>self::$appname.'.filemanager_ui.index', + 'path'=3D>$file_prefs['folderlink'.$i])); + } + } + display_sidebox(self::$appname,$title,$file); + } + self::preferences(self::$appname); + if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$ap= pname); + } + + /** + * Entries for filemanagers's admin menu + */ + static function admin($location =3D 'admin') + { + $file =3D Array( + 'Site Configuration' =3D> $GLOBALS['egw']->link('/index.php','= menuaction=3Dadmin.uiconfig.index&appname=3D'.self::$appname), + ); + if ($location =3D=3D 'admin') { + display_section(self::$appname,$file); + } else { + display_sidebox(self::$appname,lang('Admin'),$file); + } + } + = + static function preferences($location =3D 'preferences') = + { + $file =3D array( + 'Preferences' =3D> $GLOBALS['egw']->link('/index.php','menuaction=3Dpre= ferences.uisettings.index&appname=3D'.self::$appname), + ); + if ($location =3D=3D 'preferences') = + { + display_section(self::$appname,$file); + } else { + display_sidebox(self::$appname,lang('Preferences'),$file); + } + } + + static function settings() + { + $config =3D config::read(self::$appname); + if (!empty($config['max_folderlinks'])) self::$foldercount =3D (int)$con= fig['max_folderlinks']; + + $upload_boxes =3D array( + '1' =3D> '1', + '5' =3D> '5', + '10' =3D> '10', + '20' =3D> '20', + '30' =3D> '30' + ); + $yes_no =3D array( + '0' =3D> 'No', + '1' =3D> 'Yes' + ); + = + $GLOBALS['settings'] =3D array( + 'showbase' =3D> array( + 'type' =3D> 'select', + 'name' =3D> 'showbase', + 'values' =3D> $yes_no, + 'label' =3D> 'Show link to filemanagers basedirectory (/) in side box= menu?', + 'help' =3D> 'Default behavior is NO. The link will not be shown, but = you are still able to navigate to this location, = + or configure this paricular location as startfolder or folderlink.= ', + 'xmlrpc' =3D> True, + 'amin' =3D> False + ), + 'alwayssortfolderstotop' =3D> array( + 'type' =3D> 'select', + 'name' =3D> 'alwayssortfolderstotop', + 'values' =3D> $yes_no, + 'label' =3D> 'Sort folders always to the top?', + 'help' =3D> 'Default behavior is NO. If you set this to YES, folders = will always appear at the top of the list, = + no matter what you sort by. It will slow your mustang down as well= .', + 'xmlrpc' =3D> True, + 'amin' =3D> False + ), + 'startfolder' =3D> array( + 'type' =3D> 'input', + 'name' =3D> 'startfolder', + 'size' =3D> 80, + 'default' =3D> '', + 'label' =3D> 'Enter the complete VFS path to specify your desired sta= rt folder.', + 'help' =3D> 'If you leave this empty, the path does not exist or the = user does not have permission to access the specified folder, + the users startfolder will default to the users home folder.', + 'xmlrpc' =3D> True, + 'amin' =3D> False + ), +# 'show_upload_boxes' =3D> array( +# 'type' =3D> 'select', +# 'label' =3D> 'Default number of upload fields to show', +# 'name' =3D> 'show_upload_boxes', +# 'values' =3D> $upload_boxes, +# 'help' =3D> 'How many upload slots should be available = for uploading files? (The boxes are displayed at the bottom of the file lis= ting)', +# 'xmlrpc' =3D> True, +# 'admin' =3D> False +# ), + ); + for ($i=3D1;$i<=3Dself::$foldercount;$i++) { + $GLOBALS['settings']['folderlink'.$i] =3D array( + 'type' =3D> 'input', + 'name' =3D> 'folderlink'.$i, + 'size' =3D> 80, + 'default' =3D> '', + 'label' =3D> 'Enter the complete VFS path to specify a fast access li= nk to a folder ('.$i.').', + 'help' =3D> 'If you leave this empty, the path does not exist or the = user does not have permission to access the specified folder, + the link will lead the user to the start folder or users home fol= der (if the startfolder is either not configured, or + not available to the user).', + 'xmlrpc' =3D> True, + 'amin' =3D> False + ); + } + + return true; + } +} Modified: trunk/filemanager/inc/class.filemanager_ui.inc.php URL: http://www.egroupware.org/viewvc/trunk/filemanager/inc/class.filemanag= er_ui.inc.php?rev=3D25946&r1=3D25945&r2=3D25946&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/filemanager/inc/class.filemanager_ui.inc.php (original) +++ trunk/filemanager/inc/class.filemanager_ui.inc.php Wed Aug 27 13:17:00 = 2008 @@ -60,6 +60,14 @@ if (isset($_GET['path']) && ($path =3D $_GET['path']) && $path[0] =3D= =3D '/' && egw_vfs::is_dir($path)) { $content['nm']['path'] =3D $path; + } = + else = + { + if (!empty($GLOBALS['egw_info']['user']['preferences']['filemanager'][= 'startfolder']) = + && egw_vfs::is_dir($GLOBALS['egw_info']['user']['preferences']['filem= anager']['startfolder'])) + { + $content['nm']['path'] =3D $GLOBALS['egw_info']['user']['preferences'= ]['filemanager']['startfolder']; + } } if (isset($_GET['msg'])) $msg =3D $_GET['msg']; } @@ -369,45 +377,116 @@ { $namefilter =3D '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),p= reg_quote($query['search'])).'/i'; } - foreach(egw_vfs::find($query['path'],array( - 'mindepth' =3D> 1, - 'maxdepth' =3D> $query['filter'] ? $query['filter'] : null, - 'order' =3D> $query['order'], 'sort' =3D> $query['sort'], - 'limit' =3D> (int)$query['num_rows'].','.(int)$query['start'], - 'need_mime' =3D> true, - 'name_preg' =3D> $namefilter, - ),true) as $path =3D> $row) - { - $row['icon'] =3D egw_vfs::mime_icon($row['mime']); - $row['perms'] =3D egw_vfs::int2mode($row['mode']); - // only show link if we have access to the file or dir - if (egw_vfs::check_access($path,egw_vfs::READABLE)) - { - if ($row['mime'] =3D=3D egw_vfs::DIR_MIME_TYPE) - { - $row['link'] =3D '/index.php?menuaction=3Dfilemanager.filemanager_ui.= index&path=3D'.$path; - } - else - { - $row['link'] =3D egw_vfs::download_url($path); - } - } - $row['user'] =3D $row['uid'] ? $GLOBALS['egw']->accounts->id2name($row[= 'uid']) : 'root'; - $row['group'] =3D $row['gid'] ? $GLOBALS['egw']->accounts->id2name(-$ro= w['gid']) : 'root'; - $row['hsize'] =3D egw_vfs::hsize($row['size']); - - //echo $path; _debug_array($row); - - $rows[++$n] =3D $row; - - $dir =3D dirname($path); - if (!isset($dir_is_writable[$dir])) - { - $dir_is_writable[$dir] =3D egw_vfs::is_writable($dir); - } - if (!$dir_is_writable[$dir]) - { - $readonlys["delete[$path]"] =3D true; // no rights to delete the file + // if you want to have the folders on top, we must search for them first + if ((int)$GLOBALS['egw_info']['user']['preferences']['filemanager']['alw= ayssortfolderstotop']=3D=3D1) { + $dirs =3D array(); + $files =3D array(); + foreach(egw_vfs::find($query['path'],array( + 'type'=3D>'d', + 'mindepth' =3D> 1, + 'maxdepth' =3D> $query['filter'] ? $query['filter'] : null, + 'order' =3D> $query['order'], 'sort' =3D> $query['sort'], + 'limit' =3D> (int)$query['num_rows'].','.(int)$query['start'], + 'need_mime' =3D> true, + 'name_preg' =3D> $namefilter, + ),true) as $path =3D> $row) + { + $row['icon'] =3D egw_vfs::mime_icon($row['mime']); + $row['perms'] =3D egw_vfs::int2mode($row['mode']); + // only show link if we have access to the file or dir + if (egw_vfs::check_access($path,egw_vfs::READABLE)) $row['link'] =3D '= /index.php?menuaction=3Dfilemanager.filemanager_ui.index&path=3D'.$path; + $row['user'] =3D $row['uid'] ? $GLOBALS['egw']->accounts->id2name($row= ['uid']) : 'root'; + $row['group'] =3D $row['gid'] ? $GLOBALS['egw']->accounts->id2name(-$r= ow['gid']) : 'root'; + $row['hsize'] =3D egw_vfs::hsize($row['size']); + + $dirs[] =3D $row; + + $dir =3D dirname($path); + if (!isset($dir_is_writable[$dir])) $dir_is_writable[$dir] =3D egw_vfs= ::is_writable($dir); + if (!$dir_is_writable[$dir]) $readonlys["delete[$path]"] =3D true; // = no rights to delete the file + = + } + $numofdirs =3D egw_vfs::$find_total; + $dirsretrieved =3D count($dirs); + #echo "Dirs found:$numofdirs<br>"."Rows to query:".(int)$query['num_row= s']." Start at:".(int)$query['start']."<br>"; + $filesdontshowjet =3D 0; + if ($dirsretrieved >=3D (int)$query['num_rows']) { + $filesdontshowjet =3D1; + } + // retrieve the files as well, since we need the total number of the se= arch/listing + $numofrows =3D (int)$query['num_rows'] - $dirsretrieved; + $startatrow =3D 0; + if ($filesdontshowjet =3D=3D 0 && (int)$query['start'] > $numofdirs) $s= tartatrow =3D (int)$query['start']-$numofdirs; + #echo "Filessection:Dirs retrieved:$dirsretrieved<br>"."Rows to query:"= .$numofrows." Start at:".$startatrow."<br>"; + foreach(egw_vfs::find($query['path'],array( + 'type'=3D>'f', + 'mindepth' =3D> 1, + 'maxdepth' =3D> $query['filter'] ? $query['filter'] : null, + 'order' =3D> $query['order'], 'sort' =3D> $query['sort'], + 'limit' =3D> $numofrows.','.$startatrow, + 'need_mime' =3D> true, + 'name_preg' =3D> $namefilter, + ),true) as $path =3D> $row) + { + $row['icon'] =3D egw_vfs::mime_icon($row['mime']); + $row['perms'] =3D egw_vfs::int2mode($row['mode']); + // only show link if we have access to the file or dir + if (egw_vfs::check_access($path,egw_vfs::READABLE)) $row['link'] =3D e= gw_vfs::download_url($path); + $row['user'] =3D $row['uid'] ? $GLOBALS['egw']->accounts->id2name($row= ['uid']) : 'root'; + $row['group'] =3D $row['gid'] ? $GLOBALS['egw']->accounts->id2name(-$r= ow['gid']) : 'root'; + $row['hsize'] =3D egw_vfs::hsize($row['size']); + + if ($filesdontshowjet =3D=3D 0) $files[] =3D $row; + + $dir =3D dirname($path); + if (!isset($dir_is_writable[$dir])) $dir_is_writable[$dir] =3D egw_vfs= ::is_writable($dir); + if (!$dir_is_writable[$dir]) $readonlys["delete[$path]"] =3D true; // = no rights to delete the file + } + $numoffiles =3D egw_vfs::$find_total; + $rows =3D array_merge($dirs,$files); + //_debug_array($readonlys); + return egw_vfs::$find_total =3D $numofdirs + $numoffiles; + } else { + foreach(egw_vfs::find($query['path'],array( + 'type'=3D>'d', + 'mindepth' =3D> 1, + 'maxdepth' =3D> $query['filter'] ? $query['filter'] : null, + 'order' =3D> $query['order'], 'sort' =3D> $query['sort'], + 'limit' =3D> (int)$query['num_rows'].','.(int)$query['start'], + 'need_mime' =3D> true, + 'name_preg' =3D> $namefilter, + ),true) as $path =3D> $row) + { + $row['icon'] =3D egw_vfs::mime_icon($row['mime']); + $row['perms'] =3D egw_vfs::int2mode($row['mode']); + // only show link if we have access to the file or dir + if (egw_vfs::check_access($path,egw_vfs::READABLE)) + { + if ($row['mime'] =3D=3D egw_vfs::DIR_MIME_TYPE) + { + $row['link'] =3D '/index.php?menuaction=3Dfilemanager.filemanager_ui= .index&path=3D'.$path; + } + else + { + $row['link'] =3D egw_vfs::download_url($path); + } + } + $row['user'] =3D $row['uid'] ? $GLOBALS['egw']->accounts->id2name($row= ['uid']) : 'root'; + $row['group'] =3D $row['gid'] ? $GLOBALS['egw']->accounts->id2name(-$r= ow['gid']) : 'root'; + $row['hsize'] =3D egw_vfs::hsize($row['size']); + + //echo $path; _debug_array($row); + $rows[++$n] =3D $row; + + $dir =3D dirname($path); + if (!isset($dir_is_writable[$dir])) + { + $dir_is_writable[$dir] =3D egw_vfs::is_writable($dir); + } + if (!$dir_is_writable[$dir]) + { + $readonlys["delete[$path]"] =3D true; // no rights to delete the file + } } } //_debug_array($readonlys); @@ -625,4 +704,4 @@ } return $mode; } -} +} Modified: trunk/filemanager/setup/setup.inc.php URL: http://www.egroupware.org/viewvc/trunk/filemanager/setup/setup.inc.php= ?rev=3D25946&r1=3D25945&r2=3D25946&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/filemanager/setup/setup.inc.php (original) +++ trunk/filemanager/setup/setup.inc.php Wed Aug 27 13:17:00 2008 @@ -15,6 +15,11 @@ $setup_info['filemanager']['enable'] =3D 1; = /* The hooks this app includes, needed for hooks registration */ +$setup_info['filemanager']['hooks']['preferences'] =3D 'filemanager_hooks:= :preferences'; +$setup_info['filemanager']['hooks']['settings'] =3D 'filemanager_hooks::se= ttings'; +$setup_info['filemanager']['hooks']['sidebox_menu'] =3D 'filemanager_hooks= ::sidebox_menu'; +#$setup_info['filemanager']['hooks']['verify_settings'] =3D 'filemanager.f= ilemanager_hooks.verify_settings'; +$setup_info['filemanager']['hooks']['admin'] =3D 'filemanager_hooks::admin= '; = = /* Dependencies for this app to work */ Added: trunk/filemanager/templates/default/config.tpl URL: http://www.egroupware.org/viewvc/trunk/filemanager/templates/default/c= onfig.tpl?rev=3D25946&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/filemanager/templates/default/config.tpl (added) +++ trunk/filemanager/templates/default/config.tpl Wed Aug 27 13:17:00 2008 @@ -1,0 +1,33 @@ +<!-- BEGIN header --> +<form method=3D"POST" action=3D"{action_url}"> +{hidden_vars} +<table border=3D"0" align=3D"center"> + <tr class=3D"th"> + <td colspan=3D"2"><font color=3D"{th_text}"> <b>{title}</b></font= ></td> + </tr> + <tr> + <td colspan=3D"2"> <i><font color=3D"red">{error}</i></font></td> + </tr> +<!-- END header --> +<!-- BEGIN body --> + <tr class=3D"th"> + <td colspan=3D"2"> <b>{lang_filemanager_configuration}</b></td> + </tr> + <tr class=3D"row_on"> + <td> {lang_max_folderlinks}:</td> + <td><input name=3D"newsettings[max_folderlinks]" value=3D"{value_max_f= olderlinks}" size=3D"2"></td> + </tr> + <tr class=3D"row_off"> + <td colspan=3D"2"> {lang_allow_a_maximum_of_the_above_configured_fol= derlinks_to_be_configured_in_settings}</td> + </tr> +<!-- END body --> +<!-- BEGIN footer --> + <tr valign=3D"bottom" style=3D"height: 30px;"> + <td colspan=3D"2" align=3D"center"> + <input type=3D"submit" name=3D"submit" value=3D"{lang_submit}"> + <input type=3D"submit" name=3D"cancel" value=3D"{lang_cancel}"> + </td> + </tr> +</table> +</form> +<!-- END footer --> |