* @license PHP License * @package WB * @subpackage base */ WBClass::load( 'WBCli' ); /** * Command Line Interface class: VFS_Importer * * * @version 0.1.0 * @package WB * @subpackage base */ class WBCli_VFS_Importer extends WBCli { /** * Command line arguments * @var array */ protected $arguments = array( 'des' => array( 'short' => 'd', 'max' => 1, 'min' => 0, 'default' => '', 'desc' => 'destination folder', ), 'user' => array( 'short' => 'u', 'max' => 1, 'min' => 1, 'default' => '', 'desc' => 'owning user', ), CONSOLE_GETARGS_PARAMS => array( 'min' => 1, 'max' => -1, 'default' => '', 'desc' => 'files to import', ) ); /** * VFS File * @var VFS_File */ private $file; /** * VFS Explorer * @var VFS_Explorer */ private $expl; /** * 2nd constructor * * @see include/WB/WBCli#init() */ protected function init() { } /** * execute programme * * Use observer and execute event queue */ protected function execute() { $user = $this->args->getValue('user'); if (empty($user)) { $this->pl('User id required'); return false; } $this->pvl('User: ' . $user); $des = $this->args->getValue('des'); $this->pvl('Destination: ' . $des); $this->startVFS($user, $des); foreach ($this->commands as $file) { $name = basename($file); $this->file = $this->file->import($file, $name, true); $this->pl($this->file->getObscureId() . ' ' . $name); } return 0; } private function startVFS($user, $des) { $param = array( 'user' => $user ); $this->file = WBClass::create('WBVFS_File', $param); $this->expl = WBClass::create('WBVFS_Explorer', $param); $this->file->switchTranslation(false); $this->expl->switchTranslation(false); if (!empty($des)) { $this->file->setCurrentDir($des); } } }