/** * Scan for handler classes in defined directories * * @return void */ protected static function _initialize() { $ini = eZINI::instance('hwimport.ini'); $handlerDirs = $ini->variable('Handlers', 'HandlerDirs'); require_once dirname(__FILE__) . '/HwImport/Handler/Interface.php'; require_once dirname(__FILE__) . '/HwImport/Handler/Abstract.php'; $baseDir = dirname(__FILE__) . '/../../../'; foreach ($handlerDirs as $handlerDir) { $dir = realpath($baseDir . $handlerDir); $list = scandir($dir); foreach ($list as $file) { if ($file != 'Interface.php' && $file != 'Abstract.php') { if (substr($file, strlen($file) - 4) == '.php') { require_once $dir . '/' . $file; } } } } self::$_initialized = true; }
$user = eZUser::fetch($options['userid']); if (!$user) { $cli->error("Invalid user"); $script->shutdown(1); } // Fetch parent node $parentNode = eZContentObjectTreeNode::fetch($options['parentnode']); if (!$parentNode instanceof eZContentObjectTreeNode) { $cli->error('Parent node not found'); $script->shutdown(1); } // Init handler if (substr($options['data'], 0, 1) == '/') { $datafile = $options['data']; } else { $datafile = realpath(dirname(__FILE__) . '/../../' . $options['data']); } try { $handler = HwImport::factory($options['handler']); $handler->setDatafile($datafile); $handler->setCli($cli); $handler->setUser($user); $handler->setParentNode($parentNode); $handler->setOffset($offset); $handler->setLimit($limit); $handler->run(); } catch (HwImport_Exception $e) { $cli->error($e->getMessage()); $script->shutdown(1); } $script->shutdown();