This file is part of AgenDAV. AgenDAV is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. AgenDAV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with AgenDAV. If not, see .
Наследование: extends CI_Model
 /**
  * Parses a specified page ID and redirects to another ID if required.
  * 
  * @param WebSoccer $websoccer Website context.
  * @param I18n $i18n messages provider.
  * @param string $requestedPageId unfiltered Page ID that has been requested.
  * @return string target page ID to display.
  */
 public static function getTargetPageId(WebSoccer $websoccer, I18n $i18n, $requestedPageId)
 {
     $pageId = $requestedPageId;
     // set default page ID
     if ($pageId == NULL) {
         $pageId = DEFAULT_PAGE_ID;
     }
     // redirect to log-in form if website is generally protected
     $user = $websoccer->getUser();
     if ($websoccer->getConfig('password_protected') && $user->getRole() == ROLE_GUEST) {
         // list of page IDs that needs to be excluded.
         $freePageIds = array(LOGIN_PAGE_ID, 'register', 'register-success', 'activate-user', 'forgot-password', 'imprint', 'logout', 'termsandconditions');
         if (!$websoccer->getConfig('password_protected_startpage')) {
             $freePageIds[] = DEFAULT_PAGE_ID;
         }
         if (!in_array($pageId, $freePageIds)) {
             // create warning message
             $websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_WARNING, $i18n->getMessage('requireslogin_box_title'), $i18n->getMessage('requireslogin_box_message')));
             $pageId = LOGIN_PAGE_ID;
         }
     }
     // exception rule: If user clicks at breadcrumb navigation on team details, there will be no ID given, so redirect to leagues
     if ($pageId == 'team' && $websoccer->getRequestParameter('id') == null) {
         $pageId = 'leagues';
     }
     // prompt user to enter user name, after he has been created without user name (e.g. by a custom LoginMethod).
     if ($user->getRole() == ROLE_USER && !strlen($user->username)) {
         $pageId = ENTERUSERNAME_PAGE_ID;
     }
     return $pageId;
 }
Пример #2
0
 public static function formatCompactAddress($data, $locale = null)
 {
     if (!isset($locale)) {
         $locale = Locale::getLocale();
     }
     $i18n = new I18n();
     return self::_formatAddress($i18n->getAddressFormat($locale), $data, ' - ');
 }
Пример #3
0
 public static function forceClearance($roles, $user, $params = array(), $error = 'error.insufficient_rights')
 {
     $app_url = Settings::getProtected('app_url');
     $i18n = new I18n("../translations", Settings::getProtected('language'));
     if (!self::verify($roles, $user, $params)) {
         Utils::redirectToDashboard('', $i18n->t($error));
         return false;
     }
     return true;
 }
Пример #4
0
 /**
  * Read Metadata from xml array
  * @param array $xmlArr
  */
 protected function readMetadata(&$xmlArr)
 {
     parent::readMetaData($xmlArr);
     $this->m_InheritFrom = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["INHERITFROM"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["INHERITFROM"] : null;
     $this->m_Title = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["TITLE"]) ? I18n::getInstance()->translate($xmlArr["BIZFORM"]["ATTRIBUTES"]["TITLE"]) : null;
     $this->m_Description = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["DESCRIPTION"]) ? I18n::getInstance()->translate($xmlArr["BIZFORM"]["ATTRIBUTES"]["DESCRIPTION"]) : null;
     //added by Jixian
     $this->m_SearchRule = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["SEARCHRULE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["SEARCHRULE"] : null;
     $this->m_BaseSearchRule = $this->m_SearchRule;
     $this->m_jsClass = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["JSCLASS"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["JSCLASS"] : null;
     $this->m_Height = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["HEIGHT"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["HEIGHT"] : null;
     $this->m_Width = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["WIDTH"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["WIDTH"] : null;
     $this->m_Range = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["PAGESIZE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["PAGESIZE"] : null;
     $this->m_FullPage = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["FULLPAGE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["FULLPAGE"] : null;
     $this->m_Stateless = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["STATELESS"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["STATELESS"] : null;
     $this->m_Style = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["STYLE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["STYLE"] : 'display: block';
     //Get the style of a form from xml --jmmz
     $this->m_Name = $this->prefixPackage($this->m_Name);
     $this->m_DataObjName = $this->prefixPackage($xmlArr["BIZFORM"]["ATTRIBUTES"]["BIZDATAOBJ"]);
     $this->m_DisplayModes = new MetaIterator($xmlArr["BIZFORM"]["DISPLAYMODES"]["MODE"], "DisplayMode");
     $this->m_RecordRow = new RecordRow($xmlArr["BIZFORM"]["BIZCTRLLIST"]["BIZCTRL"], "FieldControl", $this);
     $this->m_ToolBar = new ToolBar($xmlArr["BIZFORM"]["TOOLBAR"]["CONTROL"], "HTMLControl", $this);
     $this->m_NavBar = new NavBar($xmlArr["BIZFORM"]["NAVBAR"]["CONTROL"], "HTMLControl", $this);
     $this->m_Parameters = new MetaIterator($xmlArr["BIZFORM"]["PARAMETERS"]["PARAMETER"], "Parameter");
 }
Пример #5
0
 public function before()
 {
     parent::before();
     // Borrowed from userguide
     if (isset($_GET['lang'])) {
         $lang = $_GET['lang'];
         // Make sure the translations is valid
         $translations = Kohana::message('langify', 'translations');
         if (in_array($lang, array_keys($translations))) {
             // Set the language cookie
             Cookie::set('langify_language', $lang, Date::YEAR);
         }
         // Reload the page
         $this->request->redirect($this->request->uri());
     }
     // Set the translation language
     I18n::$lang = Cookie::get('langify_language', Kohana::config('langify')->lang);
     // Borrowed from Vendo
     // Automaticly load a view class based on action.
     $view_name = $this->view_prefix . Request::current()->action();
     if (Kohana::find_file('classes', strtolower(str_replace('_', '/', $view_name)))) {
         $this->view = new $view_name();
         $this->view->set('version', $this->version);
     }
 }
Пример #6
0
 /**
  * Application initialization
  *     - Loads the plugins
  *     - Sets the cookie configuration
  */
 public static function init()
 {
     // Set defaule cache configuration
     Cache::$default = Kohana::$config->load('site')->get('default_cache');
     try {
         $cache = Cache::instance()->get('dummy' . rand(0, 99));
     } catch (Exception $e) {
         // Use the dummy driver
         Cache::$default = 'dummy';
     }
     // Load the plugins
     Swiftriver_Plugins::load();
     // Add the current default theme to the list of modules
     $theme = Swiftriver::get_setting('site_theme');
     if (isset($theme) and $theme != "default") {
         Kohana::modules(array_merge(array('themes/' . $theme->value => THEMEPATH . $theme->value), Kohana::modules()));
     }
     // Clean up
     unset($active_plugins, $theme);
     // Load the cookie configuration
     $cookie_config = Kohana::$config->load('cookie');
     Cookie::$httponly = TRUE;
     Cookie::$salt = $cookie_config->get('salt', Swiftriver::DEFAULT_COOKIE_SALT);
     Cookie::$domain = $cookie_config->get('domain') or '';
     Cookie::$secure = $cookie_config->get('secure') or FALSE;
     Cookie::$expiration = $cookie_config->get('expiration') or 0;
     // Set the default site locale
     I18n::$lang = Swiftriver::get_setting('site_locale');
 }
Пример #7
0
 public function get_available_langs()
 {
     $langs = I18n::available_langs();
     $system_default = Arr::get($langs, Config::get('site', 'default_locale'));
     $langs[Model_User::DEFAULT_LOCALE] = __('System default (:locale)', array(':locale' => $system_default));
     return $langs;
 }
Пример #8
0
 private static function runlevel3(){
     Logger::enter_group('Runlevel 4');
     Logger::debug('Loading Application-Variables');
     require_once(APP_ROOT . '/defaults.php');
     I18n::load();
     Logger::leave_group();
 }
Пример #9
0
 public function getDefaultLangName($lang = null)
 {
     if ($lang == null) {
         $do = BizSystem::getObject("myaccount.do.PreferenceDO", 1);
         $rec = $do->fetchOne("[user_id]='0' AND [name]='language'");
         if ($rec) {
             $lang = $rec['value'];
         } else {
             $lang = DEFAULT_LANGUAGE;
         }
     }
     $current_locale = I18n::getCurrentLangCode();
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale($current_locale);
     $display_name = Zend_Locale::getTranslation($lang, 'language', $locale);
     if ($display_name) {
         return $display_name;
     } else {
         if ($lang) {
             return $lang;
         } else {
             return DEFAULT_LANGUAGE;
         }
     }
 }
Пример #10
0
 public function before()
 {
     parent::before();
     I18n::lang('ru');
     Cookie::$salt = 'eqw67dakbs';
     Session::$default = 'cookie';
     //$this->cache = Cache::instance('file');
     $this->session = Session::instance();
     $this->auth = Auth::instance();
     $this->user = $this->auth->get_user();
     //  $captcha = Captcha::instance();
     // Подключаем стили и скрипты
     $this->template->styles = array();
     $this->template->scripts = array();
     //Вывод в шаблон
     $this->template->title = null;
     $this->template->site_name = null;
     $this->template->description = null;
     $this->template->page_title = null;
     //Подключаем главный шаблон
     $this->template->main = null;
     $this->template->userarea = null;
     $this->template->top_menu = View::factory('v_top_menu');
     $this->template->manufactures = null;
     $this->template->left_categories = null;
     $this->template->slider_banner = null;
     $this->template->block_left = array();
     $this->template->block_center = array();
     $this->template->block_right = array();
     $this->template->block_footer = null;
 }
Пример #11
0
 public function Index()
 {
     if ($this->request->isPost()) {
         if (Config::$authentication['authentication']) {
             $server = isset(Config::$server['server']) && !empty(Config::$server['server']) ? Config::$server['server'] : Config::$server['host'] . ':' . Config::$server['port'];
             $db = $this->request->getParam('db');
             $options = array('username' => $this->request->getParam('username'), 'password' => $this->request->getParam('password'), 'db' => !empty($db) ? $db : 'admin');
             $mongo = PHPMongoDB::getInstance($server, $options);
             if ($mongo->getConnection()) {
                 $seesion = Application::getInstance('Session');
                 $seesion->isLogedIn = TRUE;
                 $seesion->server = $server;
                 $seesion->options = $options;
                 $this->request->redirect(Theme::URL('Index/Index'));
             } else {
                 $this->message->error = $mongo->getExceptionMessage();
             }
         } else {
             if ($this->request->getParam('username') == Config::$authentication['user'] && $this->request->getParam('password') == Config::$authentication['password']) {
                 $server = isset(Config::$server['server']) && !empty(Config::$server['server']) ? Config::$server['server'] : Config::$server['host'] . ':' . Config::$server['port'];
                 $seesion = Application::getInstance('Session');
                 $seesion->isLogedIn = TRUE;
                 $seesion->server = $server;
                 $seesion->options = array();
                 $this->request->redirect(Theme::URL('Index/Index'));
             } else {
                 $this->message->error = I18n::t('AUTH_FAIL');
             }
         }
     }
     $data = array();
     $this->display('index', $data);
 }
Пример #12
0
 public static function setup()
 {
     language::$available_languages = Kohana::config('locale.languages');
     if (Router::$language === NULL) {
         $redirect = NULL;
         if (empty(Router::$current_uri)) {
             if (($lang = language::browser_language()) !== '') {
                 $redirect = $lang;
             } else {
                 reset(language::$available_languages);
                 $redirect = key(language::$available_languages);
             }
         } else {
             if (($lang = language::browser_language()) !== '') {
                 $redirect = $lang . '/' . Router::$current_uri;
             } else {
                 reset(language::$available_languages);
                 $redirect = key(language::$available_languages) . '/' . Router::$current_uri;
             }
         }
         url::redirect($redirect);
     }
     Kohana::config_set('locale.language', language::$available_languages[Router::$language]['language']);
     I18n::$lang = language::$available_languages[Router::$language]['language'][0];
 }
Пример #13
0
 public function before()
 {
     parent::before();
     $lang = $this->request->param('lang');
     // Make sure we have a valid language
     if (!in_array($lang, array_keys(Kohana::config('kohana')->languages))) {
         $this->request->action = 'error';
         throw new Kohana_Request_Exception('Unable to find a route to match the URI: :uri (specified language was not found in config)', array(':uri' => $this->request->uri));
     }
     I18n::$lang = $lang;
     if (isset($this->page_titles[$this->request->action])) {
         // Use the defined page title
         $title = $this->page_titles[$this->request->action];
     } else {
         // Use the page name as the title
         $title = ucwords(str_replace('_', ' ', $this->request->action));
     }
     $this->template->title = $title;
     if (!kohana::find_file('views', 'pages/' . $this->request->action)) {
         $this->request->action = 'error';
     }
     $this->template->content = View::factory('pages/' . $this->request->action);
     $this->template->set_global('request', $this->request);
     $this->template->meta_tags = array();
 }
Пример #14
0
 /**
  * string setLanguage(string $lang = "")
  *
  * Sets a language to locale options
  *
  * @param string $lang (optional)
  * @return string new language setted
  * @access public
  * @static
  * @see OPEN_LANG_DEFAULT
  */
 public static function setLanguage($lang = "")
 {
     $newLang = OPEN_LANG_DEFAULT;
     if (empty($lang)) {
         // Detect Browser Language
         if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
             $language = explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
             $langPieces = explode("-", $language[0]);
             if (strlen($language[0]) == 2) {
                 $browserLanguage = $language[0] . "_" . strtoupper($language[0]);
             } else {
                 $browserLanguage = strtolower($langPieces[0]) . "_" . strtoupper($langPieces[1]);
             }
             if (self::languageExists($browserLanguage)) {
                 $newLang = $browserLanguage;
             }
         }
     } else {
         if (self::languageExists($lang)) {
             $newLang = $lang;
         }
     }
     putenv("LANG=" . $newLang);
     //setlocale(LC_ALL, $newLang);
     $nls = I18n::getNLS();
     if (defined("PHP_OS") && preg_match("/win/i", PHP_OS)) {
         setlocale(LC_ALL, isset($nls['win32'][$newLang]) ? $nls['win32'][$newLang] : $newLang);
     } else {
         setlocale(LC_ALL, $newLang);
     }
     return $newLang;
 }
 protected function getContent()
 {
     $content = '<ol class="breadcrumb">
               <li><a href="' . ROOT_DIR . 'admin/courseadmin">' . I18n::t('courseoverview.title') . '</a></li>
               <li><a href="' . ROOT_DIR . 'admin/lessonadmin/' . $this->course->getId() . '">' . $this->course->getName(I18n::getLang()) . '</a></li>
               <li class="active">' . $this->lesson->getName(I18n::getLang()) . '</li>
             </ol>';
     $content .= '<form method="post"><input type="hidden" name="action" value="saveExercises" />
 <table id="exercise-admin-table" class="table table-hover">
 <thead>
 <tr>
 <th>' . I18n::t('admin.exerciseadmin.question') . '</th>
 <th>' . I18n::t('admin.exerciseadmin.answer') . ' (EN)</th>
 <th>' . I18n::t('admin.exerciseadmin.answer') . ' (DE)</th>
 <th>&nbsp;</th>
 </tr>
 </thead>
 <tbody>';
     foreach ((array) Exercise::getMultipleExercises($this->lesson->getId(), 50, 0) as $exercise) {
         $content .= '<tr><input type="hidden" name="exercise_id[]" value="' . $exercise->getId() . '" />
   <td><input type="text" name="question[]" value="' . $exercise->getQuestion() . '" /></td>
   <td><input type="text" name="answer_en[]" value="' . $exercise->getAnswer('en') . '" /></td>
   <td><input type="text" name="answer_de[]" value="' . $exercise->getAnswer('de') . '" /></td>
   </tr>';
     }
     $content .= '</tbody>
 </table>
 <table width="100%">
 <tr><td width="50%" align="left"><button id="exercise-add-btn" class="btn btn-default" type="button">' . I18n::t('button.add') . '</button></td>
 <td width="50%" align="right"><input type="submit" class="btn btn-default" value="' . I18n::t('button.save') . '" /></td></tr>
 </table>
 </form>';
     return $content;
 }
Пример #16
0
 public function action_index()
 {
     /*
     $lbl = array();
     $lbl['cancel'] = __('Cancel');
     $lbl['import_loading_text'] = __('Importing new files.');
     
     $lbl['login'] = __('Login');
     $lbl['username'] = __('Username');
     $lbl['password'] = __('Password');
     $lbl['remember'] = __('Remember me');
     
     $lbl['validator_messages']["required"] = __("This field is required.");
     		$lbl['validator_messages']['remote'] = __('Please fix this field.');
     		$lbl['validator_messages']['email'] = __('Please enter a valid email address.');
     		$lbl['validator_messages']['url'] = __('Please enter a valid URL.');
     		$lbl['validator_messages']['date'] = __('Please enter a valid date.');
     		$lbl['validator_messages']['dateISO'] = __('Please enter a valid date (ISO).');
     		$lbl['validator_messages']['number'] = __('Please enter a valid number.');
     		$lbl['validator_messages']['digits'] = __('Please enter only digits.');
     		$lbl['validator_messages']['creditcard'] = __('Please enter a valid credit card number.');
     		$lbl['validator_messages']['equalTo'] = __('Please enter the same value again.');
     		$lbl['validator_messages']['accept'] = __('Please enter a value with a valid extension.');
     		$lbl['validator_messages']['maxlength'] = __('Please enter no more than {0} characters.');
     		$lbl['validator_messages']['minlength'] = __('Please enter at least {0} characters.');
     		$lbl['validator_messages']['rangelength'] = __('Please enter a value between {0} and {1} characters long.');
     		$lbl['validator_messages']['range'] = __('Please enter a value between {0} and {1}.');
     		$lbl['validator_messages']['max'] = __('Please enter a value less than or equal to {0}.');
     		$lbl['validator_messages']['min'] = __('Please enter a value greater than or equal to {0}.');
     */
     $this->json(I18n::load(I18n::$lang));
 }
Пример #17
0
 public function register($userName, $email, $password, $pwdChk, &$err = null)
 {
     $init_err = $err;
     Utils::checkEmail($email, $err);
     Utils::checkPassword($password, $err);
     if (strcmp($password, $pwdChk) !== 0) {
         $err[] = I18n::get("error_pwd_mismatch");
     }
     $email = mb_strtolower($email, 'UTF-8');
     $lowUsername = mb_strtolower($userName, 'UTF-8');
     $others = $this->db->getUsersByUserNameOrEmail($lowUsername, $email);
     if ($others) {
         foreach ($others as $o) {
             if (strcmp(mb_strtolower($o["username"], 'UTF-8'), $lowUsername) == 0) {
                 $err[] = I18n::get("error_username_already_taken");
             }
             if (strcmp($o["email"], $email) == 0) {
                 $err[] = I18n::get("error_email_already_taken");
             }
         }
     }
     if ($init_err != $err) {
         return false;
     }
     $password = password_hash($password, PASSWORD_DEFAULT);
     $this->db->createUser($userName, $email, $password);
     return true;
 }
Пример #18
0
 /**
  * Render element, according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     BizSystem::clientProxy()->includeCKEditorScripts();
     $elementName = $this->m_Name;
     $value = $this->getValue();
     $value = htmlentities($value, ENT_QUOTES, "UTF-8");
     $style = $this->getStyle();
     $width = $this->m_Width ? $this->m_Width : 600;
     $height = $this->m_Height ? $this->m_Height : 300;
     //$func = "onclick=\"editRichText('$elementName', $width, $height);\"";
     if (!strlen($value) > 0) {
         // fix suggested by smarques
         $value = "&nbsp;";
     }
     $type = strtolower($this->m_Mode);
     $fileBrowserPage = APP_URL . "/bin/filebrowser/browser.html";
     $languageCode = I18n::getCurrentLangCode();
     $languageCode = str_replace("_", "-", $languageCode);
     $config = $this->m_Config;
     $sHTML .= "<textarea id=\"{$elementName}\" name=\"{$elementName}\" >{$value}</textarea>\n";
     $sHTML .= "<script type=\"text/javascript\">\n";
     if ($config) {
         //remove the last commas
         $config = trim($config);
         if (substr($config, strlen($config) - 1, 1) == ',') {
             $config = substr($config, strlen($config) - 1);
         }
         $sHTML .= "Openbiz.CKEditor.init('{$elementName}',{'type':'{$type}','filebrowserBrowseUrl':'{$fileBrowserPage}','language':'{$languageCode}','height':'{$height}','width':'{$width}',{$config}});\n";
     } else {
         $sHTML .= "Openbiz.CKEditor.init('{$elementName}',{'type':'{$type}','filebrowserBrowseUrl':'{$fileBrowserPage}','language':'{$languageCode}','height':'{$height}','width':'{$width}'});\n";
     }
     $sHTML .= "</script>\n";
     return $sHTML;
 }
Пример #19
0
 public function before()
 {
     if ($this->request->action === 'media') {
         // Do not template media files
         $this->auto_render = FALSE;
     } else {
         // Grab the necessary routes
         $this->media = Route::get('docs/media');
         $this->api = Route::get('docs/api');
         $this->guide = Route::get('docs/guide');
         if (isset($_GET['lang'])) {
             $lang = $_GET['lang'];
             // Load the accepted language list
             $translations = array_keys(Kohana::message('userguide', 'translations'));
             if (in_array($lang, $translations)) {
                 // Set the language cookie
                 Cookie::set('userguide_language', $lang, Date::YEAR);
             }
             // Reload the page
             $this->request->redirect($this->request->uri);
         }
         // Set the translation language
         I18n::$lang = Cookie::get('userguide_language', Kohana::config('userguide')->lang);
         // Use customized Markdown parser
         define('MARKDOWN_PARSER_CLASS', 'Kodoc_Markdown');
         // Load Markdown support
         require Kohana::find_file('vendor', 'markdown/markdown');
         // Set the base URL for links and images
         Kodoc_Markdown::$base_url = URL::site($this->guide->uri()) . '/';
         Kodoc_Markdown::$image_url = URL::site($this->media->uri()) . '/';
     }
     parent::before();
 }
Пример #20
0
 /**
  * 
  * Initializes configs for the APP to run
  */
 public static function initialize()
 {
     /**
      * Load all the configs from DB
      */
     //Change the default cache system, based on your config /config/cache.php
     Cache::$default = Core::config('cache.default');
     //is not loaded yet in Kohana::$config
     Kohana::$config->attach(new ConfigDB(), FALSE);
     //overwrite default Kohana init configs.
     Kohana::$base_url = Core::config('general.base_url');
     //enables friendly url @todo from config
     Kohana::$index_file = FALSE;
     //cookie salt for the app
     Cookie::$salt = Core::config('auth.cookie_salt');
     /* if (empty(Cookie::$salt)) {
     			// @TODO missing cookie salt : add warning message
     		} */
     // -- i18n Configuration and initialization -----------------------------------------
     I18n::initialize(Core::config('i18n.locale'), Core::config('i18n.charset'));
     //Loading the OC Routes
     // if (($init_routes = Kohana::find_file('config','routes')))
     // 	require_once $init_routes[0];//returns array of files but we need only 1 file
     //faster loading
     require_once APPPATH . 'config/routes.php';
     //getting the selected theme, and loading options
     Theme::initialize();
 }
 /**
  * Creates a new local user in the application data base.
  * 
  * @param WebSoccer $websoccer Application context.
  * @param DbConnection $db DB Connection.
  * @param string $nick User name of new user. Optional if e-mail address is provided. Must be unique in local data base. Case sensitive.
  * @param string $email E-mail address of new user. Optional if nick is provided. Must be unique in local data base. Case insensitive (will be stored with lower letters).
  * @throws Exception if both nick and e-mail are blank, or if nick name or e-mail address is already in use. Messages are not internationalized. Method assumes appropriate checks before calling it.
  * @return int ID of newly created user.
  */
 public static function createLocalUser(WebSoccer $websoccer, DbConnection $db, $nick = null, $email = null)
 {
     $username = trim($nick);
     $emailAddress = strtolower(trim($email));
     // check if either nick or e-mail is provided. If not, it most probably is a wrong API call,
     // hence message is not required to be translated.
     if (!strlen($username) && !strlen($emailAddress)) {
         throw new Exception("UsersDataService::createBlankUser(): Either user name or e-mail must be provided in order to create a new internal user.");
     }
     // verify that there is not already such a user. If so, the calling function is wrongly implemented, hence
     // no translation of message.
     if (strlen($username) && self::getUserIdByNick($websoccer, $db, $username) > 0) {
         throw new Exception("Nick name is already in use.");
     }
     if (strlen($emailAddress) && self::getUserIdByEmail($websoccer, $db, $emailAddress) > 0) {
         throw new Exception("E-Mail address is already in use.");
     }
     // creates user.
     $i18n = I18n::getInstance($websoccer->getConfig("supported_languages"));
     $columns = array("nick" => $username, "email" => $emailAddress, "status" => "1", "datum_anmeldung" => $websoccer->getNowAsTimestamp(), "lang" => $i18n->getCurrentLanguage());
     if ($websoccer->getConfig("premium_initial_credit")) {
         $columns["premium_balance"] = $websoccer->getConfig("premium_initial_credit");
     }
     $db->queryInsert($columns, $websoccer->getConfig("db_prefix") . "_user");
     // provide ID of created user.
     if (strlen($username)) {
         $userId = self::getUserIdByNick($websoccer, $db, $username);
     } else {
         $userId = self::getUserIdByEmail($websoccer, $db, $emailAddress);
     }
     // trigger plug-ins
     $event = new UserRegisteredEvent($websoccer, $db, I18n::getInstance($websoccer->getConfig("supported_languages")), $userId, $username, $emailAddress);
     PluginMediator::dispatchEvent($event);
     return $userId;
 }
Пример #22
0
 public function isReadonly()
 {
     if (Application::isReadonly()) {
         $this->message->error = I18n::t('I_A');
         $this->request->redirect(Theme::URL('Index/Index'));
     }
 }
 function testTranslationCaching()
 {
     Configure::write('Config.language', 'cache_test_po');
     $i18n =& i18n::getInstance();
     // reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     $lang = Configure::read('Config.language');
     #$i18n->l10n->locale;
     Cache::config('_cake_core_', Cache::config('default'));
     // make some calls to translate using different domains
     $this->assertEqual(I18n::translate('dom1.foo', false, 'dom1'), 'Dom 1 Foo');
     $this->assertEqual(I18n::translate('dom1.bar', false, 'dom1'), 'Dom 1 Bar');
     $this->assertEqual($i18n->__domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo'], 'Dom 1 Foo');
     // reset internally stored entries
     I18n::clear();
     // now only dom1 should be in cache
     $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
     $this->assertEqual($cachedDom1['LC_MESSAGES']['dom1.foo'], 'Dom 1 Foo');
     $this->assertEqual($cachedDom1['LC_MESSAGES']['dom1.bar'], 'Dom 1 Bar');
     // dom2 not in cache
     $this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
     // translate a item of dom2 (adds dom2 to cache)
     $this->assertEqual(I18n::translate('dom2.foo', false, 'dom2'), 'Dom 2 Foo');
     // verify dom2 was cached through manual read from cache
     $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
     $this->assertEqual($cachedDom2['LC_MESSAGES']['dom2.foo'], 'Dom 2 Foo');
     $this->assertEqual($cachedDom2['LC_MESSAGES']['dom2.bar'], 'Dom 2 Bar');
     // modify cache entry manually to verify that dom1 entries now will be read from cache
     $cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
     Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
     $this->assertEqual(I18n::translate('dom1.foo', false, 'dom1'), 'FOO');
 }
Пример #24
0
 /**
  * Gets the singleton instance of this class
  *
  * @return I18n The singleton instance
  */
 public static function getInstance()
 {
     if (self::$i18n_singleton == NULL) {
         self::$i18n_singleton = new I18n();
     }
     return self::$i18n_singleton;
 }
Пример #25
0
 /**
  * Initialize FieldControl with xml array
  *
  * @param array $xmlArr xml array
  * @param BizForm $formObj BizForm instance
  * @return void
  */
 function __construct(&$xmlArr, $formObj)
 {
     parent::__construct($xmlArr, $formObj);
     $this->m_BizFormName = $formObj->m_Name;
     $this->m_BizFieldName = isset($xmlArr["ATTRIBUTES"]["FIELDNAME"]) ? $xmlArr["ATTRIBUTES"]["FIELDNAME"] : null;
     $this->m_DisplayName = isset($xmlArr["ATTRIBUTES"]["DISPLAYNAME"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["DISPLAYNAME"]) : null;
     $this->m_Description = isset($xmlArr["ATTRIBUTES"]["DESCRIPTION"]) ? $xmlArr["ATTRIBUTES"]["DESCRIPTION"] : null;
     $this->m_ValuePicker = isset($xmlArr["ATTRIBUTES"]["VALUEPICKER"]) ? $xmlArr["ATTRIBUTES"]["VALUEPICKER"] : null;
     $this->m_PickerMap = isset($xmlArr["ATTRIBUTES"]["PICKERMAP"]) ? $xmlArr["ATTRIBUTES"]["PICKERMAP"] : null;
     if (isset($xmlArr["ATTRIBUTES"]["DRILLDOWNLINK"])) {
         $this->_setDrillDownLink($xmlArr["ATTRIBUTES"]["DRILLDOWNLINK"]);
     }
     $this->m_Enabled = isset($xmlArr["ATTRIBUTES"]["ENABLED"]) ? $xmlArr["ATTRIBUTES"]["ENABLED"] : null;
     $this->m_Sortable = isset($xmlArr["ATTRIBUTES"]["SORTABLE"]) ? $xmlArr["ATTRIBUTES"]["SORTABLE"] : null;
     $this->m_DataType = isset($xmlArr["ATTRIBUTES"]["DATATYPE"]) ? $xmlArr["ATTRIBUTES"]["DATATYPE"] : null;
     $this->m_Order = isset($xmlArr["ATTRIBUTES"]["ORDER"]) ? $xmlArr["ATTRIBUTES"]["ORDER"] : null;
     $this->m_DefaultValue = isset($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) ? $xmlArr["ATTRIBUTES"]["DEFAULTVALUE"] : null;
     $this->m_ColumnStyle = isset($xmlArr["ATTRIBUTES"]["COLUMNSTYLE"]) ? $xmlArr["ATTRIBUTES"]["COLUMNSTYLE"] : null;
     $this->m_Mode = MODE_R;
     // if no class name, add default class name. i.e. NewRecord => ObjName.NewRecord
     $this->m_ValuePicker = $this->prefixPackage($this->m_ValuePicker);
     if (!$this->m_BizFieldName) {
         $this->m_BizFieldName = $this->m_Name;
     }
 }
Пример #26
0
 static function translate($key, $params = array(), $reversed = null, $prefix = null)
 {
     $definitions = I18n::getDefinitions();
     $string = $key;
     if ($reversed) {
         if (is_array($params)) {
             foreach ($params as $k => $v) {
                 $key = str_replace($v, '%%' . $k . '%%', $string);
             }
         }
         if ($string = array_search($key, $definitions)) {
             return preg_replace('~^' . $prefix . '\\.~', '', $string);
         }
         return $key;
     }
     if (isset($definitions[$prefix . '.' . $key])) {
         $string = $definitions[$prefix . '.' . $key];
     } else {
         if (isset($definitions[$key])) {
             $string = $definitions[$key];
         } else {
             $string = $key;
         }
     }
     if (is_array($params)) {
         foreach ($params as $k => $v) {
             $string = str_replace('%%' . $k . '%%', $v, $string);
         }
     }
     return $string;
 }
Пример #27
0
 /**
  * initialize method
  *
  * Merge settings and set Config.language to a valid locale
  *
  * @return void
  * @access public
  */
 function initialize(&$Controller, $config = array())
 {
     App::import('Vendor', 'Mi.MiCache');
     $lang = MiCache::setting('Site.lang');
     if (!$lang) {
         if (!defined('DEFAULT_LANGUAGE')) {
             return;
         }
         $lang = DEFAULT_LANGUAGE;
     } elseif (!defined('DEFAULT_LANGUAGE')) {
         define('DEFAULT_LANGUAGE', $lang);
     }
     Configure::write('Config.language', $lang);
     App::import('Core', 'I18n');
     $I18n =& I18n::getInstance();
     $I18n->domain = 'default_' . $lang;
     $I18n->__lang = $lang;
     $I18n->l10n->get($lang);
     if (!empty($Controller->plugin)) {
         $config['plugins'][] = Inflector::underscore($Controller->plugin);
     }
     if (!empty($config['plugins'])) {
         $plugins = array_intersect(MiCache::mi('plugins'), $config['plugins']);
         $Inst = App::getInstance();
         foreach ($plugins as $path => $name) {
             $Inst->locales[] = $path . DS . 'locale' . DS;
         }
     }
 }
Пример #28
0
 public function actionEdit()
 {
     $message = "";
     $lang = CatLang::fetchAll();
     if (!empty($_POST["trans"])) {
         for ($n = 0; $n < sizeof($lang); $n++) {
             $trans = $_POST["trans"][$n];
             if ($trans["id"] > 0 || $trans["translation"]) {
                 if ($trans["id"] > 0) {
                     $model = I18nTranslate::fetch($trans->id);
                 } else {
                     $model = new I18nTranslate();
                 }
                 $model->setAttributesFromArray($trans);
                 $model->i18n_id = $this->id;
                 if (!$model->save()) {
                     print_r($model->getErrors());
                 }
             }
         }
     }
     $list = array();
     if (!empty($this->id)) {
         $item = I18n::fetch($this->id);
         $list = I18nTranslate::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("i18n_id=:id")->setParams(array(":id" => $item->id))->setLimit(-1)->setCache(0));
     } else {
         $item = new I18n();
     }
     $this->render('edit', array('form' => $item, 'list' => $list, 'lang' => $lang, 'message' => $message));
 }
Пример #29
0
 public function action_index()
 {
     $photos = ORM::factory('Storage')->where('publication_id', '>', '0')->find_all();
     foreach ($photos as $photo) {
         if ($photo->publication_type == 'news') {
             $news = ORM::factory('News', $photo->publication_id);
             if ($news->loaded()) {
                 $title = $news->title;
             }
         } elseif ($photo->publication_type == 'leader') {
             $page = ORM::factory('Leader', $photo->publication_id);
             if ($page->loaded()) {
                 $title = $page->name;
             }
         } else {
             $page = ORM::factory('Pages_content', $photo->publication_id);
             if ($page->loaded()) {
                 $title = $page->name;
             }
         }
         if (!isset($title)) {
             $title = I18n::get("This publication is absent");
         }
         $photo_arr[] = array('date' => $photo->date, 'path' => $photo->file_path, 'publication_id' => $photo->publication_id, 'type' => $photo->publication_type, 'title' => $title);
     }
     $this->set('photos', $photo_arr);
     $this->add_cumb('Photos', '/');
 }
Пример #30
0
 public function before()
 {
     $this->session = Session::instance();
     $this->config = Kohana::$config->load('settings');
     $this->language = Lang::get_accepted_language($this->config->language);
     /**
      * Sets the default timezone used by all date/time functions
      *
      * @link http://kohanaframework.org/guide/using.configuration
      * @link http://www.php.net/manual/timezones
      */
     date_default_timezone_set($this->config->timezone);
     /**
      * Set locale information
      *
      * @link http://kohanaframework.org/guide/using.configuration
      * @link http://www.php.net/manual/function.setlocale
      */
     setlocale(LC_ALL, $this->config->languages[$this->language] . '.' . Kohana::$charset);
     /**
      * Set app language
      * Provides loading of language and translation
      */
     I18n::lang($this->language);
 }