Example #1
0
 /**
  * Inerface projects list
  */
 public function fslistAction()
 {
     $path = Request::post('node', 'string', '');
     $config = $config = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php');
     $dirPath = $config->get('configs');
     $list = array();
     if (!is_dir($dirPath)) {
         Response::jsonArray(array());
     }
     if ($path === '') {
         if ($this->_configMain->get('allow_externals')) {
             $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
             $eExpert = new Externals_Expert($this->_configMain, $config);
             $extProjects = $eExpert->getProjects();
             if (!empty($extProjects)) {
                 foreach ($extProjects as $item) {
                     $list[] = $item;
                 }
             }
         }
         $path = $dirPath . $path;
     }
     $files = File::scanFiles($path, array('.dat'), false, File::Files_Dirs);
     /**
      * This is hard fix for windows
      */
     if (DIRECTORY_SEPARATOR == '\\') {
         foreach ($files as &$v) {
             $v = str_replace('\\', '/', $v);
             $v = str_replace('//', '/', $v);
         }
         unset($v);
     }
     if (empty($files)) {
         Response::jsonArray(array());
     }
     foreach ($files as $k => $fpath) {
         $text = basename($fpath);
         if ($text === '.svn') {
             continue;
         }
         $obj = new stdClass();
         $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath);
         $obj->text = $text;
         if (is_dir($fpath)) {
             $obj->expanded = false;
             $obj->leaf = false;
         } else {
             $obj->leaf = true;
         }
         $list[] = $obj;
     }
     Response::jsonArray($list);
 }
Example #2
0
File: Fs.php Project: vgrish/dvelum
 /**
  * Files list
  */
 public function fslistAction()
 {
     $path = Request::post('node', 'string', '');
     //$path = str_replace('.','', $path);
     $dirPath = $this->_config->get('configs');
     if ($path === '') {
         $path = $dirPath . $path;
     }
     if (!is_dir($dirPath)) {
         Response::jsonArray(array());
     }
     $files = File::scanFiles($path, array('.dat'), false, File::Files_Dirs);
     $list = array();
     if (!empty($files)) {
         $dirs = array();
         $pfiles = array();
         foreach ($files as $k => $fpath) {
             $text = basename($fpath);
             if ($text === '.svn') {
                 continue;
             }
             if (is_dir($fpath)) {
                 $dirs[] = $fpath;
             } else {
                 $pfiles[] = $fpath;
             }
         }
         if (!empty($dirs)) {
             sort($dirs);
             foreach ($dirs as $k => $fpath) {
                 $text = basename($fpath);
                 $obj = new stdClass();
                 $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath);
                 $obj->text = $text;
                 $obj->expanded = false;
                 $obj->leaf = false;
                 $list[] = $obj;
             }
         }
         if (!empty($pfiles)) {
             sort($pfiles);
             foreach ($pfiles as $k => $fpath) {
                 $text = basename($fpath);
                 $obj = new stdClass();
                 $obj->id = str_replace($this->_configMain->get('docroot'), './', $fpath);
                 $obj->text = $text;
                 $obj->leaf = true;
                 $list[] = $obj;
             }
         }
     }
     if ($path == '') {
         if ($this->_configMain->get('allow_externals')) {
             $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
             $eExpert = new Externals_Expert($this->_configMain, $config);
             $extProjects = $eExpert->getProjects();
             if (!empty($extProjects)) {
                 foreach ($extProjects as $item) {
                     $list[] = $item;
                 }
             }
         }
     }
     Response::jsonArray($list);
 }