示例#1
0
文件: Tool.php 项目: kevinwan/xf
 public function make($dir)
 {
     $moduleName = 'Default';
     if (strpos($dir, 'modules/') !== false) {
         $tmp = explode('modules/', $dir);
         $moduleName = ucfirst(str_replace('/controllers/', '', $tmp[1]));
     }
     $list = XF_File::fileAll($dir);
     if (!is_array($list)) {
         return;
     }
     foreach ($list as $l) {
         if (strpos($l, 'Controller.php') !== false) {
             @(require_once $dir . $l);
             $classname = $cname = str_replace('.php', '', $l);
             if ($moduleName != 'Default') {
                 $classname = $moduleName . '_' . $classname;
             }
             if (class_exists($classname) && strpos($classname, 'Abstract') === false) {
                 $this->_map[$classname] = array();
                 $ref = new ReflectionClass(new $classname());
                 $methods = $ref->getMethods(ReflectionMethod::IS_PUBLIC);
                 if (is_array($methods) && count($methods) > 0) {
                     foreach ($methods as $m) {
                         if (strpos($m->name, 'Action') !== false && $m->name != 'doAction' && $m->name != 'hasAction') {
                             $this->_map[$classname][] = strtolower($moduleName . '.' . str_replace('Controller', '', $cname) . '.' . str_replace('Action', '', $m->name));
                         }
                     }
                 }
             }
         }
     }
 }
示例#2
0
文件: File.php 项目: kevinwan/xf
 /**
  * 获取某个目录中的文件及目录
  * @access public
  * @param string $path 路径
  */
 public static function fileList($path)
 {
     if (!preg_match('#/$#', $path)) {
         $path .= '/';
     }
     $f = $d = array();
     foreach (XF_File::fileAll($path) as $name) {
         if (@is_dir($path . $name)) {
             $d[] = $name;
         } elseif (@is_file($path . $name)) {
             $f[] = $name;
         }
     }
     natcasesort($d);
     natcasesort($f);
     return array_merge($d, $f);
 }