當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Site::setLanguageCode方法代碼示例

本文整理匯總了PHP中Site::setLanguageCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Site::setLanguageCode方法的具體用法?PHP Site::setLanguageCode怎麽用?PHP Site::setLanguageCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Site的用法示例。


在下文中一共展示了Site::setLanguageCode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSites

 /**
  * @since 1.21
  *
  * @return array
  */
 public static function getSites()
 {
     $sites = array();
     $site = new Site();
     $site->setGlobalId('foobar');
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('enwiktionary');
     $site->setGroup('wiktionary');
     $site->setLanguageCode('en');
     $site->addNavigationId('enwiktionary');
     $site->setPath(MediaWikiSite::PATH_PAGE, "https://en.wiktionary.org/wiki/\$1");
     $site->setPath(MediaWikiSite::PATH_FILE, "https://en.wiktionary.org/w/\$1");
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('dewiktionary');
     $site->setGroup('wiktionary');
     $site->setLanguageCode('de');
     $site->addInterwikiId('dewiktionary');
     $site->addInterwikiId('wiktionaryde');
     $site->setPath(MediaWikiSite::PATH_PAGE, "https://de.wiktionary.org/wiki/\$1");
     $site->setPath(MediaWikiSite::PATH_FILE, "https://de.wiktionary.org/w/\$1");
     $sites[] = $site;
     $site = new Site();
     $site->setGlobalId('spam');
     $site->setGroup('spam');
     $site->setLanguageCode('en');
     $site->addNavigationId('spam');
     $site->addNavigationId('spamz');
     $site->addInterwikiId('spamzz');
     $site->setLinkPath("http://spamzz.test/testing/");
     $sites[] = $site;
     /**
      * Add at least one right-to-left language (current RTL languages in MediaWiki core are:
      * aeb, ar, arc, arz, azb, bcc, bqi, ckb, dv, en_rtl, fa, glk, he, khw, kk_arab, kk_cn,
      * ks_arab, ku_arab, lrc, mzn, pnb, ps, sd, ug_arab, ur, yi).
      */
     $languageCodes = array('de', 'en', 'fa', 'nl', 'nn', 'no', 'sr', 'sv');
     foreach ($languageCodes as $langCode) {
         $site = new MediaWikiSite();
         $site->setGlobalId($langCode . 'wiki');
         $site->setGroup('wikipedia');
         $site->setLanguageCode($langCode);
         $site->addInterwikiId($langCode);
         $site->addNavigationId($langCode);
         $site->setPath(MediaWikiSite::PATH_PAGE, "https://{$langCode}.wikipedia.org/wiki/\$1");
         $site->setPath(MediaWikiSite::PATH_FILE, "https://{$langCode}.wikipedia.org/w/\$1");
         $sites[] = $site;
     }
     return $sites;
 }
開發者ID:mb720,項目名稱:mediawiki,代碼行數:56,代碼來源:TestSites.php

示例2: testSaveSites

 /**
  * @covers HashSiteStore::saveSites
  */
 public function testSaveSites()
 {
     $store = new HashSiteStore();
     $sites = array();
     $site = new Site();
     $site->setGlobalId('enwiki');
     $site->setLanguageCode('en');
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('eswiki');
     $site->setLanguageCode('es');
     $sites[] = $site;
     $this->assertCount(0, $store->getSites(), '0 sites in store');
     $store->saveSites($sites);
     $this->assertCount(2, $store->getSites(), 'Store has 2 sites');
     $this->assertTrue($store->getSites()->hasSite('enwiki'), 'Store has enwiki');
     $this->assertTrue($store->getSites()->hasSite('eswiki'), 'Store has eswiki');
 }
開發者ID:eliagbayani,項目名稱:LiteratureEditor,代碼行數:21,代碼來源:HashSiteStoreTest.php

示例3: testSaveSites

 /**
  * @covers CachingSiteStore::saveSites
  */
 public function testSaveSites()
 {
     $store = new CachingSiteStore(new HashSiteStore(), wfGetMainCache());
     $sites = [];
     $site = new Site();
     $site->setGlobalId('ertrywuutr');
     $site->setLanguageCode('en');
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('sdfhxujgkfpth');
     $site->setLanguageCode('nl');
     $sites[] = $site;
     $this->assertTrue($store->saveSites($sites));
     $site = $store->getSite('ertrywuutr');
     $this->assertInstanceOf('Site', $site);
     $this->assertEquals('en', $site->getLanguageCode());
     $site = $store->getSite('sdfhxujgkfpth');
     $this->assertInstanceOf('Site', $site);
     $this->assertEquals('nl', $site->getLanguageCode());
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:23,代碼來源:CachingSiteStoreTest.php

示例4: testSaveSites

 /**
  * @covers DBSiteStore::saveSites
  */
 public function testSaveSites()
 {
     $store = new DBSiteStore();
     $sites = array();
     $site = new Site();
     $site->setGlobalId('ertrywuutr');
     $site->setLanguageCode('en');
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('sdfhxujgkfpth');
     $site->setLanguageCode('nl');
     $sites[] = $site;
     $this->assertTrue($store->saveSites($sites));
     $site = $store->getSite('ertrywuutr');
     $this->assertInstanceOf('Site', $site);
     $this->assertEquals('en', $site->getLanguageCode());
     $this->assertTrue(is_integer($site->getInternalId()));
     $this->assertTrue($site->getInternalId() >= 0);
     $site = $store->getSite('sdfhxujgkfpth');
     $this->assertInstanceOf('Site', $site);
     $this->assertEquals('nl', $site->getLanguageCode());
     $this->assertTrue(is_integer($site->getInternalId()));
     $this->assertTrue($site->getInternalId() >= 0);
 }
開發者ID:jpena88,項目名稱:mediawiki-dokku-deploy,代碼行數:27,代碼來源:DBSiteStoreTest.php

示例5: testSetLanguageCode

 /**
  * @dataProvider instanceProvider
  * @param Site $site
  * @covers Site::setLanguageCode
  */
 public function testSetLanguageCode(Site $site)
 {
     $site->setLanguageCode('en');
     $this->assertEquals('en', $site->getLanguageCode());
 }
開發者ID:MediaWiki-stable,項目名稱:1.26.1,代碼行數:10,代碼來源:SiteTest.php


注:本文中的Site::setLanguageCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。