Exemple #1
0
 public function ls($path = null)
 {
     xapp_import('xapp.Directory.Utils');
     xapp_import('xapp.VFS.Local');
     //we listen to VFS messages
     Xapp_Hook::connect(XApp_VFS_Base::EVENT_ON_NODE_META_CREATED, $this, "_onItem");
     Xapp_Hook::connect(XApp_VFS_Base::EVENT_ON_NODE_ADD, $this, "_addNode");
     //create a single scope for now
     //prepare vfs
     $vfsItems = array();
     //mount one item at root, the system scope.
     $vfsItems[] = array('name' => 'root', 'path' => $path . DIRECTORY_SEPARATOR);
     //vfs ctor
     $this->_vfs = XApp_VFS_Local::factory($vfsItems);
     //vfs dir scanning options
     $directoryOptions = array(XApp_Directory_Utils::OPTION_ONLY_DIRS => false, XApp_Directory_Utils::OPTION_ONLY_FILES => false, XApp_Directory_Utils::OPTION_RECURSIVE => true, XApp_Directory_Utils::OPTION_CLEAR_PATH => true);
     //prepare result
     $this->_currentNodes = array();
     $this->_currentNodes['items'] = array();
     //fire vfs
     $items = $this->_vfs->ls('root/', true, array(XApp_File_Utils::OPTION_DIR_LIST_FIELDS => XAPP_XFILE_SHOW_ISDIR, XApp_File_Utils::OPTION_DIR_LIST => $directoryOptions, XApp_Directory_Utils::OPTION_INCLUDE_LIST => array('*')));
     //complete tree-store data
     $this->_currentNodes['identifier'] = 'path';
     $this->_currentNodes['label'] = 'name';
     return $this->_currentNodes;
 }