function __($stringId) { if (!defined('PLANCAKE_PUBLIC_RELEASE')) { $lang = PcLanguagePeer::getUserPreferredLanguage()->getId(); $key = ''; if ($cache = PcCache::getInstance()) { $key = PcCache::generateKeyForTranslation($lang, $stringId); if ($cache->has($key)) { return $cache->get($key); } } $translation = PcTranslationPeer::retrieveByPK($lang, $stringId); if (!is_object($translation) || !strlen(trim($translation->getString())) > 0) { $translation = PcTranslationPeer::retrieveByPK(SfConfig::get('app_site_defaultLang'), $stringId); } if (!$translation) { throw new Exception("Couldn't find the string {$stringId} for the language {$lang}"); } $ret = $translation->getString(); if ($cache) { $cache->set($key, $ret); } } else { global $pc_lang; if (!array_key_exists($stringId, $pc_lang)) { throw new Exception("Couldn't find the string {$stringId}"); } $ret = $pc_lang[$stringId]; } return $ret; }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $lang = PcLanguagePeer::getUserPreferredLanguage()->getId(); if (!$lang) { $lang = SfConfig::get('app_site_defaultLang'); } $this->lang = $lang; $this->baseUrl = sfConfig::get('app_site_url') . (sfConfig::get('sf_environment') == 'prod' ? '' : '/') . sfConfig::get('app_publicApp_frontController'); if (defined('PLANCAKE_PUBLIC_RELEASE')) { $this->baseUrl = 'http://www.plancake.com'; } $userCulture = $this->getUser()->getCulture(); $this->cultureUrlPart = ''; if ($userCulture != SfConfig::get('app_site_defaultLang')) { $this->cultureUrlPart = '/' . $userCulture; } // this is a "backdoor" to avoid redirection: just append ?redirect=no to the URL if ($request->getParameter('redirect') == 'no') { return; } // if the user is authenticated, they will be redirected // to their account if ($this->getUser()->isAuthenticated()) { $this->redirect('/' . sfConfig::get('app_accountApp_frontController')); } }
public function executeSendFeedback(sfWebRequest $request) { $user = PcUserPeer::getLoggedInUser(); $message = $request->getParameter('message'); $to = sfConfig::get('app_emailAddress_contact'); $subject = "Submitted feedback"; if (PcLanguagePeer::getUserPreferredLanguage()->getId() == 'it') { $subject = 'Richiesta da box'; } // we need to add a 'random' code otherwise GMail groups all of them together $subject .= ' ' . date('YmdHis'); $message = $message . "\n ----- \n" . $_SERVER['HTTP_USER_AGENT']; PcUtils::sendEmail($to, $subject, $message, $to, PcUserPeer::getLoggedInUser()->getEmail()); return $this->renderDefault(); }
public static function getWebAppStrings() { $lang = PcLanguagePeer::getUserPreferredLanguage()->getId(); $c = new Criteria(); $c->add(PcStringPeer::CATEGORY_ID, array(115, 119), Criteria::NOT_IN); // Settings && GCal integration $c->add(PcStringPeer::IS_ARCHIVED, 0); $c->addJoin(PcStringPeer::CATEGORY_ID, PcStringCategoryPeer::ID); $c->add(PcStringCategoryPeer::IN_ACCOUNT, 1); $stringsFromAccount = PcStringPeer::doSelect($c); $c = new Criteria(); $c->add(PcStringPeer::CATEGORY_ID, 2); // General $c->add(PcStringPeer::IS_ARCHIVED, 0); $c->addJoin(PcStringPeer::CATEGORY_ID, PcStringCategoryPeer::ID); $c->add(PcStringCategoryPeer::IN_ACCOUNT, 0); $c->add(PcStringCategoryPeer::IN_MISC, 0); return array_merge($stringsFromAccount, PcStringPeer::doSelect($c)); }
public function executeLangSelection(sfWebRequest $request) { $this->languages = PcLanguagePeer::getAvailableLanguagesPreferredFirst(); $this->langCount = count($this->languages); $this->preferredLanguage = PcLanguagePeer::getUserPreferredLanguage(); }
public static function getMainNavigationKey() { return PcLanguagePeer::getUserPreferredLanguage()->getId() . '-' . PcUserPeer::getLoggedInUser()->getId(); }