コード例 #1
0
ファイル: EnabledTest.php プロジェクト: cargomedia/cm
 public function testEnabled()
 {
     $english = CM_Model_Language::create('English', 'en', true);
     $italian = CM_Model_Language::create('Italian', 'it', true);
     $german = CM_Model_Language::create('German', 'de', true);
     $french = CM_Model_Language::create('French', 'fr', true);
     $svenska = CM_Model_Language::create('Svenska', 'sv', false);
     $paging = new CM_Paging_Language_Enabled();
     $this->assertEquals([$english, $french, $german, $italian], $paging->getItems());
     $this->assertNotContains($svenska, $paging->getItems());
 }
コード例 #2
0
ファイル: Abstract.php プロジェクト: cargomedia/cm
 /**
  * @return CM_Model_Language|null
  */
 private function _getLanguageBrowser()
 {
     if ($this->hasHeader('Accept-Language')) {
         $languagePaging = new CM_Paging_Language_Enabled();
         $acceptLanguageHeader = explode(',', $this->getHeader('Accept-Language'));
         foreach ($acceptLanguageHeader as $acceptLanguage) {
             $acceptLanguage = explode(';', trim($acceptLanguage));
             $locale = explode('-', $acceptLanguage[0]);
             if ($language = $languagePaging->findByAbbreviation($locale[0])) {
                 return $language;
             }
         }
     }
     return null;
 }