function indexAction() { $params = array('locale_code' => $this->locale_code, 'request' => $this->getRequest()); if ($this->_auth->hasIdentity()) { $params['is_admin'] = $this->_identity->isAdmin; } else { $params['is_admin'] = false; } $additional = $this->_Bolts_plugin->doFilter($this->_mca, $params); // FILTER HOOK foreach ($additional as $key => $value) { $this->view->{$key} = $value; } // $this->view->welcome = $this->_T("Welcome!"); // TODO - find out if there is a valid cookie // then redirect to that locale // or redirect to the default locale // ONLY if localization is enabled // if localization is enabled and the URI does not contain a locale code // and there is not a valid locale cookie // redirect to a URI that contains the default locale code if (Bolts_Registry::get('enable_localization') == '1') { $locales_table = new Locales(); $locale_codes = $locales_table->getLocaleCodes(true); $uri_parts = explode("/", trim($this->_uri, "/")); if (count($uri_parts) > 0 && !in_array($uri_parts[0], $locale_codes)) { // redirect method will automatically add the correct locale code to the URI $this->_redirect("/"); } } }
function execute() { $locale = new Locales('connection'); $list = $locale->getList(); $this->smarty->assign('lang', $list); $this->smarty->assign('slide', connectionSliderModel::create()->where(array('id' => (int) Request::post('id')))->fetchOne()); }
function execute() { $app = strtolower(Request::get('app_local')); $locale = new Locales($app); $locale->deleteTranslate(Request::get('local_iso'), Request::post('var')); return false; }
function render() { // load all the locale files $locales = new Locales(); $siteLocales = $locales->getLocales(); $this->setValue("locales", $siteLocales); parent::render(); }
function execute() { $model = connectionSliderModel::create(); $locale = new Locales('connection'); $list = $locale->getList(); $this->smarty->assign('slides', $model->sort('sort', -1)->fetchAll()); $this->smarty->assign('lang', $list); }
function execute() { $locale = new Locales('connection'); $list = $locale->getList(); $page = Request::post('page'); $this->smarty->assign('seo', connectionSeoModel::create()->getByPage($page)); $this->smarty->assign('lang', $list); }
public function &GetLocales() { if (!isset($this->_locales)) { $locales = new Locales(); $locales->LoadAll(); $this->_locales = $locales; } return $this->_locales; }
function execute() { $locale = new Locales('connection'); $list = $locale->getList(); $pageModel = new connectionPagesModel(); $this->smarty->assign('pages', $pageModel->fetchAll()); $this->smarty->assign('lang', $list); $this->smarty->assign('page_url', Settings::getValue('page_url')); }
function execute() { $this->frame = false; $locale = new Locales('connection'); $list = $locale->getList(); $this->smarty->assign('lang', $list); $fieldID = Request::post('id'); $model = new connectionFieldsModel(); $this->smarty->assign('field', $model->getField($fieldID)); }
function execute() { $locale = new Locales('connection'); $list = $locale->getList(); if (Request::post('id')) { $answer = connectionFaqAnswerModel::create()->where(array('id' => (int) Request::post('id')))->fetchOne(); $this->smarty->assign('answer', $answer); } $this->smarty->assign('lang', $list); }
function execute() { $locale = new Locales('connection'); $list = $locale->getList(); $notification = connectionNotificationModel::create()->where(array('id' => (int) Request::post('id')))->fetchOne(); $eventList = connectionNotificationModel::getEventList(); $this->smarty->assign('eventInfo', $eventList[$notification['event']]); $this->smarty->assign('lang', $list); $this->smarty->assign('notification', $notification); }
function execute() { $event = Request::post('event'); $eventList = connectionNotificationModel::getEventList(); $locale = new Locales('connection'); $list = $locale->getList(); $this->smarty->assign('eventInfo', $eventList[$event]); $this->smarty->assign('lang', $list); $this->smarty->assign('event', connectionNotificationModel::create()->getEvent($event)); }
function execute() { $locale = new Locales('connection'); $list = $locale->getList(); $this->smarty->assign('lang', $list); $model = new connectionFieldsModel(); $fields = array(); $fields['info'] = $model->getGroup('info'); $fields['interest'] = $model->getGroup('interest'); $this->smarty->assign('fields', $fields); }
function chooseAction() { // TODO maybe? - prevent people from viewing this page if localization is not enabled $default_locale = strtolower(Bolts_Registry::get('default_locale', 'default')); $request = new Bolts_Request($this->getRequest()); // TODO - get cookie value and validate it // TODO - only redirect if a valid cookie value exists ! if (!$request->has('change') && false) { $this->_redirect("/" . $this->locale_code); } // Force the use of en-US if ($this->locale_code != $default_locale) { $this->locale_code = $default_locale; $this->_redirect("/" . $this->_request->getModuleName() . "/" . $this->_request->getControllerName() . "/" . $this->_request->getActionName() . "/"); } $locales_table = new Locales(); $tmp_regions = $locales_table->getDistinctRegions(); $choices = array(); foreach ($tmp_regions as $tmp_region) { if ($tmp_region['region_name'] == 'Global') { continue; } $tmp_countries = $locales_table->getDistinctCountries($tmp_region['region_name']); $tmp_pseudo_countries = $locales_table->getDistinctPseudoCountryCodes($tmp_region['region_name']); foreach ($tmp_countries as $tmp_country) { if (!empty($tmp_pseudo_countries) && in_array($tmp_country['country_code'], $tmp_pseudo_countries[0])) { continue; } $tmp_lang = $locales_table->getLanguages($tmp_region['region_name'], $tmp_country['country_code']); $tmp_country['languages'] = array(); foreach ($tmp_lang as $lan) { if (!is_null($lan['pseudo_country_code'])) { $tmp_locale_code = strtolower($lan['language_code'] . "-" . $lan['pseudo_country_code']); } else { $tmp_locale_code = strtolower($lan['language_code'] . "-" . $tmp_country['country_code']); } if (in_array($tmp_locale_code, $this->live_locales)) { $tmp_country['languages'][] = $lan; } } if (count($tmp_country['languages']) > 0) { $tmp_region['countries'][] = $tmp_country; } } if (array_key_exists('countries', $tmp_region) && count($tmp_region['countries']) > 0) { $choices[] = $tmp_region; } } $this->view->choices = $choices; if ($request->has('inline')) { $this->view->inline = $request->inline; } }
function execute() { $locale = new Locales('connection'); $list = $locale->getList(); $this->smarty->assign('lang', $list); $model = new connectionCountryModel(); $countries = array(); foreach ($list as $lang) { $countries[$lang['iso']] = $model->getList($lang['iso']); } $this->smarty->assign('country', $countries); }
function execute() { $page_id = Request::post('page_id'); if (!$page_id) { exit; } $model = new connectionPagesModel(); $locale = new Locales('connection'); $list = $locale->getList(); $this->smarty->assign('lang', $list); $this->smarty->assign('page', $model->getPage($page_id)); $this->smarty->display(APP_DIR . DS . App::getAppName() . DS . APP_TEMPLATES_DIR . DS . 'backend' . DS . '/include/modal/pageEdite.html'); exit; }
public function hasVariant($id, $variant) { $locale = new Locales('connection'); $list = $locale->getList(); $where = array('id' => (int) $id); foreach ($list as $value) { $where['$or'][] = array($value['iso'] . '.variant' => $variant); } $result = $this->where($where)->fetchAll(); if (sizeof($result) > 0) { return true; } return false; }
/** * shortuct for formatting the date in the same way that it is expected by * the "date picker" javascript calendar * *�@return a string */ function getDateFormatted() { include_once PLOG_CLASS_PATH . "class/locale/locales.class.php"; $locale = Locales::getLocale("en_UK"); $dateFormatted = $locale->formatDate($this->getDateObject(), "%d/%m/%Y %H:%M"); return $dateFormatted; }
/** * Tries to match the prefered language out of the http_accept_language string * with one of the available languages. * * @private * @param httpAcceptLanguage the value of $_SERVER['HTTP_ACCEPT_LANGUAGE'] * @return Returns returns prefered language or false if no language matched. */ function _matchHttpAcceptLanguages(&$httpAcceptLanguage) { $acceptedLanguages = explode(',', $httpAcceptLanguage); $availableLanguages =& Locales::getAvailableLocales(); $primaryLanguageMatch = ''; // we iterate through the array of languages sent by the UA and test every single // one against the array of available languages foreach ($acceptedLanguages as $acceptedLang) { // clean the string and strip it down to the language value (remove stuff like ";q=0.3") $acceptedLang = substr($acceptedLang, 0, strcspn($acceptedLang, ';')); if (strlen($acceptedLang) > 2) { // cut to primary language $primaryAcceptedLang = substr($acceptedLang, 0, 2); } else { $primaryAcceptedLang = $acceptedLang; } // this is where we start to iterate through available languages foreach ($availableLanguages as $availableLang) { if (stristr($availableLang, $acceptedLang) !== false) { // we have a exact language match return $availableLang; } elseif (stristr($availableLang, $primaryAcceptedLang) !== false && $primaryLanguageMatch == '') { // we found the first primary language match! $primaryLanguageMatch = $availableLang; } } } // foreach if ($primaryLanguageMatch != '') { return $primaryLanguageMatch; } else { return false; } }
/** * Reload the REST information. * This is only a empty placeholder. The child class can override it. * * @author David Pauli <*****@*****.**> * @since 0.0.0 * @since 0.0.1 Use HTTPRequestMethod enum. * @since 0.1.0 Use a default Locale. * @since 0.1.1 Unstatic every attributes. */ private function load() { // if the REST path empty -> this is the not the implementation or can't get something else if (InputValidator::isEmpty(self::RESTPATH) || !RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { return; } $content = RESTClient::sendWithLocalization(self::RESTPATH, Locales::getLocale()); // if respond is empty if (InputValidator::isEmpty($content)) { return; } // reset values $this->resetValues(); if (!InputValidator::isEmptyArrayKey($content, "name")) { $this->NAME = $content["name"]; } if (!InputValidator::isEmptyArrayKey($content, "navigationCaption")) { $this->NAVIGATIONCAPTION = $content["navigationCaption"]; } if (!InputValidator::isEmptyArrayKey($content, "description")) { $this->DESCRIPTION = $content["description"]; } // update timestamp when make the next request $timestamp = (int) (microtime(true) * 1000); $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME; }
/** * Performs the action. */ function perform() { // fetch the articles for the given blog $articles = new Articles(); $blogSettings = $this->_blogInfo->getSettings(); $localeCode = $blogSettings->getValue("locale"); // fetch the default profile as chosen by the administrator $defaultProfile = $this->_config->getValue("default_rss_profile"); if ($defaultProfile == "" || $defaultProfile == null) { $defaultProfile = DEFAULT_PROFILE; } // fetch the profile // if the profile specified by the user is not valid, then we will // use the default profile as configured $profile = $this->_request->getValue("profile"); if ($profile == "") { $profile = $defaultProfile; } // fetch the category, or set it to '0' otherwise, which will mean // fetch all the most recent posts from any category $categoryId = $this->_request->getValue("categoryId"); if (!is_numeric($categoryId)) { $categoryId = 0; } // check if the template is available $this->_view = new RssView($this->_blogInfo, $profile, array("profile" => $profile, "categoryId" => $categoryId)); // do nothing if the view was already cached if ($this->_view->isCached()) { return true; } // create an instance of a locale object $locale = Locales::getLocale($localeCode); // fetch the posts, though we are going to fetch the same amount in both branches $amount = $blogSettings->getValue("recent_posts_max", 15); $t = new Timestamp(); if ($blogSettings->getValue('show_future_posts_in_calendar')) { $blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0); } else { $today = $t->getTimestamp(); $blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0, $today); } $pm =& PluginManager::getPluginManager(); $pm->setBlogInfo($this->_blogInfo); $pm->setUserInfo($this->_userInfo); $result = $pm->notifyEvent(EVENT_POSTS_LOADED, array('articles' => &$blogArticles)); $articles = array(); foreach ($blogArticles as $article) { $postText = $article->getIntroText(); $postExtendedText = $article->getExtendedText(); $pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postText)); $pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postExtendedText)); $article->setIntroText($postText); $article->setExtendedText($postExtendedText); array_push($articles, $article); } $this->_view->setValue("locale", $locale); $this->_view->setValue("posts", $articles); $this->setCommonData(); return true; }
/** * provides default parameters for the FileFinder::find() method * * @see FileFinder::find() * @return An array with the new locales found in the disk */ function find() { // first find the new ones parent::find(Locales::getAvailableLocales(), "locale_*.php"); // and then return them, if any return $this->getNew(); }
/** Basic initialization - preload settings and locales * @return void */ public static function basic() { Loader::init(); Status::init(); Settings::init(); Locales::init(); Router::update_rewrite(); }
function AdminArticleCommentsListView($blogInfo, $params = array()) { $this->AdminTemplatedView($blogInfo, "editcomments"); $blogSettings = $blogInfo->getSettings(); $this->_locale =& Locales::getLocale($blogSettings->getValue("locale"), "en_UK"); $this->_setParameters($params); $this->_page = $this->getCurrentPageFromRequest(); }
/** * Carries out the specified action */ function perform() { $this->_view = new AdminHelpView($this->_blogInfo); $blogSettings = $this->_blogInfo->getSettings(); $locale =& Locales::getLocale($blogSettings->getValue("locale")); $this->_view->setValue("help", $locale->tr($this->_helpId)); $this->setCommonData(); // better to return true if everything fine return true; }
/** * @private */ function _deleteLocales() { $locales = new Locales(); // if there is only one locale available in the system, we should // not allow to remove it either if (count($locales->getAvailableLocales()) == 1) { $this->_view = new AdminSiteLocalesListView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_deleting_only_locale")); $this->setCommonData(); return false; } // keep the value of the default locale because plog should not allow // to remove the default one $defaultLocale = $this->_config->getValue("default_locale"); $errorMessage = ""; $successMessage = ""; $totalOk = 0; foreach ($this->_localeIds as $localeId) { if ($localeId != $defaultLocale) { if ($locales->removeLocale($localeId)) { $totalOk++; if ($totalOk < 2) { $successMessage = $this->_locale->pr("locale_deleted_ok", $localeId); } else { $successMessage = $this->_locale->pr("locales_deleted_ok", $totalOk); } } else { $errorMessage .= $this->_locale->pr("error_deleting_locale", $localeId) . "<br/>"; } } else { $errorMessage .= $this->_locale->pr("error_locale_is_default", $localeId) . "<br/>"; } } $this->_view = new AdminSiteLocalesListView($this->_blogInfo); if ($errorMessage != "") { $this->_view->setErrorMessage($errorMessage); } if ($successMessage != "") { $this->_view->setSuccessMessage($successMessage); } $this->setCommonData(); return true; }
/** * @private */ function _getLocale() { // load the Locale object from the view context or initialize it now if ($this->_params->keyExists("locale")) { $this->_locale = $this->_params->getValue("locale"); } else { $config =& Config::getConfig(); $this->_locale =& Locales::getLocale($config->getValue("default_locale")); } }
function sendUncachedOutput() { //$templateService = new TemplateService(); //$template = $templateService->Template( $this->_profile, "summary/rss" ); $config =& Config::getConfig(); $this->_locale =& Locales::getLocale($config->getValue("default_locale")); $this->_params->setValue("version", new Version()); $this->_params->setValue("locale", $this->_locale); $this->_template->assign($this->_params->getAsArray()); print $this->_template->fetch($this->_viewId); }
function render() { // get the list of languages available, so that users can choose $locales = Locales::getLocales(); $this->setValue("locales", $locales); $config =& Config::getConfig(); // assign default Local to template $this->setValue("defaultLocale", $config->getValue("default_locale")); // and render the rest of the contents of the view parent::render(); }
function render() { $this->setValue("blogsettings", $this->_blogInfo->getSettings()); $ts = new TemplateSets(); $templates = $ts->getBlogTemplateSets($this->_blogInfo->getId(), true); $this->setValue("templates", $templates); // loading all the locales from disk is a pretty heavy task but doing so, we'll get // nice Locale object with things like the encoding, the description, etc... which looks // waaaay nicer than just showing the locale code $this->setValue("locales", Locales::getLocales()); parent::render(); }