* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBEvent_Handler'); /** * WBEvent_Handler_TableNLSAddWord * * Adds words to NLS module on save * * @version 1.0.0 * @package Wombat * @subpackage base */ class WBEvent_Handler_TableNLSAddWord extends WBEvent_Handler { /** * table access * @var WBDatasource_Table */ static private $table; /** * text importer * @var patI18n_Importer */ static private $imp; /** * handler config * * - table name of table to update * * @var array */ protected $config = array( 'table' => '', ); /** * Import translatable strings * * Select all translatable columns and call import for each of them. * * @param WBEvent $e * @return bool true to continue, false to stop processing * @throws Exception in case of error */ public function process(WBEvent $e) { $table = $this->config['table']; if (empty($this->config['table'])) { $table = $e->get('table'); } $save = $e->get('save'); if (empty($save)) { return true; } if (!self::$table) { self::$table = WBClass::create('WBDatasource_Table'); self::$table->switchTranslation(false); } $info = self::$table->getTableInfo($table); if (!isset($info['translatable']) || empty($info['translatable'])) { return true; } foreach ($info['translatable'] as $t) { if (!isset($save[$t]) || empty($save[$t])) { continue; } $this->createImporter(); self::$imp->addMsg($save[$t]); } return true; } /** * Initialize importer * * Load locale config and create patI18n_Importer_Wombat */ private function createImporter() { if (self::$imp) { return; } self::$imp = WBClass::create('patI18n_Importer'); } }