Example #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;
 }
Example #2
0
 /**
  * creates singleton instance for this class passing options to constructor
  *
  * @error 11102
  * @param null|mixed $options expects valid option object
  * @return null|XApp_VFS_Local
  */
 public static function instance($options = null)
 {
     if (self::$_instance === null) {
         self::$_instance = new self($options);
     }
     return self::$_instance;
 }
Example #3
0
 /**
  * @param string $mount
  * @throws Exception
  */
 private function createFileSystem($mount = '')
 {
     $_fs = xapp_get_option(self::FILE_SYSTEM);
     //file system class
     //VFS instance already included
     if (is_object($_fs)) {
         $this->_vfs = $_fs;
     } elseif (is_string($_fs)) {
         //class name of the VFS
         if (class_exists($_fs)) {
             /***
              * prepare file system options
              */
             $fsOptions = xapp_has_option(self::FILE_SYSTEM_CONF) ? xapp_get_option(self::FILE_SYSTEM_CONF) : array();
             if ($fsOptions && is_array($fsOptions)) {
                 //There is no mapping data in the VFS config, but we have a path to the mappings
                 if (!xapp_has_option(XApp_VFS_Base::RESOURCES_DATA, $fsOptions) && xapp_has_option(self::VFS_CONFIG_PATH)) {
                     $vfsMappingPath = xapp_get_option(self::VFS_CONFIG_PATH);
                     if (file_exists($vfsMappingPath)) {
                         $pass = null;
                         if (xapp_has_option(self::VFS_CONFIG_PASSWORD)) {
                             $pass = xapp_get_option(self::VFS_CONFIG_PASSWORD);
                         } else {
                         }
                         $vfsMappingData = (object) XApp_Utils_JSONUtils::read_json($vfsMappingPath, 'json', false, true, null, true, $pass);
                         if ($vfsMappingData) {
                             $fsOptions[XApp_VFS_Base::RESOURCES_DATA] = $vfsMappingData;
                         }
                     }
                 }
             }
             $remoteConfig = null;
             //switch to remove file system if needed
             if (strlen($mount) > 0) {
                 $remoteConfig = XApp_VFS_Local::isRemote($mount, $fsOptions[XApp_VFS_Base::RESOURCES_DATA]);
                 if ($remoteConfig != null) {
                     xapp_import('xapp.VFS.Remote');
                     $_fs = 'XApp_VFS_Remote';
                 } else {
                 }
             }
             $this->_vfs = $_fs::instance($fsOptions);
             $this->_vfs->{'remote'} = $remoteConfig != null;
             if ($remoteConfig) {
                 $this->_vfs->initWithResource($remoteConfig);
             }
         } else {
             throw new Exception('VFS Class doesnt exists : ' . $_fs);
         }
     }
 }