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 = '******';
     $this->altUserName = '******';
     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" => "*****@*****.**", "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" => "*****@*****.**", "real_name" => "Test User Alt"));
             $this->altUser->load();
         }
         $this->anonUser = User::newFromId(0);
         $this->user = $this->userUser;
     }
 }
Exemplo n.º 2
0
	/**
	 * 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 );
	}
 /**
  * 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);
 }
Exemplo n.º 4
0
 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]);
 }
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
 function setUp()
 {
     global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang;
     parent::setUp();
     if (!$wgMemc) {
         $wgMemc = new EmptyBagOStuff();
     }
     $wgContLang = $wgLang = Language::factory('en');
     $this->userName = "******";
     $this->altUserName = "******";
     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" => "*****@*****.**", "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" => "*****@*****.**", "real_name" => "Test User Alt"));
             $this->altUser->load();
         }
         $this->anonUser = User::newFromId(0);
         $this->user = $this->userUser;
     }
 }
Exemplo n.º 7
0
 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');
 }
Exemplo n.º 8
0
 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');
 }
Exemplo n.º 9
0
 /**
  * @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'];
 }
Exemplo n.º 10
0
 protected function setUp()
 {
     parent::setUp();
     $this->initMessagesHref();
     $this->skin = new SkinTemplate();
     $this->skin->getContext()->setLanguage(Language::factory('en'));
 }
 /**
  * @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;
 }
Exemplo n.º 12
0
 /**
  * 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');
 }
Exemplo n.º 13
0
 public function setUp()
 {
     global $wgLang, $wgLanguageCode;
     self::$oldLang = $wgLang;
     $wgLanguageCode = 'en';
     $wgLang = Language::factory($wgLanguageCode);
 }
Exemplo n.º 14
0
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;
}
 public function getTestContext(User $user)
 {
     $context = new RequestContext();
     $context->setLanguage(Language::factory('en'));
     $context->setUser($user);
     return $context;
 }
Exemplo n.º 16
0
 /**
  * @covers ApiErrorFormatter
  * @dataProvider provideErrorFormatter
  */
 public function testErrorFormatter($format, $lang, $useDB, $expect1, $expect2, $expect3)
 {
     $result = new ApiResult(8388608);
     $formatter = new ApiErrorFormatter($result, Language::factory($lang), $format, $useDB);
     // Add default type
     $expect1[ApiResult::META_TYPE] = 'assoc';
     $expect2[ApiResult::META_TYPE] = 'assoc';
     $expect3[ApiResult::META_TYPE] = 'assoc';
     $formatter->addWarning('string', 'mainpage');
     $formatter->addError('err', 'mainpage');
     $this->assertSame($expect1, $result->getResultData(), 'Simple test');
     $result->reset();
     $formatter->addWarning('foo', 'mainpage');
     $formatter->addWarning('foo', 'mainpage');
     $formatter->addWarning('foo', array('parentheses', 'foobar'));
     $msg1 = wfMessage('mainpage');
     $formatter->addWarning('message', $msg1);
     $msg2 = new ApiMessage('mainpage', 'overriddenCode', array('overriddenData' => true));
     $formatter->addWarning('messageWithData', $msg2);
     $formatter->addError('errWithData', $msg2);
     $this->assertSame($expect2, $result->getResultData(), 'Complex test');
     $result->reset();
     $status = Status::newGood();
     $status->warning('mainpage');
     $status->warning('parentheses', 'foobar');
     $status->warning($msg1);
     $status->warning($msg2);
     $status->error('mainpage');
     $status->error('parentheses', 'foobar');
     $formatter->addMessagesFromStatus('status', $status);
     $this->assertSame($expect3, $result->getResultData(), 'Status test');
     $this->assertSame($expect3['errors']['status'], $formatter->arrayFromStatus($status, 'error'), 'arrayFromStatus test for error');
     $this->assertSame($expect3['warnings']['status'], $formatter->arrayFromStatus($status, 'warning'), 'arrayFromStatus test for warning');
 }
Exemplo n.º 17
0
 public function execute()
 {
     $variantLangs = array();
     $variants = array();
     foreach (LanguageConverter::$languagesWithVariants as $langCode) {
         $lang = Language::factory($langCode);
         if (count($lang->getVariants()) > 1) {
             $variants += array_flip($lang->getVariants());
             $variantLangs[$langCode] = $lang->getVariants();
         }
     }
     $variants = array_keys($variants);
     sort($variants);
     $result = $this->hasOption('flat') ? $variants : $variantLangs;
     // Not using $this->output() because muting makes no sense here
     if ($this->hasOption('json')) {
         echo FormatJson::encode($result, true) . "\n";
     } else {
         foreach ($result as $key => $value) {
             if (is_array($value)) {
                 echo "{$key}\n";
                 foreach ($value as $variant) {
                     echo "   {$variant}\n";
                 }
             } else {
                 echo "{$value}\n";
             }
         }
     }
 }
Exemplo n.º 18
0
 function setUp()
 {
     global $wgContLang, $wgUser, $wgLanguageCode;
     $wgContLang = Language::factory($wgLanguageCode);
     $this->popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
     $this->pcache = ParserCache::singleton();
 }
Exemplo n.º 19
0
function wfInstallerMain()
{
    global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
    $installer = InstallerOverrides::getWebInstaller($wgRequest);
    if (!$installer->startSession()) {
        if ($installer->request->getVal("css")) {
            // Do not display errors on css pages
            $installer->outputCss();
            exit;
        }
        $errors = $installer->getPhpErrors();
        $installer->showError('config-session-error', $errors[0]);
        $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;
}
Exemplo n.º 20
0
 protected function setUp()
 {
     parent::setUp();
     // Avoid 'GetHumanTimestamp' hook and others
     $this->setMwGlobals('wgHooks', array());
     RequestContext::getMain()->setLanguage(Language::factory('en'));
 }
Exemplo n.º 21
0
 function execute()
 {
     global $wgVersion, $wgTitle, $wgLang;
     $wgLang = Language::factory('en');
     $wgTitle = Title::newFromText("MediaWiki database updater");
     $this->output("MediaWiki {$wgVersion} Updater\n\n");
     if (!$this->hasOption('skip-compat-checks')) {
         $this->compatChecks();
     } else {
         $this->output("Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n");
         wfCountdown(5);
     }
     # Attempt to connect to the database as a privileged user
     # This will vomit up an error if there are permissions problems
     $db = wfGetDB(DB_MASTER);
     $this->output("Going to run database updates for " . wfWikiID() . "\n");
     $this->output("Depending on the size of your database this may take a while!\n");
     if (!$this->hasOption('quick')) {
         $this->output("Abort with control-c in the next five seconds (skip this countdown with --quick) ... ");
         wfCountDown(5);
     }
     $shared = $this->hasOption('doshared');
     $updates = array('core', 'extensions');
     if (!$this->hasOption('nopurge')) {
         $updates[] = 'purge';
     }
     $updater = DatabaseUpdater::newForDb($db, $shared, $this);
     $updater->doUpdates($updates);
     foreach ($updater->getPostDatabaseUpdateMaintenance() as $maint) {
         $child = $this->runChild($maint);
         $child->execute();
     }
     $this->output("\nDone.\n");
 }
Exemplo n.º 22
0
 protected function setUp()
 {
     parent::setUp();
     $langObj = Language::factory('en');
     $langObj->setNamespaces(array(-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(array('wgLang' => $langObj, 'wgWellFormedXml' => true));
 }
Exemplo n.º 23
0
 /**
  * Return the localized pretty price with currency
  * @todo localize the order currency/amount too
  * @param User $user
  * @return string 
  */
 public function getLocalizedPrice($user)
 {
     $language = Language::factory($user->getOption('language'));
     $price = $this->getPrice();
     $amount = $language->formatNum($price['amount']);
     $currency = $price['currency'] == 'EUR' ? '€' : $price['currency'];
     return $amount . $currency;
 }
 public function testGetTitleForAlias()
 {
     $this->setMwGlobals('wgContLang', Language::factory('de'));
     SpecialPageFactory::resetList();
     $title = SpecialPageFactory::getTitleForAlias('Specialpages/Foo');
     $this->assertEquals('Spezialseiten/Foo', $title->getText());
     $this->assertEquals(NS_SPECIAL, $title->getNamespace());
 }
Exemplo n.º 25
0
 function testInContentLanguage()
 {
     global $wgLang, $wgForceUIMsgAsContentMsg;
     $wgLang = Language::factory('fr');
     $this->assertEquals('Main Page', wfMessage('mainpage')->inContentLanguage()->plain(), 'ForceUIMsg disabled');
     $wgForceUIMsgAsContentMsg['testInContentLanguage'] = 'mainpage';
     $this->assertEquals('Accueil', wfMessage('mainpage')->inContentLanguage()->plain(), 'ForceUIMsg enabled');
 }
 function testGetPreferredVariantDefaultLanguageVsUrlVariant()
 {
     global $wgDefaultLanguageVariant, $wgRequest, $wgContLang;
     $wgContLang = Language::factory('tg-latn');
     $wgDefaultLanguageVariant = 'tg';
     $wgRequest->setVal('variant', null);
     $this->assertEquals('tg', $this->lc->getPreferredVariant());
 }
Exemplo n.º 27
0
 /**
  * Helper function -- setup site language for testing
  */
 protected function configureLanguages()
 {
     // for the test, we need the content language to be anything but English,
     // let's choose e.g. German (de)
     $langCode = 'de';
     $langObj = Language::factory($langCode);
     $this->setMwGlobals(array('wgLanguageCode' => $langCode, 'wgLang' => $langObj, 'wgContLang' => $langObj));
 }
Exemplo n.º 28
0
 protected function makeCodec($lang)
 {
     $gender = $this->getGenderCache();
     $lang = Language::factory($lang);
     // language object can came from cache, which does not respect test settings
     $lang->resetNamespaces();
     return new MediaWikiTitleCodec($lang, $gender);
 }
 /**
  * Get language-specific LESS variables for this module.
  *
  * @since 1.27
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getLessVars(ResourceLoaderContext $context)
 {
     $vars = parent::getLessVars($context);
     $language = Language::factory($context->getLanguage());
     foreach ($language->getImageFiles() as $key => $value) {
         $vars[$key] = CSSMin::serializeStringValue($value);
     }
     return $vars;
 }
 protected function setUp()
 {
     parent::setUp();
     $langObj = Language::factory('en');
     $localZone = 'UTC';
     $localOffset = date('Z') / 60;
     $this->setMwGlobals(array('wgMemc' => new EmptyBagOStuff(), 'wgContLang' => $langObj, 'wgLanguageCode' => 'en', 'wgLang' => $langObj, 'wgLocaltimezone' => $localZone, 'wgLocalTZoffset' => $localOffset, 'wgNamespaceProtection' => array(NS_MEDIAWIKI => 'editinterface')));
     // Without this testUserBlock will use a non-English context on non-English MediaWiki
     // installations (because of how Title::checkUserBlock is implemented) and fail.
     RequestContext::resetMain();
     $this->userName = '******';
     $this->altUserName = '******';
     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" => "*****@*****.**", "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" => "*****@*****.**", "real_name" => "Test User Alt"));
             $this->altUser->load();
         }
         $this->anonUser = User::newFromId(0);
         $this->user = $this->userUser;
     }
 }