当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Locale::getRegion方法代码示例

本文整理汇总了PHP中Zend_Locale::getRegion方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale::getRegion方法的具体用法?PHP Zend_Locale::getRegion怎么用?PHP Zend_Locale::getRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Locale的用法示例。


在下文中一共展示了Zend_Locale::getRegion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _updateFullName

 /**
  * gets the full name of the currency from the LDML files
  * 
  * @return Zend_Currency
  * @throws Zend_Currency_Exception
  */
 protected function _updateFullName()
 {
     //getting the full name of the currency
     $names = Zend_Locale_Data::getContent('', 'currencynames', $this->_currencyLocale->getRegion());
     $this->_fullName = $names[$this->_shortName];
     return $this;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:Currency.php

示例2: init

 public function init()
 {
     $this->setTitle('Locale Settings')->setDescription('CORE_FORM_ADMIN_SETTINGS_LOCALE_DESCRIPTION');
     // Init timezeon
     $this->addElement('Select', 'timezone', array('label' => 'Default Timezone', 'multiOptions' => array('US/Pacific' => '(UTC-8) Pacific Time (US & Canada)', 'US/Mountain' => '(UTC-7) Mountain Time (US & Canada)', 'US/Central' => '(UTC-6) Central Time (US & Canada)', 'US/Eastern' => '(UTC-5) Eastern Time (US & Canada)', 'America/Halifax' => '(UTC-4)  Atlantic Time (Canada)', 'America/Anchorage' => '(UTC-9)  Alaska (US & Canada)', 'Pacific/Honolulu' => '(UTC-10) Hawaii (US)', 'Pacific/Samoa' => '(UTC-11) Midway Island, Samoa', 'Etc/GMT-12' => '(UTC-12) Eniwetok, Kwajalein', 'Canada/Newfoundland' => '(UTC-3:30) Canada/Newfoundland', 'America/Buenos_Aires' => '(UTC-3) Brasilia, Buenos Aires, Georgetown', 'Atlantic/South_Georgia' => '(UTC-2) Mid-Atlantic', 'Atlantic/Azores' => '(UTC-1) Azores, Cape Verde Is.', 'Europe/London' => 'Greenwich Mean Time (Lisbon, London)', 'Europe/Berlin' => '(UTC+1) Amsterdam, Berlin, Paris, Rome, Madrid', 'Europe/Athens' => '(UTC+2) Athens, Helsinki, Istanbul, Cairo, E. Europe', 'Europe/Moscow' => '(UTC+3) Baghdad, Kuwait, Nairobi, Moscow', 'Iran' => '(UTC+3:30) Tehran', 'Asia/Dubai' => '(UTC+4) Abu Dhabi, Kazan, Muscat', 'Asia/Kabul' => '(UTC+4:30) Kabul', 'Asia/Yekaterinburg' => '(UTC+5) Islamabad, Karachi, Tashkent', 'Asia/Dili' => '(UTC+5:30) Bombay, Calcutta, New Delhi', 'Asia/Katmandu' => '(UTC+5:45) Nepal', 'Asia/Omsk' => '(UTC+6) Almaty, Dhaka', 'India/Cocos' => '(UTC+6:30) Cocos Islands, Yangon', 'Asia/Krasnoyarsk' => '(UTC+7) Bangkok, Jakarta, Hanoi', 'Asia/Hong_Kong' => '(UTC+8) Beijing, Hong Kong, Singapore, Taipei', 'Asia/Tokyo' => '(UTC+9) Tokyo, Osaka, Sapporto, Seoul, Yakutsk', 'Australia/Adelaide' => '(UTC+9:30) Adelaide, Darwin', 'Australia/Sydney' => '(UTC+10) Brisbane, Melbourne, Sydney, Guam', 'Asia/Magadan' => '(UTC+11) Magadan, Soloman Is., New Caledonia', 'Pacific/Auckland' => '(UTC+12) Fiji, Kamchatka, Marshall Is., Wellington')));
     // Init default locale
     $localeObject = Zend_Registry::get('Locale');
     $languages = Zend_Locale::getTranslationList('language', $localeObject);
     $territories = Zend_Locale::getTranslationList('territory', $localeObject);
     $localeMultiOptions = array();
     foreach (array_keys(Zend_Locale::getLocaleList()) as $key) {
         $languageName = null;
         if (!empty($languages[$key])) {
             $languageName = $languages[$key];
         } else {
             $tmpLocale = new Zend_Locale($key);
             $region = $tmpLocale->getRegion();
             $language = $tmpLocale->getLanguage();
             if (!empty($languages[$language]) && !empty($territories[$region])) {
                 $languageName = $languages[$language] . ' (' . $territories[$region] . ')';
             }
         }
         if ($languageName) {
             $localeMultiOptions[$key] = $languageName . ' [' . $key . ']';
         }
     }
     $localeMultiOptions = array_merge(array('auto' => '[Automatic]'), $localeMultiOptions);
     $this->addElement('Select', 'locale', array('label' => 'Default Locale', 'multiOptions' => $localeMultiOptions, 'value' => 'auto', 'disableTranslator' => true));
     // init submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
 }
开发者ID:robeendey,项目名称:ce,代码行数:31,代码来源:Locale.php

示例3: init

 public function init()
 {
     $this->setTitle('Language Manager')->setDescription('Create a new language pack')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
     $localeObject = Zend_Registry::get('Locale');
     $languages = Zend_Locale::getTranslationList('language', $localeObject);
     $territories = Zend_Locale::getTranslationList('territory', $localeObject);
     $localeMultiOptions = array();
     foreach (array_keys(Zend_Locale::getLocaleList()) as $key) {
         $languageName = null;
         if (!empty($languages[$key])) {
             $languageName = $languages[$key];
         } else {
             $tmpLocale = new Zend_Locale($key);
             $region = $tmpLocale->getRegion();
             $language = $tmpLocale->getLanguage();
             if (!empty($languages[$language]) && !empty($territories[$region])) {
                 $languageName = $languages[$language] . ' (' . $territories[$region] . ')';
             }
         }
         if ($languageName) {
             $localeMultiOptions[$key] = $languageName . ' [' . $key . ']';
         }
     }
     //asort($languageNameList);
     $this->addElement('Select', 'language', array('label' => 'Language', 'description' => 'Which language do you want to create a language pack for?', 'multiOptions' => $localeMultiOptions));
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Create', 'type' => 'submit', 'decorators' => array('ViewHelper')));
     $this->addElement('Cancel', 'cancel', array('prependText' => ' or ', 'link' => true, 'label' => 'cancel', 'onclick' => 'history.go(-1); return false;', 'decorators' => array('ViewHelper')));
 }
开发者ID:robeendey,项目名称:ce,代码行数:29,代码来源:Create.php

示例4: setLocale

 /**
  * Try to set given locale
  * Throw Zend_Translate_Exception if cannot
  */
 public function setLocale($name = null)
 {
     try {
         if (!$this->localeName) {
             $this->locale = new Zend_Locale($name);
         } else {
             $this->locale->setLocale($name);
         }
         if (array_key_exists($this->locale->getLanguage(), $this->translationsPaths)) {
             if (!isset($this->translate)) {
                 $this->translate = new Zend_Translate($this->translationAdapter, $this->translationsPaths[$this->locale->getLanguage()], $this->locale->getLanguage());
             } elseif ($this->translate->isAvailable($this->locale->getLanguage())) {
                 $this->translate->setLocale($this->locale->getLanguage());
             } else {
                 $this->translate->addTranslation($this->translationsPaths[$this->locale->getLanguage()], $this->locale->getLanguage());
             }
         } else {
             include_once 'Zend/Translate/Exception.php';
             throw new Zend_Translate_Exception("Unsupported language");
         }
     } catch (Zend_Exception $e) {
         if ($this->localeName) {
             $this->setLocale($this->localeName);
         }
         throw $e;
     }
     $this->localeName = $this->session->localeName = $this->locale->getLanguage() . ($this->locale->getRegion() ? "_" . $this->locale->getRegion() : "");
     Zend_Registry::set('Zend_Locale', $this->locale);
     Zend_Locale::setDefault($this->locale);
 }
开发者ID:pansot2,项目名称:PadCMS-backend,代码行数:34,代码来源:Localizer.php

示例5: getBestRegionFromBrowser

 /**
  * Get best region from browser
  * @return <type>
  */
 public function getBestRegionFromBrowser()
 {
     $region = $this->_zLocale->getRegion();
     if ($region === FALSE) {
         return null;
     }
     return $region;
 }
开发者ID:que273,项目名称:siremis,代码行数:12,代码来源:I18n.php

示例6: on_start

 public function on_start()
 {
     $this->error = Loader::helper('validation/error');
     if (USER_REGISTRATION_WITH_EMAIL_ADDRESS) {
         $this->set('uNameLabel', t('Email Address'));
     } else {
         $this->set('uNameLabel', t('Username'));
     }
     $txt = Loader::helper('text');
     if (strlen($_GET['uName'])) {
         // pre-populate the username if supplied, if its an email address with special characters the email needs to be urlencoded first,
         $this->set("uName", trim($txt->email($_GET['uName'])));
     }
     $languages = array();
     $locales = array();
     if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN')) {
         Loader::library('3rdparty/Zend/Locale');
         Loader::library('3rdparty/Zend/Locale/Data');
         $languages = Localization::getAvailableInterfaceLanguages();
         if (count($languages) > 0) {
             array_unshift($languages, 'en_US');
         }
         $locales = array();
         Zend_Locale_Data::setCache(Cache::getLibrary());
         foreach ($languages as $lang) {
             $loc = new Zend_Locale($lang);
             $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', $lang);
             $locRegion = $loc->getRegion();
             if ($locRegion !== false) {
                 $locRegionName = $loc->getTranslation($loc->getRegion(), 'country', $lang);
                 if ($locRegionName !== false) {
                     $locales[$lang] .= ' (' . $locRegionName . ')';
                 }
             }
         }
         asort($locales);
         $locales = array_merge(array('' => t('** Default')), $locales);
     }
     $this->locales = $locales;
     $this->set('locales', $locales);
     $this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
 }
开发者ID:ronlobo,项目名称:concrete5,代码行数:42,代码来源:login.php

示例7: init

 public function init()
 {
     // @todo fix form CSS/decorators
     // @todo replace fake values with real values
     $this->setTitle('General Settings')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
     // Init email
     $this->addElement('Text', 'email', array('label' => 'Email Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity()))))));
     $this->email->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty');
     $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound');
     // Init username
     $this->addElement('Text', 'username', array('label' => 'Profile Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z0-9]/i')), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'username', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity()))))));
     $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile address.', 'isEmpty');
     $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile address, please use another one.', 'recordFound');
     $this->username->getValidator('Regex')->setMessage('Profile addresses must start with a letter.', 'regexNotMatch');
     $this->username->getValidator('Alnum')->setMessage('Profile addresses must be alphanumeric.', 'notAlnum');
     // Init type
     $this->addElement('Select', 'accountType', array('label' => 'Account Type'));
     // Init Facebook
     $facebook_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_facebook_enable', 'none');
     if ('none' != $facebook_enable) {
         $and_publish = 'publish' == $facebook_enable ? ' and publish content to your Facebook wall.' : '.';
         $this->addElement('Dummy', 'facebook', array('label' => 'Facebook Integration', 'description' => 'Linking your Facebook account will let you login with Facebook' . $and_publish, 'content' => User_Model_DbTable_Facebook::loginButton('Integrate with my Facebook')));
         $this->addElement('Checkbox', 'facebook_id', array('label' => 'Integrate with my Facebook', 'description' => 'Facebook Integration'));
     }
     // Init timezone
     $this->addElement('Select', 'timezone', array('label' => 'Timezone', 'description' => 'Select the city closest to you that shares your same timezone.', 'multiOptions' => array('US/Pacific' => '(UTC-8) Pacific Time (US & Canada)', 'US/Mountain' => '(UTC-7) Mountain Time (US & Canada)', 'US/Central' => '(UTC-6) Central Time (US & Canada)', 'US/Eastern' => '(UTC-5) Eastern Time (US & Canada)', 'America/Halifax' => '(UTC-4)  Atlantic Time (Canada)', 'America/Anchorage' => '(UTC-9)  Alaska (US & Canada)', 'Pacific/Honolulu' => '(UTC-10) Hawaii (US)', 'Pacific/Samoa' => '(UTC-11) Midway Island, Samoa', 'Etc/GMT-12' => '(UTC-12) Eniwetok, Kwajalein', 'Canada/Newfoundland' => '(UTC-3:30) Canada/Newfoundland', 'America/Buenos_Aires' => '(UTC-3) Brasilia, Buenos Aires, Georgetown', 'Atlantic/South_Georgia' => '(UTC-2) Mid-Atlantic', 'Atlantic/Azores' => '(UTC-1) Azores, Cape Verde Is.', 'Europe/London' => 'Greenwich Mean Time (Lisbon, London)', 'Europe/Berlin' => '(UTC+1) Amsterdam, Berlin, Paris, Rome, Madrid', 'Europe/Athens' => '(UTC+2) Athens, Helsinki, Istanbul, Cairo, E. Europe', 'Europe/Moscow' => '(UTC+3) Baghdad, Kuwait, Nairobi, Moscow', 'Iran' => '(UTC+3:30) Tehran', 'Asia/Dubai' => '(UTC+4) Abu Dhabi, Kazan, Muscat', 'Asia/Kabul' => '(UTC+4:30) Kabul', 'Asia/Yekaterinburg' => '(UTC+5) Islamabad, Karachi, Tashkent', 'Asia/Dili' => '(UTC+5:30) Bombay, Calcutta, New Delhi', 'Asia/Katmandu' => '(UTC+5:45) Nepal', 'Asia/Omsk' => '(UTC+6) Almaty, Dhaka', 'India/Cocos' => '(UTC+6:30) Cocos Islands, Yangon', 'Asia/Krasnoyarsk' => '(UTC+7) Bangkok, Jakarta, Hanoi', 'Asia/Hong_Kong' => '(UTC+8) Beijing, Hong Kong, Singapore, Taipei', 'Asia/Tokyo' => '(UTC+9) Tokyo, Osaka, Sapporto, Seoul, Yakutsk', 'Australia/Adelaide' => '(UTC+9:30) Adelaide, Darwin', 'Australia/Sydney' => '(UTC+10) Brisbane, Melbourne, Sydney, Guam', 'Asia/Magadan' => '(UTC+11) Magadan, Soloman Is., New Caledonia', 'Pacific/Auckland' => '(UTC+12) Fiji, Kamchatka, Marshall Is., Wellington')));
     // Init default locale
     $locale = Zend_Registry::get('Locale');
     $localeMultiKeys = array_merge(array_keys(Zend_Locale::getLocaleList()));
     $localeMultiOptions = array();
     $languages = Zend_Locale::getTranslationList('language', $locale);
     $territories = Zend_Locale::getTranslationList('territory', $locale);
     foreach ($localeMultiKeys as $key) {
         if (!empty($languages[$key])) {
             $localeMultiOptions[$key] = $languages[$key];
         } else {
             $locale = new Zend_Locale($key);
             $region = $locale->getRegion();
             $language = $locale->getLanguage();
             if (!empty($languages[$language]) && !empty($territories[$region])) {
                 $localeMultiOptions[$key] = $languages[$language] . ' (' . $territories[$region] . ')';
             }
         }
     }
     $localeMultiOptions = array_merge(array('auto' => '[Automatic]'), $localeMultiOptions);
     $this->addElement('Select', 'locale', array('label' => 'Locale', 'description' => 'Dates, times, and other settings will be displayed using this locale setting.', 'multiOptions' => $localeMultiOptions));
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
     // Create display group for buttons
     #$this->addDisplayGroup($emailAlerts, 'checkboxes');
     // Set default action
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'settings', 'action' => 'general'), 'default'));
 }
开发者ID:robeendey,项目名称:ce,代码行数:53,代码来源:General.php

示例8: Field

 public function Field($properties = array())
 {
     $source = $this->getSource();
     if (!$this->value || !isset($source[$this->value])) {
         if ($this->config()->get('default_to_locale') && $this->locale()) {
             $locale = new Zend_Locale();
             $locale->setLocale($this->locale());
             $this->value = $locale->getRegion();
         }
     }
     if (!$this->value || !isset($source[$this->value])) {
         $this->value = $this->config()->get('default_country');
     }
     return parent::Field();
 }
开发者ID:normann,项目名称:sapphire,代码行数:15,代码来源:CountryDropdownField.php

示例9: init

 public function init()
 {
     // Set form attributes
     $this->setTitle('Mail Templates')->setDescription('CORE_FORM_ADMIN_SETTINGS_EMAIL_DESCRIPTION');
     // Element: language
     $this->addElement('Select', 'language', array('label' => 'Language Pack', 'description' => 'Your community has more than one language pack installed. Please select the language pack you want to edit right now.', 'onchange' => 'javascript:setEmailLanguage(this.value);'));
     // Languages
     $localeObject = Zend_Registry::get('Locale');
     $translate = Zend_Registry::get('Zend_Translate');
     $languageList = $translate->getList();
     $languages = Zend_Locale::getTranslationList('language', $localeObject);
     $territories = Zend_Locale::getTranslationList('territory', $localeObject);
     $localeMultiOptions = array();
     foreach ($languageList as $key) {
         $languageName = null;
         if (!empty($languages[$key])) {
             $languageName = $languages[$key];
         } else {
             $tmpLocale = new Zend_Locale($key);
             $region = $tmpLocale->getRegion();
             $language = $tmpLocale->getLanguage();
             if (!empty($languages[$language]) && !empty($territories[$region])) {
                 $languageName = $languages[$language] . ' (' . $territories[$region] . ')';
             }
         }
         if ($languageName) {
             $localeMultiOptions[$key] = $languageName . ' [' . $key . ']';
         }
     }
     $defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
     if (isset($localeMultiOptions[$defaultLanguage])) {
         $localeMultiOptions = array_merge(array($defaultLanguage => $localeMultiOptions[$defaultLanguage]), $localeMultiOptions);
     }
     $this->language->setMultiOptions($localeMultiOptions);
     // Element: template_id
     $this->addElement('Select', 'template', array('label' => 'Choose Message', 'onchange' => 'javascript:fetchEmailTemplate(this.value);', 'ignore' => true));
     $this->template->getDecorator("Description")->setOption("placement", "append");
     foreach (Engine_Api::_()->getDbtable('MailTemplates', 'core')->fetchAll() as $mailTemplate) {
         $title = $translate->_(strtoupper("_email_" . $mailTemplate->type . "_title"));
         $this->template->addMultiOption($mailTemplate->mailtemplate_id, $title);
     }
     // Element: subject
     $this->addElement('Text', 'subject', array('label' => 'Subject', 'style' => 'min-width:400px;'));
     // Element: body
     $this->addElement('Textarea', 'body', array('label' => 'Message Body'));
     // Element: submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
 }
开发者ID:robeendey,项目名称:ce,代码行数:48,代码来源:Templates.php

示例10: changelanguageAction

 public function changelanguageAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     //        die("language");
     $request = $this->getRequest();
     if ($this->getRequest()->isPost()) {
         $locale = new Zend_Locale($request->getPost('language'));
         $default = new Zend_Session_Namespace('default');
         $default->language = $locale->getLanguage();
         $default->locale = $locale->getRegion();
         $this->_redirect($request->getPost('refer'));
     } else {
         return;
     }
     return;
 }
开发者ID:roigrande,项目名称:globalpms,代码行数:16,代码来源:IndexController.php

示例11: Field

 public function Field($properties = array())
 {
     $source = $this->getSource();
     // Default value to best availabel locale
     $value = $this->Value();
     if ($this->config()->default_to_locale && (!$value || !isset($source[$value])) && $this->locale()) {
         $locale = new Zend_Locale();
         $locale->setLocale($this->locale());
         $value = $locale->getRegion();
         $this->setValue($value);
     }
     // Default to default country otherwise
     if (!$value || !isset($source[$value])) {
         $this->setValue($this->config()->default_country);
     }
     return parent::Field($properties);
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:17,代码来源:CountryDropdownField.php

示例12: _initLocale

 protected function _initLocale()
 {
     $locale = new Zend_Locale();
     $config = $this->getOptions();
     $defaultLocale = $config['lang_local'];
     try {
         $locale = new Zend_Locale('auto');
     } catch (Zend_Locale_Exception $e) {
         $locale = new Zend_Locale($defaultLocale);
     }
     if (!isset($_SESSION['default']['locale'])) {
         $_SESSION['default']['locale'] = $locale->getRegion();
     }
     if (!isset($_SESSION['default']['language'])) {
         $_SESSION['default']['language'] = $locale->getLanguage();
     }
     Zend_Registry::set('Zend_Locale', $locale);
 }
开发者ID:roigrande,项目名称:globalpms,代码行数:18,代码来源:Bootstrap.php

示例13: setLocale

 /**
  * Sets the locale to use
  *
  * @param string|Zend_Locale $locale
  * @throws Zend_Validate_Exception On unrecognised region
  * @throws Zend_Validate_Exception On not detected format
  * @return Zend_Validate_PostCode  Provides fluid interface
  */
 public function setLocale($locale = null)
 {
     #require_once 'Zend/Locale.php';
     $this->_locale = Zend_Locale::findLocale($locale);
     $locale = new Zend_Locale($this->_locale);
     $region = $locale->getRegion();
     if (empty($region)) {
         #require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception("Unable to detect a region for the locale '{$locale}'");
     }
     $format = Zend_Locale::getTranslation($locale->getRegion(), 'postaltoterritory', $this->_locale);
     if (empty($format)) {
         #require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception("Unable to detect a postcode format for the region '{$locale->getRegion()}'");
     }
     $this->setFormat($format);
     return $this;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:26,代码来源:PostCode.php

示例14: getPresentationModel

 /**
  * Returns the topics table as a presentation model (array of arrays containing
  * information about each topic, suitable for use by a view) by mirroring
  * the domain model into a presentation model.  The presentation model can be modified
  * to support the needs of a view, without mangling the raw, real underlying table data.
  * STAGE 4: Apply business logic to create a presentation model for the view.
  * @return array of ArrayObjects (containing topic info) indexed by topic id
  */
 public static function getPresentationModel()
 {
     if (self::$_presentationModel === null) {
         foreach (self::getDomainModel() as $row) {
             $row = new ArrayObject($row->toArray(), ArrayObject::ARRAY_AS_PROPS);
             $row->user = ZFDemoModel_Users::getById($row->user_id);
             self::$_presentationModel[$row->topic_id] = $row;
             /////////////////////////////
             // ==> SECTION: l10n <==
             // create a Locale object for the owner of this post (not the user of this request)
             $postLocale = new Zend_Locale($row->user->locale);
             $row->country = ZFModule_Forum::getCountry($postLocale->getRegion());
             $userLocale = ZFModule_Forum::getUserLocale();
             // locale of the user of this request
             $userLocale = Zend_Registry::get('userLocale');
             $offset = ZFModule_Forum::getTimeOffset();
             if ($row->modification_time != $row->creation_time) {
                 $row->modification_time = new Zend_Date($row->modification_time, $userLocale);
                 $row->modification_time->addTimestamp($offset);
                 // express date/time in user's local timezone
             } else {
                 $row->modification_time = '';
             }
             $row->creation_time = new Zend_Date($row->creation_time, $userLocale);
             $row->creation_time->addTimestamp($offset);
             // express date/time in user's local timezone
         }
     }
     return self::$_presentationModel;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:38,代码来源:Topics.php

示例15: getCountryLanguages

 public static function getCountryLanguages()
 {
     if (!self::$countryLanguages) {
         $locales = Zend_Locale::getLocaleList();
         $enLocale = new Zend_Locale('en');
         $countries = array();
         foreach ($locales as $k => $v) {
             $tmpLocale = new Zend_Locale($k);
             $region = $tmpLocale->getRegion();
             try {
                 $countryName = Zend_Locale::getTranslation($region, 'Territory', self::getLocale());
                 if (!trim($countryName)) {
                     throw new Zmz_Culture_Exception('No translation for current locale');
                 }
             } catch (Exception $e) {
                 $countryName = Zend_Locale::getTranslation($region, 'Territory', $enLocale);
             }
             if (!trim($countryName)) {
                 continue;
             }
             try {
                 $languageTranslation = Zend_Locale::getTranslation($tmpLocale->getLanguage(), 'language', self::getLocale());
                 if (!trim($languageTranslation)) {
                     throw new Zmz_Culture_Exception('No translation for current locale');
                 }
             } catch (Exception $e) {
                 $languageTranslation = Zend_Locale::getTranslation($tmpLocale->getLanguage(), 'language', $enLocale);
             }
             if (!trim($languageTranslation)) {
                 continue;
             }
             if (!isset($countries[$region])) {
                 $countries[$region] = array('name' => $countryName, 'locales' => array());
             }
             $countries[$region]['locales'][$k] = $languageTranslation;
         }
         self::$countryLanguages = $countries;
     }
     return self::$countryLanguages;
 }
开发者ID:massimozappino,项目名称:zmz,代码行数:40,代码来源:Culture.php


注:本文中的Zend_Locale::getRegion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。