/** * Class constructor * @param String $language * @return Void */ public function __construct($language = null) { // If no language is given, try to read from the Registry if (!$language) { $language = Garp_I18n::getCurrentLocale(); } if (!$language) { throw new Garp_I18n_Exception('No language found! Make sure at least one language is available.'); } $this->setLanguage($language); }
/** * @param String $model_name (not prefixed) * @param Garp_Db_Table_Row|Int $record The record on which the alternative is based, * or the id thereof. * @param String $foreign_key Foreign key column to the parent table * @return Array * @todo Make it work with various other parameters, not just 'slug' */ public function direct($model_name, $foreign_key, $record, $default_to_same_slug = true) { $record_id = $record; if ($record instanceof Garp_Db_Table_Row) { $record_id = $record_id->id; } // Add the slugs of the group in alternate languages for the language picker $alt_param_slug = null; if ($default_to_same_slug && $record instanceof Garp_Db_Table_Row) { $alt_param_slug = $record->slug; } $alternate_url_params = array_fill_keys(Garp_I18n::getLocales(), array('slug' => $alt_param_slug)); $model_name = 'Model_' . $model_name . 'I18n'; $i18n_model = new $model_name(); $select = $i18n_model->select()->from($i18n_model->getName(), array('slug', 'lang'))->where("{$foreign_key} = ?", $record_id)->where('lang != ?', Garp_I18n::getCurrentLocale()); $localized_recordset = $i18n_model->fetchAll($select); foreach ($localized_recordset as $record) { $alternate_url_params[$record->lang] = array('slug' => $record->slug); } return $alternate_url_params; }
protected function _setCmsClosedMessage() { $config = Zend_Registry::get('config'); if (!isset($config->cms->closed) || !$config->cms->closed) { return; } $this->view->isClosed = true; try { $snippetModel = new Model_Snippet(); if ($snippetModel->isMultilingual()) { $snippetModel = instance(new Garp_I18n_ModelFactory())->getModel('Snippet'); } $snippet = $snippetModel->fetchByIdentifier('cms closed message'); $cmsClosedMessage = $snippet->html; if (isset($cmsClosedMessage[Garp_I18n::getCurrentLocale()])) { $cmsClosedMessage = $cmsClosedMessage[Garp_I18n::getCurrentLocale()]; } $this->view->cmsClosedMessage = $cmsClosedMessage; } catch (Exception $e) { throw $e; $this->view->cmsClosedMessage = '<p>The CMS is closed.</p>'; } }