2008-08-27 13:17:00 +02:00
< ? 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 General Public License
2012-05-11 10:35:32 +02:00
* @ version $Id $
2008-08-27 13:17:00 +02:00
*/
/**
* Class containing admin , preferences and sidebox - menus ( used as hooks )
*/
class filemanager_hooks
{
static $appname = 'filemanager' ;
static $foldercount = 1 ;
2008-10-05 19:07:36 +02:00
2008-09-04 08:44:48 +02:00
/**
* Data for Filemanagers sidebox menu
*
* @ param array $args
*/
2008-08-27 13:17:00 +02:00
static function sidebox_menu ( $args )
{
2013-12-02 21:13:17 +01:00
// Magic etemplate2 favorites menu (from nextmatch widget)
2014-02-12 22:51:25 +01:00
display_sidebox ( self :: $appname , lang ( 'Favorites' ), egw_framework :: favorite_list ( self :: $appname ));
2008-08-27 13:17:00 +02:00
$location = is_array ( $args ) ? $args [ 'location' ] : $args ;
2008-09-04 08:44:48 +02:00
$rootpath = '/' ;
$basepath = '/home' ;
2008-08-27 13:17:00 +02:00
$homepath = '/home/' . $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_lid' ];
//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
$config = config :: read ( self :: $appname );
if ( ! empty ( $config [ 'max_folderlinks' ])) self :: $foldercount = ( int ) $config [ 'max_folderlinks' ];
$file_prefs = & $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ self :: $appname ];
if ( $location == 'sidebox_menu' )
{
$title = $GLOBALS [ 'egw_info' ][ 'apps' ][ self :: $appname ][ 'title' ] . ' ' . lang ( 'Menu' );
2010-10-15 21:42:38 +02:00
$file = array ();
2014-02-12 22:46:27 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'apps' ][ 'stylite' ])
{
// add "file a file" (upload) dialog
$file [] = array (
'text' => 'File a file' ,
'link' => " javascript:egw_openWindowCentered2(' " . egw :: link ( '/index.php' , array (
'menuaction' => 'stylite.stylite_filemanager.upload' ,
), false ) . " ','_blank',550,350) " ,
'app' => 'phpgwapi' ,
'icon' => 'upload' ,
);
}
2010-10-15 21:42:38 +02:00
// add selection for available views, if we have more then one
if ( count ( filemanager_ui :: init_views ()) > 1 )
{
$index_url = egw :: link ( '/index.php' , array ( 'menuaction' => 'filemanager.filemanager_ui.index' ), false );
$file [] = array (
'text' => html :: select ( 'filemanager_view' , filemanager_ui :: get_view (), filemanager_ui :: $views , false ,
' onchange="' . " egw_appWindow('filemanager').location=' $index_url &view='+this.value; " .
'" style="width: 100%;"' ),
'no_lang' => True ,
'link' => False
);
}
2010-11-30 15:29:06 +01:00
if ( $file_prefs [ 'showhome' ] != 'no' )
{
2014-01-17 15:05:24 +01:00
$file [ 'Your home directory' ] = egw :: link ( '/index.php' , array ( 'menuaction' => self :: $appname . '.filemanager_ui.index' , 'path' => $homepath , 'ajax' => 'true' ));
2010-11-30 15:29:06 +01:00
}
if ( $file_prefs [ 'showusers' ] != 'no' )
{
2014-01-17 15:05:24 +01:00
$file [ 'Users and groups' ] = egw :: link ( '/index.php' , array ( 'menuaction' => self :: $appname . '.filemanager_ui.index' , 'path' => $basepath , 'ajax' => 'true' ));
2010-11-30 15:29:06 +01:00
}
2008-09-04 08:44:48 +02:00
if ( ! empty ( $file_prefs [ 'showbase' ]) && $file_prefs [ 'showbase' ] == 'yes' )
{
2014-01-17 15:05:24 +01:00
$file [ 'Basedirectory' ] = egw :: link ( '/index.php' , array ( 'menuaction' => self :: $appname . '.filemanager_ui.index' , 'path' => $rootpath , 'ajax' => 'true' ));
2008-09-04 08:44:48 +02:00
}
2014-01-17 15:05:24 +01:00
if ( ! empty ( $file_prefs [ 'startfolder' ])) $file [ 'Startfolder' ] = egw :: link ( '/index.php' , array ( 'menuaction' => self :: $appname . '.filemanager_ui.index' , 'path' => $file_prefs [ 'startfolder' ], 'ajax' => 'true' ));
2008-10-05 19:07:36 +02:00
for ( $i = 1 ; $i <= self :: $foldercount ; $i ++ )
2008-09-04 08:44:48 +02:00
{
2008-10-05 19:07:36 +02:00
if ( ! empty ( $file_prefs [ 'folderlink' . $i ]))
2008-09-04 08:44:48 +02:00
{
$foldername = array_pop ( explode ( '/' , $file_prefs [ 'folderlink' . $i ]));
2010-10-15 21:42:38 +02:00
$file [ lang ( 'Link %1: %2' , $i , $foldername )] = egw :: link ( '/index.php' , array (
2008-09-04 08:44:48 +02:00
'menuaction' => self :: $appname . '.filemanager_ui.index' ,
'path' => $file_prefs [ 'folderlink' . $i ],
'nolang' => true ,
2014-01-17 15:05:24 +01:00
'ajax' => 'true'
2008-09-04 08:44:48 +02:00
));
2008-08-27 13:17:00 +02:00
}
}
2014-04-14 19:08:43 +02:00
$file [ 'Placeholders' ] = egw :: link ( '/index.php' , 'menuaction=filemanager.filemanager_merge.show_replacements' );
2014-12-08 17:04:20 +01:00
$file [ 'Shared files' ] = egw :: link ( '/index.php' , 'menuaction=filemanager.filemanager_shares.index&ajax=true' );
2008-08-27 13:17:00 +02:00
display_sidebox ( self :: $appname , $title , $file );
}
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'admin' ]) self :: admin ( self :: $appname );
}
/**
* Entries for filemanagers ' s admin menu
2009-05-29 12:48:19 +02:00
*
* @ param string | array $location = 'admin' hook name or params
2008-08-27 13:17:00 +02:00
*/
static function admin ( $location = 'admin' )
{
2010-05-15 22:42:46 +02:00
if ( is_array ( $location )) $location = $location [ 'location' ];
2014-06-12 17:39:17 +02:00
$file = Array (
'Site Configuration' => egw :: link ( '/index.php' , 'menuaction=admin.uiconfig.index&appname=' . self :: $appname ),
2014-10-22 21:55:27 +02:00
'Custom fields' => egw :: link ( '/index.php' , 'menuaction=admin.customfields.index&appname=' . self :: $appname . '&ajax=true' ),
2014-06-13 11:22:45 +02:00
'Check virtual filesystem' => egw :: link ( '/index.php' , 'menuaction=filemanager.filemanager_admin.fsck' ),
2014-06-12 17:11:11 +02:00
'VFS mounts and versioning' => egw :: link ( '/index.php' , 'menuaction=filemanager.filemanager_admin.index' ),
2014-06-12 17:39:17 +02:00
);
2008-10-06 19:43:42 +02:00
if ( $location == 'admin' )
{
2008-08-27 13:17:00 +02:00
display_section ( self :: $appname , $file );
2008-10-06 19:43:42 +02:00
}
else
{
2008-08-27 13:17:00 +02:00
display_sidebox ( self :: $appname , lang ( 'Admin' ), $file );
}
}
2008-10-05 19:07:36 +02:00
2009-05-29 12:48:19 +02:00
/**
* Settings for preferences
*
* @ return array with settings
*/
2008-08-27 13:17:00 +02:00
static function settings ()
{
$config = config :: read ( self :: $appname );
if ( ! empty ( $config [ 'max_folderlinks' ])) self :: $foldercount = ( int ) $config [ 'max_folderlinks' ];
$yes_no = array (
2009-10-19 19:04:11 +02:00
'no' => lang ( 'No' ),
2008-08-28 13:09:09 +02:00
'yes' => lang ( 'Yes' )
2008-08-27 13:17:00 +02:00
);
2008-10-05 19:07:36 +02:00
2009-05-29 12:48:19 +02:00
$settings = array (
2008-08-27 13:17:00 +02:00
'startfolder' => array (
'type' => 'input' ,
'name' => 'startfolder' ,
2008-10-06 19:43:42 +02:00
'size' => 60 ,
2010-05-21 09:22:10 +02:00
'label' => 'Enter the complete VFS path to specify your desired start folder.' ,
'help' => 'The default start folder is your personal Folder. The default is used, if you leave this empty, the path does not exist or you lack the neccessary access permissions.' ,
2008-08-27 13:17:00 +02:00
'xmlrpc' => True ,
2009-10-19 19:04:11 +02:00
'admin' => False ,
2008-08-27 13:17:00 +02:00
),
);
2008-10-06 19:43:42 +02:00
for ( $i = 1 ; $i <= self :: $foldercount ; $i ++ )
{
2009-05-29 12:48:19 +02:00
$settings [ 'folderlink' . $i ] = array (
2008-08-27 13:17:00 +02:00
'type' => 'input' ,
'name' => 'folderlink' . $i ,
2008-10-06 19:43:42 +02:00
'size' => 60 ,
2008-08-27 13:17:00 +02:00
'default' => '' ,
2008-08-28 13:09:09 +02:00
'label' => lang ( 'Enter the complete VFS path to specify a fast access link to a folder' ) . ' (' . $i . ').' ,
2010-05-21 09:22:10 +02:00
'run_lang' => - 1 , // -1 = no lang on label
2008-08-27 13:17:00 +02:00
'xmlrpc' => True ,
2009-10-19 19:04:11 +02:00
'admin' => False
2008-08-27 13:17:00 +02:00
);
}
2010-11-30 15:29:06 +01:00
$settings += array (
'showbase' => array (
'type' => 'select' ,
'name' => 'showbase' ,
'values' => $yes_no ,
'label' => 'Show link to filemanagers basedirectory (/) in side box menu?' ,
'help' => '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' => True ,
'admin' => False ,
'default' => 'no' ,
),
'showhome' => array (
'type' => 'select' ,
'name' => 'showhome' ,
'values' => $yes_no ,
'label' => lang ( 'Show link "%1" in side box menu?' , lang ( 'Your home directory' )),
'xmlrpc' => True ,
'admin' => False ,
'forced' => 'yes' ,
),
'showusers' => array (
'type' => 'select' ,
'name' => 'showusers' ,
'values' => $yes_no ,
'label' => lang ( 'Show link "%1" in side box menu?' , lang ( 'Users and groups' )),
'xmlrpc' => True ,
'admin' => False ,
'forced' => 'yes' ,
),
);
2012-05-11 10:35:32 +02:00
$settings [ 'default_document' ] = array (
2012-05-22 15:51:30 +02:00
'type' => 'vfs_file' ,
2012-05-11 10:35:32 +02:00
'size' => 60 ,
'label' => 'Default document to insert entries' ,
'name' => 'default_document' ,
2012-06-19 21:15:21 +02:00
'help' => lang ( 'If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.' , lang ( 'filemanager' )) . ' ' .
2014-06-24 11:47:08 +02:00
lang ( 'The document can contain placeholder like {{%1}}, to be replaced with the data.' , 'name' ) . ' ' .
2012-05-11 10:35:32 +02:00
lang ( 'The following document-types are supported:' ) . implode ( ',' , bo_merge :: get_file_extensions ()),
'run_lang' => false ,
'xmlrpc' => True ,
'admin' => False ,
);
$settings [ 'document_dir' ] = array (
2012-05-22 15:51:30 +02:00
'type' => 'vfs_dirs' ,
2012-05-11 10:35:32 +02:00
'size' => 60 ,
'label' => 'Directory with documents to insert entries' ,
'name' => 'document_dir' ,
2012-06-19 21:15:21 +02:00
'help' => lang ( 'If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the %1 data inserted.' , lang ( 'filemanager' )) . ' ' .
2014-06-24 11:47:08 +02:00
lang ( 'The document can contain placeholder like {{%1}}, to be replaced with the data.' , 'name' ) . ' ' .
2012-05-11 10:35:32 +02:00
lang ( 'The following document-types are supported:' ) . implode ( ',' , bo_merge :: get_file_extensions ()),
'run_lang' => false ,
'xmlrpc' => True ,
'admin' => False ,
'default' => '/templates/filemanager' ,
);
2012-05-03 19:58:16 +02:00
2011-03-02 00:07:36 +01:00
// Import / Export for nextmatch
if ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'importexport' ])
{
$definitions = new importexport_definitions_bo ( array (
'type' => 'export' ,
'application' => 'filemanager'
));
$options = array ();
2014-06-12 17:11:11 +02:00
foreach (( array ) $definitions -> get_definitions () as $identifier )
{
2011-03-02 00:07:36 +01:00
try {
$definition = new importexport_definition ( $identifier );
2014-06-12 17:11:11 +02:00
}
catch ( Exception $e ) {
unset ( $e );
2011-03-02 00:07:36 +01:00
// permission error
continue ;
}
2014-06-12 17:11:11 +02:00
if (( $title = $definition -> get_title ()))
{
2011-03-02 00:07:36 +01:00
$options [ $title ] = $title ;
}
unset ( $definition );
}
$settings [ 'nextmatch-export-definition' ] = array (
'type' => 'select' ,
'values' => $options ,
2011-07-04 22:00:26 +02:00
'label' => 'Export definition to use for nextmatch export' ,
2011-03-02 00:07:36 +01:00
'name' => 'nextmatch-export-definition' ,
'help' => lang ( 'If you specify an export definition, it will be used when you export' ),
'run_lang' => false ,
'xmlrpc' => True ,
'admin' => False ,
);
}
2009-05-29 12:48:19 +02:00
return $settings ;
2008-08-27 13:17:00 +02:00
}
2012-02-29 15:55:25 +01:00
2012-03-21 11:28:48 +01:00
/**
* Register filemanager as handler for directories
*
* @ return array see egw_link class
*/
static function search_link ()
{
return array (
2012-07-09 23:23:21 +02:00
'edit' => array (
'menuaction' => 'filemanager.filemanager_ui.file' ,
),
'edit_id' => 'path' ,
'edit_popup' => '495x425' ,
2012-03-21 11:28:48 +01:00
'mime' => array (
egw_vfs :: DIR_MIME_TYPE => array (
'menuaction' => 'filemanager.filemanager_ui.index' ,
'mime_id' => 'path' ,
2012-03-28 15:01:37 +02:00
'mime_target' => '_self' ,
2012-03-21 11:28:48 +01:00
),
),
2012-07-04 19:00:03 +02:00
'merge' => true ,
2014-10-21 15:51:37 +02:00
'entry' => 'File' ,
'entries' => 'Files' ,
2012-03-21 11:28:48 +01:00
);
}
2008-08-27 13:17:00 +02:00
}