本文整理汇总了PHP中SpecialPageFactory::resolveAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPageFactory::resolveAlias方法的具体用法?PHP SpecialPageFactory::resolveAlias怎么用?PHP SpecialPageFactory::resolveAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPageFactory
的用法示例。
在下文中一共展示了SpecialPageFactory::resolveAlias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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);
}
示例2: wfCreatePageConfirmEdit
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;
}
}
示例3: addLicencing
/**
* 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;
}
示例4: formatChangeLine
/**
* @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;
}
示例5: execute
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);
}
示例6: efDspHook
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;
}
示例7: parseItem
/**
* Parse one line from MediaWiki message to array with indexes 'text' and 'href'
*
* @return array
* @author Inez Korczynski <inez@wikia.com>
*/
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);
}
示例8: displayAdminDashboard
/**
* @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;
}
示例9: onBeforeInitialize
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);
}
}
}
示例10: linkfix
/**
* 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;
}
示例11: testCanonicalRedirect
/**
* @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
}
}
示例12: executeChrome
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");
}
示例13: executeChrome
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");
}
示例14: efSkinPerPageBeforePageDisplayHook
/**
* 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;
}
示例15: performRequest
/**
* Performs the request.
* - bad titles
* - read restriction
* - local interwiki redirects
* - redirect loop
* - special pages
* - normal pages
*
* @throws MWException|PermissionsError|BadTitleError|HttpError
* @return void
*/
private function performRequest()
{
global $wgServer, $wgUsePathInfo, $wgTitle;
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
$requestTitle = $title = $this->context->getTitle();
$output = $this->context->getOutput();
$user = $this->context->getUser();
if ($request->getVal('printable') === 'yes') {
$output->setPrintable();
}
$unused = null;
// To pass it by reference
wfRunHooks('BeforeInitialize', array(&$title, &$unused, &$output, &$user, $request, $this));
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if (is_null($title) || $title->getDBkey() == '' && $title->getInterwiki() == '' || $title->isSpecial('Badtitle')) {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
wfProfileOut(__METHOD__);
throw new BadTitleError();
}
// Check user's permissions to read this page.
// We have to check here to catch special pages etc.
// We will check again in Article::view().
$permErrors = $title->getUserPermissionsErrors('read', $user);
if (count($permErrors)) {
// Bug 32276: allowing the skin to generate output with $wgTitle or
// $this->context->title set to the input title would allow anonymous users to
// determine whether a page exists, potentially leaking private data. In fact, the
// curid and oldid request parameters would allow page titles to be enumerated even
// when they are not guessable. So we reset the title to Special:Badtitle before the
// permissions error is displayed.
//
// The skin mostly uses $this->context->getTitle() these days, but some extensions
// still use $wgTitle.
$badTitle = SpecialPage::getTitleFor('Badtitle');
$this->context->setTitle($badTitle);
$wgTitle = $badTitle;
wfProfileOut(__METHOD__);
throw new PermissionsError('read', $permErrors);
}
$pageView = false;
// was an article or special page viewed?
// Interwiki redirects
if ($title->getInterwiki() != '') {
$rdfrom = $request->getVal('rdfrom');
if ($rdfrom) {
$url = $title->getFullURL(array('rdfrom' => $rdfrom));
} else {
$query = $request->getValues();
unset($query['title']);
$url = $title->getFullURL($query);
}
// Check for a redirect loop
if (!preg_match('/^' . preg_quote($wgServer, '/') . '/', $url) && $title->isLocal()) {
// 301 so google et al report the target as the actual url.
$output->redirect($url, 301);
} else {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
wfProfileOut(__METHOD__);
throw new BadTitleError();
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ($request->getVal('action', 'view') == 'view' && !$request->wasPosted() && ($request->getVal('title') === null || $title->getPrefixedDBkey() != $request->getVal('title')) && !count($request->getValueNames(array('action', 'title'))) && wfRunHooks('TestCanonicalRedirect', array($request, $title, $output))) {
if ($title->isSpecialPage()) {
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 {
$output->setSquidMaxage(1200);
$output->redirect($targetUrl, '301');
}
// Special pages
} elseif (NS_SPECIAL == $title->getNamespace()) {
$pageView = true;
// Actions that need to be made when we have a special pages
SpecialPageFactory::executePath($title, $this->context);
//.........这里部分代码省略.........