public function beforeFilter() { SlConfigure::setCollections(); if (isset($this->data[$this->modelClass]['id'])) { $this->id = $this->data[$this->modelClass]['id']; } elseif (isset($this->params['pass'][0])) { $this->id = $this->params['pass'][0]; } if (!empty($this->params['named']['ref'])) { SlSession::write('Routing.ref', base64_decode($this->params['named']['ref'])); } // Make AJAX errors and warnings readable if (class_exists('Debugger')) { if ($this->RequestHandler->isAjax()) { Debugger::output('base'); } } // update current language if (!empty($this->params['named']['lang'])) { $this->params['lang'] =& $this->params['named']['lang']; } if (!empty($this->params['lang'])) { Sl::setLocale($this->params['lang'], true); } $languages = SlConfigure::read('I18n.languages'); $currLang = SlConfigure::read('I18n.lang'); $languageLinks = array(); foreach ($languages as $lang => $language) { $languageLinks[$lang] = array('title' => $language, 'active' => $lang == $currLang, 'url' => am($this->passedArgs, array('action' => $this->action, 'lang' => $lang))); } SlConfigure::write('Navigation.languages', $languageLinks); }
/** * * @param AppModel $model */ public function refreshMirror($model, $checkPendingOperations = false) { if ($checkPendingOperations) { if ($this->_pending[$model->alias] > 0) { return; } $this->_pending[$model->alias] = 0; } $config = $this->settings[$model->alias]; if ($model->Behaviors->enabled('Translate')) { if ($config['findOptions']['recursive'] >= 0 || $model->Behaviors->Translate->settings[$model->alias]) { $oldLang = SlConfigure::read('I18n.lang'); $locales = SlConfigure::read('I18n.locales'); $localesPreg = '/_' . implode('$|_', $locales) . '$/'; foreach ($locales as $lang => $locale) { Sl::setLocale($lang); $data = $model->find($config['findType'], $config['findOptions']); if ($config['collectionField']) { $this->_cleanup($config['name'], $locale); } $this->_write($config['name'], $this->_prepareData($model, $config, $data, $localesPreg), $locale); } Sl::setLocale($oldLang); return; } } $data = $model->find($config['findType'], $config['findOptions']); if ($config['collectionField']) { $this->_cleanup($config['name']); } $this->_write($config['name'], $this->_prepareData($model, $config, $data)); }
protected static function _load() { self::$_loaded = true; // load core configurations self::load('default.php'); // load extensions' configurations SlExtensions::getInstance(); if (!self::load('site.php')) { self::load('site.sample.php'); $isHtml = isset($_GET['url']) && !preg_match('!(^|/)(js|css|img)/|\\.(rss|xml|atom)|/isAjax:1$!', '/' . $_GET['url']); if (!Configure::read() && $isHtml && env('HTTP_X_REQUESTED_WITH') !== "XMLHttpRequest") { self::write('Message.noConfig', '<b>Site configuration file not found!</b><br />Please create <em>/app/config/site.php</em>. You may use <em>/app/config/site.sample.php</em> as a template.'); } } self::$_persistentData = self::load(TMP . 'sl_configuration.php'); if (SlSession::started()) { self::$_data['session'] =& SlSession::$data; } SlCookie::ready(); self::setCollections(); Sl::setLocale(); // If you are on PHP 5.3 correct your server timezone to fix the date & time related errors. $tz = self::read('I18n.options.timeZone'); if ($tz) { date_default_timezone_set($tz); } }