コード例 #1
0
 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
0
ファイル: CreateAPage.php プロジェクト: schwarer2006/wikia
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
0
/**
 * 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
0
 /**
  * @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
0
 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'], '&amp;') !== 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
0
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
0
 /**
  * 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);
 }
コード例 #8
0
 /**
  * @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 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
0
 /**
  * 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
0
 /**
  * @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
0
 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
0
 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
0
/**
 * 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
0
ファイル: Wiki.php プロジェクト: mangowi/mediawiki
 /**
  * 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);
     } else {
         // ...otherwise treat it as an article view. The article
         // may be a redirect to another article or URL.
         $article = $this->initializeArticle();
         if (is_object($article)) {
             $pageView = true;
             /**
              * $wgArticle is deprecated, do not use it.
              * @deprecated since 1.18
              */
             global $wgArticle;
             $wgArticle = new DeprecatedGlobal('wgArticle', $article, '1.18');
             $this->performAction($article, $requestTitle);
         } elseif (is_string($article)) {
             $output->redirect($article);
         } else {
             wfProfileOut(__METHOD__);
             throw new MWException("Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL");
         }
     }
     if ($pageView) {
         // Promote user to any groups they meet the criteria for
         $user->addAutopromoteOnceGroups('onView');
     }
     wfProfileOut(__METHOD__);
 }
コード例 #16
0
 public static function special($parser, $text)
 {
     list($page, $subpage) = SpecialPageFactory::resolveAlias($text);
     if ($page) {
         $title = SpecialPage::getTitleFor($page, $subpage);
         return $title->getPrefixedText();
     } else {
         // unknown special page, just use the given text as its title, if at all possible
         $title = Title::makeTitleSafe(NS_SPECIAL, $text);
         return $title ? $title->getPrefixedText() : self::special($parser, 'Badtitle');
     }
 }
コード例 #17
0
 /**
  * @dataProvider provideTestConflictResolution
  */
 public function testConflictResolution($test, $aliasesList, $alias, $expectedName, $expectedAlias, $expectWarnings)
 {
     global $wgContLang;
     $lang = clone $wgContLang;
     $lang->mExtendedSpecialPageAliases = $aliasesList;
     $this->setMwGlobals('wgContLang', $lang);
     $this->setMwGlobals('wgSpecialPages', array_combine(array_keys($aliasesList), array_keys($aliasesList)));
     SpecialPageFactory::resetList();
     // Catch the warnings we expect to be raised
     $warnings = array();
     $this->setMwGlobals('wgDevelopmentWarnings', true);
     set_error_handler(function ($errno, $errstr) use(&$warnings) {
         if (preg_match('/First alias \'[^\']*\' for .*/', $errstr) || preg_match('/Did not find a usable alias for special page .*/', $errstr)) {
             $warnings[] = $errstr;
             return true;
         }
         return false;
     });
     $reset = new ScopedCallback('restore_error_handler');
     list($name, ) = SpecialPageFactory::resolveAlias($alias);
     $this->assertEquals($expectedName, $name, "{$test}: Alias to name");
     $result = SpecialPageFactory::getLocalNameFor($name);
     $this->assertEquals($expectedAlias, $result, "{$test}: Alias to name to alias");
     $gotWarnings = count($warnings);
     if ($gotWarnings !== $expectWarnings) {
         $this->fail("Expected {$expectWarnings} warning(s), but got {$gotWarnings}:\n" . join("\n", $warnings));
     }
 }
コード例 #18
0
ファイル: LogPage.php プロジェクト: eFFemeer/seizamcore
 /**
  * TODO document
  * @param  $type String
  * @param  $lang Language or null
  * @param  $title Title
  * @param  $params Array
  * @return String
  */
 protected static function getTitleLink($type, $lang, $title, &$params)
 {
     global $wgContLang, $wgUserrightsInterwikiDelimiter;
     if (!$lang) {
         return $title->getPrefixedText();
     }
     switch ($type) {
         case 'move':
             $titleLink = Linker::link($title, htmlspecialchars($title->getPrefixedText()), array(), array('redirect' => 'no'));
             $targetTitle = Title::newFromText($params[0]);
             if (!$targetTitle) {
                 # Workaround for broken database
                 $params[0] = htmlspecialchars($params[0]);
             } else {
                 $params[0] = Linker::link($targetTitle, htmlspecialchars($params[0]));
             }
             break;
         case 'block':
             if (substr($title->getText(), 0, 1) == '#') {
                 $titleLink = $title->getText();
             } else {
                 // TODO: Store the user identifier in the parameters
                 // to make this faster for future log entries
                 $id = User::idFromName($title->getText());
                 $titleLink = Linker::userLink($id, $title->getText()) . Linker::userToolLinks($id, $title->getText(), false, Linker::TOOL_LINKS_NOBLOCK);
             }
             break;
         case 'rights':
             $text = $wgContLang->ucfirst($title->getText());
             $parts = explode($wgUserrightsInterwikiDelimiter, $text, 2);
             if (count($parts) == 2) {
                 $titleLink = WikiMap::foreignUserLink($parts[1], $parts[0], htmlspecialchars($title->getPrefixedText()));
                 if ($titleLink !== false) {
                     break;
                 }
             }
             $titleLink = Linker::link(Title::makeTitle(NS_USER, $text));
             break;
         case 'merge':
             $titleLink = Linker::link($title, $title->getPrefixedText(), array(), array('redirect' => 'no'));
             $params[0] = Linker::link(Title::newFromText($params[0]), htmlspecialchars($params[0]));
             $params[1] = $lang->timeanddate($params[1]);
             break;
         default:
             if ($title->getNamespace() == NS_SPECIAL) {
                 list($name, $par) = SpecialPageFactory::resolveAlias($title->getDBkey());
                 # Use the language name for log titles, rather than Log/X
                 if ($name == 'Log') {
                     $titleLink = '(' . Linker::link($title, LogPage::logName($par)) . ')';
                 } else {
                     $titleLink = Linker::link($title);
                 }
             } else {
                 $titleLink = Linker::link($title);
             }
     }
     return $titleLink;
 }
コード例 #19
0
/**
 * Returns the article ID for a given article name. This function has a special
 * handling for Special pages, which do not have an article ID. IntraACL stores
 * special IDs for these pages. Their IDs are always negative while the IDs of
 * normal pages are positive.
 *
 * @param string $articleName   Name of the article
 * @param int $defaultNS        The default namespace if no namespace is given in the name
 * @param boolean $force        True to force the namespace to be $defaultNS
 *
 * @return int
 *         ID of the article:
 *         >0: ID of an article in a normal namespace
 *         =0: Name of the article is invalid
 *         <0: ID of a Special Page
 *
 */
function haclfArticleID($articleName, $defaultNS = NS_MAIN, $force = false)
{
    $t = $articleName;
    if (!is_object($t)) {
        $etc = haclfDisableTitlePatch();
        $t = $force ? Title::makeTitleSafe($defaultNS, $articleName) : Title::newFromText($articleName, $defaultNS);
        haclfRestoreTitlePatch($etc);
    }
    if (!$t || $t->getInterwiki()) {
        return 0;
    }
    if ($t->getNamespace() == NS_SPECIAL) {
        // Canonicalize special page titles
        list($base, $par) = SpecialPageFactory::resolveAlias($t->getText());
        if (!$base) {
            // No such special page exists, just take the base text
            $base = $t->getBaseText();
        }
        return -IACLStorage::get('SpecialPage')->idForSpecial($base);
    }
    $id = $t->getArticleID();
    if ($id === 0) {
        $id = $t->getArticleID(Title::GAID_FOR_UPDATE);
    }
    return $id;
}
コード例 #20
0
ファイル: Linker.php プロジェクト: paladox/2
 /**
  * @param Title $title
  * @return Title
  */
 static function normaliseSpecialPage(Title $title)
 {
     if ($title->isSpecialPage()) {
         list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
         if (!$name) {
             return $title;
         }
         $ret = SpecialPage::getTitleFor($name, $subpage, $title->getFragment());
         return $ret;
     } else {
         return $title;
     }
 }
コード例 #21
0
ファイル: SpecialConnect.php プロジェクト: schwarer2006/wikia
 /**
  * Performs any necessary execution and outputs the resulting Special page.
  */
 function execute($par)
 {
     global $wgUser, $wgRequest;
     if ($wgRequest->getVal("action", "") == "disconnect_reclamation") {
         self::disconnectReclamationAction();
         return;
     }
     $this->mReturnTo = $wgRequest->getVal('returnto');
     $this->mReturnToQuery = $wgRequest->getVal('returntoquery');
     /**
      * BugId:13709
      * Before the fix the logic and the usage of parse_str was wrong
      * which had fatal side effects.
      *
      * The goal if the block below is  to remove the fbconnected
      * variable from the $this->mReturnToQuery (which is supposed
      * to be a QUERY_STRING-like string.
      */
     if (!empty($this->mReturnToQuery)) {
         // a temporary array
         $aReturnToQuery = array();
         // decompose the query string to the array
         parse_str($this->mReturnToQuery, $aReturnToQuery);
         // remove unwanted elements
         unset($aReturnToQuery['fbconnected']);
         //recompose the query string
         foreach ($aReturnToQuery as $k => $v) {
             $aReturnToQuery[$k] = "{$k}={$v}";
         }
         // oh, parse_str implicitly urldecodes values which wasn't
         // mentioned in the PHP documentation.
         $this->mReturnToQuery = urlencode(implode('&', $aReturnToQuery));
         // remove the temporary array
         unset($aReturnToQuery);
     }
     $title = Title::newFromText($this->mReturnTo);
     if (!empty($title)) {
         $this->mResolvedReturnTo = strtolower(array_shift(SpecialPageFactory::resolveAlias($title->getDBKey())));
         if (in_array($this->mResolvedReturnTo, array('userlogout', 'signup', 'connect'))) {
             $titleObj = Title::newMainPage();
             $this->mReturnTo = $titleObj->getText();
             $this->mReturnToQuery = '';
         }
     }
     // Connect to the Facebook API
     $fb = new FBConnectAPI();
     $fb_user = $fb->user();
     // fb id or 0 if none is found.
     // Setup the session
     global $wgSessionStarted;
     if (!$wgSessionStarted) {
         wfSetupSession();
     }
     // Look at the subpage name to discover where we are in the login process
     wfDebug("FBConnect: Executing Special:Connect with the parameter of \"{$par}\".\n");
     wfDebug("FBConnect: User is" . ($wgUser->isLoggedIn() ? "" : " NOT") . " logged in.\n");
     // If the user is logged in to Wikia on an unconnected account, and trying to connect a
     // facebook id, but the FB-id is already connected to a DIFFERENT Wikia account... display an error message.
     global $wgUser;
     if ($wgUser->isLoggedIn() && $fb_user) {
         $foundUser = FBConnectDB::getUser($fb_user);
         if ($foundUser && $foundUser->getId() != $wgUser->getId()) {
             $this->sendPage('fbIdAlreadyConnected');
             return;
         }
     }
     switch ($par) {
         case 'ChooseName':
             $choice = $wgRequest->getText('wpNameChoice');
             if ($wgRequest->getCheck('wpCancel')) {
                 $this->sendError('fbconnect-cancel', 'fbconnect-canceltext');
             } else {
                 switch ($choice) {
                     // Check to see if the user opted to connect an existing account
                     case 'existing':
                         $this->attachUser($fb_user, $wgRequest->getText('wpExistingName'), $wgRequest->getText('wpExistingPassword'));
                         break;
                         // Check to see if the user selected another valid option
                     // Check to see if the user selected another valid option
                     case 'nick':
                     case 'first':
                     case 'full':
                         // Get the username from Facebook (Note: not from the form)
                         $username = FBConnectUser::getOptionFromInfo($choice . 'name', $fb->getUserInfo());
                     case 'manual':
                         if (!isset($username) || !$this->userNameOK($username)) {
                             // Use manual name if no username is set, even if manual wasn't chosen
                             $username = $wgRequest->getText('wpName2');
                         }
                         // If no valid username was found, something's not right; ask again
                         if (!$this->userNameOK($username)) {
                             $this->sendPage('chooseNameForm', 'fbconnect-invalidname');
                         } else {
                             $this->createUser($fb_user, $username);
                         }
                         break;
                     case 'auto':
                         // Create a user with a unique generated username
                         $this->createUser($fb_user, $this->generateUserName());
                         break;
                     default:
                         $this->sendError('fbconnect-invalid', 'fbconnect-invalidtext');
                 }
             }
             break;
         case 'ConnectExisting':
             // If not logged in, slide down to the default
             if ($wgUser->isLoggedIn()) {
                 self::connectExisting();
                 break;
             }
         default:
             // Main entry point
             #if ( $wgRequest->getText( 'returnto' ) ) {
             #	$this->setReturnTo( $wgRequest->getText( 'returnto' ),
             #				$wgRequest->getVal( 'returntoquery' ) );
             #}
             if ($wgUser->isLoggedIn()) {
                 if ($fb_user) {
                     // If the user has previously connected, log them in.  If they have not, then complete the connection process.
                     $fb_ids = FBConnectDB::getFacebookIDs($wgUser);
                     if (count($fb_ids) == 0) {
                         self::connectExisting();
                     } else {
                         // Will display a message that they're already logged in and connected.
                         $this->sendPage('alreadyLoggedIn');
                     }
                 } else {
                     // If the user isn't Connected, then show a form with the Connect button (regardless of whether they are logged in or not).
                     $this->sendPage('connectForm');
                 }
             } else {
                 if ($fb_user) {
                     // If the user is connected, log them in
                     $this->login($fb_user);
                 } else {
                     // If the user isn't Connected, then show a form with the Connect button
                     $this->sendPage('connectForm');
                 }
             }
     }
 }
コード例 #22
0
 /**
  * TODO: document
  * @param $title Title
  * @return String
  */
 function getPageClasses($title)
 {
     $numeric = 'ns-' . $title->getNamespace();
     if ($title->isSpecialPage()) {
         $type = 'ns-special';
         // bug 23315: provide a class based on the canonical special page name without subpages
         list($canonicalName) = SpecialPageFactory::resolveAlias($title->getDBkey());
         if ($canonicalName) {
             $type .= ' ' . Sanitizer::escapeClass("mw-special-{$canonicalName}");
         } else {
             $type .= ' mw-invalidspecialpage';
         }
     } elseif ($title->isTalkPage()) {
         $type = 'ns-talk';
     } else {
         $type = 'ns-subject';
     }
     $name = Sanitizer::escapeClass('page-' . $title->getPrefixedText());
     return "{$numeric} {$type} {$name}";
 }
コード例 #23
0
 /**
  * Get an array containing the variables to be set in mw.config in JavaScript.
  *
  * Do not add things here which can be evaluated in ResourceLoaderStartUpModule
  * - in other words, page-independent/site-wide variables (without state).
  * You will only be adding bloat to the html page and causing page caches to
  * have to be purged on configuration changes.
  * @return array
  */
 public function getJSVars()
 {
     global $wgContLang;
     $curRevisionId = 0;
     $articleId = 0;
     $canonicalSpecialPageName = false;
     # bug 21115
     $title = $this->getTitle();
     $ns = $title->getNamespace();
     $canonicalNamespace = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $title->getNsText();
     $sk = $this->getSkin();
     // Get the relevant title so that AJAX features can use the correct page name
     // when making API requests from certain special pages (bug 34972).
     $relevantTitle = $sk->getRelevantTitle();
     $relevantUser = $sk->getRelevantUser();
     if ($ns == NS_SPECIAL) {
         list($canonicalSpecialPageName, ) = SpecialPageFactory::resolveAlias($title->getDBkey());
     } elseif ($this->canUseWikiPage()) {
         $wikiPage = $this->getWikiPage();
         $curRevisionId = $wikiPage->getLatest();
         $articleId = $wikiPage->getId();
     }
     $lang = $title->getPageLanguage();
     // Pre-process information
     $separatorTransTable = $lang->separatorTransformTable();
     $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
     $compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
     $digitTransTable = $lang->digitTransformTable();
     $digitTransTable = $digitTransTable ? $digitTransTable : array();
     $compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
     $user = $this->getUser();
     $vars = array('wgCanonicalNamespace' => $canonicalNamespace, 'wgCanonicalSpecialPageName' => $canonicalSpecialPageName, 'wgNamespaceNumber' => $title->getNamespace(), 'wgPageName' => $title->getPrefixedDBkey(), 'wgTitle' => $title->getText(), 'wgCurRevisionId' => $curRevisionId, 'wgRevisionId' => (int) $this->getRevisionId(), 'wgArticleId' => $articleId, 'wgIsArticle' => $this->isArticle(), 'wgIsRedirect' => $title->isRedirect(), 'wgAction' => Action::getActionName($this->getContext()), 'wgUserName' => $user->isAnon() ? null : $user->getName(), 'wgUserGroups' => $user->getEffectiveGroups(), 'wgCategories' => $this->getCategories(), 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', 'wgPageContentLanguage' => $lang->getCode(), 'wgPageContentModel' => $title->getContentModel(), 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgDefaultDateFormat' => $lang->getDefaultDateFormat(), 'wgMonthNames' => $lang->getMonthNamesArray(), 'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(), 'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(), 'wgRelevantArticleId' => $relevantTitle->getArticleId());
     if ($user->isLoggedIn()) {
         $vars['wgUserId'] = $user->getId();
         $vars['wgUserEditCount'] = $user->getEditCount();
         $userReg = wfTimestampOrNull(TS_UNIX, $user->getRegistration());
         $vars['wgUserRegistration'] = $userReg !== null ? $userReg * 1000 : null;
         // Get the revision ID of the oldest new message on the user's talk
         // page. This can be used for constructing new message alerts on
         // the client side.
         $vars['wgUserNewMsgRevisionId'] = $user->getNewMessageRevisionId();
     }
     if ($wgContLang->hasVariants()) {
         $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
     }
     // Same test as SkinTemplate
     $vars['wgIsProbablyEditable'] = $title->quickUserCan('edit', $user) && ($title->exists() || $title->quickUserCan('create', $user));
     foreach ($title->getRestrictionTypes() as $type) {
         $vars['wgRestriction' . ucfirst($type)] = $title->getRestrictions($type);
     }
     if ($title->isMainPage()) {
         $vars['wgIsMainPage'] = true;
     }
     if ($this->mRedirectedFrom) {
         $vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBkey();
     }
     if ($relevantUser) {
         $vars['wgRelevantUserName'] = $relevantUser->getName();
     }
     // Allow extensions to add their custom variables to the mw.config map.
     // Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
     // page-dependant but site-wide (without state).
     // Alternatively, you may want to use OutputPage->addJsConfigVars() instead.
     Hooks::run('MakeGlobalVariablesScript', array(&$vars, $this));
     // Merge in variables from addJsConfigVars last
     return array_merge($vars, $this->getJsConfigVars());
 }
コード例 #24
0
 /**
  * Format a line using the old system (aka without any javascript).
  *
  * @param $rc RecentChange
  */
 public function recentChangesLine(&$rc, $watched = false, $linenumber = null)
 {
     global $wgRCShowChangedSize;
     wfProfileIn(__METHOD__);
     # Should patrol-related stuff be shown?
     $unpatrolled = $this->showAsUnpatrolled($rc);
     $dateheader = '';
     // $s now contains only <li>...</li>, for hooks' convenience.
     $this->insertDateHeader($dateheader, $rc->mAttribs['rc_timestamp']);
     $s = '';
     $classes = array();
     // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
     if ($linenumber) {
         if ($linenumber & 1) {
             $classes[] = 'mw-line-odd';
         } else {
             $classes[] = 'mw-line-even';
         }
     }
     // Moved pages (very very old, not supported anymore)
     if ($rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT) {
         // Log entries
     } elseif ($rc->mAttribs['rc_log_type']) {
         $logtitle = Title::newFromText('Log/' . $rc->mAttribs['rc_log_type'], NS_SPECIAL);
         $this->insertLog($s, $logtitle, $rc->mAttribs['rc_log_type']);
         // Log entries (old format) or log targets, and special pages
     } elseif ($rc->mAttribs['rc_namespace'] == NS_SPECIAL) {
         list($name, $subpage) = SpecialPageFactory::resolveAlias($rc->mAttribs['rc_title']);
         if ($name == 'Log') {
             $this->insertLog($s, $rc->getTitle(), $subpage);
         }
         // Regular entries
     } else {
         $this->insertDiffHist($s, $rc, $unpatrolled);
         # M, N, b and ! (minor, new, bot and unpatrolled)
         $s .= $this->recentChangesFlags(array('newpage' => $rc->mAttribs['rc_new'], 'minor' => $rc->mAttribs['rc_minor'], 'unpatrolled' => $unpatrolled, 'bot' => $rc->mAttribs['rc_bot']), '');
         $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
     }
     # Edit/log timestamp
     $this->insertTimestamp($s, $rc);
     # Bytes added or removed
     if ($wgRCShowChangedSize) {
         $cd = $rc->getCharacterDifference();
         if ($cd != '') {
             $s .= "{$cd}  . . ";
         }
     }
     if ($rc->mAttribs['rc_type'] == RC_LOG) {
         $s .= $this->insertLogEntry($rc);
     } else {
         # User tool links
         $this->insertUserRelatedLinks($s, $rc);
         # LTR/RTL direction mark
         $s .= $this->getLanguage()->getDirMark();
         $s .= $this->insertComment($rc);
     }
     # Tags
     $this->insertTags($s, $rc, $classes);
     # Rollback
     $this->insertRollback($s, $rc);
     # For subclasses
     $this->insertExtra($s, $rc, $classes);
     # How many users watch this page
     if ($rc->numberofWatchingusers > 0) {
         $s .= ' ' . wfMsgExt('number_of_watching_users_RCview', array('parsemag', 'escape'), $this->getLanguage()->formatNum($rc->numberofWatchingusers));
     }
     if ($this->watchlist) {
         $classes[] = Sanitizer::escapeClass('watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title']);
     }
     wfRunHooks('OldChangesListRecentChangesLine', array(&$this, &$s, $rc));
     wfProfileOut(__METHOD__);
     return "{$dateheader}<li class=\"" . implode(' ', $classes) . "\">" . $s . "</li>\n";
 }
コード例 #25
0
ファイル: Linker.php プロジェクト: eFFemeer/seizamcore
 /**
  * @param $title Title
  * @return Title
  */
 static function normaliseSpecialPage(Title $title)
 {
     if ($title->getNamespace() == NS_SPECIAL) {
         list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
         if (!$name) {
             return $title;
         }
         $ret = SpecialPage::getTitleFor($name, $subpage);
         $ret->mFragment = $title->getFragment();
         return $ret;
     } else {
         return $title;
     }
 }
コード例 #26
0
ファイル: LogPage.php プロジェクト: T282/mediawiki
 /**
  * @todo Document
  * @param string $type
  * @param Language|null $lang
  * @param Title $title
  * @param array $params
  * @return string
  */
 protected static function getTitleLink($type, $lang, $title, &$params)
 {
     if (!$lang) {
         return $title->getPrefixedText();
     }
     if ($title->isSpecialPage()) {
         list($name, $par) = SpecialPageFactory::resolveAlias($title->getDBkey());
         # Use the language name for log titles, rather than Log/X
         if ($name == 'Log') {
             $logPage = new LogPage($par);
             $titleLink = Linker::link($title, $logPage->getName()->escaped());
             $titleLink = wfMessage('parentheses')->inLanguage($lang)->rawParams($titleLink)->escaped();
         } else {
             $titleLink = Linker::link($title);
         }
     } else {
         $titleLink = Linker::link($title);
     }
     return $titleLink;
 }
コード例 #27
0
ファイル: Title.php プロジェクト: MediaWiki-stable/1.26.1
 /**
  * Check that the user is allowed to read this page.
  *
  * @param string $action The action to check
  * @param User $user User to check
  * @param array $errors List of current errors
  * @param string $rigor Same format as Title::getUserPermissionsErrors()
  * @param bool $short Short circuit on first error
  *
  * @return array List of errors
  */
 private function checkReadPermissions($action, $user, $errors, $rigor, $short)
 {
     global $wgWhitelistRead, $wgWhitelistReadRegexp;
     $whitelisted = false;
     if (User::isEveryoneAllowed('read')) {
         # Shortcut for public wikis, allows skipping quite a bit of code
         $whitelisted = true;
     } elseif ($user->isAllowed('read')) {
         # If the user is allowed to read pages, he is allowed to read all pages
         $whitelisted = true;
     } elseif ($this->isSpecial('Userlogin') || $this->isSpecial('ChangePassword') || $this->isSpecial('PasswordReset')) {
         # Always grant access to the login page.
         # Even anons need to be able to log in.
         $whitelisted = true;
     } elseif (is_array($wgWhitelistRead) && count($wgWhitelistRead)) {
         # Time to check the whitelist
         # Only do these checks is there's something to check against
         $name = $this->getPrefixedText();
         $dbName = $this->getPrefixedDBkey();
         // Check for explicit whitelisting with and without underscores
         if (in_array($name, $wgWhitelistRead, true) || in_array($dbName, $wgWhitelistRead, true)) {
             $whitelisted = true;
         } elseif ($this->getNamespace() == NS_MAIN) {
             # Old settings might have the title prefixed with
             # a colon for main-namespace pages
             if (in_array(':' . $name, $wgWhitelistRead)) {
                 $whitelisted = true;
             }
         } elseif ($this->isSpecialPage()) {
             # If it's a special page, ditch the subpage bit and check again
             $name = $this->getDBkey();
             list($name, ) = SpecialPageFactory::resolveAlias($name);
             if ($name) {
                 $pure = SpecialPage::getTitleFor($name)->getPrefixedText();
                 if (in_array($pure, $wgWhitelistRead, true)) {
                     $whitelisted = true;
                 }
             }
         }
     }
     if (!$whitelisted && is_array($wgWhitelistReadRegexp) && !empty($wgWhitelistReadRegexp)) {
         $name = $this->getPrefixedText();
         // Check for regex whitelisting
         foreach ($wgWhitelistReadRegexp as $listItem) {
             if (preg_match($listItem, $name)) {
                 $whitelisted = true;
                 break;
             }
         }
     }
     if (!$whitelisted) {
         # If the title is not whitelisted, give extensions a chance to do so...
         Hooks::run('TitleReadWhitelist', array($this, $user, &$whitelisted));
         if (!$whitelisted) {
             $errors[] = $this->missingPermissionError($action, $short);
         }
     }
     return $errors;
 }
コード例 #28
0
 /**
  * build array of urls for personal toolbar
  * @return array
  */
 protected function buildPersonalUrls()
 {
     $title = $this->getTitle();
     $request = $this->getRequest();
     $pageurl = $title->getLocalURL();
     /* set up the default links for the personal toolbar */
     $personal_urls = array();
     # Due to bug 32276, if a user does not have read permissions,
     # $this->getTitle() will just give Special:Badtitle, which is
     # not especially useful as a returnto parameter. Use the title
     # from the request instead, if there was one.
     if ($this->getUser()->isAllowed('read')) {
         $page = $this->getTitle();
     } else {
         $page = Title::newFromText($request->getVal('title', ''));
     }
     $page = $request->getVal('returnto', $page);
     $a = array();
     if (strval($page) !== '') {
         $a['returnto'] = $page;
         $query = $request->getVal('returntoquery', $this->thisquery);
         if ($query != '') {
             $a['returntoquery'] = $query;
         }
     }
     $returnto = wfArrayToCgi($a);
     if ($this->loggedin) {
         $personal_urls['userpage'] = array('text' => $this->username, 'href' => &$this->userpageUrlDetails['href'], 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', 'active' => $this->userpageUrlDetails['href'] == $pageurl, 'dir' => 'auto');
         $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
         $personal_urls['mytalk'] = array('text' => $this->msg('mytalk')->text(), 'href' => &$usertalkUrlDetails['href'], 'class' => $usertalkUrlDetails['exists'] ? false : 'new', 'active' => $usertalkUrlDetails['href'] == $pageurl);
         $href = self::makeSpecialUrl('Preferences');
         $personal_urls['preferences'] = array('text' => $this->msg('mypreferences')->text(), 'href' => $href, 'active' => $href == $pageurl);
         if ($this->getUser()->isAllowed('viewmywatchlist')) {
             $href = self::makeSpecialUrl('Watchlist');
             $personal_urls['watchlist'] = array('text' => $this->msg('mywatchlist')->text(), 'href' => $href, 'active' => $href == $pageurl);
         }
         # We need to do an explicit check for Special:Contributions, as we
         # have to match both the title, and the target, which could come
         # from request values (Special:Contributions?target=Jimbo_Wales)
         # or be specified in "sub page" form
         # (Special:Contributions/Jimbo_Wales). The plot
         # thickens, because the Title object is altered for special pages,
         # so it doesn't contain the original alias-with-subpage.
         $origTitle = Title::newFromText($request->getText('title'));
         if ($origTitle instanceof Title && $origTitle->isSpecialPage()) {
             list($spName, $spPar) = SpecialPageFactory::resolveAlias($origTitle->getText());
             $active = $spName == 'Contributions' && ($spPar && $spPar == $this->username || $request->getText('target') == $this->username);
         } else {
             $active = false;
         }
         $href = self::makeSpecialUrlSubpage('Contributions', $this->username);
         $personal_urls['mycontris'] = array('text' => $this->msg('mycontris')->text(), 'href' => $href, 'active' => $active);
         $personal_urls['logout'] = array('text' => $this->msg('pt-userlogout')->text(), 'href' => self::makeSpecialUrl('Userlogout', $title->isSpecial('Preferences') ? 'noreturnto' : $returnto), 'active' => false);
     } else {
         $useCombinedLoginLink = $this->useCombinedLoginLink();
         $loginlink = $this->getUser()->isAllowed('createaccount') && $useCombinedLoginLink ? 'nav-login-createaccount' : 'pt-login';
         $is_signup = $request->getText('type') == 'signup';
         $login_url = array('text' => $this->msg($loginlink)->text(), 'href' => self::makeSpecialUrl('Userlogin', $returnto), 'active' => $title->isSpecial('Userlogin') && ($loginlink == 'nav-login-createaccount' || !$is_signup));
         $createaccount_url = array('text' => $this->msg('pt-createaccount')->text(), 'href' => self::makeSpecialUrl('Userlogin', "{$returnto}&type=signup"), 'active' => $title->isSpecial('Userlogin') && $is_signup);
         if ($this->showIPinHeader()) {
             $href =& $this->userpageUrlDetails['href'];
             $personal_urls['anonuserpage'] = array('text' => $this->username, 'href' => $href, 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', 'active' => $pageurl == $href);
             $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
             $href =& $usertalkUrlDetails['href'];
             $personal_urls['anontalk'] = array('text' => $this->msg('anontalk')->text(), 'href' => $href, 'class' => $usertalkUrlDetails['exists'] ? false : 'new', 'active' => $pageurl == $href);
         }
         if ($this->getUser()->isAllowed('createaccount') && !$useCombinedLoginLink) {
             $personal_urls['createaccount'] = $createaccount_url;
         }
         $personal_urls['login'] = $login_url;
     }
     Hooks::run('PersonalUrls', array(&$personal_urls, &$title, $this));
     return $personal_urls;
 }
コード例 #29
0
 /**
  * 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__);
 }
コード例 #30
0
ファイル: Title.php プロジェクト: namrenni/mediawiki
 /**
  * If the Title refers to a special page alias which is not the local default, resolve
  * the alias, and localise the name as necessary.  Otherwise, return $this
  *
  * @return Title
  */
 public function fixSpecialName()
 {
     if ($this->getNamespace() == NS_SPECIAL) {
         list($canonicalName, $par) = SpecialPageFactory::resolveAlias($this->mDbkeyform);
         if ($canonicalName) {
             $localName = SpecialPageFactory::getLocalNameFor($canonicalName, $par);
             if ($localName != $this->mDbkeyform) {
                 return Title::makeTitle(NS_SPECIAL, $localName);
             }
         }
     }
     return $this;
 }