/** * Modify personal URLs list */ private function setupPersonalUrls() { global $wgUser; // Import the starting set of urls from the skin template $this->personal_urls = F::app()->getSkinTemplateObj()->data['personal_urls']; if ($wgUser->isAnon()) { // add login and register links for anons //$skin = RequestContext::getMain()->getSkin(); // where to redirect after login $query = F::app()->wg->Request->getValues(); if (isset($query['title'])) { if (!self::isBlacklisted($query['title'])) { $returnto = $query['title']; } else { $returnto = Title::newMainPage()->getPartialURL(); } } else { $returnto = Title::newMainPage()->getPartialURL(); } $returnto = wfGetReturntoParam($returnto); $this->personal_urls['login'] = array('text' => wfMsg('login'), 'href' => Skin::makeSpecialUrl('UserLogin', $returnto), 'class' => 'ajaxLogin', 'afterText' => Xml::element('img', array('src' => $this->wg->BlankImgUrl, 'class' => 'chevron', 'width' => '0', 'height' => '0'), '')); $this->personal_urls['register'] = array('text' => wfMsg('oasis-signup'), 'href' => Skin::makeSpecialUrl('UserSignup'), 'class' => 'ajaxRegister'); } else { // use Mypage message for userpage entry $this->personal_urls['userpage']['text'] = wfMsg('mypage'); } }
public function executeWordmark() { $themeSettings = new ThemeSettings(); $settings = $themeSettings->getSettings(); $this->wordmarkText = $settings['wordmark-text']; $this->wordmarkType = $settings['wordmark-type']; $this->wordmarkSize = $settings['wordmark-font-size']; $this->wordmarkFont = $settings['wordmark-font']; $this->wordmarkFontClass = !empty($settings["wordmark-font"]) ? "font-{$settings['wordmark-font']}" : ''; $this->wordmarkUrl = ''; if ($this->wordmarkType == "graphic") { wfProfileIn(__METHOD__ . 'graphicWordmark'); $this->wordmarkUrl = $themeSettings->getWordmarkUrl(); $imageTitle = Title::newFromText($themeSettings::WordmarkImageName, NS_IMAGE); if ($imageTitle instanceof Title) { $attributes = array(); $file = wfFindFile($imageTitle); if ($file instanceof File) { $attributes[] = 'width="' . $file->width . '"'; $attributes[] = 'height="' . $file->height . '"'; if (!empty($attributes)) { $this->wordmarkStyle = ' ' . implode(' ', $attributes) . ' '; } } } wfProfileOut(__METHOD__ . 'graphicWordmark'); } $this->mainPageURL = Title::newMainPage()->getLocalURL(); }
/** * Render the special page * @param string|null $par Parameter submitted as subpage */ public function execute($par = '') { parent::execute($par); $context = MobileContext::singleton(); wfIncrStats('mobile.options.views'); $this->returnToTitle = Title::newFromText($this->getRequest()->getText('returnto')); if (!$this->returnToTitle) { $this->returnToTitle = Title::newMainPage(); } $this->setHeaders(); $context->setForceMobileView(true); $context->setContentTransformations(false); if (isset($this->options[$par])) { $option = $this->options[$par]; if ($this->getRequest()->wasPosted() && isset($option['post'])) { $func = $option['post']; } else { $func = $option['get']; } $this->{$func}(); } else { if ($this->getRequest()->wasPosted()) { $this->submitSettingsForm(); } else { $this->getSettingsForm(); } } }
/** * Check whether comments should be enabled for given title */ public static function ArticleCommentCheckTitle($title) { wfProfileIn(__METHOD__); //enable comments only on content namespaces (use $wgArticleCommentsNamespaces if defined) if (!self::ArticleCommentCheckNamespace($title)) { wfProfileOut(__METHOD__); return false; } //non-existing articles if (!$title->exists()) { wfProfileOut(__METHOD__); return false; } //disable on main page (RT#33703) if (Title::newMainPage()->getText() == $title->getText()) { wfProfileOut(__METHOD__); return false; } //disable on pages that cant be read (RT#49525) if (!$title->userCan('read')) { wfProfileOut(__METHOD__); return false; } //blog listing? (eg: User:Name instead of User:Name/Blog_name) - do not show comments if (ArticleComment::isBlog() && strpos($title->getText(), '/') === false) { wfProfileOut(__METHOD__); return false; } wfProfileOut(__METHOD__); return true; }
public function Wordmark() { $themeSettings = new ThemeSettings(); $settings = $themeSettings->getSettings(); $wordmarkURL = ''; if ($settings['wordmark-type'] == 'graphic') { wfProfileIn(__METHOD__ . 'graphicWordmark'); $imageTitle = Title::newFromText($themeSettings::WordmarkImageName, NS_IMAGE); $file = wfFindFile($imageTitle); $attributes = []; $wordmarkStyle = ''; if ($file instanceof File) { $wordmarkURL = $file->getUrl(); $attributes[] = 'width="' . $file->width . '"'; $attributes[] = 'height="' . $file->height . '"'; if (!empty($attributes)) { $this->wordmarkStyle = ' ' . implode(' ', $attributes) . ' '; } } wfProfileOut(__METHOD__ . 'graphicWordmark'); } $mainPageURL = Title::newMainPage()->getLocalURL(); $this->setVal('mainPageURL', $mainPageURL); $this->setVal('wordmarkText', $settings['wordmark-text']); $this->setVal('wordmarkFontSize', $settings['wordmark-font-size']); $this->setVal('wordmarkUrl', $wordmarkURL); $this->setVal('wordmarkStyle', $wordmarkStyle); }
function doBeforeContent() { global $wgOut; $s = ""; $qb = $this->qbSetting(); $mainPageObj = Title::newMainPage(); $s .= file_get_contents('../wwwroot/templates/header.html'); $title = htmlspecialchars($wgOut->getPageTitle()); $s = str_replace('{PAGE_TITLE}', $title, $s); $s .= '<tr><td>'; $s .= '<table border="0" cellpadding="0" cellspacing="0" width="760">'; $s .= '<tr>'; $s .= '<td bgcolor="#20292E" width="1"><img src="/images/pixel.gif" height="10" width="1" /><br /></td>'; $s .= '<td bgcolor="#4C626F" width="758">'; $s .= "\n<div id='content'>\n"; //$s .= '<table border="0" cellpadding="0" cellspacing="0" width="758"><tr>'; //$s .= '<td width="10"><img src="/images/pixel.gif" height="10" width="10" /><br /></td>'; //$s .= '<td width="738">'; $s .= "<div id='article'>"; $notice = wfGetSiteNotice(); if( $notice ) { $s .= "\n<div id='siteNotice'>$notice</div>\n"; } //$s .= $this->pageTitle(); // $s .= $this->pageSubtitle() . "\n"; return $s; }
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); }
/** * Show a return link or redirect to it. * Extensions can change where the link should point or inject content into the page * (which will change it from redirect to link mode). * * @param string $type One of the following: * - error: display a return to link ignoring $wgRedirectOnLogin * - success: display a return to link using $wgRedirectOnLogin if needed * - successredirect: send an HTTP redirect using $wgRedirectOnLogin if needed * @param string $returnTo * @param array|string $returnToQuery * @param bool $stickHTTPS Keep redirect link on HTTPS */ public function showReturnToPage($type, $returnTo = '', $returnToQuery = '', $stickHTTPS = false) { global $wgRedirectOnLogin, $wgSecureLogin; if ($type !== 'error' && $wgRedirectOnLogin !== null) { $returnTo = $wgRedirectOnLogin; $returnToQuery = []; } elseif (is_string($returnToQuery)) { $returnToQuery = wfCgiToArray($returnToQuery); } // Allow modification of redirect behavior Hooks::run('PostLoginRedirect', [&$returnTo, &$returnToQuery, &$type]); $returnToTitle = Title::newFromText($returnTo) ?: Title::newMainPage(); if ($wgSecureLogin && !$stickHTTPS) { $options = ['http']; $proto = PROTO_HTTP; } elseif ($wgSecureLogin) { $options = ['https']; $proto = PROTO_HTTPS; } else { $options = []; $proto = PROTO_RELATIVE; } if ($type === 'successredirect') { $redirectUrl = $returnToTitle->getFullURL($returnToQuery, false, $proto); $this->getOutput()->redirect($redirectUrl); } else { $this->getOutput()->addReturnTo($returnToTitle, $returnToQuery, null, $options); } }
function setUp() { parent::setUp(); $parser = new Parser(); $options = new ParserOptions(); $options->setTemplateCallback(array($this, 'templateCallback')); $parser->startExternalParse(Title::newMainPage(), $options, Parser::OT_HTML, true); try { $engine = new Scribunto_LuaSandboxEngine(array('parser' => $parser) + $this->sandboxOpts); $engine->setTitle($parser->getTitle()); $engine->getInterpreter(); $this->engines['LuaSandbox'] = $engine; } catch (Scribunto_LuaInterpreterNotFoundError $e) { $this->markTestSkipped("LuaSandbox interpreter not available"); return; } try { $engine = new Scribunto_LuaStandaloneEngine(array('parser' => $parser) + $this->standaloneOpts); $engine->setTitle($parser->getTitle()); $engine->getInterpreter(); $this->engines['LuaStandalone'] = $engine; } catch (Scribunto_LuaInterpreterNotFoundError $e) { $this->markTestSkipped("LuaStandalone interpreter not available"); return; } }
/** * Main execution point * @param $par Namespace to select the redirect from */ function wfSpecialRandomredirect($par = NULL) { global $wgOut, $wgExtraRandompageSQL, $wgContLang; $fname = 'wfSpecialRandomredirect'; # Validate the namespace $namespace = $wgContLang->getNsIndex($par); if ($namespace === false || $namespace < NS_MAIN) { $namespace = NS_MAIN; } # Same logic as RandomPage $randstr = wfRandom(); $dbr =& wfGetDB(DB_SLAVE); $use_index = $dbr->useIndexClause('page_random'); $page = $dbr->tableName('page'); $extra = $wgExtraRandompageSQL ? "AND ({$wgExtraRandompageSQL})" : ''; $sql = "SELECT page_id,page_title\n\t\tFROM {$page} {$use_index}\n\t\tWHERE page_namespace = {$namespace} AND page_is_redirect = 1 {$extra}\n\t\tAND page_random > {$randstr}\n\t\tORDER BY page_random"; $sql = $dbr->limitResult($sql, 1, 0); $res = $dbr->query($sql, $fname); $title = NULL; if ($row = $dbr->fetchObject($res)) { $title = Title::makeTitleSafe($namespace, $row->page_title); } # Catch dud titles and return to the main page if (is_null($title)) { $title = Title::newMainPage(); } $wgOut->reportTime(); $wgOut->redirect($title->getFullUrl('redirect=no')); }
/** * Checks some initial queries * Note that $title here is *not* a Title object, but a string! */ function checkInitialQueries($title, $action, &$output, $request, $lang) { if ($request->getVal('printable') == 'yes') { $output->setPrintable(); } $ret = NULL; if ('' == $title && 'delete' != $action) { $ret = Title::newMainPage(); } elseif ($curid = $request->getInt('curid')) { # URLs like this are generated by RC, because rc_title isn't always accurate $ret = Title::newFromID($curid); } else { $ret = Title::newFromURL($title); /* check variant links so that interwiki links don't have to worry about the possible different language variants */ if (count($lang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0) { $lang->findVariantLink($title, $ret); } } if (($oldid = $request->getInt('oldid')) && (is_null($ret) || $ret->getNamespace() != NS_SPECIAL)) { // Allow oldid to override a changed or missing title. $rev = Revision::newFromId($oldid); if ($rev) { $ret = $rev->getTitle(); } } return $ret; }
function doAfterContent() { global $wgOut; $s = "\n</div><br clear='all' />\n"; $s .= "\n<div id='footer'>"; $s .= "<table width='98%' border='0' cellspacing='0'><tr>"; $qb = $this->qbSetting(); if (1 == $qb || 3 == $qb) { # Left $s .= $this->getQuickbarCompensator(); } $s .= "<td class='bottom' align='center' valign='top'>"; $s .= $this->bottomLinks(); $s .= "\n<br />" . $this->makeKnownLinkObj(Title::newMainPage()) . " | " . $this->aboutLink() . " | " . $this->searchForm(wfMsg("qbfind")); $s .= "\n<br />" . $this->pageStats(); $s .= "</td>"; if (2 == $qb) { # Right $s .= $this->getQuickbarCompensator(); } $s .= "</tr></table>\n</div>\n</div>\n"; if (0 != $qb) { $s .= $this->quickBar(); } return $s; }
public function executeIndex() { OasisController::addBodyClass('wikinav2'); $themeSettings = new ThemeSettings(); $settings = $themeSettings->getSettings(); $this->wordmarkText = $settings["wordmark-text"]; $this->wordmarkType = $settings["wordmark-type"]; $this->wordmarkSize = $settings["wordmark-font-size"]; $this->wordmarkFont = $settings["wordmark-font"]; if ($this->wordmarkType == "graphic") { wfProfileIn(__METHOD__ . 'graphicWordmarkV2'); $this->wordmarkUrl = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster()); $imageTitle = Title::newFromText($themeSettings::WordmarkImageName,NS_IMAGE); if($imageTitle instanceof Title) { $attributes = array(); $file = wfFindFile($imageTitle); if($file instanceof File) { $attributes []= 'width="' . $file->width . '"'; $attributes []= 'height="' . $file->height. '"'; if(!empty($attributes)) { $this->wordmarkStyle = ' ' . implode(' ',$attributes) . ' '; } } } wfProfileOut(__METHOD__. 'graphicWordmarkV2'); } $this->mainPageURL = Title::newMainPage()->getLocalURL(); $this->displaySearch = !empty($this->wg->EnableAdminDashboardExt) && AdminDashboardLogic::displayAdminDashboard($this, $this->wg->Title); }
public static function renderHeroTag($content, array $attributes, Parser $parser, PPFrame $frame) { $wikiData = new WikiDataModel(Title::newMainPage()->getText()); $wikiData->setFromAttributes($attributes); $wikiData->storeInProps(); return ''; }
public function setUp() { $this->setupFile = dirname(__FILE__) . '/../ShareButtons.setup.php'; parent::setUp(); $this->mockGlobalVariable('wgTitle', Title::newMainPage()); $this->mockApp(); }
function doBeforeContent() { global $wgOut, $wgTitle; $s = ""; $qb = $this->qbSetting(); $mainPageObj = Title::newMainPage(); $s .= "\n<div id='content'>\n<div id='topbar'>" . "<table width='100%' border='0' cellspacing='0' cellpadding='8'><tr>"; $s .= "<td class='top' align='left' valign='middle' nowrap='nowrap'>"; $s .= "<a href=\"" . $mainPageObj->escapeLocalURL() . "\">"; $s .= "<span id='sitetitle'>" . wfMsg("sitetitle") . "</span></a>"; $s .= "</td><td class='top' align='right' valign='bottom' width='100%'>"; $s .= $this->sysLinks(); $s .= "</td></tr><tr><td valign='top'>"; $s .= "<font size='-1'><span id='sitesub'>"; $s .= htmlspecialchars(wfMsg("sitesubtitle")) . "</span></font>"; $s .= "</td><td align='right'>"; $s .= "<font size='-1'><span id='langlinks'>"; $s .= str_replace("<br />", "", $this->otherLanguages()); $cat = $this->getCategoryLinks(); if ($cat) { $s .= "<br />{$cat}\n"; } $s .= "<br />" . $this->pageTitleLinks(); $s .= "</span></font>"; $s .= "</td></tr></table>\n"; $s .= "\n</div>\n<div id='article'>"; $notice = wfGetSiteNotice(); if ($notice) { $s .= "\n<div id='siteNotice'>{$notice}</div>\n"; } $s .= $this->pageTitle(); $s .= $this->pageSubtitle() . "\n"; return $s; }
/** * Creates a NMSendMailJob * * @param Title $title */ function __construct($title, $params) { wfDebug(__METHOD__ . " " . get_class($this) . " \r\n"); wfProfileIn(__METHOD__); parent::__construct(get_class($this), Title::newMainPage(), $params); wfProfileOut(__METHOD__); }
function efGroupPortal_MediaWikiPerformAction($output, $article, $title, $user, $request) { $action = $request->getVal('action', 'view'); $redirect = $request->getVal('redirect'); if ($action === 'view' && $redirect === null) { if ($title->equals(Title::newMainPage())) { $groupPortals = spliti("\n", wfMsgForContentNoTrans('groupportal')); $groups = $user->getGroups(); $targetPortal = ''; foreach ($groupPortals as $groupPortal) { $mcount = preg_match('/^(.+)\\|(.+)$/', $groupPortal, $matches); if ($mcount > 0) { if (in_array($matches[1], $groups) || $matches[1] == '*' && empty($targetPortal)) { $targetPortal = $matches[2]; } } } if (!empty($targetPortal)) { $target = Title::newFromText($targetPortal); if (is_object($target)) { $output->redirect($target->getLocalURL()); return false; } } } } return true; }
/** * @covers ApiRawMessage */ public function testApiRawMessage() { $msg = new RawMessage('foo', array('baz')); $msg->inLanguage('de')->title(Title::newMainPage()); $msg2 = new ApiRawMessage($msg, 'code', array('data')); $this->compareMessages($msg, $msg2); $this->assertEquals('code', $msg2->getApiCode()); $this->assertEquals(array('data'), $msg2->getApiData()); $msg2 = unserialize(serialize($msg2)); $this->compareMessages($msg, $msg2); $this->assertEquals('code', $msg2->getApiCode()); $this->assertEquals(array('data'), $msg2->getApiData()); $msg = new RawMessage('foo', array('baz')); $msg2 = new ApiRawMessage(array('foo', 'baz'), 'code', array('data')); $this->compareMessages($msg, $msg2); $this->assertEquals('code', $msg2->getApiCode()); $this->assertEquals(array('data'), $msg2->getApiData()); $msg = new RawMessage('foo'); $msg2 = new ApiRawMessage('foo', 'code', array('data')); $this->compareMessages($msg, $msg2); $this->assertEquals('code', $msg2->getApiCode()); $this->assertEquals(array('data'), $msg2->getApiData()); $msg2->setApiCode('code', array('data')); $this->assertEquals('code', $msg2->getApiCode()); $this->assertEquals(array('data'), $msg2->getApiData()); $msg2->setApiCode(null); $this->assertEquals('foo', $msg2->getApiCode()); $this->assertEquals(array('data'), $msg2->getApiData()); $msg2->setApiData(array('data2')); $this->assertEquals(array('data2'), $msg2->getApiData()); }
/** * @dataProvider provideContentObjs */ public function testGetParsedFooter(CollaborationHubContent $content, $id) { $expected = ["<p><b>Test</b> content footer\n</p>", '', '']; $wc = TestingAccessWrapper::newFromObject($content); $actual = $wc->getParsedFooter(Title::newMainPage(), new ParserOptions()); $this->assertEquals($expected[$id], $actual, $id); }
/** * @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]; }
/** * @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]; }
function doAfterContent() { global $wgLang; $s = "\n</div><br clear='all' />\n"; $s .= "\n<div id='footer'>"; $s .= '<table width="98%" border="0" cellspacing="0"><tr>'; $qb = $this->qbSetting(); if (1 == $qb || 3 == $qb) { # Left $s .= $this->getQuickbarCompensator(); } $s .= '<td class="bottom" align="center" valign="top">'; $s .= $this->bottomLinks(); $s .= $wgLang->pipeList(array("\n<br />" . $this->link(Title::newMainPage(), null, array(), array(), array('known', 'noclasses')), $this->aboutLink(), $this->searchForm(wfMsg('qbfind')))); $s .= "\n<br />" . $this->pageStats(); $s .= '</td>'; if (2 == $qb) { # Right $s .= $this->getQuickbarCompensator(); } $s .= "</tr></table>\n</div>\n</div>\n"; if (0 != $qb) { $s .= $this->quickBar(); } return $s; }
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 execute( $par ) { global $wgOut; $title = ''; $params = array(); if( IncubatorTest::isContentProject() ) { global $wgRequest; $title = Title::newFromText( IncubatorTest::displayPrefix() ); if( $wgRequest->getVal( 'goto' ) != 'infopage' ) { $params['goto'] = 'mainpage'; } $url = IncubatorTest::getUrlParam(); if( $url ) { $params['testwiki'] = $url['prefix']; } } # Go to the main page if given invalid title, or if it's not a content project if ( !$title ) { $title = Title::newMainPage(); } $wgOut->redirect( $title->getLocalURL( $params ) ); }
function execute() { wfProfileIn(__METHOD__); global $wgOut, $wgRequest; if (wfReadOnly()) { $wgOut->readOnlyPage(); wfProfileOut(__METHOD__); return; } $articleID = $wgRequest->getInt('articleid'); $title = Title::newFromID($articleID); if (!is_null($title) && $title->exists()) { if (strpos($_SERVER['HTTP_USER_AGENT'], 'facebook') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'bitlybot') === false) { $sharerID = $wgRequest->getInt('userid'); $viewerIP = $wgRequest->getIP(); $awardingService = new AchAwardingService(); $awardingService->processSharing($articleID, $sharerID, $viewerIP); } } else { $title = Title::newMainPage(); } // this works only for Wikia and only in current varnish configuration if (!headers_sent()) { header('X-Pass-Cache-Control: no-store, private, no-cache, must-revalidate'); } $wgOut->redirect($title->getLocalURL()); wfProfileOut(__METHOD__); }
function getRepublishText($t) { global $wgRequest, $wgContLang, $wgOut, $wgServer; if (!$t) { return ""; } $r = Revision::newFromTitle($t); $mp = Title::newMainPage(); $title = "<h1 style='margin-bottom: 0px;'><a href=\"" . $t->getFullURL() . "\">" . wfMsg('howto', $t->getText()) . "</a></h1>\n" . wfMsg('republish_taglinelink', $mp->getFullURL()) . "<br/>"; if (!$r) { return ""; } $text = $r->getText(); if ($wgRequest->getVal('striptags', 'true') != 'false') { $text = preg_replace("/\\[\\[" . $wgContLang->getNSText(NS_IMAGE) . "[^\\]]*\\]\\]/", "", $text); } $output = $wgOut->parse($text); //$output = str_replace("<div class='SecL'></div><div class='SecR'></div>", "", $output); //$output = preg_replace("/<div id=\"[a-z]*\"/", "<div ", $output); $output = str_replace('href="/', 'href="' . $wgServer . '/', $output); if ($wgRequest->getVal('striptags', 'true') != 'false') { $output = strip_tags($output, '<b><i><h1><h2><ol><ul><li><a>'); } else { $output = str_replace('<img src="/', '<img src="http://www.wikihow.com/', $output); } $output = preg_replace("@href=(['\"])/@", "href=\$1{$wgServer}/", $output); $output = $title . "\n" . $output . wfMsg('republish_footer', $t->getText(), $t->getFullURL()); $output = preg_replace("/\n\n[\n]*/", "\n", $output); return $output; }
function WidgetAncientPages($id, $params) { wfProfileIn(__METHOD__); global $wgTitle, $wgLang, $wgOut; // load class if it's not loaded yet... if (!class_exists('AncientPagesPage')) { require_once $IP . 'includes/SpecialAncientpages.php'; } if (!is_object($wgTitle)) { $wgTitle = Title::newMainPage(); } $offset = 0; $limit = intval($params['limit']); $limit = $limit <= 0 || $limit > 50 ? 10 : $limit; $pages = array(); // query the special page object $showSpecial = false; $app = new WidgetAncientPagesPage($showSpecial); $app->setListoutput(TRUE); $app->doQuery($offset, $limit, $showSpecial); $items = array(); $aRows = $app->getResult(); if (!empty($aRows) && is_array($aRows)) { foreach ($aRows as $sTitle => $sTimestamp) { $date = $wgLang->sprintfDate('j M Y', date('YmdHis', $sTimestamp)); $oTitle = Title::newFromText($sTitle, NS_MAIN); if ($oTitle instanceof Title) { $items[] = array('name' => $oTitle->getText(), 'href' => $oTitle->getLocalURL(), 'title' => wfMsg('lastmodifiedat', date('H:i', $sTimestamp), $date)); } } } wfProfileOut(__METHOD__); return WidgetFramework::wrapLinks($items) . WidgetFramework::moreLink(Title::newFromText('Ancientpages', NS_SPECIAL)->getLocalURL()); }
/** * @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; }
/** * 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); }