Beispiel #1
0
 /**
  * Files list
  */
 public function fslistAction()
 {
     $path = Request::post('node', 'string', '');
     $path = str_replace('.', '', $path);
     $dirPath = $this->_config->get('controllers');
     if (!is_dir($dirPath)) {
         Response::jsonArray(array());
     }
     if (!strlen($path)) {
         $files = array($dirPath . 'Backend', $dirPath . 'Frontend');
     } else {
         $files = File::scanFiles($dirPath . $path, array('.php'), false, File::Files_Dirs);
     }
     if (empty($files)) {
         Response::jsonArray(array());
     }
     sort($files);
     $list = array();
     foreach ($files as $k => $fpath) {
         $text = basename($fpath);
         if ($text === '.svn') {
             continue;
         }
         $obj = new stdClass();
         $obj->id = str_replace($dirPath, '', $fpath);
         $obj->text = $text;
         if ($obj->text === 'Controller.php') {
             $controllerName = str_replace(array($dirPath, DIRECTORY_SEPARATOR), array('', '_'), substr($fpath, 0, -4));
             $obj->url = Backend_Designer_Code::getControllerUrl($controllerName);
         } else {
             $obj->url = '';
         }
         if (is_dir($fpath)) {
             $obj->expanded = false;
             $obj->leaf = false;
         } else {
             if ($text !== 'Controller.php') {
                 continue;
             }
             $obj->leaf = true;
         }
         $list[] = $obj;
     }
     if ($this->_configMain->get('allow_externals') && $path == '') {
         $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
         $eExpert = new Externals_Expert($this->_configMain, $config);
         $list[] = $eExpert->getControllersTree();
     }
     Response::jsonArray($list);
 }