public function build() { if (!\Sifo\Domains::getInstance()->getDevMode()) { throw new \Sifo\Exception_404('Translation only available while in devel mode'); } $filter = \Sifo\Filter::getInstance(); // Get instance name. $params = $this->getParams(); $instance = $this->instance; if (isset($params['params'][0])) { $instance = $params['params'][0]; } $lang = $filter->getString('lang'); $given_translation = $filter->getUnfiltered('translation'); $id_message = $filter->getString('id_message'); $translator_email = !isset($user['email']) ? '' : $user['email']; if ($given_translation) { // TODO: REMOVE this: Temporal fix until magic quotes is disabled: $given_translation = str_replace('\\', '', $given_translation); $query = 'REPLACE i18n_translations (id_message, lang, translation,author,instance) VALUES(?,?,?,?,?);'; $result = \Sifo\Database::getInstance()->Execute($query, array($id_message, $lang, $given_translation, $translator_email, $instance)); if ($result) { return array('status' => 'OK', 'msg' => 'Successfully saved'); } } return array('status' => 'KO', 'msg' => 'Failed to save the translation'); }
public function build() { $this->setLayout('manager/findi18n.tpl'); if (!\Sifo\Domains::getInstance()->getDevMode()) { throw new \Sifo\Exception_404('Translation only available while in devel mode'); } $post = \Sifo\Filter::getInstance(); $available_instances = $this->getFileSystemFiles('instances', true); $locales_available = array(); foreach ($available_instances as $inst) { $locales_available[$inst] = $this->getFilesystemFiles("instances/{$inst}/locale"); } $this->assign('instances', $available_instances); $this->assign('locales', $locales_available); $charset = $post->getString('charset'); $this->assign('charset', $charset ? $charset : 'utf-8'); $this->assign('instance', 'common'); if ($post->isSent('instance')) { $instance = $post->getString('instance'); $locale = $post->getString('locale'); $temp_lang = explode('_', $locale); $this->assign('language', $temp_lang[1]); $literals = $this->getLiterals($instance); $this->assign('literals', $literals); $path = \Sifo\Bootstrap::$application . "/{$instance}"; $translations_file = "{$path}/locale/{$locale}"; if (file_exists($translations_file)) { include "{$translations_file}"; $missing = array(); foreach ($literals as $key => $relative_path) { if (!isset($translations[$key])) { $missing[$key] = $relative_path; } } $this->assign('missing', $missing); $this->assign('instance', $instance); $this->assign('locale', $locale); } else { $this->assign('error', "File {$locale} not available for <strong>{$instance}</strong>"); } } }
public function build() { if (true !== \Sifo\Domains::getInstance()->getDevMode()) { throw new \Sifo\Exception_404('User tried to access the rebuild page, but he\'s not in development'); } $get = \Sifo\FilterGet::getInstance(); if ($this->_selected_template = $get->getString('template')) { $this->assign('selected_template', $this->_selected_template); } $post = \Sifo\Filter::getInstance(); if ($post_elems = $post->getRawRequest()) { if (!$this->_selected_template) { trigger_error('Template identifier not found in the current url.', E_USER_ERROR); } $this->setLayout($this->_selected_template); foreach ($post_elems as $key => $elem) { if (!empty($elem)) { $elem = false !== stripos($elem, 'array') ? $elem : "'{$elem}'"; eval('$var = ' . $elem . ';'); // Usefull for $var=dummy and $var=array('k'=>'v'); $this->assign($key, $var); } } } else { $this->setLayout('manager/tpl_launcher.tpl'); $this->_available_templates = $this->getAvailableTemplates(); if (empty($this->_available_templates)) { trigger_error("Templates config files is empty. Your instance hasn't available templates yet.", E_USER_WARNING); } $this->assign('available_templates', array_keys($this->_available_templates)); if ($this->_selected_template) { $used_vars = $this->_getRequiredVars($this->_selected_template); $this->assign('used_vars', $used_vars); } } }