private function getPageGroups() { global $wgSortSpecialPages; $pages = SpecialPageFactory::getUsablePages($this->getUser()); if (!count($pages)) { # Yeah, that was pointless. Thanks for coming. return false; } /** Put them into a sortable array */ $groups = array(); foreach ($pages as $page) { if ($page->isListed()) { $group = SpecialPageFactory::getGroup($page); if (!isset($groups[$group])) { $groups[$group] = array(); } $groups[$group][$page->getDescription()] = array($page->getTitle(), $page->isRestricted(), $page->isExpensive()); } } /** Sort */ if ($wgSortSpecialPages) { foreach ($groups as $group => $sortedPages) { ksort($groups[$group]); } } /** Always move "other" to end */ if (array_key_exists('other', $groups)) { $other = $groups['other']; unset($groups['other']); $groups['other'] = $other; } return $groups; }
function wfCreatePageConfirmEdit(&$captcha, &$editPage, $newtext, $section, $merged, &$result) { global $wgTitle, $wgCreatePageCoverRedLinks; // Enable only if the configuration global is set to true, // only for Special:CreatePage and only when ConfirmEdit is installed $canonspname = array_shift(SpecialPageFactory::resolveAlias($wgTitle->getDBkey())); if (!$wgCreatePageCoverRedLinks) { return true; } if ($canonspname != 'CreatePage') { return true; } if (!class_exists('SimpleCaptcha')) { return true; } if ($captcha->shouldCheck($editPage, $newtext, $section, $merged)) { if ($captcha->passCaptcha()) { $result = true; return false; } else { // display CAP page $mainform = new CreatePageCreatePlateForm(); $mainform->showForm('', false, array(&$captcha, 'editCallback')); $editor = new CreatePageMultiEditor($_SESSION['article_createplate']); $editor->generateForm($newtext); $result = false; return false; } } else { return true; } }
public static function onSpecialPage_initList( &$list ) { global $wgOpenIDOnly, $wgOpenIDClientOnly; if ( $wgOpenIDOnly ) { $list['Userlogin'] = '******'; # as Special:CreateAccount is an alias for Special:UserLogin/signup # we show our own OpenID page here, too $list['CreateAccount'] = 'SpecialOpenIDLogin'; } # Special pages are added at global scope; # remove server-related ones if client-only flag is set $addList = array( 'Login', 'Convert', 'Dashboard' ); if ( !$wgOpenIDClientOnly ) { $addList[] = 'Server'; $addList[] = 'XRDS'; } foreach ( $addList as $sp ) { $list['OpenID' . $sp] = 'SpecialOpenID' . $sp; SpecialPageFactory::setGroup( 'OpenID' . $sp, 'openid' ); } return true; }
public function buildData() { global $wgUser, $wgTitle; $page = SpecialPageFactory::getPage($this->name); if (!is_object($page)) { $this->buildExternalData(); return; } $this->available = true; $this->enabled = $page->userCanExecute($wgUser); $this->caption = $page->getDescription(); $this->description = $page->getDescription(); $this->href = $page->getTitle()->getLocalUrl(); switch ($this->name) { case 'RecentChangesLinked': $this->href .= '/' . $wgTitle->getPartialUrl(); break; case 'Contributions': $this->href .= '/' . $wgUser->getTitleKey(); break; } $specialPageName = $page->getName(); $options = array(); wfRunHooks("UserCommand::SpecialPage::{$specialPageName}", array($this, &$options)); foreach ($options as $k => $v) { $this->{$k} = $v; } }
public function buildData() { global $wgUser, $wgTitle; $page = SpecialPageFactory::getPage($this->name); if (!is_object($page)) { $this->buildExternalData(); // BugId:22989 - we don't want the PageLayoutBuilder to be shown if disabled. if ('LayoutBuilder' == $this->name) { // do not show PLB if it's not available on the wiki $this->available = $this->enabled; } return; } $this->available = true; $this->enabled = $page->userCanExecute($wgUser); $this->caption = $page->getDescription(); $this->description = $page->getDescription(); $this->href = $page->getTitle()->getLocalUrl(); switch ($this->name) { case 'RecentChangesLinked': $this->href .= '/' . $wgTitle->getPartialUrl(); break; case 'Contributions': $this->href .= '/' . $wgUser->getTitleKey(); break; } $specialPageName = $page->getName(); $options = array(); wfRunHooks("UserCommand::SpecialPage::{$specialPageName}", array($this, &$options)); foreach ($options as $k => $v) { $this->{$k} = $v; } }
/** * @dataProvider provideSpecialPages */ public function testSpecialPage($name) { $page = SpecialPageFactory::getPage($name); $title = $page->getPageTitle(); $context = RequestContext::newExtraneousContext($title); $page->setContext($context); try { $page->run(null); } catch (PermissionsError $e) { // This is okay wfDebug('Permissions error caught; expected.'); } catch (ErrorPageError $e) { // This is okay as well wfDebug('Page error caught; expected.'); } $this->assertTrue(true, "Special page {$name} was executed succesfully with anon user"); $user = new MockSuperUser(); $context->setUser($user); $page->setContext($context); // This should not throw permission errors try { $page->run(null); } catch (ErrorPageError $e) { // This is okay here wfDebug('Page error caught; expected.'); } $this->assertTrue(true, "Special page {$name} was executed succesfully with super user"); }
function execute($par) { /** * Some satellite ISPs use broken precaching schemes that log people out straight after * they're logged in (bug 17790). Luckily, there's a way to detect such requests. */ if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '&') !== false) { wfDebug("Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n"); throw new HttpError(400, wfMessage('suspicious-userlogout'), wfMessage('loginerror')); } $this->setHeaders(); $this->outputHeader(); $user = $this->getUser(); $oldName = $user->getName(); $user->logout(); $out = $this->getOutput(); $out->addWikiMsg('logouttext'); // Hook. $injected_html = ''; wfRunHooks('UserLogoutComplete', array(&$user, &$injected_html, $oldName)); $out->addHTML($injected_html); $mReturnTo = $this->getRequest()->getVal('returnto'); $mReturnToQuery = $this->getRequest()->getVal('returntoquery'); $title = Title::newFromText($mReturnTo); if (!empty($title)) { $mResolvedReturnTo = strtolower(array_shift(SpecialPageFactory::resolveAlias($title->getDBKey()))); if (in_array($mResolvedReturnTo, array('userlogout', 'signup', 'connect'))) { $titleObj = Title::newMainPage(); $mReturnTo = $titleObj->getText(); $mReturnToQuery = ''; } } $out->returnToMain(false, $mReturnTo, $mReturnToQuery); }
private function getPageGroups() { $pages = SpecialPageFactory::getUsablePages($this->getUser()); if (!count($pages)) { # Yeah, that was pointless. Thanks for coming. return false; } /** Put them into a sortable array */ $groups = []; /** @var SpecialPage $page */ foreach ($pages as $page) { if ($page->isListed()) { $group = $page->getFinalGroupName(); if (!isset($groups[$group])) { $groups[$group] = []; } $groups[$group][$page->getDescription()] = [$page->getPageTitle(), $page->isRestricted(), $page->isCached()]; } } /** Sort */ foreach ($groups as $group => $sortedPages) { ksort($groups[$group]); } /** Always move "other" to end */ if (array_key_exists('other', $groups)) { $other = $groups['other']; unset($groups['other']); $groups['other'] = $other; } return $groups; }
public function show() { $special = SpecialPageFactory::getPage('Revisiondelete'); $special->setContext($this->getContext()); $special->getContext()->setTitle($special->getPageTitle()); $special->run(''); }
function __construct( $name = 'RandomExcludeBlank' ){ global $wgContentNamespaces; $this->namespaces = $wgContentNamespaces; parent::__construct( $name ); SpecialPageFactory::setGroup( 'RandomExcludeBlank','redirects' ); }
/** * @param RecentChange $rc * @param string[] &$classes * @param bool $watched * * @return string */ private function formatChangeLine(RecentChange $rc, array &$classes, $watched) { $html = ''; $unpatrolled = $this->showAsUnpatrolled($rc); if ($rc->mAttribs['rc_log_type']) { $logtitle = SpecialPage::getTitleFor('Log', $rc->mAttribs['rc_log_type']); $this->insertLog($html, $logtitle, $rc->mAttribs['rc_log_type']); $flags = $this->recentChangesFlags(array('unpatrolled' => $unpatrolled, 'bot' => $rc->mAttribs['rc_bot']), ''); if ($flags !== '') { $html .= ' ' . $flags; } // Log entries (old format) or log targets, and special pages } elseif ($rc->mAttribs['rc_namespace'] == NS_SPECIAL) { list($name, $htmlubpage) = SpecialPageFactory::resolveAlias($rc->mAttribs['rc_title']); if ($name == 'Log') { $this->insertLog($html, $rc->getTitle(), $htmlubpage); } // Regular entries } else { $this->insertDiffHist($html, $rc, $unpatrolled); # M, N, b and ! (minor, new, bot and unpatrolled) $html .= $this->recentChangesFlags(array('newpage' => $rc->mAttribs['rc_type'] == RC_NEW, 'minor' => $rc->mAttribs['rc_minor'], 'unpatrolled' => $unpatrolled, 'bot' => $rc->mAttribs['rc_bot']), ''); $html .= $this->getArticleLink($rc, $unpatrolled, $watched); } # Edit/log timestamp $this->insertTimestamp($html, $rc); # Bytes added or removed if ($this->getConfig()->get('RCShowChangedSize')) { $cd = $this->formatCharacterDifference($rc); if ($cd !== '') { $html .= $cd . ' <span class="mw-changeslist-separator">. .</span> '; } } if ($rc->mAttribs['rc_type'] == RC_LOG) { $html .= $this->insertLogEntry($rc); } elseif ($this->isCategorizationWithoutRevision($rc)) { $html .= $this->insertComment($rc); } else { # User tool links $this->insertUserRelatedLinks($html, $rc); # LTR/RTL direction mark $html .= $this->getLanguage()->getDirMark(); $html .= $this->insertComment($rc); } # Tags $this->insertTags($html, $rc, $classes); # Rollback $this->insertRollback($html, $rc); # For subclasses $this->insertExtra($html, $rc, $classes); # How many users watch this page if ($rc->numberofWatchingusers > 0) { $html .= ' ' . $this->numberofWatchingusers($rc->numberofWatchingusers); } return $html; }
/** * Add the terms of service to the registration form. * Die if this fails. * @return Boolean: true */ function addLicencing(&$out, &$skin) { $context = $out; $title = $context->getTitle(); $pagename = ''; list($pagename, ) = SpecialPageFactory::resolveAlias($title->getBaseText()); if ($title->isSpecialPage() && $pagename == "Userlogin") { $query = $context->getRequest()->getQueryValues(); if (!empty($query["type"]) && $query["type"] == "signup") { // Append the licence iframe and text message $search_token = '<div class="mw-createacct-benefits-container">'; $replacement = <<<EOT <div> <h2>Nutzungsbedingungen</h2> <ul> <li>Mit der Anmeldung auf „offene-bibel.de“ inklusive aller Unterbereiche und Subdomains (im Folgenden „Offene Bibel“) schließt du einen Nutzungsvertrag mit dem Betreiber der Offenen Bibel ab (im Folgenden „Betreiber“) und erklärst dich mit den nachfolgenden Regelungen einverstanden.</li> <li>Wenn du mit diesen Regelungen nicht einverstanden bist, so darfst du die Offene Bibel nicht weiter nutzen. Für die Nutzung der Offenen Bibel gelten jeweils die an dieser Stelle veröffentlichten Regelungen.</li> <li>Der Nutzungsvertrag wird auf unbestimmte Zeit geschlossen und kann von beiden Seiten ohne Einhaltung einer Frist jederzeit gekündigt werden.</li> </ul> <h2>Lizenz der Beiträge</h2> <ul> <li>Mit dem Erstellen eines Beitrags (Forenbeitrag, Blogeintrag, Newsbeitrag, Kommentar, Wikieintrag, ...) akzeptierst du, dass du deinen Beitrag damit automatisch unter die <a title="Urheberrecht" href="/wiki/Die_Offene_Bibel:Urheberrecht">CC-by-sa 3.0</a> stellst. Abweichende Lizenzen eingestellter Texte oder Medien, Bilder, Dateien,... müssen vermerkt werden.</li> <li>Diese Lizenz für deinen Beitrag bleibt unabhängig von der Weiternutzung der Offenen Bibel bestehen.</li> </ul> <h2>Pflichten des Nutzers</h2> <ul> <li>Du erklärst mit der Erstellung eines Beitrags, dass er keine Inhalte enthält, die gegen geltendes Recht oder die guten Sitten verstoßen. Du erklärst insbesondere, dass du das Recht besitzt, die in deinen Beiträgen verwendeten Links und Bilder zu setzen bzw. zu verwenden.</li> <li>Du nimmst zur Kenntnis, dass der Betreiber keine Verantwortung für die Inhalte von Beiträgen übernimmt, die er nicht selbst erstellt hat oder die er nicht zur Kenntnis genommen hat. Du gestattest dem Betreiber, dein Benutzerkonto, Beiträge und Funktionen jederzeit zu löschen oder zu sperren.</li> <li>Du gestattest dem Betreiber darüber hinaus, deine Beiträge abzuändern, sofern sie gegen o. g. Regeln verstoßen oder geeignet sind, dem Betreiber oder einem Dritten Schaden zuzufügen.</li> <li>Du verpflichtest dich, deine Zugangsdaten (insbesondere Passwörter) geheim zu halten und nicht an Dritte weiterzugeben.</li> </ul> <h2>Änderungsvorbehalt</h2> <ul> <li>Der Betreiber ist berechtigt, die Nutzungsbedingungen, die Eckpunkte und die Datenschutzrichtlinie zu ändern. Die Änderung wird dem Nutzer per E-Mail mitgeteilt.</li> <li>Der Nutzer ist berechtigt, den Änderungen zu widersprechen. Im Falle des Widerspruchs erlischt das zwischen dem Betreiber und dem Nutzer bestehende Vertragsverhältnis mit sofortiger Wirkung.</li> <li>Die Änderungen gelten als anerkannt und verbindlich, wenn der Nutzer den Änderungen zugestimmt hat.</li> </ul> <h2>Weitere Regeln</h2> <ul> <li>Du verpflichtest dich, keine illegalen, pornografischen, menschenverachtenden und/oder gegen die guten Sitten verstoßenden Beiträge einzustellen. Achte bei deinen Beiträgen auf einen angemessenen Ton, beleidige niemanden.</li> <li>Die Offene Bibel für Werbezwecke zu nutzen ist untersagt (Ausnahmen sind <i>nach Rücksprache mit dem Betreiber</i> möglich).</li> <li>Der Betreiber behält sich vor, bei Verstößen gegen diese Regeln oder die <a href="/wiki/Eckpunkte">Eckpunkte</a> Benutzer zeitweise oder ganz zu sperren.</li> <li>Der Betreiber behält sich das Recht vor, ohne Rücksprache Beiträge zu ändern oder zu löschen, falls sie den Regeln oder <a href="/wiki/Eckpunkte">Eckpunkten</a> widersprechen oder den Portalfrieden gefährden. </li> </ul> </div> <div class="mw-createacct-benefits-container" style="display:none"> EOT; $replacement_count = 0; $out->mBodytext = preg_replace("/{$search_token}/", "{$replacement}", $out->mBodytext, -1, $replacement_count); #if($replacement_count != 1) { # die("Registration form terms of service logic broken."); #} } } return true; }
public function show() { $action = self::getName(); if ($action === 'nosuchaction') { throw new ErrorPageError($this->msg('nosuchaction'), $this->msg('nosuchactiontext')); } // map actions to (whitelisted) special pages $special = SpecialPageFactory::getPage(self::$actionToSpecialPageMapping[$action]); $special->setContext($this->getContext()); $special->getContext()->setTitle($special->getPageTitle()); $special->run(''); }
/** * hook handler * check conditions and display message * * @author Maciej Błaszkowski <marooned at wikia-inc.com> */ static function onSkinTemplatePageBeforeUserMsg(&$msgs) { global $wgUser, $wgMemc, $wgCookiePrefix; if (self::$messageSeen) { //user is just seeing the message - hide notification for this session return true; } //get timestamp of message $communityMessagesTimestamp = $wgMemc->get(wfMemcKey('CommunityMessagesTimestamp')); if (!$communityMessagesTimestamp) { $msgTitle = Title::newFromText('community-corner', NS_MEDIAWIKI); if ($msgTitle) { $msgRev = Revision::newFromTitle($msgTitle); if ($msgRev) { $communityMessagesTimestamp = wfTimestamp(TS_UNIX, $msgRev->getTimestamp()); $wgMemc->set(wfMemcKey('CommunityMessagesTimestamp'), $communityMessagesTimestamp, 86400); } } } if (!$communityMessagesTimestamp) { //no message? return true; } if ($communityMessagesTimestamp < time() - 86400) { //message older than 24h - do not inform user about it return true; } if ($wgUser->isLoggedIn()) { $userTimestamp = self::getUserTimestamp($wgUser); if ($userTimestamp !== false && $userTimestamp >= $communityMessagesTimestamp) { //old, seen message return true; } } else { //anon //compare timestamp from cookie if (isset($_COOKIE[$wgCookiePrefix . 'CommunityMessages']) && $_COOKIE[$wgCookiePrefix . 'CommunityMessages'] >= $communityMessagesTimestamp) { //old, seen message return true; } } if ($msgs != '') { $msgs .= '<br/>'; } // render message $msg = ''; if (SpecialPageFactory::exists('WikiActivity')) { $msg = wfMsgExt('communitymessages-notice-msg', array('parseinline', 'content')); } // macbre: add an easy way for Oasis to show it's own notification for community messages wfRunHooks('CommunityMessages::showMessage', array(&$msg)); return true; }
function printAltFormsList($alt_forms, $target_name) { $text = ""; $fe = SpecialPageFactory::getPage('FormEdit'); $fe_url = $fe->getTitle()->getFullURL(); $i = 0; foreach ($alt_forms as $alt_form) { if ($i++ > 0) { $text .= ', '; } $text .= "<a href=\"{$fe_url}/{$alt_form}/{$target_name}\">" . str_replace('_', ' ', $alt_form) . '</a>'; } return $text; }
function execute($par) { global $wgUser; /* wikia change */ /** * Some satellite ISPs use broken precaching schemes that log people out straight after * they're logged in (bug 17790). Luckily, there's a way to detect such requests. */ if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '&') !== false) { wfDebug("Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n"); throw new HttpError(400, wfMessage('suspicious-userlogout'), wfMessage('loginerror')); } $this->setHeaders(); $this->outputHeader(); $user = $this->getUser(); $oldName = $user->getName(); $user->logout(); /* * Special pages use the new-style context-based user object. However, much of the rest of the world * (e.g. Global Nav) uses the old-style global wgUser object. As such, when we log out we need to * ensure that both copies of the user object are properly addressed, or else parts of the page will still * believe they have an authenticated user object. * * Once the old-style global wgUser object is fully deprecated, this line can be removed. */ $wgUser->logout(); /* wikia change */ // Wikia change // regenerate session ID on user logout to avoid race conditions with // long running requests logging the user back in (@see PLATFORM-1028) wfResetSessionID(); $out = $this->getOutput(); $out->addWikiMsg('logouttext'); // Hook. $injected_html = ''; wfRunHooks('UserLogoutComplete', array(&$user, &$injected_html, $oldName)); $out->addHTML($injected_html); $mReturnTo = $this->getRequest()->getVal('returnto'); $mReturnToQuery = $this->getRequest()->getVal('returntoquery'); $title = Title::newFromText($mReturnTo); if (!empty($title)) { $mResolvedReturnTo = strtolower(array_shift(SpecialPageFactory::resolveAlias($title->getDBKey()))); if (in_array($mResolvedReturnTo, array('userlogout', 'signup', 'connect'))) { $titleObj = Title::newMainPage(); $mReturnTo = $titleObj->getText(); $mReturnToQuery = ''; } } $out->returnToMain(false, $mReturnTo, $mReturnToQuery); }
function efDspHook(&$list) { global $wgDisabledSpecialPages; foreach ($wgDisabledSpecialPages as $page) { $title = efDspMakeTitle($page); if (!$title) { continue; } $canonicalName = array_shift(SpecialPageFactory::resolveAlias($title->getDBkey())); if (!efDspWhitelisted($canonicalName) && isset($list[$canonicalName])) { unset($list[$canonicalName]); } } return true; }
function printAltFormsList($alt_forms, $target_name) { $text = ""; $fe = SpecialPageFactory::getPage('FormEdit'); $fe_url = $fe->getTitle()->getFullURL(); $i = 0; foreach ($alt_forms as $alt_form) { if ($i++ > 0) { $text .= ', '; } $altFormURL = $fe_url . '/' . rawurlencode($alt_form) . '/' . rawurlencode($target_name); $text .= Html::element('a', array('href' => $altFormURL), str_replace('_', ' ', $alt_form)); } return $text; }
public function testSubPageRedirect() { $ctx = new RequestContext(); SpecialPageFactory::executePath(Title::newFromText('Special:Search/foo_bar'), $ctx); $url = $ctx->getOutput()->getRedirect(); // some older versions of hhvm have a bug that doesn't parse relative // urls with a port, so help it out a little bit. // https://github.com/facebook/hhvm/issues/7136 $url = wfExpandUrl($url, PROTO_CURRENT); $parts = parse_url($url); $this->assertEquals('/w/index.php', $parts['path']); parse_str($parts['query'], $query); $this->assertEquals('Special:Search', $query['title']); $this->assertEquals('foo bar', $query['search']); }
/** * Parse one line from MediaWiki message to array with indexes 'text' and 'href' * * @return array * @author Inez Korczynski <*****@*****.**> */ public static function parseItem($line) { $href = $specialCanonicalName = false; $line_temp = explode('|', trim($line, '* '), 3); $line_temp[0] = trim($line_temp[0], '[]'); if (count($line_temp) >= 2 && $line_temp[1] != '') { $line = trim($line_temp[1]); $link = trim(wfMsgForContent($line_temp[0])); } else { $line = trim($line_temp[0]); $link = trim($line_temp[0]); } $descText = null; if (count($line_temp) > 2 && $line_temp[2] != '') { $desc = $line_temp[2]; if (wfEmptyMsg($desc, $descText = wfMsg($desc))) { $descText = $desc; } } if (wfEmptyMsg($line, $text = wfMsg($line))) { $text = $line; } if ($link != null) { if (wfEmptyMsg($line_temp[0], $link)) { $link = $line_temp[0]; } if (preg_match('/^(?:' . wfUrlProtocols() . ')/', $link)) { $href = $link; } else { $title = Title::newFromText($link); if ($title) { if ($title->getNamespace() == NS_SPECIAL) { $dbkey = $title->getDBkey(); $specialCanonicalName = SpecialPageFactory::resolveAlias($dbkey); if (!$specialCanonicalName) { $specialCanonicalName = $dbkey; } } $title = $title->fixSpecialName(); $href = $title->getLocalURL(); } else { $href = '#'; } } } return array('text' => $text, 'href' => $href, 'org' => $line_temp[0], 'desc' => $descText, 'specialCanonicalName' => $specialCanonicalName); }
/** * @brief Helper function which determines whether to display the Admin Dashboard Chrome in the Oasis Skin * @param WikiaApp $app * @param Title $title Title of page we are on * @return boolean */ public static function displayAdminDashboard($app, $title) { // Admin Dashboard is only for logged in plus a list of groups if (!$app->wg->User->isLoggedIn()) { return false; } if (!$app->wg->User->isAllowed('admindashboard')) { return false; } if ($title && $title->isSpecialPage()) { $bits = explode('/', $title->getDBkey(), 2); $alias = array_shift(SpecialPageFactory::resolveAlias($bits[0])); // NOTE: keep this list in alphabetical order static $exclusionList = array("AbTesting", "ApiExplorer", "ApiGate", "Chat", "CloseWiki", "Code", "Confirmemail", "Connect", "Contact", "Contributions", "CreateBlogPage", "CreatePage", "CreateNewWiki", "CreateTopList", "Crunchyroll", "EditAccount", "EditTopList", "Following", "Forum", "ImageReview", "Invalidateemail", "LandingPageSmurfs", "LayoutBuilder", "LayoutBuilderForm", "Leaderboard", "LookupContribs", "LookupUser", "ManageWikiaHome", "MiniEditor", "MovePage", "MultiLookup", "NewFiles", "Newimages", "Our404Handler", "PageLayoutBuilder", "PageLayoutBuilderForm", "Phalanx", "PhalanxStats", "PhotoPopSetup", "Places", "Play", "Preferences", "PromoteImageReview", "ScavengerHunt", "Search", "Signup", "SiteWideMessages", "SponsorshipDashboard", "StructuredData", "TaskManager", "ThemeDesigner", "ThemeDesignerPreview", "UserLogin", "UserManagement", "UserPathPrediction", "UserSignup", "Version", "Videos", "WhereIsExtension", "WikiActivity", "WikiaHubsV2", "WikiaSearch", "WikiaStyleGuide", "WikiFactory", "WikiFactoryReporter", "WikiStats"); return !in_array($alias, $exclusionList); } return false; }
public function execute($param) { $this->setHeaders(); $oOutput = new SpecialNewWikisGraphOutput(); $endDate = new DateTime(date('Y-m-d')); $endDate->sub(new DateInterval('P1D')); $startDate = clone $endDate; $startDate->sub(new DateInterval('P1M')); $oOutput->set($this->getReport($startDate, $endDate, $param)); $aAllOptions = array_merge($this->aAvailableLanguages, $this->aAvailableOtherOptions); $param = in_array($param, $aAllOptions) ? $param : ''; $oOutput->setActive($param); $sReturnChart = $oOutput->getHTML(); $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $oTmpl->set_vars(array("tabs" => $this->aAvailableLanguages, "other" => $this->aAvailableOtherOptions, "active" => $param, "path" => SpecialPageFactory::getPage(self::NEW_WIKIS_GRAPH)->getTitle()->getFullURL())); F::app()->wg->out->addHTML($oTmpl->render("metrics-menu")); F::app()->wg->out->addHTML($sReturnChart); }
public static function onBeforeInitialize($title, &$unused, &$output, &$user, $request) { if (!$title->isSpecialPage()) { return true; } list($name) = SpecialPageFactory::resolveAlias($title->getDBkey()); if ($name !== 'Userlogin') { return true; } $hash = $request->getVal('invite', $request->getCookie('invite')); if ($hash) { $store = new InviteStore(wfGetDB(DB_SLAVE), 'invitesignup'); $invite = $store->getInvite($hash); if ($invite && $invite['used'] === null) { global $wgInviteSignupHash; $wgInviteSignupHash = $hash; $request->response()->setCookie('invite', $hash); } } }
/** * Make Special:MyLanguage links red if the target page doesn't exists. * A bit hacky because the core code is not so flexible. * @param $dummy * @param $target Title * @param $html * @param $customAttribs * @param $query * @param $options * @param $ret * @return bool */ public static function linkfix($dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret) { if ($target->getNamespace() == NS_SPECIAL) { list($name, $subpage) = SpecialPageFactory::resolveAlias($target->getDBkey()); if ($name === 'MyLanguage') { $realTarget = Title::newFromText($subpage); if (!$realTarget || !$realTarget->exists()) { $options[] = 'broken'; $index = array_search('known', $options, true); if ($index !== false) { unset($options[$index]); } $index = array_search('noclasses', $options, true); if ($index !== false) { unset($options[$index]); } } } } return true; }
/** * @param $request WebRequest * @param $title Title * @param $output OutputPage * @return bool * @throws HttpError */ public function testCanonicalRedirect($request, $title, $output) { global $wgUsePathInfo, $wgMobileDomain; $xDevice = isset($_SERVER['HTTP_X_DEVICE']) ? $_SERVER['HTTP_X_DEVICE'] : ''; if (empty($xDevice)) { return true; // Let the redirect happen } else { if ($title->getNamespace() == NS_SPECIAL) { list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey()); if ($name) { $title = SpecialPage::getTitleFor($name, $subpage); } } $targetUrl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT); // Redirect to canonical url, make it a 301 to allow caching if ($targetUrl == $request->getFullRequestURL()) { $message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n"; if ($wgUsePathInfo) { $message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct."; } else { $message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true."; } throw new HttpError(500, $message); } else { $parsedUrl = wfParseUrl($targetUrl); if (stristr($parsedUrl['host'], $wgMobileDomain) === false) { $hostParts = explode('.', $parsedUrl['host']); $parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2]; } $fragmentDelimiter = !empty($parsedUrl['fragment']) ? '#' : ''; $queryDelimiter = !empty($parsedUrl['query']) ? '?' : ''; $targetUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path'] . $queryDelimiter . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment']; $output->setSquidMaxage(1200); $output->redirect($targetUrl, '301'); } return false; // Prevent the redirect from occuring } }
public function executeChrome() { global $wgRequest, $wgTitle; $this->tab = $wgRequest->getVal("tab", ""); if (empty($this->tab) && $this->isAdminDashboardTitle()) { $this->tab = 'general'; } else { if (AdminDashboardLogic::isGeneralApp(array_shift(SpecialPageFactory::resolveAlias($wgTitle->getDBKey())))) { $this->tab = 'general'; } else { if (empty($this->tab)) { $this->tab = 'advanced'; } } } $this->response->addAsset('extensions/wikia/AdminDashboard/css/AdminDashboard.scss'); $this->response->addAsset('extensions/wikia/AdminDashboard/js/AdminDashboard.js'); $this->isAdminDashboard = $this->isAdminDashboardTitle(); $this->adminDashboardUrl = Title::newFromText('AdminDashboard', NS_SPECIAL)->getFullURL("tab={$this->tab}"); $this->adminDashboardUrlGeneral = Title::newFromText('AdminDashboard', NS_SPECIAL)->getFullURL("tab=general"); $this->adminDashboardUrlAdvanced = Title::newFromText('AdminDashboard', NS_SPECIAL)->getFullURL("tab=advanced"); }
public function executeChrome() { global $wgRequest, $wgTitle; $adminDashboardTitle = Title::newFromText('AdminDashboard', NS_SPECIAL); $this->isAdminDashboard = $wgTitle->getText() == $adminDashboardTitle->getText(); $this->tab = $wgRequest->getVal("tab", ""); if (empty($this->tab) && $this->isAdminDashboard) { $this->tab = 'general'; } else { if (AdminDashboardLogic::isGeneralApp(array_shift(SpecialPageFactory::resolveAlias($wgTitle->getDBKey())))) { $this->tab = 'general'; } else { if (empty($this->tab)) { $this->tab = 'advanced'; } } } $this->wg->Out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/AdminDashboard/css/AdminDashboard.scss')); $this->wg->Out->addScriptFile($this->wg->ExtensionsPath . '/wikia/AdminDashboard/js/AdminDashboard.js'); $this->adminDashboardUrl = Title::newFromText('AdminDashboard', NS_SPECIAL)->getFullURL("tab={$this->tab}"); $this->adminDashboardUrlGeneral = Title::newFromText('AdminDashboard', NS_SPECIAL)->getFullURL("tab=general"); $this->adminDashboardUrlAdvanced = Title::newFromText('AdminDashboard', NS_SPECIAL)->getFullURL("tab=advanced"); }
/** * Extract information from a Title object for return to Lua * * This also records a link to this title in the current ParserOutput * and caches the title for repeated lookups. The caller should call * incrementExpensiveFunctionCount() if necessary. * * @param $title Title Title to return * @return array Lua data */ private function returnTitleToLua(Title $title) { // Cache it $this->titleCache[$title->getPrefixedDBkey()] = $title; if ($title->getArticleID() > 0) { $this->idCache[$title->getArticleID()] = $title; } // Record a link if ($this->getParser() && !$title->equals($this->getTitle())) { $this->getParser()->getOutput()->addLink($title); } $ns = $title->getNamespace(); $ret = array('isLocal' => (bool) $title->isLocal(), 'isRedirect' => (bool) $title->isRedirect(), 'interwiki' => $title->getInterwiki(), 'namespace' => $ns, 'nsText' => $title->getNsText(), 'text' => $title->getText(), 'id' => $title->getArticleID(), 'fragment' => $title->getFragment(), 'thePartialUrl' => $title->getPartialURL()); if ($ns === NS_SPECIAL) { $ret['exists'] = (bool) SpecialPageFactory::exists($title->getDBkey()); } else { $ret['exists'] = $ret['id'] > 0; } if ($ns !== NS_FILE && $ns !== NS_MEDIA) { $ret['fileExists'] = false; } return $ret; }
/** * Hook function for BeforePageDisplay */ function efSkinPerPageBeforePageDisplayHook(OutputPage &$out, Skin &$skin) { global $wgSkinPerNamespace, $wgSkinPerSpecialPage, $wgSkinPerNamespaceOverrideLoggedIn, $wgUser; if (!$wgSkinPerNamespaceOverrideLoggedIn && $wgUser->isLoggedIn()) { return true; } $title = $out->getTitle(); $ns = $title->getNamespace(); $skinName = null; if ($ns == NS_SPECIAL) { list($canonical, ) = SpecialPageFactory::resolveAlias($title->getDBkey()); if (isset($wgSkinPerSpecialPage[$canonical])) { $skinName = $wgSkinPerSpecialPage[$canonical]; } } if ($skinName === null && isset($wgSkinPerNamespace[$ns])) { $skinName = $wgSkinPerNamespace[$ns]; } if ($skinName !== null) { $skin = Skin::newFromKey($skinName); $skin->setRelevantTitle($title); } return true; }
/** * Output the HTML form on Special:Editcount * * @param string $username * @param int $uid * @param array $nscount * @param int $total */ function outputHTML($username, $uid, $nscount, $total, $nscountall, $totalall) { global $wgTitle, $wgOut, $wgLang; /* current wiki */ $this->nscount = $nscount; $this->total = $total; /* all wikis */ $this->nscountall = $nscountall; $this->totalall = $totalall; $this->setHeaders(); list($name, $subpage) = SpecialPageFactory::resolveAlias($this->getTitle()->getDBkey()); $title = SpecialPage::getTitleFor($name); // get link WITHOUT subpage $action = $title->getLocalUrl(); $user = wfMsgHtml('editcount_username'); $submit = wfMsgHtml('editcount_submit'); $editcounttable = $username != null && $uid != 0 ? $this->makeTable() : ""; $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $oTmpl->set_vars(array("action" => $action, "submit" => $submit, "user" => $user, "username" => $username, "editcounttable" => $editcounttable)); $wgOut->addHTML($oTmpl->render("main-form")); wfProfileOut(__METHOD__); }