[Phpcms-plugins-cvs] admin4phpCMS/modules/filemanager module_filemanager_en.lng,NONE,1.1 class.modul
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2005-05-26 15:56:08
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19290/modules/filemanager Modified Files: class.module_filemanager.php Added Files: module_filemanager_en.lng Log Message: beginning of phpcms-content and filemanager --- NEW FILE: module_filemanager_en.lng --- title_filemanager = "Filemanager" title_basedir = "Path: " Index: class.module_filemanager.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/filemanager/class.module_filemanager.php,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- class.module_filemanager.php 7 Dec 2004 06:34:49 -0000 1.9 +++ class.module_filemanager.php 26 May 2005 15:55:27 -0000 1.10 @@ -28,6 +28,9 @@ /* * $Log$ +* Revision 1.10 2005/05/26 15:55:27 mjahn +* beginning of phpcms-content and filemanager +* * Revision 1.9 2004/12/07 06:34:49 mjahn * prepration of first Alpha-Preview * @@ -61,8 +64,8 @@ /** * Include the file-utility-class **/ -include_once (dirname (__FILE__).'/class.file_util.php'); -define ('FM_IMGPATH', MODULE_PATH.'/filemanager/img/'); +include_once (dirname (__FILE__).'/includes/class.file_util.php'); +define ('FM_IMGPATH', MODULE_PATH.'/filemanager/images/'); /** * Filemanager-class for administrative work in the filesystem * @@ -74,79 +77,90 @@ * @uses file_editor **/ class module_filemanager extends module { + + var $_CONF = array (); + + var $docroot = ''; + function init () { // connect to actions - $this->_registerAction ('doParseParam', 'parseParam'); - $this->_registerAction ('doParseMenuMain', 'getMenuMain'); + $this->_registerAction('doParseParam', 'parseParam'); + $this->_registerAction('doGetMenu', 'getMenu'); - $this->docroot = realpath ($_SERVER['DOCUMENT_ROOT']); + $actiondata1 = array ('module' => 'filemanager'); + $this->_callEvent('CONFIG_GET', $actiondata1); + $this->_CONF = array_merge ($this->_CONF, $actiondata1['config']); - $actiondata1 = array ('module'=>'filemanager', 'format'=>'array'); - $this->_callEvent ('CONFIG_GET', $actiondata1); - $this->CONF =& $actiondata1 ['config']; - - include_once (dirname (__FILE__).'/config.filemanager.php'); + $this->docroot = realpath ($_SERVER['DOCUMENT_ROOT']); + return true; } /** * @param array $actiondata **/ function parseParam (&$actiondata) { - - $actiondata1 = array ('filename'=>dirname (__FILE__).'/layout.filemanager.xml'); - $this->_callEvent ('LAYOUT_ADD_TEMPLATE', $actiondata1); - + $this->display = (isset ($actiondata['request']['moduleid']) && $actiondata['request']['moduleid'] == 'filemanager'); + $actiondata1 = array(); - $this->_callEvent ('USER_GET_STATUS', $actiondata1); + $this->_callEvent('USER_GET_STATUS', $actiondata1); $this->_USER = $actiondata1; - - $this->display = (isset ($actiondata['request']['moduleid']) && $actiondata['request']['moduleid'] == 'filemanager'); - $this->viewdir = $this->viewfile = $this->editfile = $this->action = ''; if (isset ($actiondata['request']['action'])) { $this->action = $actiondata['request']['action']; } - $this->basedir = '/'; - if (isset ($actiondata['request']['basedir'])) { - $this->basedir = $actiondata['request']['basedir']; + $this->basedir = $this->docroot; + + if ($this->display && $this->_USER ['isLoggedIn']) { + $this->_registerAction ('doProcess', 'process'); + $this->_registerAction('doGetData', 'getData'); } - if ($this->action == 'viewfile' && isset ($actiondata['request']['filename'])) { - $this->viewfile = $actiondata['request']['filename']; + if (isset ($_REQUEST ['basedir'])) { + $this->basedir = $_REQUEST ['basedir']; } - if ($this->action == 'viewdir' && isset ($actiondata['request']['filename'])) { - $this->viewdir = $actiondata['request']['filename']; + } + + /** + * Get structure for menu + * + * @param array $actiondata $actiondata['_root'] must provide the id of the parental element + **/ + function getMenu(&$actiondata) { + if (!$this->_USER['isLoggedIn']) { + return true; } - if ($this->action == 'editfile' && isset ($actiondata['request']['filename'])) { - $this->editfile = $actiondata['request']['filename']; + $data = array ('name'=>'Filemanager', 'module'=>'filemanager', 'action'=>''); + $_data = array (); + + if ($this->display) { + $data ['extra'] = 'class="current"'; } - if ($this->display && $this->_USER ['isLoggedIn']) { - $this->_registerAction ('doProcess', 'processFiletree'); - } - + $actiondata [$actiondata ['tag']] ['filemanager'] = array ($data); + + return true; } - - function processFiletree (&$actiondata) { + // function getMenu () + + function process (&$actiondata) { if (!$this->display) { return true; } - $this->_registerAction ('doParseContent', 'getContentFiletree'); - if (!$this->_USER['isLoggedIn']) { return true; } + include (dirname (__FILE__).'/includes/config.filemanager.php'); if (is_dir ($this->docroot.'/'.$this->basedir.'/'.$this->viewdir)) { $this->basedir = realpath ($this->docroot.'/'.$this->basedir.'/'.$this->viewdir).'/'; if (strpos ($this->basedir, $this->docroot) === false) { $this->basedir = '/'; - $actiondata1 = array ('errortext'=>'Das angeforderte Verzeichnis liegt außerhalb des zugelassenen Bereiches!'); + $actiondata1 = array ('errortext'=>'Das angeforderte Verzeichnis liegt au�erhalb des zugelassenen Bereiches!'); $this->_callEvent ('ERROR_NOTICE', $actiondata1); } else { $this->basedir = str_replace ($this->docroot, '', $this->basedir); @@ -157,45 +171,19 @@ $actiondata1 = array ('errortext'=>'Das angeforderte Verzeichnis existiert nicht!'); $this->_callEvent ('ERROR_NOTICE', $actiondata1); } + + $this->_getFiletree (); } - /** - * @param array $actiondata - **/ - function getMenuMain (&$actiondata) { - if (!$this->_USER['isLoggedIn']) { - return true; - } - - $root = $actiondata['_root']; - $actiondata1 = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Dateimanager', 'module'=>'filemanager', '_id'=>'filemanager', '_root'=>'mainmenu'); - if ($this->display) { - $actiondata1 ['extra'] = 'class="active"'; - } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - } - - /** - * Generates the output for the fileviewer - * - * @param array $actiondata - **/ - function getContentViewer (&$actiondata) { - $actiondata1 = array (); - $this->_callEvent ('EDITOR_VIEW_FILE', $actiondata1); - } + function getData (&$actiondata) { + $data = array ('structure'=>$this->structure, 'action'=>$this->action, 'basedir'=>$this->basedir, 'counter'=>$this->counter); - /** - * Generates the ouput for the editor - * - * @param array $actiondata - **/ - function getContentEditor (&$actiondata) { - $actiondata1 = array (); - $this->_callEvent ('EDITOR_EDIT_FILE', $actiondata1); - } + $actiondata [$actiondata ['tag']] ['filemanager'] = $data; + return true; + } + /** * Generates the list of folders and files in the current directory. * @@ -204,8 +192,7 @@ * of filelist_entry. This enables the function to provide different buttons dependent * to the file-entry. **/ - function getContentFiletree (&$actiondata) { - $root = $actiondata ['_root']; + function _getFiletree () { $dir = $this->docroot.'/'.$this->basedir; $files = $dirs = array(); @@ -238,19 +225,12 @@ $entries = array_merge ($dirs, $files); unset ($files, $dirs); $num = count ($entries); - - $actiondata1 = array ('_type'=>'form', '_id'=>'fm_form', '_root'=>$root, - 'action'=>INDEX_FILE.'?moduleid=filemanager', 'imgpath' => FM_IMGPATH, 'method'=>'post'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_type'=>'fm_list', '_id'=>'filelist', '_root'=>'fm_form', - 'basedir'=>htmlentities ($this->basedir), 'imgpath' => FM_IMGPATH); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - $alternate = 1; $sum_size = 0; $num_files = 0; $num_dirs = 0; + + $this->structure = array (); for ($i = 0; $i < $num; $i++) { $entry = $entries[$i]; @@ -266,43 +246,45 @@ $file['uid'] = file_util::uid ($data[4]); $file['gid'] = file_util::gid ($data[5]); $file['filename'] = $entry; - $file['filemtime'] = strftime ('%d.%m.%Y %H:%M:%S', $data[9]); - $file['filectime'] = strftime ('%d.%m.%Y %H:%M:%S', $data[8]); - $file['fileatime'] = strftime ('%d.%m.%Y %H:%M:%S', $data[10]); + $file['filemtime'] = $data[9]; + $file['filectime'] = $data[8]; + $file['fileatime'] = $data[10]; $file['filesize'] = file_util::filesize ($dir.'/'.$entry); $file['chmod'] = array ('oct'=>file_util::fileperms($dir.'/'.$entry), 'str'=>file_util::fileperms ($dir.'/'.$entry, true)); + $file ['nolink'] = 0; $entrypath = realpath ($dir.'/'.$entry); // entry is directory if (is_dir ($entrypath)) { - $nolink = false; + $num_files++; + $file ['nolink'] = 0; // check if entry is parent directory if ($entry == '..') { - $type = 'parent'; + $file ['type'] = 'parent'; } elseif ($entry == '.') { - $type = 'empty'; - $nolink = true; + $file ['type'] = 'empty'; + $file ['nolink'] = 1; } else { $num_dirs++; - $type = 'folder'; + $file ['type'] = 'folder'; // check if entry has executive permission if (!@file_exists($entrypath.'/.')) { - $type = 'folder_inactive'; - $nolink = true; + $file ['type'] = 'folder_inactive'; + $file ['nolink'] = 1; } // check if entry has reading permission if (!is_readable ($entrypath)) { - $type = 'folder_inactive'; - $nolink = true; + $file ['type'] = 'folder_inactive'; + $file ['nolink'] = 1; } // check if entry is a symlink if (is_link ($dir.$entry)) { - $type = 'symlink'; + $file ['type'] = 'symlinkdir'; } @@ -310,120 +292,42 @@ // check if destination-path of entry is within the allowed path if (!file_util::checkpath ($this->docroot, $entrypath)) { - $nolink = true; + $file ['nolink'] = 1; } - $actiondata1 = array ('_root'=>'filelist', 'imgpath' => FM_IMGPATH, '_id'=>'dir-'.$entry, 'basedir'=>$this->basedir, 'filename'=>htmlentities ($entry), 'filesize'=>$file ['filesize'], 'fileatime'=>$file ['fileatime'], 'filectime'=>$file ['filectime'], 'filemtime'=>$file ['filemtime'], 'gid'=>$file ['gid'] ['str'], 'uid'=>$file ['uid'] ['str'], 'chmod'=>$file ['chmod'] ['str'], 'extra'=>'class="line'.$alternate++.'"', 'filetype'=>$type); - if ($nolink) { - // set no link for open directory - $actiondata1 ['_type'] = 'fm_dir_inactive'; - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - } else { - // set link for open directory - $actiondata1 ['_type'] = 'fm_dir'; - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - } } if (is_file ($dir.'/'.$entry)) { $num_files++; $sum_size += $data[7]; - $type = 'text.gif'; + $file ['type'] = 'text.gif'; foreach ($this->FILETYPES as $filetype) { if (eregi ($filetype[0], $entry)) { - $type = $filetype[1]; + $file ['type'] = $filetype[1]; break; } } // check if file is a symlink if (is_link ($dir.'/'.$entry)) { - $type = 'symlink.gif'; + $file ['type'] = 'symlink'; } - $actiondata1 = array ('_root'=>'filelist', 'imgpath' => FM_IMGPATH, '_id'=>'file-'.$entry, 'filename'=>$entry, 'basedir'=>$this->basedir, 'filename'=>htmlentities ($entry), 'filesize'=>$file ['filesize'], 'fileatime'=>$file ['fileatime'], 'filectime'=>$file ['filectime'], 'filemtime'=>$file ['filemtime'], 'gid'=>$file ['gid'] ['str'], 'uid'=>$file ['uid'] ['str'], 'chmod'=>$file ['chmod'] ['str'], 'extra'=>'class="line'.$alternate++.'"', 'filetype'=>$type); - // check if file is writeable if (!is_writeable ($dir.'/'.$entry)) { - $actiondata1 ['_type'] = 'fm_file_inactive'; + $file ['writeable'] = 0; } else { - $actiondata1 ['_type'] = 'fm_file'; + $file ['writeable'] = 1; } - // insert fileentry - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); } + $this->structure [] = $file; } - $actiondata1 = array ('_root'=>'filelist', 'imgpath' => FM_IMGPATH, '_id'=>'filelist-summary', '_type'=>'fm_sum', 'dirs'=>$num_dirs, 'files'=>$num_files, 'sumsize'=>file_util::filesize ($sum_size)); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set options-box - $actiondata1 = array ('_root'=>'fm_form', 'imgpath' => FM_IMGPATH, '_id'=>'fm-options', '_type'=>'block', 'extra'=>'id="fm-options"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set tablist - $actiondata1 = array ('_root'=>'fm-options', 'imgpath' => FM_IMGPATH, '_id'=>'tablist', '_type'=>'ulist', 'extra'=>'class="tabbed"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set tabbox - $actiondata1 = array ('_root'=>'fm-options', 'imgpath' => FM_IMGPATH, '_id'=>'tabbox', '_type'=>'block', 'extra'=>'class="tabbox"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - $tabs = array ( - array ('name'=>'Neu', 'id'=>'new'), - array ('name'=>'Hochladen', 'id'=>'upload'), - array ('name'=>'Archivieren', 'id'=>'backup'), - array ('name'=>'Zwischenablage', 'id'=>'clipboard') - ); - - $num = count ($tabs); - for ($i = 0; $i < $num; $i++) { - - // set tab-list - $actiondata1 = array ('_root'=>'tablist', 'imgpath' => FM_IMGPATH, '_id'=>'tablistitem-'.$tabs [$i] ['id'], '_type'=>'list_entry'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set tab-script - $actiondata1 = array ('_root'=>'tablist', 'imgpath' => FM_IMGPATH, '_id'=>'tablistscript-'.$tabs [$i] ['id'], '_type'=>'script', 'content'=>'registerTab (\'tabbox-'.$tabs [$i] ['id'].'\');'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set the tab-link - $actiondata1 = array ('_root'=>'tablistitem-'.$tabs [$i] ['id'], 'imgpath' => FM_IMGPATH, '_id'=>'tablink-'.$tabs [$i] ['id'], '_type'=>'link', 'href'=>'#tabbox-'.$tabs [$i] ['id'], 'content'=>$tabs [$i] ['name'], 'extra'=>'class="" id="tabbox-'.$tabs [$i] ['id'].'-nav" onclick="displayTab (\'tabbox-'.$tabs [$i] ['id'].'\')" onkeypress="displayTab (\'tabbox-'.$tabs [$i] ['id'].'\')"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set the tab-box container - $actiondata1 = array ('_root'=>'tabbox', 'imgpath' => FM_IMGPATH, '_id'=>'tabbox-'.$tabs [$i] ['id'], '_type'=>'block', 'extra'=>'id="tabbox-'.$tabs [$i] ['id'].'"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - } - - // set the tab-box (new) - $actiondata1 = array ('_root'=>'tabbox-new', 'imgpath' => FM_IMGPATH, '_id'=>'tabbox-new-content', '_type'=>'fm_new'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set the tab-box (upload) - $actiondata1 = array ('_root'=>'tabbox-upload', 'imgpath' => FM_IMGPATH, '_id'=>'tabbox-upload-content', '_type'=>'fm_upload'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set the tab-box (backup) - $actiondata1 = array ('_root'=>'tabbox-backup', 'imgpath' => FM_IMGPATH, '_id'=>'tabbox-backup-content', '_type'=>'fm_backup'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - // set the tab-box (clipboard) - $actiondata1 = array ('_root'=>'tabbox-clipboard', 'imgpath' => FM_IMGPATH, '_id'=>'tabbox-clipboard-content', '_type'=>'fm_clipboard'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - + $this->counter = array ('files'=>$num_files, 'dirs'=>$num_dirs, 'sizes'=>file_util::filesize ($sum_size, 2)); } - /** - * Let the user et the chmod of a file - * - * @param array $actiondata - **/ - function getContentChmod (&$actiondata) { - } - function _userSort (&$dirs, &$files) { sort ($dirs); sort ($files); |