/**
  * Checks if the user is allowed to use the upload-by-URL feature. If the
  * user is allowed, pass on permissions checking to the parent.
  *
  * @param $user User
  *
  * @return bool
  */
 public static function isAllowed($user)
 {
     if (!$user->isAllowed('upload_by_url')) {
         return 'upload_by_url';
     }
     return parent::isAllowed($user);
 }
 protected function checkPermission()
 {
     $permissionRequired = UploadBase::isAllowed($this->getUser());
     if ($permissionRequired !== true) {
         throw new PermissionsError($permissionRequired);
     }
 }
 function isUploadAllowed()
 {
     global $wgUser;
     if (\UploadBase::isAllowed($wgUser) == true) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #4
0
 /**
  * Checks that the user has permissions to perform this upload.
  * Dies with usage message on inadequate permissions.
  * @param User $user The user to check.
  */
 protected function checkPermissions($user)
 {
     // Check whether the user has the appropriate permissions to upload anyway
     $permission = $this->mUpload->isAllowed($user);
     if ($permission !== true) {
         if (!$user->isLoggedIn()) {
             $this->dieUsageMsg(array('mustbeloggedin', 'upload'));
         }
         $this->dieUsageMsg('badaccess-groups');
     }
 }
Beispiel #5
0
 /**
  * Checks that the user has permissions to perform this upload.
  * Dies with usage message on inadequate permissions.
  * @param User $user The user to check.
  */
 protected function checkPermissions($user)
 {
     // Check whether the user has the appropriate permissions to upload anyway
     $permission = $this->mUpload->isAllowed($user);
     if ($permission !== true) {
         if (!$user->isLoggedIn()) {
             $this->dieUsageMsg(['mustbeloggedin', 'upload']);
         }
         $this->dieUsageMsg('badaccess-groups');
     }
     // Check blocks
     if ($user->isBlocked()) {
         $this->dieBlocked($user->getBlock());
     }
     // Global blocks
     if ($user->isBlockedGlobally()) {
         $this->dieBlocked($user->getGlobalBlock());
     }
 }
Beispiel #6
0
 function topLinks()
 {
     global $wgOut, $wgUser;
     $sep = " |\n";
     $s = $this->mainPageLink() . $sep . $this->specialLink('Recentchanges');
     if ($wgOut->isArticle()) {
         $s .= $sep . '<strong>' . $this->editThisPage() . '</strong>' . $sep . $this->historyLink();
     }
     /* show links to different language variants */
     $s .= $this->variantLinks();
     $s .= $this->extensionTabLinks();
     if ($wgUser->isAnon()) {
         $s .= $sep . $this->specialLink('Userlogin');
     } else {
         /* show user page and user talk links */
         $s .= $sep . $this->link($wgUser->getUserPage(), wfMsgHtml('mypage'));
         $s .= $sep . $this->link($wgUser->getTalkPage(), wfMsgHtml('mytalk'));
         if ($wgUser->getNewtalk()) {
             $s .= ' *';
         }
         /* show watchlist link */
         $s .= $sep . $this->specialLink('Watchlist');
         /* show my contributions link */
         $s .= $sep . $this->link(SpecialPage::getSafeTitleFor('Contributions', $wgUser->getName()), wfMsgHtml('mycontris'));
         /* show my preferences link */
         $s .= $sep . $this->specialLink('Preferences');
         /* show upload file link */
         if (UploadBase::isEnabled() && UploadBase::isAllowed($wgUser) === true) {
             $s .= $sep . $this->getUploadLink();
         }
         /* show log out link */
         $s .= $sep . $this->specialLink('Userlogout');
     }
     $s .= $sep . $this->specialPagesList();
     return $s;
 }
Beispiel #7
0
 /**
  * Special page entry point
  * @param string $par
  * @throws ErrorPageError
  * @throws Exception
  * @throws FatalError
  * @throws MWException
  * @throws PermissionsError
  * @throws ReadOnlyError
  * @throws UserBlockedError
  */
 public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     # Check uploading enabled
     if (!UploadBase::isEnabled()) {
         throw new ErrorPageError('uploaddisabled', 'uploaddisabledtext');
     }
     $this->addHelpLink('Help:Managing files');
     # Check permissions
     $user = $this->getUser();
     $permissionRequired = UploadBase::isAllowed($user);
     if ($permissionRequired !== true) {
         throw new PermissionsError($permissionRequired);
     }
     # Check blocks
     if ($user->isBlocked()) {
         throw new UserBlockedError($user->getBlock());
     }
     # Check whether we actually want to allow changing stuff
     $this->checkReadOnly();
     $this->loadRequest();
     # Unsave the temporary file in case this was a cancelled upload
     if ($this->mCancelUpload) {
         if (!$this->unsaveUploadedFile()) {
             # Something went wrong, so unsaveUploadedFile showed a warning
             return;
         }
     }
     # Process upload or show a form
     if ($this->mTokenOk && !$this->mCancelUpload && ($this->mUpload && $this->mUploadClicked)) {
         $this->processUpload();
     } else {
         # Backwards compatibility hook
         if (!Hooks::run('UploadForm:initial', array(&$this))) {
             wfDebug("Hook 'UploadForm:initial' broke output of the upload form\n");
             return;
         }
         $this->showUploadForm($this->getUploadForm());
     }
     # Cleanup
     if ($this->mUpload) {
         $this->mUpload->cleanupTempFile();
     }
 }
Beispiel #8
0
 /**
  * @return string
  */
 function topLinks()
 {
     $sep = " |\n";
     $s = $this->getSkin()->mainPageLink() . $sep . Linker::specialLink('Recentchanges');
     if ($this->data['isarticle']) {
         $s .= $sep . '<strong>' . $this->editThisPage() . '</strong>' . $sep . $this->talkLink() . $sep . $this->historyLink();
     }
     /* show links to different language variants */
     $s .= $this->variantLinks();
     $s .= $this->extensionTabLinks();
     if (!$this->data['loggedin']) {
         $s .= $sep . Linker::specialLink('Userlogin');
     } else {
         /* show user page and user talk links */
         $user = $this->getSkin()->getUser();
         $s .= $sep . Linker::link($user->getUserPage(), wfMessage('mypage')->escaped());
         $s .= $sep . Linker::link($user->getTalkPage(), wfMessage('mytalk')->escaped());
         if ($user->getNewtalk()) {
             $s .= ' *';
         }
         /* show watchlist link */
         $s .= $sep . Linker::specialLink('Watchlist');
         /* show my contributions link */
         $s .= $sep . Linker::link(SpecialPage::getSafeTitleFor('Contributions', $this->data['username']), wfMessage('mycontris')->escaped());
         /* show my preferences link */
         $s .= $sep . Linker::specialLink('Preferences');
         /* show upload file link */
         if (UploadBase::isEnabled() && UploadBase::isAllowed($user) === true) {
             $s .= $sep . $this->getUploadLink();
         }
         /* show log out link */
         $s .= $sep . Linker::specialLink('Userlogout');
     }
     $s .= $sep . $this->specialPagesList();
     return $s;
 }
 /**
  * build array of common navigation links
  * @return array
  */
 protected function buildNavUrls()
 {
     global $wgUploadNavigationUrl;
     $out = $this->getOutput();
     $request = $this->getRequest();
     $nav_urls = array();
     $nav_urls['mainpage'] = array('href' => self::makeMainPageUrl());
     if ($wgUploadNavigationUrl) {
         $nav_urls['upload'] = array('href' => $wgUploadNavigationUrl);
     } elseif (UploadBase::isEnabled() && UploadBase::isAllowed($this->getUser()) === true) {
         $nav_urls['upload'] = array('href' => self::makeSpecialUrl('Upload'));
     } else {
         $nav_urls['upload'] = false;
     }
     $nav_urls['specialpages'] = array('href' => self::makeSpecialUrl('Specialpages'));
     $nav_urls['print'] = false;
     $nav_urls['permalink'] = false;
     $nav_urls['info'] = false;
     $nav_urls['whatlinkshere'] = false;
     $nav_urls['recentchangeslinked'] = false;
     $nav_urls['contributions'] = false;
     $nav_urls['log'] = false;
     $nav_urls['blockip'] = false;
     $nav_urls['emailuser'] = false;
     $nav_urls['userrights'] = false;
     // A print stylesheet is attached to all pages, but nobody ever
     // figures that out. :)  Add a link...
     if (!$out->isPrintable() && ($out->isArticle() || $this->getTitle()->isSpecialPage())) {
         $nav_urls['print'] = array('text' => $this->msg('printableversion')->text(), 'href' => $this->getTitle()->getLocalURL($request->appendQueryValue('printable', 'yes', true)));
     }
     if ($out->isArticle()) {
         // Also add a "permalink" while we're at it
         $revid = $this->getRevisionId();
         if ($revid) {
             $nav_urls['permalink'] = array('text' => $this->msg('permalink')->text(), 'href' => $this->getTitle()->getLocalURL("oldid={$revid}"));
         }
         // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
         Hooks::run('SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array(&$this, &$nav_urls, &$revid, &$revid));
     }
     if ($out->isArticleRelated()) {
         $nav_urls['whatlinkshere'] = array('href' => SpecialPage::getTitleFor('Whatlinkshere', $this->thispage)->getLocalURL());
         $nav_urls['info'] = array('text' => $this->msg('pageinfo-toolboxlink')->text(), 'href' => $this->getTitle()->getLocalURL("action=info"));
         if ($this->getTitle()->exists()) {
             $nav_urls['recentchangeslinked'] = array('href' => SpecialPage::getTitleFor('Recentchangeslinked', $this->thispage)->getLocalURL());
         }
     }
     $user = $this->getRelevantUser();
     if ($user) {
         $rootUser = $user->getName();
         $nav_urls['contributions'] = array('text' => $this->msg('contributions', $rootUser)->text(), 'href' => self::makeSpecialUrlSubpage('Contributions', $rootUser));
         $nav_urls['log'] = array('href' => self::makeSpecialUrlSubpage('Log', $rootUser));
         if ($this->getUser()->isAllowed('block')) {
             $nav_urls['blockip'] = array('text' => $this->msg('blockip', $rootUser)->text(), 'href' => self::makeSpecialUrlSubpage('Block', $rootUser));
         }
         if ($this->showEmailUser($user)) {
             $nav_urls['emailuser'] = array('href' => self::makeSpecialUrlSubpage('Emailuser', $rootUser));
         }
         if (!$user->isAnon()) {
             $sur = new UserrightsPage();
             $sur->setContext($this->getContext());
             if ($sur->userCanExecute($this->getUser())) {
                 $nav_urls['userrights'] = array('href' => self::makeSpecialUrlSubpage('Userrights', $rootUser));
             }
         }
     }
     return $nav_urls;
 }
Beispiel #10
0
 /**
  * Compute the sidebar
  * @access private
  *
  * @return string
  */
 function quickBar()
 {
     $s = "\n<div id='quickbar'>";
     $sep = '<br />';
     $s .= $this->menuHead('qbfind');
     $s .= $this->searchForm();
     $s .= $this->menuHead('qbbrowse');
     # Use the first heading from the Monobook sidebar as the "browse" section
     $bar = $this->getSkin()->buildSidebar();
     unset($bar['SEARCH']);
     unset($bar['LANGUAGES']);
     unset($bar['TOOLBOX']);
     $barnumber = 1;
     foreach ($bar as $heading => $browseLinks) {
         if ($barnumber > 1) {
             $headingMsg = wfMessage($heading);
             if ($headingMsg->exists()) {
                 $h = $headingMsg->text();
             } else {
                 $h = $heading;
             }
             $s .= "\n<h6>" . htmlspecialchars($h) . "</h6>";
         }
         if (is_array($browseLinks)) {
             foreach ($browseLinks as $link) {
                 if ($link['text'] != '-') {
                     $s .= "<a href=\"{$link['href']}\">" . htmlspecialchars($link['text']) . '</a>' . $sep;
                 }
             }
         }
         $barnumber++;
     }
     $user = $this->getSkin()->getUser();
     if ($this->data['isarticle']) {
         $s .= $this->menuHead('qbedit');
         $s .= '<strong>' . $this->editThisPage() . '</strong>';
         $s .= $sep . Linker::linkKnown(Title::newFromText(wfMsgForContent('edithelppage')), wfMsg('edithelp'));
         if ($this->data['loggedin']) {
             $s .= $sep . $this->moveThisPage();
         }
         if ($user->isAllowed('delete')) {
             $dtp = $this->deleteThisPage();
             if ($dtp != '') {
                 $s .= $sep . $dtp;
             }
         }
         if ($user->isAllowed('protect')) {
             $ptp = $this->protectThisPage();
             if ($ptp != '') {
                 $s .= $sep . $ptp;
             }
         }
         $s .= $sep;
         $s .= $this->menuHead('qbpageoptions');
         $s .= $this->talkLink() . $sep . $this->commentLink() . $sep . $this->printableLink();
         if ($this->data['loggedin']) {
             $s .= $sep . $this->watchThisPage();
         }
         $s .= $sep;
         $s .= $this->menuHead('qbpageinfo') . $this->historyLink() . $sep . $this->whatLinksHere() . $sep . $this->watchPageLinksLink();
         $title = $this->getSkin()->getTitle();
         $tns = $title->getNamespace();
         if ($tns == NS_USER || $tns == NS_USER_TALK) {
             $id = User::idFromName($title->getText());
             if ($id != 0) {
                 $s .= $sep . $this->userContribsLink();
                 if ($this->getSkin()->showEmailUser($id)) {
                     $s .= $sep . $this->emailUserLink();
                 }
             }
         }
         $s .= $sep;
     }
     $s .= $this->menuHead('qbmyoptions');
     if ($this->data['loggedin']) {
         $tl = Linker::link($user->getTalkPage(), wfMsg('mytalk'), array(), array(), array('known', 'noclasses'));
         if ($user->getNewtalk()) {
             $tl .= ' *';
         }
         $s .= Linker::link($user->getUserPage(), wfMsg('mypage'), array(), array(), array('known', 'noclasses')) . $sep . $tl . $sep . Linker::specialLink('Watchlist') . $sep . Linker::link(SpecialPage::getSafeTitleFor('Contributions', $user->getName()), wfMsg('mycontris'), array(), array(), array('known', 'noclasses')) . $sep . Linker::specialLink('Preferences') . $sep . Linker::specialLink('Userlogout');
     } else {
         $s .= Linker::specialLink('Userlogin');
     }
     $s .= $this->menuHead('qbspecialpages') . Linker::specialLink('Newpages') . $sep . Linker::specialLink('Listfiles') . $sep . Linker::specialLink('Statistics');
     if (UploadBase::isEnabled() && UploadBase::isAllowed($user) === true) {
         $s .= $sep . $this->getUploadLink();
     }
     global $wgSiteSupportPage;
     if ($wgSiteSupportPage) {
         $s .= $sep . '<a href="' . htmlspecialchars($wgSiteSupportPage) . '" class="internal">' . wfMsg('sitesupport') . '</a>';
     }
     $s .= $sep . Linker::link(SpecialPage::getTitleFor('Specialpages'), wfMsg('moredotdotdot'), array(), array(), array('known', 'noclasses'));
     $s .= $sep . "\n</div>\n";
     return $s;
 }
Beispiel #11
0
 /**
  * Special page entry point
  */
 public function execute($par)
 {
     // Only output the body of the page.
     $this->getOutput()->setArticleBodyOnly(true);
     // This line is needed to get around Squid caching.
     $this->getOutput()->sendCacheControl();
     $this->setHeaders();
     $this->outputHeader();
     # Check uploading enabled
     if (!UploadBase::isEnabled()) {
         throw new ErrorPageError('uploaddisabled', 'uploaddisabledtext');
     }
     # Check permissions
     $user = $this->getUser();
     $permissionRequired = UploadBase::isAllowed($user);
     if ($permissionRequired !== true) {
         throw new PermissionsError($permissionRequired);
     }
     # Check blocks
     if ($this->getUser()->isBlocked()) {
         throw new UserBlockedError($this->getUser()->getBlock());
     }
     # Check whether we actually want to allow changing stuff
     if (wfReadOnly()) {
         throw new ReadOnlyError();
     }
     # Unsave the temporary file in case this was a cancelled upload
     if ($this->mCancelUpload) {
         if (!$this->unsaveUploadedFile()) {
             # Something went wrong, so unsaveUploadedFile showed a warning
             return;
         }
     }
     # Process upload or show a form
     if ($this->mTokenOk && !$this->mCancelUpload && ($this->mUpload && $this->mUploadClicked)) {
         $this->processUpload();
     } else {
         # Backwards compatibility hook
         if (!Hooks::run('UploadForm:initial', array(&$this))) {
             wfDebug("Hook 'UploadForm:initial' broke output of the upload form");
             return;
         }
         $this->showUploadForm($this->getUploadForm());
     }
     # Cleanup
     if ($this->mUpload) {
         $this->mUpload->cleanupTempFile();
     }
 }
Beispiel #12
0
 function quickBar()
 {
     global $wgOut, $wgUser, $wgRequest, $wgContLang;
     wfProfileIn(__METHOD__);
     $action = $wgRequest->getText('action');
     $wpPreview = $wgRequest->getBool('wpPreview');
     $tns = $this->getSkin()->getTitle()->getNamespace();
     $s = "\n<div id='quickbar'>";
     $s .= "\n" . $this->getSkin()->logoText() . "\n<hr class='sep' />";
     $sep = "\n<br />";
     # Use the first heading from the Monobook sidebar as the "browse" section
     $bar = $this->getSkin()->buildSidebar();
     unset($bar['SEARCH']);
     unset($bar['LANGUAGES']);
     unset($bar['TOOLBOX']);
     $barnumber = 1;
     foreach ($bar as $browseLinks) {
         if (is_array($browseLinks)) {
             if ($barnumber > 1) {
                 $s .= "\n<hr class='sep' />";
             }
             foreach ($browseLinks as $link) {
                 if ($link['text'] != '-') {
                     $s .= "<a href=\"{$link['href']}\">" . htmlspecialchars($link['text']) . '</a>' . $sep;
                 }
             }
         }
         if ($barnumber == 1) {
             // only show watchlist link if logged in
             if ($wgUser->isLoggedIn()) {
                 $s .= Linker::specialLink('Watchlist');
                 $s .= $sep . Linker::linkKnown(SpecialPage::getTitleFor('Contributions'), wfMsg('mycontris'), array(), array('target' => $wgUser->getName()));
             }
         }
         $barnumber = $barnumber + 1;
     }
     $s .= "\n<hr class='sep' />";
     $articleExists = $this->getSkin()->getTitle()->getArticleId();
     if ($wgOut->isArticle() || $action == 'edit' || $action == 'history' || $wpPreview) {
         if ($wgOut->isArticle()) {
             $s .= '<strong>' . $this->editThisPage() . '</strong>';
         } else {
             # backlink to the article in edit or history mode
             if ($articleExists) {
                 # no backlink if no article
                 switch ($tns) {
                     case NS_TALK:
                     case NS_USER_TALK:
                     case NS_PROJECT_TALK:
                     case NS_FILE_TALK:
                     case NS_MEDIAWIKI_TALK:
                     case NS_TEMPLATE_TALK:
                     case NS_HELP_TALK:
                     case NS_CATEGORY_TALK:
                         $text = wfMsg('viewtalkpage');
                         break;
                     case NS_MAIN:
                         $text = wfMsg('articlepage');
                         break;
                     case NS_USER:
                         $text = wfMsg('userpage');
                         break;
                     case NS_PROJECT:
                         $text = wfMsg('projectpage');
                         break;
                     case NS_FILE:
                         $text = wfMsg('imagepage');
                         break;
                     case NS_MEDIAWIKI:
                         $text = wfMsg('mediawikipage');
                         break;
                     case NS_TEMPLATE:
                         $text = wfMsg('templatepage');
                         break;
                     case NS_HELP:
                         $text = wfMsg('viewhelppage');
                         break;
                     case NS_CATEGORY:
                         $text = wfMsg('categorypage');
                         break;
                     default:
                         $text = wfMsg('articlepage');
                 }
                 $link = $this->getSkin()->getTitle()->getText();
                 $nstext = $wgContLang->getNsText($tns);
                 if ($nstext) {
                     # add namespace if necessary
                     $link = $nstext . ':' . $link;
                 }
                 $s .= Linker::link(Title::newFromText($link), $text);
             } elseif ($this->getSkin()->getTitle()->getNamespace() != NS_SPECIAL) {
                 # we just throw in a "New page" text to tell the user that he's in edit mode,
                 # and to avoid messing with the separator that is prepended to the next item
                 $s .= '<strong>' . wfMsg('newpage') . '</strong>';
             }
         }
         # "Post a comment" link
         if (($this->getSkin()->getTitle()->isTalkPage() || $wgOut->showNewSectionLink()) && $action != 'edit' && !$wpPreview) {
             $s .= '<br />' . $this->getSkin()->link($this->getSkin()->getTitle(), wfMsg('postcomment'), array(), array('action' => 'edit', 'section' => 'new'), array('known', 'noclasses'));
         }
         /*
         watching could cause problems in edit mode:
         if user edits article, then loads "watch this article" in background and then saves
         article with "Watch this article" checkbox disabled, the article is transparently
         unwatched. Therefore we do not show the "Watch this page" link in edit mode
         */
         if ($wgUser->isLoggedIn() && $articleExists) {
             if ($action != 'edit' && $action != 'submit') {
                 $s .= $sep . $this->watchThisPage();
             }
             if ($this->getSkin()->getTitle()->userCan('edit')) {
                 $s .= $sep . $this->moveThisPage();
             }
         }
         if ($wgUser->isAllowed('delete') && $articleExists) {
             $s .= $sep . $this->deleteThisPage() . $sep . $this->protectThisPage();
         }
         $s .= $sep . $this->talkLink();
         if ($articleExists && $action != 'history') {
             $s .= $sep . $this->historyLink();
         }
         $s .= $sep . $this->whatLinksHere();
         if ($wgOut->isArticleRelated()) {
             $s .= $sep . $this->watchPageLinksLink();
         }
         if (NS_USER == $this->getSkin()->getTitle()->getNamespace() || $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK) {
             $id = User::idFromName($this->getSkin()->getTitle()->getText());
             $ip = User::isIP($this->getSkin()->getTitle()->getText());
             if ($id || $ip) {
                 $s .= $sep . $this->userContribsLink();
             }
             if ($this->getSkin()->showEmailUser($id)) {
                 $s .= $sep . $this->emailUserLink();
             }
         }
         $s .= "\n<br /><hr class='sep' />";
     }
     if (UploadBase::isEnabled() && UploadBase::isAllowed($wgUser) === true) {
         $s .= $this->getUploadLink() . $sep;
     }
     $s .= Linker::specialLink('Specialpages');
     global $wgSiteSupportPage;
     if ($wgSiteSupportPage) {
         $s .= "\n<br /><a href=\"" . htmlspecialchars($wgSiteSupportPage) . '" class="internal">' . wfMsg('sitesupport') . '</a>';
     }
     $s .= "\n<br /></div>\n";
     wfProfileOut(__METHOD__);
     return $s;
 }
 /**
  * Special page entry point
  */
 public function execute($par)
 {
     global $wgUser, $wgOut;
     $this->setHeaders();
     $this->outputHeader();
     # Check uploading enabled
     if (!UploadBase::isEnabled()) {
         $wgOut->showErrorPage('uploaddisabled', 'uploaddisabledtext');
         return;
     }
     # Check permissions
     global $wgGroupPermissions;
     $permissionRequired = UploadBase::isAllowed($wgUser);
     if ($permissionRequired !== true) {
         if (!$wgUser->isLoggedIn() && ($wgGroupPermissions['user']['upload'] || $wgGroupPermissions['autoconfirmed']['upload'])) {
             // Custom message if logged-in users without any special rights can upload
             $wgOut->showErrorPage('uploadnologin', 'uploadnologintext');
         } else {
             $wgOut->permissionRequired($permissionRequired);
         }
         return;
     }
     # Check blocks
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     # Check whether we actually want to allow changing stuff
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     # Unsave the temporary file in case this was a cancelled upload
     if ($this->mCancelUpload) {
         if (!$this->unsaveUploadedFile()) {
             # Something went wrong, so unsaveUploadedFile showed a warning
             return;
         }
     }
     # Process upload or show a form
     if ($this->mTokenOk && !$this->mCancelUpload && ($this->mUpload && $this->mUploadClicked)) {
         $this->processUpload();
     } else {
         # Backwards compatibility hook
         if (!wfRunHooks('UploadForm:initial', array(&$this))) {
             wfDebug("Hook 'UploadForm:initial' broke output of the upload form");
             return;
         }
         $this->showUploadForm($this->getUploadForm());
     }
     # Cleanup
     if ($this->mUpload) {
         $this->mUpload->cleanupTempFile();
     }
 }
 /**
  * build array of common navigation links
  * @return array
  * @private
  */
 protected function buildNavUrls(OutputPage $out)
 {
     global $wgUseTrackbacks, $wgUser, $wgRequest;
     global $wgUploadNavigationUrl;
     wfProfileIn(__METHOD__);
     $action = $wgRequest->getVal('action', 'view');
     $nav_urls = array();
     $nav_urls['mainpage'] = array('href' => self::makeMainPageUrl());
     if ($wgUploadNavigationUrl) {
         $nav_urls['upload'] = array('href' => $wgUploadNavigationUrl);
     } elseif (UploadBase::isEnabled() && UploadBase::isAllowed($wgUser) === true) {
         $nav_urls['upload'] = array('href' => self::makeSpecialUrl('Upload'));
     } else {
         $nav_urls['upload'] = false;
     }
     $nav_urls['specialpages'] = array('href' => self::makeSpecialUrl('Specialpages'));
     // default permalink to being off, will override it as required below.
     $nav_urls['permalink'] = false;
     // A print stylesheet is attached to all pages, but nobody ever
     // figures that out. :)  Add a link...
     if ($this->iscontent && ($action == 'view' || $action == 'purge')) {
         if (!$out->isPrintable()) {
             $nav_urls['print'] = array('text' => wfMsg('printableversion'), 'href' => $this->getTitle()->getLocalURL($wgRequest->appendQueryValue('printable', 'yes', true)));
         }
         // Also add a "permalink" while we're at it
         $revid = $this->getRevisionId();
         if ($revid) {
             $nav_urls['permalink'] = array('text' => wfMsg('permalink'), 'href' => $out->getTitle()->getLocalURL("oldid={$revid}"));
         }
         // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
         wfRunHooks('SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array(&$this, &$nav_urls, &$revid, &$revid));
     }
     if ($this->getTitle()->getNamespace() != NS_SPECIAL) {
         $wlhTitle = SpecialPage::getTitleFor('Whatlinkshere', $this->thispage);
         $nav_urls['whatlinkshere'] = array('href' => $wlhTitle->getLocalUrl());
         if ($this->getTitle()->getArticleId()) {
             $rclTitle = SpecialPage::getTitleFor('Recentchangeslinked', $this->thispage);
             $nav_urls['recentchangeslinked'] = array('href' => $rclTitle->getLocalUrl());
         } else {
             $nav_urls['recentchangeslinked'] = false;
         }
         if ($wgUseTrackbacks) {
             $nav_urls['trackbacklink'] = array('href' => $out->getTitle()->trackbackURL());
         }
     }
     $user = $this->getRelevantUser();
     if ($user) {
         $id = $user->getID();
         $ip = $user->isAnon();
         $rootUser = $user->getName();
     } else {
         $id = 0;
         $ip = false;
         $rootUser = null;
     }
     if ($id || $ip) {
         # both anons and non-anons have contribs list
         $nav_urls['contributions'] = array('href' => self::makeSpecialUrlSubpage('Contributions', $rootUser));
         if ($id) {
             $logPage = SpecialPage::getTitleFor('Log');
             $nav_urls['log'] = array('href' => $logPage->getLocalUrl(array('user' => $rootUser)));
         } else {
             $nav_urls['log'] = false;
         }
         if ($wgUser->isAllowed('block')) {
             $nav_urls['blockip'] = array('href' => self::makeSpecialUrlSubpage('Block', $rootUser));
         } else {
             $nav_urls['blockip'] = false;
         }
     } else {
         $nav_urls['contributions'] = false;
         $nav_urls['log'] = false;
         $nav_urls['blockip'] = false;
     }
     $nav_urls['emailuser'] = false;
     if ($this->showEmailUser($id)) {
         $nav_urls['emailuser'] = array('href' => self::makeSpecialUrlSubpage('Emailuser', $rootUser));
     }
     wfProfileOut(__METHOD__);
     return $nav_urls;
 }