Esempio n. 1
0
 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;
 }