public function getUnInstalled() { $installed = (array) $this->getInstalled(); $folders = dir::folders(ZPATH_MODULES, '.', false); $folders = array_diff($folders, array_keys($installed)); $modules = array(); foreach ($folders as $folder) { $modulePath = ZPATH_MODULES . DS . $folder; $moduleUrl = url::modules() . '/' . $folder; $moduleFile = $modulePath . DS . 'module.php'; if (file::exists($moduleFile)) { $m = (include $moduleFile); $m['path'] = '$modules/' . $folder; $m['url'] = '$modules/' . $folder; if (!isset($m['icon'])) { if (!file::exists($modulePath . '/icon.png')) { $m['icon'] = url::theme() . '/image/skin/none.png'; } else { $m['icon'] = $moduleUrl . '/icon.png'; } } $modules[$m['id']] = $m; } } return $modules; }
public function getUnInstalled() { $installed = (array) $this->getInstalled(); $folders = dir::folders(ZOTOP_PATH_MODULES, '.', false); $modules = array(); foreach ($folders as $folder) { $modulePath = ZOTOP_PATH_MODULES . DS . $folder; $moduleUrl = '$modules/' . $folder; $moduleFile = $modulePath . DS . 'module.php'; $m = @(include $moduleFile); if (is_array($m) && isset($m['id']) && !in_array($m['id'], array_keys($installed))) { $m['path'] = '$modules/' . $folder; $m['url'] = '$modules/' . $folder; if (!isset($m['icon'])) { if (file::exists($modulePath . '/icon.png')) { $m['icon'] = $moduleUrl . '/icon.png'; } } $modules[$m['id']] = $m; } } return $modules; }
public function notInstalled() { $datalist = (array) $this->datalist(); $folders = dir::folders(ZOTOP_MODULES, '.', false); $folders = array_diff($folders, array_keys($datalist)); $modules = array(); foreach ($folders as $folder) { $modulePath = ZOTOP_MODULES . DS . $folder; $moduleUrl = url::modules() . '/' . $folder; $moduleFile = $modulePath . DS . 'module.php'; if (file::exists($moduleFile)) { $m = (include $moduleFile); if (!isset($m['icon'])) { $m['icon'] = $moduleUrl . '/icon.gif'; if (!file::exists($m['icon'])) { $m['icon'] = url::theme() . '/image/icon/module.gif'; } } $modules[$m['id']] = $m; } } return $modules; }
public function actionIndex($dir = '') { $dir = url::clean($dir); $path = ZOTOP_PATH_ROOT . DS . trim($dir, DS); $path = path::clean($path); //获取当前目录的子目录及子文件 $folders = (array) dir::folders($path); $files = (array) dir::files($path); $position = '<a href="' . zotop::url('webftp/index/index') . '">wwwroot</a>'; $dirs = arr::dirpath($dir, '/'); foreach ($dirs as $d) { $position .= ' / <a href="' . zotop::url('webftp/index/index', array('dir' => rawurlencode($d[1]))) . '">' . $d[0] . '</a>'; } $page = new page(); $page->title = '文件管理器'; $page->set('position', $position); $page->set('navbar', $this->navbar($dir)); $page->set('folders', $folders); $page->set('files', $files); $page->set('path', $path); $page->set('dir', $dir); $page->display(); }
/** * 返回目录下的全部文件夹的数组 * @param string $path 路径 * @param array $filter * @param bool|int $recurse 子目录,或者子目录级数 * @param bool $fullpath 全路径或者仅仅获取文件名称 * @param array $ignore 忽略的文件夹名称 * @return array */ public static function folders($path, $filter = '.', $recurse = false, $fullpath = false, $ignore = array('.svn', 'CVS', '.DS_Store', '__MACOSX')) { $folders = array(); $path = path::clean($path); if (!is_dir($path)) { return false; } $handle = opendir($path); while (($file = readdir($handle)) !== false) { $f = $path . DS . $file; if ($file != '.' && $file != '..' && !in_array($file, $ignore) && is_dir($f)) { if (preg_match("/{$filter}/", $file)) { if ($fullpath) { $folders[] = $f; } else { $folders[] = $file; } } if ($recurse) { if (is_integer($recurse)) { $recurse--; } $subfolders = dir::folders($f, $filter, $recurse, $fullpath, $ignore); $folders = array_merge($folders, $subfolders); } } } closedir($handle); return $folders; }
public function onDefault($dir = '') { $path = ROOT . DS . trim($dir, DS); $path = path::clean($path); $folders = dir::folders($path); $files = dir::files($path); $fileext = array('php', 'css', 'js', 'jpg', 'jpeg', 'gif', 'png', 'bmp', 'psd', 'html', 'htm', 'tpl', 'rar', 'zip', 'mp3'); $page['title'] = '文件管理器'; page::header($page); page::add('<div id="page" class="clearfix">'); page::add('<div id="main">'); page::add('<div id="main-inner">'); page::top(); page::navbar($this->navbar(), 'default'); $column = array(); $column['select'] = ''; $column['name'] = '名称'; $column['type'] = '类型'; $column['size w60'] = '大小'; $column['atime w120'] = '创建时间'; $column['mtime w120'] = '修改时间'; $column['manage rename w80'] = '重命名'; $column['manage edit w80'] = '编辑'; $column['manage delete'] = '删除'; table::header('list', $column); foreach ($folders as $folder) { $column = array(); $column['select w20 center'] = html::image(url::theme() . '/image/fileext/folder.gif'); $column['name'] = '<a href="' . zotop::url('filemanager/index/default', array('dir' => $dir . DS . $folder)) . '"><b>' . $folder . '</b></a>'; $column['type w60'] = '文件夹'; $column['size w60'] = '--'; $column['atime w120'] = time::format(@fileatime($path . DS . $folder)); $column['mtime w120'] = time::format(@filemtime($path . DS . $folder)); $column['manage rename w80'] = '<a>重命名</a>'; $column['manage edit w80'] = '<a class="disabled">编辑</a>'; $column['manage delete'] = '<a>删除</a>'; table::row($column); } foreach ($files as $file) { $column = array(); $column['select w20 center'] = in_array(file::ext($file), $fileext) ? html::image(url::theme() . '/image/fileext/' . file::ext($file) . '.gif') : html::image(url::theme() . '/image/fileext/unknown.gif'); $column['name'] = '<a href="' . zotop::url('filemanager/index/default', array('dir' => $dir . DS . $file)) . '"><b>' . $file . '</b></a>'; $column['type w60'] = '文件'; $column['size w60'] = format::byte(@filesize($path . DS . $file)); $column['atime w120'] = time::format(@fileatime($path . DS . $file)); $column['mtime w120'] = time::format(@filemtime($path . DS . $file)); $column['manage rename w80'] = '<a>重命名</a>'; $column['manage edit w80'] = '<a href="' . zotop::url('filemanager/file/edit', array('filename' => $dir . DS . $file, 'dir' => '***')) . '">编辑</a>'; $column['manage delete'] = '<a>删除</a>'; table::row($column); } table::footer(); page::bottom(); page::add('</div>'); page::add('</div>'); page::add('<div id="side">'); block::header('快捷操作'); echo '<ul class="list">'; echo '<li class="file"><a href="' . zotop::url('zotop/file/newfile') . '" class="dialog">新建文件</a></li>'; echo '<li class="folder"><a href="' . zotop::url('zotop/file/newfolder') . '" class="dialog">新建文件夹</a></li>'; echo '<li class="folder"><a href="' . zotop::url('zotop/file/upload') . '" class="dialog">文件上传</a></li>'; echo '</ul>'; block::footer(); block::header('其他位置'); echo '<ul class="list">'; echo '<li class="root"><a>根目录</a></li>'; echo '<li class="root"><a>模板目录</a></li>'; echo '<li class="root"><a>模块目录</a></li>'; echo '<li class="root"><a>缓存目录</a></li>'; echo '</ul>'; block::footer(); page::add('</div>'); page::add('</div>'); page::footer(); }