Пример #1
0
 /**
  * Get a list of localized timezone names
  *
  * @return array
  */
 public static function getList()
 {
     $xoops = \Xoops::getInstance();
     $locale = \Xoops\Locale::getCurrent();
     $key = ['system', 'lists', 'timezone', $locale];
     //$xoops->cache()->delete($key);
     $timeZones = $xoops->cache()->cacheRead($key, function () {
         $timeZones = array();
         $territories = Territory::getContinentsAndCountries();
         $maxLen = 0;
         $utcDtz = new \DateTimeZone('UTC');
         foreach ($territories as $byContinent) {
             $continent = $byContinent['name'];
             foreach ($byContinent['children'] as $cCode => $cName) {
                 $allZones = $utcDtz->listIdentifiers(\DateTimeZone::PER_COUNTRY, $cCode);
                 foreach ($allZones as $zone) {
                     $maxLen = max(strlen($zone), $maxLen);
                     $name = Calendar::getTimezoneExemplarCity($zone);
                     if (!isset($timeZones[$zone]) && !empty($name)) {
                         $timeZones[$zone] = $continent . '/' . $name;
                     }
                 }
             }
         }
         \XoopsLocale::asort($timeZones);
         $default = array('UTC' => Calendar::getTimezoneNameNoLocationSpecific(new \DateTimeZone('GMT')));
         $timeZones = array_merge($default, $timeZones);
         return $timeZones;
     });
     return $timeZones;
 }
Пример #2
0
 /**
  * gets list of locales
  *
  * @param boolean $showInCodeLanguage true to show a code's name in the language the code represents
  *
  * @return array
  */
 public static function getList($showInCodeLanguage = false)
 {
     $locales = Data::getAvailableLocales();
     $languages = array();
     foreach ($locales as $locale) {
         $key = \Xoops\Locale::normalizeLocale($locale);
         $languages[$key] = Language::getName($locale, $showInCodeLanguage ? $locale : null);
     }
     \XoopsLocale::asort($languages);
     return $languages;
 }
Пример #3
0
 /**
  * gets list of image file names in a directory
  *
  * @param string $path   filesystem path
  * @param string $prefix prefix added to file names
  *
  * @return array
  */
 public static function getList($path = null, $prefix = '')
 {
     $fileList = array();
     if (is_dir($path) && ($handle = opendir($path))) {
         while (false !== ($file = readdir($handle))) {
             if (preg_match('/\\.(gif|jpg|jpeg|png|swf)$/i', $file)) {
                 $file = $prefix . $file;
                 $fileList[$file] = $file;
             }
         }
         closedir($handle);
         \XoopsLocale::asort($fileList);
         reset($fileList);
     }
     return $fileList;
 }
Пример #4
0
 /**
  * Get a list of localized country names
  *
  * @return array
  */
 public static function getList()
 {
     $countryList = Territory::getCountries();
     \XoopsLocale::asort($countryList);
     return $countryList;
 }