/** * Load translation data * * @param string|array $data * @param string $locale Locale/Language to add data for, identical with locale identifier, * see Zend_Locale for more information * @param array $options OPTIONAL Options to use * @return array */ protected function _loadTranslationData($data, $locale, array $options = array()) { $data = array(); try { $i18nModelFactory = new Garp_I18n_ModelFactory($locale); $snippetModel = $i18nModelFactory->getModel('Snippet'); $out = array(); $data = $snippetModel->fetchAll($snippetModel->select()->from($snippetModel->getName(), array('identifier', 'text' => new Zend_Db_Expr('IF(text IS NULL, IF(name IS NULL, identifier, name), text)')))->where('has_text = ?', 1)->orWhere('has_name = ?', 1)->order('identifier ASC')); $data = $this->_reformatData($data); } catch (Zend_Db_Adapter_Exception $e) { Garp_ErrorHandler::handlePrematureException($e); } $out[$locale] = $data; return $out; }
/** * Create a unique token for the currently logged in user. * @param String $input Serialized user data * @return String */ public function createToken($input) { $config = $this->getConfigValues(); $salt = $config['salt']; $token = ''; $token .= !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $token .= md5($input); $token .= md5($salt); /** * Embed an outline of the User table columns in the token. That way, whenever the * database changes, all current cookies are made invalid and users have to generate a * new cookie afresh by logging in. * This ensures the user cookies always contains all the columns. */ $columns = ''; try { $userModel = new Model_User(); $columns = $userModel->info(Zend_Db_Table_Abstract::COLS); $columns = implode('.', $columns); } catch (Zend_Db_Adapter_Exception $e) { Garp_ErrorHandler::handlePrematureException($e); } $token .= $columns; $token = md5($token); return $token; }