public function __construct($route) { // See if first part is language code (i.e. first part is exactly // two characters in length) if (strlen($route) === 2 || substr($route, 2, 1) === '/') { $shortLang = substr($route, 0, 2); $langInstance = Ajde_Lang::getInstance(); if ($lang = $langInstance->getAvailableLang($shortLang)) { $this->set("lang", $lang); $route = substr($route, 3); } } if (!$route) { $route = Config::get('homepageRoute'); } // Check for route aliases $aliases = Config::get("aliases"); if (array_key_exists($route, $aliases)) { $this->_route = $aliases[$route]; } else { $this->_route = $route; } // Get route parts $routeParts = $this->_extractRouteParts(); if (empty($routeParts)) { $exception = new Ajde_Exception(sprintf("Invalid route: %s", $route), 90021); Ajde::routingError($exception); } $defaultParts = Config::get('defaultRouteParts'); $parts = array_merge($defaultParts, $routeParts); foreach ($parts as $part => $value) { $this->set($part, $value); } }
function view() { // Grab the view to easily assign variables $view = $this->getView(); // Get all warnings from Ajde_Dump::warn() if (Ajde_Dump::getWarnings()) { $view->assign('warn', Ajde_Dump::getWarnings()); } // Get all dumps from Ajde_Dump::dump() [Aliased as a global function dump()] if (Ajde_Dump::getAll()) { $view->assign('dump', Ajde_Dump::getAll()); } // Get request parameters $view->assign('request', Ajde::app()->getRequest()); // Get Configuration stage $view->assign('configstage', Config::$stage); // Get database queries if (Ajde_Core_Autoloader::exists('Ajde_Db_PDO')) { $view->assign('database', Ajde_Db_PDO::getLog()); } // Get language $view->assign('lang', Ajde_Lang::getInstance()->getLang()); // Get session $view->assign('session', $_SESSION); // Get ACL if (Ajde_Core_Autoloader::exists('Ajde_Acl')) { $view->assign('acl', Ajde_Acl::getLog()); } // Get the application timer Ajde::app()->endTimer(0); Ajde::app()->endTimer(Ajde::app()->getLastTimerKey()); $view->assign('timers', Ajde::app()->getTimers()); return $this->render(); }
public function getCanonicalUrl() { if ($this->node->hasLoaded()) { return config('i18n.enabled') ? Ajde_Lang::getInstance()->getShortLang() . '/' . $this->node->getSlug() : $this->node->getSlug(); } return ''; }
/** * Optional function called before controller is invoked * When returning false, invocation is cancelled. * * @return bool */ public function beforeInvoke($allowed = []) { // set admin layout Ajde::app()->getDocument()->setLayout(new Ajde_Layout(config('layout.admin'))); // disable cache and auto translations Ajde_Cache::getInstance()->disable(); Ajde_Lang::getInstance()->disableAutoTranslationOfModels(); return parent::beforeInvoke($allowed); }
public function getRedirectParams($description = null) { $transaction = $this->getTransaction(); // NOOOO.. THE UGLY HACKING $return = config('app.rootUrl') . 'presale/transaction:complete'; $method = $transaction->shipment_method; if ($method == 'presale-remainder') { $return = config('app.rootUrl') . 'presale/transaction:confirm_complete'; } return ['cmd' => '_xclick', 'business' => config('shop.transaction.paypal.account'), 'notify_url' => config('app.rootUrl') . $this->returnRoute . 'paypal' . $this->getMethod() . '.html', 'bn' => config('app.id') . '_BuyNow_WPS_' . strtoupper(Ajde_Lang::getInstance()->getShortLang()), 'amount' => $transaction->payment_amount, 'item_name' => issetor($description, config('app.title') . ': ' . Ajde_Component_String::makePlural($transaction->shipment_itemsqty, 'item')), 'quantity' => 1, 'address_ override' => 1, 'address1' => $transaction->shipment_address, 'zip' => $transaction->shipment_zipcode, 'city' => $transaction->shipment_city, 'state' => $transaction->shipment_region, 'country' => $transaction->shipment_country, 'email' => $transaction->email, 'first_name' => $transaction->name, 'currency_code' => config('shop.currency.code'), 'custom' => $transaction->secret, 'no_shipping' => 1, 'no_note' => 1, 'return' => $return, 'rm' => 1]; }
public function displayLang() { Ajde::app()->getDocument()->getLayout()->getParser()->getHelper()->requireCssPublic('core/flags.css'); $lang = Ajde_Lang::getInstance(); $currentLang = $this->get('lang'); if ($currentLang) { $image = '<img src="" class="flag flag-' . strtolower(substr($currentLang, 3, 2)) . '" alt="' . $currentLang . '" />'; return $image . $lang->getNiceName($currentLang); } return ''; }
public function get($ident, $module = null) { $module = $this->getModule($module); $lang = Ajde_Lang::getInstance()->getLang(); $iniFilename = LANG_DIR . $lang . '/' . $module . '.ini'; if (is_file($iniFilename)) { $book = parse_ini_file($iniFilename); if (array_key_exists($ident, $book)) { return $book[$ident]; } } return $ident; }
public function __construct() { //$lang = Ajde_Lang::getInstance()->getLang(); //$newSystemLocale = setlocale(LC_ALL, $lang); // if ($lang !== $newSystemLocale) { // // TODO: now this adapter is not working properly... // } //bindtextdomain(config("app.id"), rtrim(LANG_DIR, DIRECTORY_SEPARATOR)); //textdomain(config("app.id")); // Dammit you gettext, try the Zend_Translate approach here... $this->_lang = Ajde_Lang::getInstance()->getLang(); $this->_gettext = new Zend_Translate_Adapter_Gettext(); $filename = LANG_DIR . $this->_lang . '/LC_MESSAGES/' . config('app.id') . '.mo'; $this->_gettext->_loadTranslationData($filename, $this->_lang); $this->_dictionary = $this->_gettext->get($this->_lang); }
public function beforeInvoke($allowed = []) { // disable cache and auto translations Ajde_Cache::getInstance()->disable(); Ajde_Lang::getInstance()->disableAutoTranslationOfModels(); // try to get the crud instance $crud = $this->hasCrudInstance() ? $this->getCrudInstance() : false; if (!$crud && Ajde::app()->getRequest()->has('crudId')) { $session = new Ajde_Session('AC.Crud'); $crud = $session->getModel(Ajde::app()->getRequest()->getParam('crudId')); } if ($crud) { /* @var $crud Ajde_Crud */ $this->setAclParam($crud->getSessionName()); } return parent::beforeInvoke(); }
public function get($ident, $module = null) { $module = $this->getModule($module); $lang = Ajde_Lang::getInstance()->getLang(); $iniFilename = LANG_DIR . $lang . DIRECTORY_SEPARATOR . $module . '.ini'; if (is_file(LOCAL_ROOT . $iniFilename)) { $book = parse_ini_file(LOCAL_ROOT . $iniFilename); // Strip slashes foreach ($book as $key => $value) { $key = str_replace("'", '', $key); $book[$key] = $value; } // Lookup if (array_key_exists($ident, $book)) { return $book[$ident]; } } $this->log($ident, $module, $lang); return $ident; }
public function __construct($route) { $this->_originalRoute = $route; // See if first part is language code (i.e. first part is exactly // two characters in length) if (strlen($route) === 2 || substr($route, 2, 1) === '/') { $shortLang = substr($route, 0, 2); $langInstance = Ajde_Lang::getInstance(); if ($lang = $langInstance->getAvailableLang($shortLang)) { $this->set('lang', $lang); $route = substr($route, 3); // set global lang $langInstance->setGlobalLang($lang); } } Ajde_Event::trigger($this, 'onAfterLangSet'); if (!$route) { $route = config('routes.homepage'); } // Check for route aliases $aliases = config('routes.aliases'); if (array_key_exists($route, $aliases)) { $this->_route = $aliases[$route]; } else { $this->_route = $route; } Ajde_Event::trigger($this, 'onAfterRouteSet'); // Get route parts $routeParts = $this->_extractRouteParts(); if (empty($routeParts)) { $exception = new Ajde_Core_Exception_Routing(sprintf('Invalid route: %s', $route), 90021); Ajde::routingError($exception); } $defaultParts = config('routes.default'); $parts = array_merge($defaultParts, $routeParts); foreach ($parts as $part => $value) { $this->set($part, $value); } }
public function getRedirectParams() { $transaction = $this->getTransaction(); return array('cmd' => '_xclick', 'business' => Config::get('shopPaypalAccount'), 'notify_url' => 'http://' . Config::get('site_root') . 'shop/transaction:callback/paypal.html', 'bn' => Config::get('ident') . '_BuyNow_WPS_' . strtoupper(Ajde_Lang::getInstance()->getShortLang()), 'amount' => $transaction->payment_amount, 'item_name' => Config::get('ident') . ': ' . Ajde_Component_String::makePlural($transaction->shipment_itemsqty, 'item'), 'quantity' => 1, 'address_ override' => 1, 'address1' => $transaction->shipment_address, 'zip' => $transaction->shipment_zipcode, 'city' => $transaction->shipment_city, 'state' => $transaction->shipment_region, 'country' => $transaction->shipment_country, 'email' => $transaction->email, 'first_name' => $transaction->name, 'currency_code' => Config::get('currencyCode'), 'custom' => $transaction->secret, 'no_shipping' => 1, 'no_note' => 1, 'return' => 'http://' . Config::get('site_root') . 'shop/transaction:complete', 'rm' => 1); }
protected function _load($sql, $values, $populate = true) { $return = parent::_load($sql, $values, $populate); if (Ajde_Lang::getInstance()->autoTranslateModels() && $return) { // get translation $lang = Ajde_Lang::getInstance(); if ($translation = $this->getTranslated($lang->getLang())) { /* @var $translation Ajde_Lang_Proxy_Model */ $this->reset(); $this->loadFromValues($translation->values()); } } return $return; }
public function initRoute() { $route = $this->getRoute(); $langInstance = Ajde_Lang::getInstance(); if ($route->hasLang()) { $langInstance->setGlobalLang($route->getLang()); } return $route; }
function __($ident, $module = null) { return Ajde_Lang::getInstance()->translate($ident, $module); }
public function log($ident, $module) { Ajde_Log::_('Language key [' . $module . '.' . $ident . '] not found for language [' . Ajde_Lang::getInstance()->getLang() . ']', Ajde_Log::CHANNEL_INFO, Ajde_Log::LEVEL_DEBUG, '', '', strip_tags(Ajde_Exception_Handler::trace(new Ajde_Exception(), Ajde_Exception_Handler::EXCEPTION_TRACE_ONLY))); }