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


PHP Language::factory方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $langObj = Language::factory('en');
     $localZone = 'UTC';
     $localOffset = date('Z') / 60;
     $this->setMwGlobals(array('wgMemc' => new EmptyBagOStuff(), 'wgContLang' => $langObj, 'wgLang' => $langObj, 'wgLocaltimezone' => $localZone, 'wgLocalTZoffset' => $localOffset, 'wgNamespaceProtection' => array(NS_MEDIAWIKI => 'editinterface')));
     $this->userName = 'Useruser';
     $this->altUserName = 'Altuseruser';
     date_default_timezone_set($localZone);
     $this->title = Title::makeTitle(NS_MAIN, "Main Page");
     if (!isset($this->userUser) || !$this->userUser instanceof User) {
         $this->userUser = User::newFromName($this->userName);
         if (!$this->userUser->getID()) {
             $this->userUser = User::createNew($this->userName, array("email" => "test@example.com", "real_name" => "Test User"));
             $this->userUser->load();
         }
         $this->altUser = User::newFromName($this->altUserName);
         if (!$this->altUser->getID()) {
             $this->altUser = User::createNew($this->altUserName, array("email" => "alttest@example.com", "real_name" => "Test User Alt"));
             $this->altUser->load();
         }
         $this->anonUser = User::newFromId(0);
         $this->user = $this->userUser;
     }
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:26,代码来源:TitlePermissionTest.php

示例2: initLanguage

	/**
	 * Internal utility function for initialising the global entity language 
	 * fallback sequence.
	 */
	function initLanguage( $user, $election ) {
		global $wgRequest, $wgLang;
		$uselang = $wgRequest->getVal( 'uselang' );
		if ( $uselang !== null ) {
			$userLang = $uselang;
		} elseif ( $user instanceof SecurePoll_Voter ) {
			$userLang = $user->getLanguage();
		} else {
			$userLang = $user->getOption( 'language' );
		}
		$wgLang = Language::factory( $userLang );

		$languages = array( $userLang );
		$fallback = $userLang;
		while ( $fallback = Language::getFallbackFor( $fallback ) ) {
			$languages[] = $fallback;
		}
		if ( $fallback != $election->getLanguage() ) {
			$fallback = $election->getLanguage();
			$languages[] = $fallback;
		}
		if ( $fallback != 'en' ) {
			$languages[] = 'en';
		}
		$this->context->setLanguages( $languages );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:30,代码来源:Page.php

示例3: execute

 /**
  * Generates the html snippet for ajax edit. Echoes it to the output and
  * disabled all other output.
  */
 public function execute()
 {
     global $wgServer, $wgScriptPath;
     $context = RequestContext::getMain();
     $context->getOutput()->disable();
     $data = $this->getEditInfo();
     $helpers = new TranslationHelpers($this->getTitle(), '');
     $id = "tm-target-{$helpers->dialogID()}";
     $helpers->setTextareaId($id);
     if ($this->suggestions === 'checks') {
         echo $helpers->getBoxes($this->suggestions);
         return;
     }
     $handle = new MessageHandle($this->getTitle());
     $groupId = MessageIndex::getPrimaryGroupId($handle);
     $translation = '';
     if ($groupId) {
         $translation = $helpers->getTranslation();
     }
     $targetLang = Language::factory($helpers->getTargetLanguage());
     $textareaParams = array('name' => 'text', 'class' => 'mw-translate-edit-area', 'id' => $id, 'lang' => $targetLang->getCode(), 'dir' => $targetLang->getDir());
     if (!$groupId || !$context->getUser()->isAllowed('translate')) {
         $textareaParams['readonly'] = 'readonly';
     }
     $extraInputs = '';
     Hooks::run('TranslateGetExtraInputs', array(&$translation, &$extraInputs));
     $textarea = Html::element('textarea', $textareaParams, $translation);
     $hidden = array();
     $hidden[] = Html::hidden('title', $this->getTitle()->getPrefixedDbKey());
     if (isset($data['revisions'][0]['timestamp'])) {
         $hidden[] = Html::hidden('basetimestamp', $data['revisions'][0]['timestamp']);
     }
     $hidden[] = Html::hidden('starttimestamp', $data['starttimestamp']);
     if (isset($data['edittoken'])) {
         $hidden[] = Html::hidden('token', $data['edittoken']);
     }
     $hidden[] = Html::hidden('format', 'json');
     $hidden[] = Html::hidden('action', 'edit');
     $summary = Xml::inputLabel($context->msg('translate-js-summary')->text(), 'summary', 'summary', 40);
     $save = Xml::submitButton($context->msg('translate-js-save')->text(), array('class' => 'mw-translate-save'));
     $saveAndNext = Xml::submitButton($context->msg('translate-js-next')->text(), array('class' => 'mw-translate-next'));
     $skip = Html::element('input', array('class' => 'mw-translate-skip', 'type' => 'button', 'value' => $context->msg('translate-js-skip')->text()));
     if ($this->getTitle()->exists()) {
         $history = Html::element('input', array('class' => 'mw-translate-history', 'type' => 'button', 'value' => $context->msg('translate-js-history')->text()));
     } else {
         $history = '';
     }
     $support = $this->getSupportButton($this->getTitle());
     if ($context->getUser()->isAllowed('translate')) {
         $bottom = "{$summary}{$save}{$saveAndNext}{$skip}{$history}{$support}";
     } else {
         $text = $context->msg('translate-edit-nopermission')->escaped();
         $button = $this->getPermissionPageButton();
         $bottom = "{$text} {$button}{$skip}{$history}{$support}";
     }
     // Use the api to submit edits
     $formParams = array('action' => "{$wgServer}{$wgScriptPath}/api.php", 'method' => 'post');
     $form = Html::rawElement('form', $formParams, implode("\n", $hidden) . "\n" . $helpers->getBoxes($this->suggestions) . "\n" . Html::rawElement('div', array('class' => 'mw-translate-inputs'), "{$textarea}\n{$extraInputs}") . "\n" . Html::rawElement('div', array('class' => 'mw-translate-bottom'), $bottom));
     echo Html::rawElement('div', array('class' => 'mw-ajax-dialog'), $form);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:64,代码来源:TranslationEditPage.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     $langObj = Language::factory('en');
     $langObj->setNamespaces([-2 => 'Media', -1 => 'Special', 0 => '', 1 => 'Talk', 2 => 'User', 3 => 'User_talk', 4 => 'MyWiki', 5 => 'MyWiki_Talk', 6 => 'File', 7 => 'File_talk', 8 => 'MediaWiki', 9 => 'MediaWiki_talk', 10 => 'Template', 11 => 'Template_talk', 100 => 'Custom', 101 => 'Custom_talk']);
     $this->setMwGlobals(['wgLang' => $langObj, 'wgUseMediaWikiUIEverywhere' => false]);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:XmlTest.php

示例5: wfInstallerMain

function wfInstallerMain()
{
    global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
    $installer = new WebInstaller($wgRequest);
    if (!$installer->startSession()) {
        $installer->finish();
        exit;
    }
    $fingerprint = $installer->getFingerprint();
    if (isset($_SESSION['installData'][$fingerprint])) {
        $session = $_SESSION['installData'][$fingerprint];
    } else {
        $session = array();
    }
    if (!is_null($wgRequest->getVal('uselang'))) {
        $langCode = $wgRequest->getVal('uselang');
    } elseif (isset($session['settings']['_UserLang'])) {
        $langCode = $session['settings']['_UserLang'];
    } else {
        $langCode = 'en';
    }
    $wgLang = Language::factory($langCode);
    $installer->setParserLanguage($wgLang);
    $wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
    $session = $installer->execute($session);
    $_SESSION['installData'][$fingerprint] = $session;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:index.php

示例6: setUp

 function setUp()
 {
     global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang;
     parent::setUp();
     if (!$wgMemc) {
         $wgMemc = new EmptyBagOStuff();
     }
     $wgContLang = $wgLang = Language::factory('en');
     $this->userName = "Useruser";
     $this->altUserName = "Altuseruser";
     date_default_timezone_set($wgLocaltimezone);
     $wgLocalTZoffset = date("Z") / 60;
     $this->title = Title::makeTitle(NS_MAIN, "Main Page");
     if (!isset($this->userUser) || !$this->userUser instanceof User) {
         $this->userUser = User::newFromName($this->userName);
         if (!$this->userUser->getID()) {
             $this->userUser = User::createNew($this->userName, array("email" => "test@example.com", "real_name" => "Test User"));
             $this->userUser->load();
         }
         $this->altUser = User::newFromName($this->altUserName);
         if (!$this->altUser->getID()) {
             $this->altUser = User::createNew($this->altUserName, array("email" => "alttest@example.com", "real_name" => "Test User Alt"));
             $this->altUser->load();
         }
         $this->anonUser = User::newFromId(0);
         $this->user = $this->userUser;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:28,代码来源:TitlePermissionTest.php

示例7: execute

 public function execute()
 {
     global $wgMessageCache;
     $params = $this->extractRequestParams();
     if (!is_null($params['lang'])) {
         global $wgLang;
         $wgLang = Language::factory($params['lang']);
     }
     //Determine which messages should we print
     $messages_target = array();
     if ($params['messages'] == '*') {
         $wgMessageCache->loadAllMessages();
         $message_names = array_keys(array_merge(Language::getMessagesFor('en'), $wgMessageCache->getExtensionMessagesFor('en')));
         sort($message_names);
         $messages_target = $message_names;
     } else {
         $messages_target = explode('|', $params['messages']);
     }
     //Filter messages
     if (isset($params['filter'])) {
         $messages_filtered = array();
         foreach ($messages_target as $message) {
             if (strpos($message, $params['filter']) !== false) {
                 //!== is used because filter can be at the beginnig of the string
                 $messages_filtered[] = $message;
             }
         }
         $messages_target = $messages_filtered;
     }
     //Get all requested messages
     $messages = array();
     $skip = !is_null($params['from']);
     foreach ($messages_target as $message) {
         // Skip all messages up to $params['from']
         if ($skip && $message === $params['from']) {
             $skip = false;
         }
         if (!$skip) {
             $messages[$message] = wfMsg($message);
         }
     }
     //Print the result
     $result = $this->getResult();
     $messages_out = array();
     foreach ($messages as $name => $value) {
         $message = array();
         $message['name'] = $name;
         if (wfEmptyMsg($name, $value)) {
             $message['missing'] = '';
         } else {
             $result->setContent($message, $value);
         }
         $fit = $result->addValue(array('query', $this->getModuleName()), null, $message);
         if (!$fit) {
             $this->setContinueEnumParameter('from', $name);
             break;
         }
     }
     $result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'message');
 }
开发者ID:josephdye,项目名称:wikireader,代码行数:60,代码来源:ApiQueryAllmessages.php

示例8: __construct

 public function __construct()
 {
     // This will set $locale and collators, which affect the actual sorting order
     parent::__construct('fa');
     // Override the 'fa' language set by parent constructor, which affects #getFirstLetterData()
     $this->digitTransformLanguage = Language::factory('ckb');
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:CollationCkb.php

示例9: testGetpageviewlanguage

 /**
  * @dataProvider provideCasesForGetpageviewlanguage
  */
 function testGetpageviewlanguage($expected, $titleText, $contLang, $lang, $variant, $msg = '')
 {
     // Save globals
     global $wgContLang, $wgLang, $wgAllowUserJs, $wgLanguageCode, $wgDefaultLanguageVariant;
     $save['wgContLang'] = $wgContLang;
     $save['wgLang'] = $wgLang;
     $save['wgAllowUserJs'] = $wgAllowUserJs;
     $save['wgLanguageCode'] = $wgLanguageCode;
     $save['wgDefaultLanguageVariant'] = $wgDefaultLanguageVariant;
     // Setup test environnement:
     $wgContLang = Language::factory($contLang);
     $wgLang = Language::factory($lang);
     # To test out .js titles:
     $wgAllowUserJs = true;
     $wgLanguageCode = $contLang;
     $wgDefaultLanguageVariant = $variant;
     $title = Title::newFromText($titleText);
     $this->assertInstanceOf('Title', $title, "Test must be passed a valid title text, you gave '{$titleText}'");
     $this->assertEquals($expected, $title->getPageViewLanguage()->getCode(), $msg);
     // Restore globals
     $wgContLang = $save['wgContLang'];
     $wgLang = $save['wgLang'];
     $wgAllowUserJs = $save['wgAllowUserJs'];
     $wgLanguageCode = $save['wgLanguageCode'];
     $wgDefaultLanguageVariant = $save['wgDefaultLanguageVariant'];
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:29,代码来源:TitleTest.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->initMessagesHref();
     $this->skin = new SkinTemplate();
     $this->skin->getContext()->setLanguage(Language::factory('en'));
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:7,代码来源:SideBarTest.php

示例11: getFeedsInternal

 /**
  * @param $langCode string
  * @return array
  * @throws MWException
  */
 private static function getFeedsInternal($langCode)
 {
     global $wgFeaturedFeeds, $wgFeaturedFeedsDefaults, $wgContLang;
     wfProfileIn(__METHOD__);
     $feedDefs = $wgFeaturedFeeds;
     wfRunHooks('FeaturedFeeds::getFeeds', array(&$feedDefs));
     // fill defaults
     foreach ($feedDefs as $name => $opts) {
         foreach ($wgFeaturedFeedsDefaults as $setting => $value) {
             if (!isset($opts[$setting])) {
                 $feedDefs[$name][$setting] = $value;
             }
         }
     }
     $feeds = array();
     $requestedLang = Language::factory($langCode);
     $parser = new Parser();
     foreach ($feedDefs as $name => $opts) {
         $feed = new FeaturedFeedChannel($name, $opts, $requestedLang);
         if (!$feed->isOK()) {
             continue;
         }
         $feed->getFeedItems();
         $feeds[$name] = $feed;
     }
     wfProfileOut(__METHOD__);
     return $feeds;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:33,代码来源:FeaturedFeeds.body.php

示例12: setUp

 /**
  * Anything that needs to happen before your tests should go here.
  */
 function setUp()
 {
     global $wgContLang;
     parent::setUp();
     /* For example, we need to set $wgContLang for creating a new Title */
     $wgContLang = Language::factory('en');
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:10,代码来源:SampleTest.php

示例13: setUp

 public function setUp()
 {
     global $wgLang, $wgLanguageCode;
     self::$oldLang = $wgLang;
     $wgLanguageCode = 'en';
     $wgLang = Language::factory($wgLanguageCode);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:7,代码来源:XmlTest.php

示例14: go_auth

function go_auth()
{
    global $wgUser, $wgLanguageCode, $wgRequest, $wgOut;
    // For a few special pages, don't do anything.
    $title = $wgRequest->getVal('title');
    $lg = Language::factory($wgLanguageCode);
    if ($title == $lg->specialPage("Userlogout") || $title == $lg->specialPage("Userlogin")) {
        return true;
    }
    $data = go_getsession();
    if ($wgUser->IsAnon() || $data && $wgUser->getName() != $data['username']) {
        if (isset($data['user_id'])) {
            $wgUser = User::newFromName($data['username']);
            // Create a new account if the user does not exists
            if ($wgUser->getID() == 0) {
                // Create the user
                $wgUser->addToDatabase();
                $wgUser->setRealName($data['username']);
                //$wgUser->setEmail($data['GO_SESSION']['email']);
                $wgUser->setPassword(md5($data['username'] . 'zout'));
                // do something random
                $wgUser->setToken();
                $wgUser->saveSettings();
                // Update user count
                $ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1);
                $ssUpdate->doUpdate();
            }
            $wgUser->setOption("rememberpassword", 1);
            $wgUser->setCookies();
            $wgOut->returnToMain();
        }
    }
    return true;
}
开发者ID:ajaboa,项目名称:crmpuan,代码行数:34,代码来源:GOAuth.php

示例15: getTestContext

 public function getTestContext(User $user)
 {
     $context = new RequestContext();
     $context->setLanguage(Language::factory('en'));
     $context->setUser($user);
     return $context;
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:7,代码来源:TestRecentChangesHelper.php


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