function getOptions($addEmpty = false) { //if admin show all countries, if user show only active countries $where = defined('AM_ADMIN') ? '' : 'WHERE tag>=0'; $res = $this->_db->selectCol("SELECT country as ARRAY_KEY,\n CASE WHEN tag<0 THEN CONCAT(title, ' (disabled)') ELSE title END\n FROM ?_country {$where}\n ORDER BY tag DESC, title"); $translatedNames = array(); if (strpos($locale = $this->getDi()->app->getDefaultLocale(), 'en') !== 0) { $locale = new Am_Locale(); $tr = $locale->getTerritoryNames(); foreach ($res as $k => $v) { if (array_key_exists($k, $tr)) { $res[$k] = $tr[$k]; } } } if ($res && $addEmpty) { $res = array_merge(array('' => ___('[Select country]')), $res); } return $res; }
public function getForm() { $languageTranslation = Am_Locale::getSelfNames(); $avalableLocaleList = Zend_Locale::getLocaleList(); $existingLanguages = Am_Di::getInstance()->languagesListUser; $languageOptions = array(); foreach ($avalableLocaleList as $k => $v) { $locale = new Zend_Locale($k); if (!array_key_exists($locale->getLanguage(), $existingLanguages) && isset($languageTranslation[$locale->getLanguage()])) { $languageOptions[$locale->getLanguage()] = "({$k}) " . $languageTranslation[$locale->getLanguage()]; } } asort($languageOptions); $form = new Am_Form_Admin(); $form->setAction($this->grid->makeUrl(null)); $form->addElement('select', 'new_language')->setLabel(___('Language'))->loadOptions($languageOptions)->setId('languageSelect'); $form->addElement('hidden', 'a')->setValue('new'); $form->addSaveButton(); foreach ($this->grid->getVariablesList() as $k) { if ($val = $this->grid->getRequest()->get($k)) { $form->addHidden($this->grid->getId() . '_' . $k)->setValue($val); } } return $form; }
public function bootstrap() { if (defined('APPLICATION_ENV') && APPLICATION_ENV == 'debug') { error_reporting(E_ALL | E_RECOVERABLE_ERROR | E_NOTICE | E_DEPRECATED | E_STRICT); @ini_set('display_errors', true); } else { error_reporting(error_reporting() & ~E_RECOVERABLE_ERROR); // that is really annoying } spl_autoload_register(array(__CLASS__, '__autoload')); $this->di = new Am_Di($this->config); Am_Di::_setInstance($this->di); $this->di->app = $this; set_error_handler(array($this, '__error')); set_exception_handler(array($this, '__exception')); $this->di->init(); try { $this->di->getService('db'); } catch (Am_Exception $e) { if (defined('AM_DEBUG') && AM_DEBUG) { amDie($e->getMessage()); } else { amDie($e->getPublicError()); } } $this->di->config; // this will reset timezone to UTC if nothing configured in PHP date_default_timezone_set(@date_default_timezone_get()); $this->initConstants(); // set memory limit $limit = @ini_get('memory_limit'); if (preg_match('/(\\d+)M$/', $limit, $regs) && $regs[1] <= 64) { @ini_set('memory_limit', '64M'); } // $this->initModules(); $this->initSession(); Am_Locale::initLocale($this->di); $this->initTranslate(); $this->initFront(); require_once 'Am/License.php'; // Load user in order to check may be we need to refresh user's session; $this->di->auth->getUser(); $this->di->hook->call(Am_Event::INIT_FINISHED); $this->bindUploadsIfNecessary(); $this->initFinished = true; if (file_exists(APPLICATION_PATH . "/configs/site.php")) { require_once APPLICATION_PATH . "/configs/site.php"; } }
public function bootstrap() { if (defined('APPLICATION_ENV') && APPLICATION_ENV == 'debug') { error_reporting(E_ALL | E_RECOVERABLE_ERROR | E_NOTICE | E_DEPRECATED | E_STRICT); @ini_set('display_errors', true); } else { error_reporting(error_reporting() & ~E_RECOVERABLE_ERROR); // that is really annoying } spl_autoload_register(array(__CLASS__, '__autoload')); $this->di = new Am_Di($this->config); Am_Di::_setInstance($this->di); $this->di->app = $this; set_error_handler(array($this, '__error')); set_exception_handler(array($this, '__exception')); $this->di->init(); try { $this->di->getService('db'); } catch (Am_Exception $e) { if (defined('AM_DEBUG') && AM_DEBUG) { amDie($e->getMessage()); } else { amDie($e->getPublicError()); } } $this->di->config; $this->initConstants(); // set memory limit $limit = @ini_get('memory_limit'); if (preg_match('/(\\d+)M$/', $limit, $regs) && $regs[1] <= 32) { @ini_set('memory_limit', '32M'); } // $this->initFront(); require_once 'Am/License.php'; $this->initModules(); /** @todo 4.2.0 move after initTranlate !! alex */ $this->initSession(); Am_Locale::initLocale($this->di); $this->initTranslate(); $this->di->blocks->addDefaultBlocks(); $this->di->hook->call(Am_Event::INIT_FINISHED); if (file_exists(APPLICATION_PATH . "/configs/site.php")) { require_once APPLICATION_PATH . "/configs/site.php"; } }