* @license PHP License * @package WB * @subpackage base */ //WBClass::load('WBNLS'); /** * Native Lanauge Support: Extractor * * * @version 1.0.0 * @package WB * @subpackage nls */ class WBNLS_Extractor extends WBStdClass { /** * text importer * @var patI18n_Importer */ protected $imp; /** * list of extraction errors * @var array */ protected $errors = array(); /** * Default configuration * * @var array */ protected $config = array(); /** * constructor * * Start importer */ public function __construct() { //$this->imp = WBClass::create('patI18n_Importer'); } public function setImporter($imp) { $this->imp = $imp; } /** * Configure * * Merge default config with paramter * * @param array $config */ public function configure($config) { if (!is_array($config)) { return; } $this->config = array_merge($this->config, $config); } /** * Set opratation mode * * @see patI18n_Importer_Wombat::setMode() * @param string $mode either MODE_IMPORT or MODE_ORPHANCHECK */ public function setMode($mode = patI18n_Importer_Wombat::MODE_IMPORT) { $this->imp->setMode($mode); } /** * Mark message or messages as orphans * * @see patI18n_Importer_Wombat::markOrphan() * @param string $id or -1 for all * @param string text domain or null for all */ public function markOrphan($id = -1, $domain = null) { $this->imp->markOrphan($id, $domain); } /** * get collected errors * * @param bool $flush * @return array */ final public function getErrors($flush = false) { $errors = $this->errors; if ($flush) { $this->errors = array(); } return $errors; } /** * add error to collection * * @param array $error */ final protected function addError($error) { $this->errors[] = $error; } /** * run extrator * * Template method to run actual extractor. * Call onStart(), extract() and onEnd() * @see onStart() * @see extract() * @see onEnd() */ final public function run() { $this->onStart(); $cnt = $this->extract(); $this->onEnd(); return $cnt; } /** * setup extractor * * Implement concrete behaviour in child classes */ protected function onStart() { } /** * actually extract messages * * Implement concrete behaviour in child classes */ protected function extract() { } /** * tear down extractor * * Implement concrete behaviour in child classes */ protected function onEnd() { } } ?>