コード例 #1
0
ファイル: waContact.class.php プロジェクト: Lazary/webasyst
 /**
  * Returns contact's locale id.
  *
  * @return string
  */
 public function getLocale()
 {
     if (!$this->id) {
         $locale = isset($this->data['locale']) ? $this->data['locale'] : null;
         if (!$locale) {
             $locale = waRequest::get('lang');
         }
     } else {
         if (isset(self::$cache[$this->id]['locale'])) {
             $locale = self::$cache[$this->id]['locale'];
         } else {
             $contact_model = new waContactModel();
             $contact_info = $contact_model->getById($this->id);
             $this->setCache($contact_info);
             $locale = isset($contact_info['locale']) ? $contact_info['locale'] : '';
         }
     }
     if (wa()->getEnv() == 'frontend' && waRequest::param('locale')) {
         return waRequest::param('locale');
     }
     // try get locale by header Accept-Language (only for current user)
     if (!$locale && $this instanceof waAuthUser) {
         $locale = waRequest::getLocale();
     }
     if (!$locale) {
         $locale = self::$options['default']['locale'];
     }
     return $locale;
 }