Ejemplo n.º 1
0
/** 
 * 获取文件夹下列表信息
 * dir 包含结尾/   d:/wwwroot/test/
 * 传入需要读取的文件夹路径,为程序编码
 */
function path_list($dir, $list_file = true, $check_children = false)
{
    $dir = rtrim($dir, '/') . '/';
    if (!is_dir($dir) || !($dh = opendir($dir))) {
        return array('folderlist' => array(), 'filelist' => array());
    }
    $folderlist = array();
    $filelist = array();
    //文件夹与文件
    while (($file = readdir($dh)) !== false) {
        if ($file != "." && $file != ".." && $file != ".svn") {
            $fullpath = $dir . $file;
            if (is_dir($fullpath)) {
                $info = folder_info($fullpath);
                if ($check_children) {
                    $info['isParent'] = path_haschildren($fullpath, $list_file);
                }
                $folderlist[] = $info;
            } else {
                if ($list_file) {
                    //是否列出文件
                    $info = file_info($fullpath);
                    if ($check_children) {
                        $info['isParent'] = false;
                    }
                    $filelist[] = $info;
                }
            }
        }
    }
    closedir($dh);
    return array('folderlist' => $folderlist, 'filelist' => $filelist);
}
 private function _tree_init($app)
 {
     if ($app == 'editor' && isset($this->in['project'])) {
         $list_project = $this->path(_DIR($this->in['project']), true, true);
         $project = array_merge($list_project['folderlist'], $list_project['filelist']);
         $tree_data = array(array('name' => get_path_this($this->in['project']), 'children' => $project, 'iconSkin' => "my", 'menuType' => "menuTreeRoot", 'open' => true, 'this_path' => $this->in['project'], 'isParent' => count($project) > 0 ? true : false));
         show_json($tree_data);
         return;
     }
     $check_file = $app == 'editor' ? true : false;
     $favData = new fileCache($this->config['user_fav_file']);
     $fav_list = $favData->get();
     $fav = array();
     foreach ($fav_list as $key => $val) {
         $fav[] = array('name' => $val['name'], 'this_path' => $val['path'], 'iconSkin' => "fav", 'menuType' => "menuTreeFav", 'type' => 'folder', 'isParent' => path_haschildren(_DIR($val['path']), $check_file));
     }
     $list_root = $this->path(_DIR(MYHOME), $check_file, true);
     $list_public = $this->path(PUBLIC_PATH, $check_file, true);
     if ($check_file) {
         //编辑器
         $root = array_merge($list_root['folderlist'], $list_root['filelist']);
         $public = array_merge($list_public['folderlist'], $list_public['filelist']);
     } else {
         //文件管理器
         $root = $list_root['folderlist'];
         $public = $list_public['folderlist'];
     }
     $root_isparent = count($root) > 0 ? true : false;
     $public_isparent = count($public) > 0 ? true : false;
     $tree_data = array(array('name' => $this->L['fav'], 'iconSkin' => "fav", 'menuType' => "menuTreeFavRoot", 'open' => true, 'children' => $fav), array('name' => $this->L['root_path'], 'children' => $root, 'menuType' => "menuTreeRoot", 'iconSkin' => "my", 'open' => true, 'this_path' => MYHOME, 'isParent' => $root_isparent), array('name' => $this->L['public_path'], 'children' => $public, 'menuType' => "menuTreeRoot", 'iconSkin' => "lib", 'open' => true, 'this_path' => '*public*', 'isParent' => $public_isparent));
     show_json($tree_data);
 }
Ejemplo n.º 3
0
 private function _tree_init($app)
 {
     $check_file = $app == 'editor' ? true : false;
     $favData = new fileCache($this->config['user_fav_file']);
     $fav_list = $favData->get();
     $fav = array();
     foreach ($fav_list as $key => $val) {
         $fav[] = array('ext' => 'folder', 'name' => $val['name'], 'this_path' => $val['path'], 'iconSkin' => "fav", 'type' => 'folder', 'isParent' => path_haschildren(_DIR($val['path']), $check_file));
     }
     $list_root = $this->path(_DIR(MYHOME), true, true);
     $list_share = $this->path(_DIR(PUBLIC_PATH), true, true);
     if ($check_file) {
         //编辑器
         $root = array_merge($list_root['folderlist'], $list_root['filelist']);
         $share = array_merge($list_share['folderlist'], $list_share['filelist']);
         $tree_data = array(array('name' => $this->L['fav'], 'ext' => '__fav__', 'iconSkin' => "fav", 'open' => true, 'children' => $fav), array('name' => $this->L['root_path'], 'ext' => '__root__', 'children' => $root, 'iconSkin' => "my", 'open' => true, 'this_path' => MYHOME, 'isParent' => true), array('name' => $this->L['public_path'], 'ext' => '__root__', 'children' => $share, 'iconSkin' => "lib", 'open' => true, 'this_path' => PUBLIC_PATH, 'isParent' => true));
     } else {
         //文件管理器
         $root = $list_root['folderlist'];
         $share = $list_share['folderlist'];
         $tree_data = array(array('name' => $this->L['fav'], 'ext' => '__fav__', 'iconSkin' => "fav", 'open' => true, 'children' => $fav), array('name' => $this->L['root_path'], 'ext' => '__root__', 'children' => $root, 'iconSkin' => "my", 'open' => true, 'this_path' => MYHOME, 'isParent' => true), array('name' => $this->L['public_path'], 'ext' => '__root__', 'children' => $share, 'iconSkin' => "lib", 'open' => true, 'this_path' => PUBLIC_PATH, 'isParent' => true));
     }
     show_json($tree_data);
 }