/**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfigSettings($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgContLang;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     $conf = $this->getConfig();
     // Build list of variables
     $vars = array('wgLoadScript' => wfScript('load'), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $conf->get('StylePath'), 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $conf->get('ArticlePath'), 'wgScriptPath' => $conf->get('ScriptPath'), 'wgScriptExtension' => '.php', 'wgScript' => wfScript(), 'wgSearchType' => $conf->get('SearchType'), 'wgVariantArticlePath' => $conf->get('VariantArticlePath'), 'wgActionPaths' => (object) $conf->get('ActionPaths'), 'wgServer' => $conf->get('Server'), 'wgServerName' => $conf->get('ServerName'), 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgTranslateNumerals' => $conf->get('TranslateNumerals'), 'wgVersion' => $conf->get('Version'), 'wgEnableAPI' => $conf->get('EnableAPI'), 'wgEnableWriteAPI' => $conf->get('EnableWriteAPI'), 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get('Sitename'), 'wgDBname' => $conf->get('DBname'), 'wgExtraSignatureNamespaces' => $conf->get('ExtraSignatureNamespaces'), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get('ExtensionAssetsPath'), 'wgCookiePrefix' => $conf->get('CookiePrefix'), 'wgCookieDomain' => $conf->get('CookieDomain'), 'wgCookiePath' => $conf->get('CookiePath'), 'wgCookieExpiration' => $conf->get('CookieExpiration'), 'wgResourceLoaderMaxQueryLength' => $conf->get('ResourceLoaderMaxQueryLength'), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $conf->get('ResourceLoaderStorageVersion'), 'wgResourceLoaderStorageEnabled' => $conf->get('ResourceLoaderStorageEnabled'), 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get('ForeignUploadTargets'), 'wgEnableUploads' => $conf->get('EnableUploads'));
     Hooks::run('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), 'wgMonthNames' => $wgContLang->getMonthNamesArray(), 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgSassParams' => SassUtil::getSassSettings());
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
Example #3
0
    public static function PlusoHeader(&$article, &$outputDone, &$pcache)
    {
        global $wgOut, $wgPlusoUserID, $wgPlusoHeader, $wgPlusoMain, $wgPlusoBackgroundHeader, $wgPlusoThemeHeader, $wgPlusoServicesHeader;
        # Check if page is in content namespace and the setting to enable/disable article header tooblar either on the main page or at all
        if (!MWNamespace::isContent($article->getTitle()->getNamespace()) || !$wgPlusoHeader || $article->getTitle()->equals(Title::newMainPage()) && !$wgPlusoMain) {
            return true;
        }
        /* Output Pluso header in <h1> */
        $wgOut->addHTML('
			<script type="text/javascript">
			(function() {
				if (window.pluso)if (typeof window.pluso.start == "function") return;
				if (window.ifpluso==undefined) { window.ifpluso = 1;
					var d = document, s = d.createElement("script"), g = "getElementsByTagName";
						s.type = "text/javascript"; s.charset="UTF-8"; s.async = true;
						s.src = ("https:" == window.location.protocol ? "https" : "http")  + "://share.pluso.ru/pluso-like.js";
					var h=d[g]("body")[0];
						h.appendChild(s);
				}
			})();
			jQuery(document).ready(function() {
				var title = jQuery("#firstHeading").html();
				jQuery("#firstHeading").html(title + \'<div data-user="******" class="pluso" style="float: right;right: 10px;" data-background="' . $wgPlusoBackgroundHeader . '" data-options="medium,round,line,horizontal,counter,theme=' . $wgPlusoThemeHeader . '" data-services="' . $wgPlusoServicesHeader . '"></div>\'); 
			});</script>');
        return true;
    }
 public function thread()
 {
     wfProfileIn(__METHOD__);
     $this->addAsset();
     $title = $this->request->getVal('title', $this->app->wg->Title);
     $id = $this->request->getVal('id', null);
     $this->getThread($id);
     $this->response->setVal('showNewMessage', false);
     $this->response->setVal('type', 'Thread');
     $this->response->setVal('condenseMessage', false);
     if (count($this->threads) > 0) {
         $wn = F::build('WallNotifications', array());
         foreach ($this->threads as $key => $val) {
             $all = $wn->markRead($this->wg->User->getId(), $this->wg->CityId, $key);
             break;
         }
     }
     $this->response->setVal('renderUserTalkArchiveAnchor', false);
     $this->response->setVal('greeting', '');
     $title = F::build('Title', array($id), 'newFromId');
     if (!empty($title) && $title->exists() && in_array(MWNamespace::getSubject($title->getNamespace()), $this->app->wg->WallNS)) {
         $wallMessage = F::build('WallMessage', array($title), 'newFromTitle');
         $wallMessage->load();
         $this->app->wg->Out->setPageTitle($wallMessage->getMetaTitle());
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * main()
  */
 public function execute($par)
 {
     global $wgOut;
     $fname = 'SpecialAdvancedRandom::execute';
     wfProfileIn($fname);
     list($page, $namespace) = $this->extractParamaters($par);
     $ft = Title::newFromText($page);
     if (is_null($ft)) {
         $this->redirect(Title::newMainPage());
         wfProfileOut($fname);
         return;
     }
     $rand = wfRandom();
     $dbr = wfGetDB(DB_SLAVE);
     if ($ft->getNamespace() == NS_TEMPLATE) {
         $res = $dbr->selectRow(array('page', 'templatelinks'), array('page_namespace', 'page_title', 'page_random'), array('page_id = tl_from', 'tl_namespace' => NS_TEMPLATE, 'page_namespace' => $namespace, 'tl_title' => $ft->getDBkey(), "page_random > {$rand}"), $fname, array('ORDER BY' => 'page_random', 'USE INDEX' => array('page' => 'page_random')));
     } else {
         $res = $dbr->selectRow(array('page', 'pagelinks'), array('page_namespace', 'page_title', 'page_random'), array('page_id = pl_from', 'pl_namespace' => $ft->getNamespace(), 'page_namespace' => $namespace, 'pl_title' => $ft->getDBkey(), "page_random > {$rand}"), $fname, array('ORDER BY' => 'page_random', 'USE INDEX' => array('page' => 'page_random')));
     }
     $title =& Title::makeTitle(MWNamespace::getSubject($namespace), $res->page_title);
     if (is_null($title) || $title->getText() == '') {
         $title = Title::newMainPage();
     }
     $this->redirect($title);
     wfProfileOut($fname);
 }
 public static function onGetNotificationMessage($nc, &$msg, $isMain, $data, $authors, $userCount, $myName)
 {
     if (empty($data->article_title_ns) || MWNamespace::getSubject($data->article_title_ns) != NS_WIKIA_FORUM_BOARD) {
         return true;
     }
     if (!$isMain) {
         if ($data->parent_username == $myName) {
             $replyTo = "your";
         } else {
             $replyTo = "someone";
         }
         $secondUser = '';
         if ($userCount == 2) {
             $secondUser = $nc->getDisplayname($authors[1]['displayname']);
         }
         $params = [$nc->getDisplayname($data->msg_author_displayname), $secondUser, $data->article_title_text, $myName];
         // Messages that can be used here:
         // * forum-notification-user1-reply-to-your
         // * forum-notification-user2-reply-to-your
         // * forum-notification-user3-reply-to-your
         // * forum-notification-user1-reply-to-someone
         // * forum-notification-user2-reply-to-someone
         // * forum-notification-user3-reply-to-someone
         $msgKey = "forum-notification-user{$userCount}-reply-to-{$replyTo}";
     } else {
         $msgKey = 'forum-notification-newmsg-on-followed-wall';
         $params = [$nc->getDisplayname($data->msg_author_displayname), $data->wall_displayname];
     }
     $msg = wfMessage($msgKey, $params)->text();
     return true;
 }
 public function thread()
 {
     wfProfileIn(__METHOD__);
     $this->addAsset();
     $title = $this->request->getVal('title', $this->app->wg->Title);
     $id = $this->request->getVal('id', null);
     $this->getThread($id);
     $this->response->setVal('showNewMessage', false);
     $this->response->setVal('type', 'Thread');
     $this->response->setVal('condenseMessage', false);
     if (count($this->threads) > 0) {
         $wn = new WallNotifications();
         foreach ($this->threads as $key => $val) {
             $all = $wn->markRead($this->wg->User->getId(), $this->wg->CityId, $key);
             break;
         }
     }
     $this->response->setVal('renderUserTalkArchiveAnchor', false);
     $this->response->setVal('greeting', '');
     $title = Title::newFromId($id);
     if (!empty($title) && $title->exists() && in_array(MWNamespace::getSubject($title->getNamespace()), $this->app->wg->WallNS)) {
         $wallMessage = WallMessage::newFromTitle($title);
         $wallMessage->load();
         $this->app->wg->Out->setPageTitle($wallMessage->getMetaTitle());
     }
     // TODO: keep the varnish cache and do purging on post
     $this->response->setCacheValidity(WikiaResponse::CACHE_DISABLED);
     wfProfileOut(__METHOD__);
 }
 /**
  * @param Title $rootPage The root page under which all pages should be
  * created
  */
 public function __construct(Title $rootPage)
 {
     if (!MWNamespace::hasSubpages($rootPage->getNamespace())) {
         throw new MWException("The root page you specified, {$rootPage}, is in a " . "namespace where subpages are not allowed");
     }
     $this->rootPage = $rootPage;
 }
 /**
  * @param int $ns The namespace to use for all pages
  */
 public function __construct($ns)
 {
     if (!MWNamespace::exists($ns)) {
         throw new MWException("Namespace {$ns} doesn't exist on this wiki");
     }
     $this->ns = $ns;
 }
 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfig($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion, $wgSearchType;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgSearchType' => $wgSearchType, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values(array_unique($wgFileExtensions)), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $wgResourceLoaderStorageVersion, 'wgResourceLoaderStorageEnabled' => $wgResourceLoaderStorageEnabled);
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
 function getQueryInfo()
 {
     $dbr = wfGetDB(DB_SLAVE);
     $dMsgText = wfMsgForContent('disambiguationspage');
     $linkBatch = new LinkBatch();
     # If the text can be treated as a title, use it verbatim.
     # Otherwise, pull the titles from the links table
     $dp = Title::newFromText($dMsgText);
     if ($dp) {
         if ($dp->getNamespace() != NS_TEMPLATE) {
             # @todo FIXME: We assume the disambiguation message is a template but
             # the page can potentially be from another namespace :/
             wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
         }
         $linkBatch->addObj($dp);
     } else {
         # Get all the templates linked from the Mediawiki:Disambiguationspage
         $disPageObj = Title::makeTitleSafe(NS_MEDIAWIKI, 'disambiguationspage');
         $res = $dbr->select(array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), __METHOD__);
         foreach ($res as $row) {
             $linkBatch->addObj(Title::makeTitle(NS_TEMPLATE, $row->pl_title));
         }
     }
     $set = $linkBatch->constructSet('tl', $dbr);
     if ($set === false) {
         # We must always return a valid SQL query, but this way
         # the DB will always quickly return an empty result
         $set = 'FALSE';
         wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
     }
     // @todo FIXME: What are pagelinks and p2 doing here?
     return array('tables' => array('templatelinks', 'p1' => 'page', 'pagelinks', 'p2' => 'page'), 'fields' => array('p1.page_namespace AS namespace', 'p1.page_title AS title', 'pl_from AS value'), 'conds' => array($set, 'p1.page_id = tl_from', 'pl_namespace = p1.page_namespace', 'pl_title = p1.page_title', 'p2.page_id = pl_from', 'p2.page_namespace' => MWNamespace::getContentNamespaces()));
 }
 public static function getIconType($item)
 {
     wfProfileIn(__METHOD__);
     $type = false;
     if (MWNamespace::isTalk($item['namespace'])) {
         wfProfileOut(__METHOD__);
         return self::FEED_TALK_ICON;
     }
     if (defined('NS_BLOG_ARTICLE_TALK') && $item['namespace'] == NS_BLOG_ARTICLE_TALK) {
         wfProfileOut(__METHOD__);
         return self::FEED_COMMENT_ICON;
     }
     //video namespace
     if ($item['namespace'] == 400) {
         wfProfileOut(__METHOD__);
         return self::FEED_FILM_ICON;
     }
     switch ($item['type']) {
         case 'upload':
             $type = self::FEED_PHOTO_ICON;
             break;
         default:
             $type = $item['new'] == '1' ? self::FEED_SUN_ICON : self::FEED_PENCIL_ICON;
     }
     wfProfileOut(__METHOD__);
     return $type;
 }
 /**
  * Creates and returns the HTML for a single watchlist group.
  *
  * @since 0.1
  *
  * @param SWLGroup $group
  *
  * @return string
  */
 protected function getGroupHtml(SWLGroup $group)
 {
     $namespaces = $group->getNamespaces();
     foreach ($namespaces as &$ns) {
         $ns = $ns == 0 ? 'Main' : MWNamespace::getCanonicalName($ns);
     }
     return Html::rawElement('fieldset', array('id' => 'swl_group_' . $group->getId(), 'groupid' => $group->getId(), 'class' => 'swl_group', 'groupname' => $group->getName(), 'categories' => implode('|', $group->getCategories()), 'namespaces' => implode('|', $namespaces), 'properties' => implode('|', $group->getProperties()), 'concepts' => implode('|', $group->getConcepts()), 'customTexts' => implode('|', $group->getSerializedCustomTexts())), Html::element('legend', array(), $this->msg('swl-group-legend')->text()));
 }
Example #14
0
 public function tearDown()
 {
     global $wgContLang;
     // Reset namespace cache
     MWNamespace::getCanonicalNamespaces(true);
     $wgContLang->resetNamespaces();
     parent::tearDown();
 }
 public function onGetMailNotificationMessage($notification, &$data, $key, $watcherName, $author_signature, $textNoHtml, $text)
 {
     if (empty($notification->data->article_title_ns) || MWNamespace::getSubject($notification->data->article_title_ns) != NS_WIKIA_FORUM_BOARD) {
         return true;
     }
     $data = array('$WATCHER' => $watcherName, '$BOARDNAME' => $notification->data->article_title_text, '$WIKI' => $notification->data->wikiname, '$AUTHOR_NAME' => $notification->data->msg_author_displayname, '$AUTHOR' => $notification->data->msg_author_username, '$AUTHOR_SIGNATURE' => $author_signature, '$MAIL_SUBJECT' => wfMsg('forum-mail-notification-subject', array('$1' => $notification->data->thread_title, '$2' => $notification->data->wikiname)), '$METATITLE' => $notification->data->thread_title, '$MESSAGE_LINK' => $notification->data->url, '$MESSAGE_NO_HTML' => $textNoHtml, '$MESSAGE_HTML' => $text, '$MSG_KEY_SUBJECT' => 'forum-' . $key, '$MSG_KEY_BODY' => 'forum-mail-notification-body', '$MSG_KEY_GREETING' => 'forum-mail-notification-html-greeting');
     return true;
 }
 /**
  * @todo Document
  * @param $fix Boolean: whether or not to fix broken entries
  * @param $suffix String: suffix to append to renamed articles
  *
  * @return bool
  */
 private function checkAll($fix, $suffix = '')
 {
     global $wgContLang, $wgNamespaceAliases, $wgCapitalLinks;
     $spaces = array();
     // List interwikis first, so they'll be overridden
     // by any conflicting local namespaces.
     foreach ($this->getInterwikiList() as $prefix) {
         $name = $wgContLang->ucfirst($prefix);
         $spaces[$name] = 0;
     }
     // Now pull in all canonical and alias namespaces...
     foreach (MWNamespace::getCanonicalNamespaces() as $ns => $name) {
         // This includes $wgExtraNamespaces
         if ($name !== '') {
             $spaces[$name] = $ns;
         }
     }
     foreach ($wgContLang->getNamespaces() as $ns => $name) {
         if ($name !== '') {
             $spaces[$name] = $ns;
         }
     }
     foreach ($wgNamespaceAliases as $name => $ns) {
         $spaces[$name] = $ns;
     }
     foreach ($wgContLang->getNamespaceAliases() as $name => $ns) {
         $spaces[$name] = $ns;
     }
     // We'll need to check for lowercase keys as well,
     // since we're doing case-sensitive searches in the db.
     foreach ($spaces as $name => $ns) {
         $moreNames = array();
         $moreNames[] = $wgContLang->uc($name);
         $moreNames[] = $wgContLang->ucfirst($wgContLang->lc($name));
         $moreNames[] = $wgContLang->ucwords($name);
         $moreNames[] = $wgContLang->ucwords($wgContLang->lc($name));
         $moreNames[] = $wgContLang->ucwordbreaks($name);
         $moreNames[] = $wgContLang->ucwordbreaks($wgContLang->lc($name));
         if (!$wgCapitalLinks) {
             foreach ($moreNames as $altName) {
                 $moreNames[] = $wgContLang->lcfirst($altName);
             }
             $moreNames[] = $wgContLang->lcfirst($name);
         }
         foreach (array_unique($moreNames) as $altName) {
             if ($altName !== $name) {
                 $spaces[$altName] = $ns;
             }
         }
     }
     ksort($spaces);
     asort($spaces);
     $ok = true;
     foreach ($spaces as $name => $ns) {
         $ok = $this->checkNamespace($ns, $name, $fix, $suffix) && $ok;
     }
     return $ok;
 }
 function getOrderFields()
 {
     // For some crazy reason ordering by a constant
     // causes a filesort
     if ($this->requestedNamespace === false && count(MWNamespace::getContentNamespaces()) > 1) {
         return array('page_namespace', 'page_title');
     }
     return array('page_title');
 }
 function getQueryInfo()
 {
     $query = array('tables' => array('page', 'langlinks'), 'fields' => array('namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_title'), 'conds' => array('ll_title IS NULL', 'page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0), 'join_conds' => array('langlinks' => array('LEFT JOIN', 'll_from = page_id')));
     if ($this->prefix) {
         $dbr = wfGetDB(DB_SLAVE);
         $query['conds'][] = 'page_title ' . $dbr->buildLike($this->prefix, $dbr->anyString());
     }
     return $query;
 }
 /**
  * @param $title Title of page to check
  * @return bool
  */
 public function canBeUsedOn(Title $title)
 {
     global $wgCollaborationHubAllowedNamespaces;
     $namespace = $title->getNamespace();
     if (in_array($namespace, array_keys(array_filter($wgCollaborationHubAllowedNamespaces))) && MWNamespace::hasSubpages($namespace)) {
         return true;
     }
     return false;
 }
 /**
  * change the message in WikiActivity for forum namespace
  */
 public function onAfterWallWikiActivityFilter(&$item, $wmessage)
 {
     if (!empty($item['ns']) && MWNamespace::getSubject($item['ns']) == NS_WIKIA_FORUM_BOARD) {
         $app = F::App();
         $board = $wmessage->getArticleTitle();
         $item['wall-msg'] = wfMsg('forum-wiki-activity-msg', '<a href="' . $board->getFullURL() . '">' . wfMsg('forum-wiki-activity-msg-name', $board->getText()) . '</a>');
     }
     return true;
 }
 function tearDown()
 {
     global $wgContLang;
     MWNamespace::getCanonicalNamespaces(true);
     # reset namespace cache
     $wgContLang->resetNamespaces();
     # reset namespace cache
     parent::tearDown();
 }
 public function getQueryInfo()
 {
     $tables = ['page'];
     $conds = ['page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0];
     $joinConds = [];
     $options = ['USE INDEX' => ['page' => 'page_redirect_namespace_len']];
     // Allow extensions to modify the query
     Hooks::run('ShortPagesQuery', [&$tables, &$conds, &$joinConds, &$options]);
     return ['tables' => $tables, 'fields' => ['namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_len'], 'conds' => $conds, 'join_conds' => $joinConds, 'options' => $options];
 }
 public function __construct()
 {
     global $wgContentStagingPrefix, $wgContentStagingNamespace, $wgContentStagingStages;
     $this->mwNamespaceIndex = isset($wgContentStagingNamespace) ? $wgContentStagingNamespace : 0;
     $this->mwNamespace = MWNamespace::getCanonicalName($this->mwNamespaceIndex) . ":";
     $this->pagePrefix = isset($wgContentStagingPrefix) ? $wgContentStagingPrefix : "CMS";
     # TODO: make the special page respect user defined names and number of stages
     $this->stages = isset($wgContentStagingStages) ? $wgContentStagingStages : array("test" => 0, "stage" => 0, "production" => 0);
     parent::__construct('ContentStaging', 'edit', true, false, 'default', false);
 }
 protected function tearDown()
 {
     global $wgContLang;
     // Reset namespace cache
     MWNamespace::getCanonicalNamespaces(true);
     $wgContLang->resetNamespaces();
     // And LinkCache
     LinkCache::destroySingleton();
     parent::tearDown();
 }
 function getOrderFields()
 {
     // For some crazy reason ordering by a constant
     // causes a filesort in MySQL 5
     if (count(MWNamespace::getContentNamespaces()) > 1) {
         return array('page_namespace', 'page_title');
     } else {
         return array('page_title');
     }
 }
Example #26
0
 /**
  * Same as addFavorite, only the opposite.
  * @return bool
  */
 public function removeFavorite()
 {
     $success = false;
     $dbw = wfGetDB(DB_MASTER);
     $dbw->delete('favoritelist', array('fl_user' => $this->id, 'fl_namespace' => MWNamespace::getSubject($this->ns), 'fl_title' => $this->ti), __METHOD__);
     if ($dbw->affectedRows()) {
         $success = true;
     }
     return $success;
 }
Example #27
0
 public function getQueryInfo()
 {
     $tables = array('page');
     $conds = array('page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0);
     $joinConds = array();
     $options = array('USE INDEX' => array('page' => 'page_redirect_namespace_len'));
     // Allow extensions to modify the query
     Hooks::run('ShortPagesQuery', array(&$tables, &$conds, &$joinConds, &$options));
     return array('tables' => $tables, 'fields' => array('namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_len'), 'conds' => $conds, 'join_conds' => $joinConds, 'options' => $options);
 }
 /**
  * Article::view() hook
  *
  * @param Article $article
  * @return bool
  */
 public static function viewHook($article)
 {
     global $wgOut;
     $title = $article->getTitle();
     if (MWNamespace::isContent($title->getNamespace())) {
         $wgOut->addHTML(self::buildLinks($title));
         $wgOut->addHeadItem('backandforth', self::buildHeadItem());
     }
     return true;
 }
Example #29
0
 protected function tearDown()
 {
     global $wgContLang;
     // Reset namespace cache
     MWNamespace::getCanonicalNamespaces(true);
     $wgContLang->resetNamespaces();
     // And LinkCache
     MediaWikiServices::getInstance()->resetServiceForTesting('LinkCache');
     parent::tearDown();
 }
Example #30
0
function cdbfGetMainSubpage($title)
{
    if ($title->getNamespace() != NS_MAIN) {
        return true;
    }
    if (!MWNamespace::hasSubpages($title->getNamespace())) {
        return true;
    }
    $parts = explode('/', $title->getText());
    return $parts[0];
}