getList() public method

+---------------------------------------------------------- 取得目录中的结构信息 +---------------------------------------------------------- +---------------------------------------------------------- +----------------------------------------------------------
public getList ( $directory )
 public function index()
 {
     $list = D('SysConf')->where("status=1 and group_id > 0 and is_show = 1")->order("sort asc")->findAll();
     $conf_list = array();
     //用于输出分组格式化后的数组
     foreach ($list as $k => $v) {
         if ($v['name'] == 'DEFAULT_LANG') {
             $lang_list = Dir::getList(LANG_PATH);
             $v['val_arr'] = array();
             foreach ($lang_list as $lang_item) {
                 if ($lang_item != '.' && $lang_item != '..') {
                     $v['val_arr'][] = $lang_item;
                 }
             }
         } elseif ($v['name'] == 'SITE_TMPL') {
             $tmpl_list = Dir::getList(FANWE_ROOT . 'tpl');
             $v['val_arr'] = array();
             foreach ($tmpl_list as $tmpl_item) {
                 if ($tmpl_item != '.' && $tmpl_item != '..') {
                     $v['val_arr'][] = $tmpl_item;
                 }
             }
         } else {
             $v['val_arr'] = explode(",", $v['val_arr']);
         }
         $conf_list[L("SYSCONF_GROUP_" . $v['group_id'])][$k] = $v;
     }
     $this->assign("conf_list", $conf_list);
     $this->display();
 }
Beispiel #2
0
function sp_get_url_route()
{
    $apps = Dir::getList(SPAPP);
    $host = (is_ssl() ? 'https' : 'http') . "://" . $_SERVER['HTTP_HOST'];
    $routes = array();
    foreach ($apps as $a) {
        if (is_dir(SPAPP . $a)) {
            if (!(strpos($a, ".") === 0)) {
                $navfile = SPAPP . $a . "/nav.php";
                $app = $a;
                if (file_exists($navfile)) {
                    $navgeturls = (include $navfile);
                    foreach ($navgeturls as $url) {
                        //echo U("$app/$url");
                        $nav = file_get_contents($host . U("{$app}/{$url}"));
                        $nav = json_decode($nav, true);
                        if (!empty($nav) && isset($nav['urlrule'])) {
                            if (!is_array($nav['urlrule']['param'])) {
                                $params = $nav['urlrule']['param'];
                                $params = explode(",", $params);
                            }
                            sort($params);
                            $param = "";
                            foreach ($params as $p) {
                                $param .= ":{$p}/";
                            }
                            $routes[strtolower($nav['urlrule']['action']) . "/" . $param] = $nav['urlrule']['action'];
                        }
                    }
                }
            }
        }
    }
    return $routes;
}
 public function edit()
 {
     $arr = Dir::getList(FANWE_ROOT . "/tpl/");
     foreach ($arr as $item) {
         if (strpos($item, '.') === FALSE) {
             $themes[] = $item;
         }
     }
     $adv = D("advPosition")->field("id,name")->findAll();
     $this->assign("adv", $adv);
     $this->assign("themes", $themes);
     parent::edit();
 }
Beispiel #4
0
 private function initModule()
 {
     $actions = array('index' => 1, 'add' => 1, 'insert' => 0, 'update' => 0, 'remove' => 0, 'editfield' => 0, 'togglestatus' => 0);
     $custom_modules = array('Cache' => array(), 'Index' => array());
     $disable_modules = array('Fanwe', 'Common', 'Public');
     $files = Dir::getList(ADMIN_PATH . '/Lib/Action/');
     //$modules = D('RoleNode')->where('auth_type = 1')->select();
     $exists_modules = array();
     foreach ($files as $file) {
         if ($file != '.' && $file != '..' && stripos($file, 'Action.class.php') !== false) {
             $module = str_ireplace('Action.class.php', '', $file);
             if (!in_array($module, $disable_modules)) {
                 if (D("RoleNode")->where("module='" . $module . "' AND action=''")->count() == 0) {
                     //增加该模块授权
                     $module_data = array();
                     $module_data['status'] = 1;
                     $module_data['module'] = $module;
                     $module_data['module_name'] = L($module);
                     $module_data['auth_type'] = 1;
                     $module_data['is_show'] = 0;
                     $module_data['sort'] = 10;
                     D("RoleNode")->add($module_data);
                     if (array_key_exists($module, $custom_modules)) {
                         $module_actions = $custom_modules[$module];
                     } else {
                         $module_actions = $actions;
                     }
                     foreach ($module_actions as $action => $is_show) {
                         //增加该模块操作授权
                         $action_data = array();
                         $action_data['module'] = $module;
                         $action_data['module_name'] = L($module);
                         $action_data['action'] = $action;
                         $action_data['action_name'] = L($module . '_' . $action);
                         $action_data['auth_type'] = 0;
                         $action_data['is_show'] = $is_show;
                         $action_data['status'] = 1;
                         $action_data['sort'] = 10;
                         if ($is_show) {
                             $action_data['nav_id'] = 3;
                         }
                         D("RoleNode")->add($action_data);
                     }
                 }
                 array_push($exists_modules, $module);
             }
         }
     }
     //删除多余的module
     D("RoleNode")->where(array("module" => array("not in", $exists_modules), "action" => ''))->delete();
 }
Beispiel #5
0
 public function inport_db()
 {
     //导入数据库
     import("ORG.Io.Dir");
     $path = './Backup/SQL/';
     $fil = array('.', '..', '.svn');
     $dir = Dir::getList($path);
     $f = array_diff($dir, $fil);
     $this->assign('list', $f);
     $this->assign('path', $path);
     $this->display();
 }
Beispiel #6
0
 public function spmy_export_menu()
 {
     $menus = $this->Menu->order(array("app" => "ASC", "model" => "ASC", "action" => "ASC"))->select();
     $menus_tree = array();
     $apps = Dir::getList(SPAPP);
     foreach ($apps as $a) {
         if (is_dir(SPAPP . $a)) {
             if (!(strpos($a, ".") === 0)) {
                 $menudir = SPAPP . $a . "/Menu";
                 Dir::del($menudir);
             }
         }
     }
     foreach ($menus as $m) {
         $mm = $m;
         unset($mm['app']);
         unset($mm['model']);
         unset($mm['id']);
         unset($mm['parentid']);
         $menus_tree[$m['app']][$m['model']][] = $mm;
     }
     foreach ($menus_tree as $app => $models) {
         $menudir = SPAPP . $app . "/Menu";
         foreach ($models as $model => $a) {
             if (!file_exists($menudir)) {
                 mkdir($menudir);
             }
             file_put_contents($menudir . "/{$model}.php", "<?php\treturn " . var_export($a, true) . ";?>");
         }
     }
     $this->display("export_menu");
 }