Example #1
0
 /**
  * @name acl_load_lib
  * @package 系统后台装载模块
  * @return array or null
  */
 public function acl_load_lib()
 {
     global $BASETHEME_COMMON_ACTION;
     if (file_exists(LIBS)) {
         $_libs = (include LIBS);
     } else {
         return null;
     }
     $libs = unserialize($_libs);
     $lib_array = array();
     $BASETHEME_COMMON_ACTION = false;
     foreach ($libs as $k => $v) {
         if (substr($v, -4) != ".php") {
             continue;
         }
         if ($k == get_class($this->stdClass)) {
             $lib = $this->stdClass;
         } else {
             if (class_exists($k)) {
                 continue;
             } else {
                 require_once $v;
                 if (class_exists($k)) {
                     $lib = new $k();
                 } else {
                     continue;
                 }
             }
         }
         $seg = getSeg();
         $name = explode($seg, $v);
         switch (get_parent_class($lib)) {
             case "BasePrograma":
                 //后台主菜单栏
                 if (method_exists($lib, "getProg")) {
                     $lib_array[$name[count($name) - 2]][$k] = $lib->getProg();
                 }
                 break;
             case "Permission":
                 //后台子目录列表
                 if (method_exists($lib, "get_name")) {
                     if ($lib->get_name() != null) {
                         $list = array("name" => $lib->get_name(), "desc" => $lib->get_desc(), "ismenu" => $lib->get_ismenu());
                         $lib_array[$name[count($name) - 2]][$k] = $list;
                     }
                 }
                 break;
             default:
                 break;
         }
         unset($lib);
     }
     $BASETHEME_COMMON_ACTION = true;
     if (empty($lib_array)) {
         return null;
     }
     $this->acl_save_lib($lib_array);
     return $lib_array;
 }
Example #2
0
 /**
  * 
  * @name load
  * @param unknown_type $stdClass
  * @package load lang file
  * @return null
  */
 private function load($stdClass)
 {
     $this->stdClass = $stdClass;
     $seg = getSeg();
     if (!is_file(LIBS)) {
         CacheLibs();
     }
     include LIBS;
     $m_lib = unserialize($_libs);
     //echo $m_lib[$this->stdClass]."--";
     $langDir = "";
     if (array_key_exists($this->stdClass, $m_lib)) {
         $dn = dirname($m_lib[$this->stdClass]);
         $dir = explode("lib", $dn);
         $langDir = $dir[1];
     }
     if (is_file(LANG . $seg . $langDir . $seg . $this->stdClass . ".php")) {
         include_once LANG . $seg . $langDir . $seg . $this->stdClass . ".php";
     } else {
         if (is_file(LANG . $this->stdClass . ".php")) {
             include_once LANG . $this->stdClass . ".php";
         } else {
             //echo LANG.$seg.$langDir.$seg.$this->stdClass.".php<br />";
             return;
             //throw new \Exception("Lib '{$stdClass}' lang does not exist.");
         }
     }
     $class = "_" . $this->stdClass;
     if (class_exists($class)) {
         if ($stdClass == LANG_COMMON) {
             $this->langComm = new $class();
         } else {
             $this->langClass = new $class();
         }
     }
 }
Example #3
0
/**
 * 得到某个目录下所有文件夹和文件
 * string $dir 目录路径
 * return array('files'=>array(...),'dirs'=>array(...))
 * @package 还不够完善
 * @see ACLRole
 */
function find_all_files($dir)
{
    $seg = getSeg();
    $lib_name = function ($name) {
        return basename($name, ".php");
    };
    $root = scandir($dir);
    if ($root == false) {
        return false;
    }
    foreach ($root as $value) {
        if ($value === '.' || $value === '..') {
            continue;
        }
        if (is_file("{$dir}{$seg}{$value}")) {
            $result[$lib_name($value)] = "{$dir}{$seg}{$value}";
            continue;
        }
        $sub_root = find_all_files("{$dir}{$seg}{$value}");
        if ($sub_root == false) {
            continue;
        }
        foreach ($sub_root as $value) {
            if (substr($value, -4) == ".php") {
                if ($lib_name($value) == "index") {
                    $result[basename(dirname($value)) . "_" . $lib_name($value)] = $value;
                } else {
                    $result[$lib_name($value)] = $value;
                }
            }
        }
    }
    return $result;
}