/**
  * @param $user User
  * @param $output OutputPage
  */
 protected function showLogFragment($user, $output)
 {
     $pageTitle = Title::makeTitleSafe(NS_USER, $user->getName());
     $logPage = new LogPage('gblrights');
     $output->addHTML(Xml::element('h2', null, $logPage->getName()->text() . "\n"));
     LogEventsList::showLogExtract($output, 'gblrights', $pageTitle->getPrefixedText());
 }
/**
 * Special page allowing users with the appropriate permissions to view
 * and hide revisions. Log items can also be hidden.
 *
 * @file
 * @ingroup SpecialPage
 */
function wfSpecialRevisiondelete($par = null)
{
    global $wgOut, $wgRequest, $wgUser;
    # Handle our many different possible input types
    $target = $wgRequest->getText('target');
    $oldid = $wgRequest->getArray('oldid');
    $artimestamp = $wgRequest->getArray('artimestamp');
    $logid = $wgRequest->getArray('logid');
    $img = $wgRequest->getArray('oldimage');
    $fileid = $wgRequest->getArray('fileid');
    # For reviewing deleted files...
    $file = $wgRequest->getVal('file');
    # If this is a revision, then we need a target page
    $page = Title::newFromUrl($target);
    if (is_null($page)) {
        $wgOut->addWikiMsg('undelete-header');
        return;
    }
    # Only one target set at a time please!
    $i = (bool) $file + (bool) $oldid + (bool) $logid + (bool) $artimestamp + (bool) $fileid + (bool) $img;
    if ($i !== 1) {
        $wgOut->showErrorPage('revdelete-nooldid-title', 'revdelete-nooldid-text');
        return;
    }
    # Logs must have a type given
    if ($logid && !strpos($page->getDBKey(), '/')) {
        $wgOut->showErrorPage('revdelete-nooldid-title', 'revdelete-nooldid-text');
        return;
    }
    # Either submit or create our form
    $form = new RevisionDeleteForm($page, $oldid, $logid, $artimestamp, $fileid, $img, $file);
    if ($wgRequest->wasPosted()) {
        $form->submit($wgRequest);
    } else {
        if ($oldid || $artimestamp) {
            $form->showRevs();
        } else {
            if ($fileid || $img) {
                $form->showImages();
            } else {
                if ($logid) {
                    $form->showLogItems();
                }
            }
        }
    }
    # Show relevant lines from the deletion log. This will show even if said ID
    # does not exist...might be helpful
    $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n");
    LogEventsList::showLogExtract($wgOut, 'delete', $page->getPrefixedText());
    if ($wgUser->isAllowed('suppressionlog')) {
        $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('suppress')) . "</h2>\n");
        LogEventsList::showLogExtract($wgOut, 'suppress', $page->getPrefixedText());
    }
}
 /**
  * Show a log if the user has been renamed and point to the new username.
  * Don't show the log if the $oldUserName exists as a user.
  *
  * @param $article Article
  * @return bool
  */
 public static function onShowMissingArticle($article)
 {
     $title = $article->getTitle();
     $oldUser = User::newFromName($title->getBaseText());
     if (($title->getNamespace() === NS_USER || $title->getNamespace() === NS_USER_TALK) && ($oldUser && $oldUser->isAnon())) {
         // Get the title for the base userpage
         $page = Title::makeTitle(NS_USER, str_replace(' ', '_', $title->getBaseText()))->getPrefixedDBkey();
         $out = $article->getContext()->getOutput();
         LogEventsList::showLogExtract($out, 'renameuser', $page, '', array('lim' => 10, 'showIfEmpty' => false, 'msgKey' => array('renameuser-renamed-notice', $title->getBaseText())));
     }
     return true;
 }
Esempio n. 4
0
    protected function openShowImage()
    {
        global $wgImageLimits, $wgEnableUploads, $wgSend404Code;
        $this->loadFile();
        $out = $this->getContext()->getOutput();
        $user = $this->getContext()->getUser();
        $lang = $this->getContext()->getLanguage();
        $dirmark = $lang->getDirMarkEntity();
        $request = $this->getContext()->getRequest();
        $max = $this->getImageLimitsFromOption($user, 'imagesize');
        $maxWidth = $max[0];
        $maxHeight = $max[1];
        if ($this->displayImg->exists()) {
            # image
            $page = $request->getIntOrNull('page');
            if (is_null($page)) {
                $params = array();
                $page = 1;
            } else {
                $params = array('page' => $page);
            }
            $renderLang = $request->getVal('lang');
            if (!is_null($renderLang)) {
                $handler = $this->displayImg->getHandler();
                if ($handler && $handler->validateParam('lang', $renderLang)) {
                    $params['lang'] = $renderLang;
                } else {
                    $renderLang = null;
                }
            }
            $width_orig = $this->displayImg->getWidth($page);
            $width = $width_orig;
            $height_orig = $this->displayImg->getHeight($page);
            $height = $height_orig;
            $filename = wfEscapeWikiText($this->displayImg->getName());
            $linktext = $filename;
            wfRunHooks('ImageOpenShowImageInlineBefore', array(&$this, &$out));
            if ($this->displayImg->allowInlineDisplay()) {
                # image
                # "Download high res version" link below the image
                # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
                # We'll show a thumbnail of this image
                if ($width > $maxWidth || $height > $maxHeight) {
                    # Calculate the thumbnail size.
                    # First case, the limiting factor is the width, not the height.
                    if ($width / $height >= $maxWidth / $maxHeight) {
                        // FIXME: Possible division by 0. bug 36911
                        $height = round($height * $maxWidth / $width);
                        // FIXME: Possible division by 0. bug 36911
                        $width = $maxWidth;
                        # Note that $height <= $maxHeight now.
                    } else {
                        $newwidth = floor($width * $maxHeight / $height);
                        // FIXME: Possible division by 0. bug 36911
                        $height = round($height * $newwidth / $width);
                        // FIXME: Possible division by 0. bug 36911
                        $width = $newwidth;
                        # Note that $height <= $maxHeight now, but might not be identical
                        # because of rounding.
                    }
                    $linktext = wfMessage('show-big-image')->escaped();
                    if ($this->displayImg->getRepo()->canTransformVia404()) {
                        $thumbSizes = $wgImageLimits;
                        // Also include the full sized resolution in the list, so
                        // that users know they can get it. This will link to the
                        // original file asset if mustRender() === false. In the case
                        // that we mustRender, some users have indicated that they would
                        // find it useful to have the full size image in the rendered
                        // image format.
                        $thumbSizes[] = array($width_orig, $height_orig);
                    } else {
                        # Creating thumb links triggers thumbnail generation.
                        # Just generate the thumb for the current users prefs.
                        $thumbSizes = array($this->getImageLimitsFromOption($user, 'thumbsize'));
                        if (!$this->displayImg->mustRender()) {
                            // We can safely include a link to the "full-size" preview,
                            // without actually rendering.
                            $thumbSizes[] = array($width_orig, $height_orig);
                        }
                    }
                    # Generate thumbnails or thumbnail links as needed...
                    $otherSizes = array();
                    foreach ($thumbSizes as $size) {
                        // We include a thumbnail size in the list, if it is
                        // less than or equal to the original size of the image
                        // asset ($width_orig/$height_orig). We also exclude
                        // the current thumbnail's size ($width/$height)
                        // since that is added to the message separately, so
                        // it can be denoted as the current size being shown.
                        if ($size[0] <= $width_orig && $size[1] <= $height_orig && $size[0] != $width && $size[1] != $height) {
                            $sizeLink = $this->makeSizeLink($params, $size[0], $size[1]);
                            if ($sizeLink) {
                                $otherSizes[] = $sizeLink;
                            }
                        }
                    }
                    $otherSizes = array_unique($otherSizes);
                    $msgsmall = '';
                    $sizeLinkBigImagePreview = $this->makeSizeLink($params, $width, $height);
                    if ($sizeLinkBigImagePreview) {
                        $msgsmall .= wfMessage('show-big-image-preview')->rawParams($sizeLinkBigImagePreview)->parse();
                    }
                    if (count($otherSizes)) {
                        $msgsmall .= ' ' . Html::rawElement('span', array('class' => 'mw-filepage-other-resolutions'), wfMessage('show-big-image-other')->rawParams($lang->pipeList($otherSizes))->params(count($otherSizes))->parse());
                    }
                } elseif ($width == 0 && $height == 0) {
                    # Some sort of audio file that doesn't have dimensions
                    # Don't output a no hi res message for such a file
                    $msgsmall = '';
                } elseif ($this->displayImg->isVectorized()) {
                    # For vectorized images, full size is just the frame size
                    $msgsmall = '';
                } else {
                    # Image is small enough to show full size on image page
                    $msgsmall = wfMessage('file-nohires')->parse();
                }
                $params['width'] = $width;
                $params['height'] = $height;
                $thumbnail = $this->displayImg->transform($params);
                Linker::processResponsiveImages($this->displayImg, $thumbnail, $params);
                $anchorclose = Html::rawElement('div', array('class' => 'mw-filepage-resolutioninfo'), $msgsmall);
                $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
                if ($isMulti) {
                    $out->addModules('mediawiki.page.image.pagination');
                    $out->addHTML('<table class="multipageimage"><tr><td>');
                }
                if ($thumbnail) {
                    $options = array('alt' => $this->displayImg->getTitle()->getPrefixedText(), 'file-link' => true);
                    $out->addHTML('<div class="fullImageLink" id="file">' . $thumbnail->toHtml($options) . $anchorclose . "</div>\n");
                }
                if ($isMulti) {
                    $count = $this->displayImg->pageCount();
                    if ($page > 1) {
                        $label = $out->parse(wfMessage('imgmultipageprev')->text(), false);
                        // on the client side, this link is generated in ajaxifyPageNavigation()
                        // in the mediawiki.page.image.pagination module
                        $link = Linker::linkKnown($this->getTitle(), $label, array(), array('page' => $page - 1));
                        $thumb1 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page - 1));
                    } else {
                        $thumb1 = '';
                    }
                    if ($page < $count) {
                        $label = wfMessage('imgmultipagenext')->text();
                        $link = Linker::linkKnown($this->getTitle(), $label, array(), array('page' => $page + 1));
                        $thumb2 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page + 1));
                    } else {
                        $thumb2 = '';
                    }
                    global $wgScript;
                    $formParams = array('name' => 'pageselector', 'action' => $wgScript);
                    $options = array();
                    for ($i = 1; $i <= $count; $i++) {
                        $options[] = Xml::option($lang->formatNum($i), $i, $i == $page);
                    }
                    $select = Xml::tags('select', array('id' => 'pageselector', 'name' => 'page'), implode("\n", $options));
                    $out->addHTML('</td><td><div class="multipageimagenavbox">' . Xml::openElement('form', $formParams) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . wfMessage('imgmultigoto')->rawParams($select)->parse() . Xml::submitButton(wfMessage('imgmultigo')->text()) . Xml::closeElement('form') . "<hr />{$thumb1}\n{$thumb2}<br style=\"clear: both\" /></div></td></tr></table>");
                }
            } elseif ($this->displayImg->isSafeFile()) {
                # if direct link is allowed but it's not a renderable image, show an icon.
                $icon = $this->displayImg->iconThumb();
                $out->addHTML('<div class="fullImageLink" id="file">' . $icon->toHtml(array('file-link' => true)) . "</div>\n");
            }
            $longDesc = wfMessage('parentheses', $this->displayImg->getLongDesc())->text();
            $medialink = "[[Media:{$filename}|{$linktext}]]";
            if (!$this->displayImg->isSafeFile()) {
                $warning = wfMessage('mediawarning')->plain();
                // dirmark is needed here to separate the file name, which
                // most likely ends in Latin characters, from the description,
                // which may begin with the file type. In RTL environment
                // this will get messy.
                // The dirmark, however, must not be immediately adjacent
                // to the filename, because it can get copied with it.
                // See bug 25277.
                $out->addWikiText(<<<EOT
<div class="fullMedia"><span class="dangerousLink">{$medialink}</span> {$dirmark}<span class="fileInfo">{$longDesc}</span></div>
<div class="mediaWarning">{$warning}</div>
EOT
);
            } else {
                $out->addWikiText(<<<EOT
<div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">{$longDesc}</span>
</div>
EOT
);
            }
            $renderLangOptions = $this->displayImg->getAvailableLanguages();
            if (count($renderLangOptions) >= 1) {
                $currentLanguage = $renderLang;
                $defaultLang = $this->displayImg->getDefaultRenderLanguage();
                if (is_null($currentLanguage)) {
                    $currentLanguage = $defaultLang;
                }
                $out->addHtml($this->doRenderLangOpt($renderLangOptions, $currentLanguage, $defaultLang));
            }
            // Add cannot animate thumbnail warning
            if (!$this->displayImg->canAnimateThumbIfAppropriate()) {
                // Include the extension so wiki admins can
                // customize it on a per file-type basis
                // (aka say things like use format X instead).
                // additionally have a specific message for
                // file-no-thumb-animation-gif
                $ext = $this->displayImg->getExtension();
                $noAnimMesg = wfMessageFallback('file-no-thumb-animation-' . $ext, 'file-no-thumb-animation')->plain();
                $out->addWikiText(<<<EOT
<div class="mw-noanimatethumb">{$noAnimMesg}</div>
EOT
);
            }
            if (!$this->displayImg->isLocal()) {
                $this->printSharedImageText();
            }
        } else {
            # Image does not exist
            if (!$this->getID()) {
                # No article exists either
                # Show deletion log to be consistent with normal articles
                LogEventsList::showLogExtract($out, array('delete', 'move'), $this->getTitle()->getPrefixedText(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
            }
            if ($wgEnableUploads && $user->isAllowed('upload')) {
                // Only show an upload link if the user can upload
                $uploadTitle = SpecialPage::getTitleFor('Upload');
                $nofile = array('filepage-nofile-link', $uploadTitle->getFullURL(array('wpDestFile' => $this->mPage->getFile()->getName())));
            } else {
                $nofile = 'filepage-nofile';
            }
            // Note, if there is an image description page, but
            // no image, then this setRobotPolicy is overridden
            // by Article::View().
            $out->setRobotPolicy('noindex,nofollow');
            $out->wrapWikiMsg("<div id='mw-imagepage-nofile' class='plainlinks'>\n\$1\n</div>", $nofile);
            if (!$this->getID() && $wgSend404Code) {
                // If there is no image, no shared image, and no description page,
                // output a 404, to be consistent with articles.
                $request->response()->header('HTTP/1.1 404 Not Found');
            }
        }
        $out->setFileVersion($this->displayImg);
    }
Esempio n. 5
0
 public static function onContributionsToolLinks($id, $nt, &$tools)
 {
     global $wgOut, $wgCityId, $wgUser, $wgCityId;
     wfProfileIn(__METHOD__);
     $user = User::newFromId($id);
     if (!empty($user)) {
         $tools[] = Linker::link(SpecialPage::getSafeTitleFor('Log', 'chatban'), wfMessage('chat-chatban-log')->escaped(), array('class' => 'chat-ban-log'), array('page' => $user->getUserPage()->getPrefixedText()));
         # Add chat ban log link (@author: Sactage)
         if (Chat::getBanInformation($wgCityId, $user) !== false) {
             $dir = "change";
             LogEventsList::showLogExtract($wgOut, 'chatban', $nt->getPrefixedText(), '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('chat-contributions-ban-notice', $nt->getText()), 'offset' => ''));
         } else {
             if ($wgUser->isAllowed('chatmoderator') && !$user->isAllowed('chatmoderator')) {
                 $tools[] = "<a class='chat-change-ban' data-user-id='{$id}' href='#'>" . wfMsg('chat-ban-contributions-heading') . "</a>";
             }
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Esempio n. 6
0
 protected function showHeader()
 {
     global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
     if ($this->mTitle->isTalkPage()) {
         $wgOut->addWikiMsg('talkpagetext');
     }
     # Optional notices on a per-namespace and per-page basis
     $editnotice_ns = 'editnotice-' . $this->mTitle->getNamespace();
     $editnotice_ns_message = wfMessage($editnotice_ns)->inContentLanguage();
     if ($editnotice_ns_message->exists()) {
         $wgOut->addWikiText($editnotice_ns_message->plain());
     }
     if (MWNamespace::hasSubpages($this->mTitle->getNamespace())) {
         $parts = explode('/', $this->mTitle->getDBkey());
         $editnotice_base = $editnotice_ns;
         while (count($parts) > 0) {
             $editnotice_base .= '-' . array_shift($parts);
             $editnotice_base_msg = wfMessage($editnotice_base)->inContentLanguage();
             if ($editnotice_base_msg->exists()) {
                 $wgOut->addWikiText($editnotice_base_msg->plain());
             }
         }
     } else {
         # Even if there are no subpages in namespace, we still don't want / in MW ns.
         $editnoticeText = $editnotice_ns . '-' . str_replace('/', '-', $this->mTitle->getDBkey());
         $editnoticeMsg = wfMessage($editnoticeText)->inContentLanguage();
         if ($editnoticeMsg->exists()) {
             $wgOut->addWikiText($editnoticeMsg->plain());
         }
     }
     if ($this->isConflict) {
         $wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1\n</div>", 'explainconflict');
         $this->edittime = $this->mArticle->getTimestamp();
     } else {
         if ($this->section != '' && !$this->isSectionEditSupported()) {
             // We use $this->section to much before this and getVal('wgSection') directly in other places
             // at this point we can't reset $this->section to '' to fallback to non-section editing.
             // Someone is welcome to try refactoring though
             $wgOut->showErrorPage('sectioneditnotsupported-title', 'sectioneditnotsupported-text');
             return false;
         }
         if ($this->section != '' && $this->section != 'new') {
             if (!$this->summary && !$this->preview && !$this->diff) {
                 $sectionTitle = self::extractSectionTitle($this->textbox1);
                 if ($sectionTitle !== false) {
                     $this->summary = "/* {$sectionTitle} */ ";
                 }
             }
         }
         if ($this->missingComment) {
             $wgOut->wrapWikiMsg("<div id='mw-missingcommenttext'>\n\$1\n</div>", 'missingcommenttext');
         }
         if ($this->missingSummary && $this->section != 'new') {
             $wgOut->wrapWikiMsg("<div id='mw-missingsummary'>\n\$1\n</div>", 'missingsummary');
         }
         if ($this->missingSummary && $this->section == 'new') {
             $wgOut->wrapWikiMsg("<div id='mw-missingcommentheader'>\n\$1\n</div>", 'missingcommentheader');
         }
         if ($this->hookError !== '') {
             $wgOut->addWikiText($this->hookError);
         }
         if (!$this->checkUnicodeCompliantBrowser()) {
             $wgOut->addWikiMsg('nonunicodebrowser');
         }
         if ($this->section != 'new') {
             $revision = $this->mArticle->getRevisionFetched();
             if ($revision) {
                 // Let sysop know that this will make private content public if saved
                 if (!$revision->userCan(Revision::DELETED_TEXT)) {
                     $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-permission');
                 } elseif ($revision->isDeleted(Revision::DELETED_TEXT)) {
                     $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-view');
                 }
                 if (!$revision->isCurrent()) {
                     $this->mArticle->setOldSubtitle($revision->getId());
                     $wgOut->addWikiMsg('editingold');
                 }
             } elseif ($this->mTitle->exists()) {
                 // Something went wrong
                 $wgOut->wrapWikiMsg("<div class='errorbox'>\n\$1\n</div>\n", array('missing-article', $this->mTitle->getPrefixedText(), wfMsgNoTrans('missingarticle-rev', $this->oldid)));
             }
         }
     }
     if (wfReadOnly()) {
         $wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
     } elseif ($wgUser->isAnon()) {
         if ($this->formtype != 'preview') {
             $wgOut->wrapWikiMsg("<div id=\"mw-anon-edit-warning\">\n\$1</div>", 'anoneditwarning');
         } else {
             $wgOut->wrapWikiMsg("<div id=\"mw-anon-preview-warning\">\n\$1</div>", 'anonpreviewwarning');
         }
     } else {
         if ($this->isCssJsSubpage) {
             # Check the skin exists
             if ($this->isWrongCaseCssJsPage) {
                 $wgOut->wrapWikiMsg("<div class='error' id='mw-userinvalidcssjstitle'>\n\$1\n</div>", array('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
             }
             if ($this->getTitle()->isSubpageOf($wgUser->getUserPage())) {
                 if ($this->formtype !== 'preview') {
                     if ($this->isCssSubpage) {
                         $wgOut->wrapWikiMsg("<div id='mw-usercssyoucanpreview'>\n\$1\n</div>", array('usercssyoucanpreview'));
                     }
                     if ($this->isJsSubpage) {
                         $wgOut->wrapWikiMsg("<div id='mw-userjsyoucanpreview'>\n\$1\n</div>", array('userjsyoucanpreview'));
                     }
                 }
             }
         }
     }
     if ($this->mTitle->getNamespace() != NS_MEDIAWIKI && $this->mTitle->isProtected('edit')) {
         # Is the title semi-protected?
         if ($this->mTitle->isSemiProtected()) {
             $noticeMsg = 'semiprotectedpagewarning';
         } else {
             # Then it must be protected based on static groups (regular)
             $noticeMsg = 'protectedpagewarning';
         }
         LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle, '', array('lim' => 1, 'msgKey' => array($noticeMsg)));
     }
     if ($this->mTitle->isCascadeProtected()) {
         # Is this page under cascading protection from some source pages?
         list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
         $notice = "<div class='mw-cascadeprotectedwarning'>\n\$1\n";
         $cascadeSourcesCount = count($cascadeSources);
         if ($cascadeSourcesCount > 0) {
             # Explain, and list the titles responsible
             foreach ($cascadeSources as $page) {
                 $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
             }
         }
         $notice .= '</div>';
         $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', $cascadeSourcesCount));
     }
     if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create')) {
         LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle, '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('titleprotectedwarning'), 'wrap' => "<div class=\"mw-titleprotectedwarning\">\n\$1</div>"));
     }
     if ($this->kblength === false) {
         $this->kblength = (int) (strlen($this->textbox1) / 1024);
     }
     if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
         $wgOut->wrapWikiMsg("<div class='error' id='mw-edit-longpageerror'>\n\$1\n</div>", array('longpageerror', $wgLang->formatNum($this->kblength), $wgLang->formatNum($wgMaxArticleSize)));
     } else {
         if (!wfMessage('longpage-hint')->isDisabled()) {
             $wgOut->wrapWikiMsg("<div id='mw-edit-longpage-hint'>\n\$1\n</div>", array('longpage-hint', $wgLang->formatSize(strlen($this->textbox1)), strlen($this->textbox1)));
         }
     }
 }
 public function execute($par)
 {
     $this->useTransactionalTimeLimit();
     $this->checkPermissions();
     $this->checkReadOnly();
     $output = $this->getOutput();
     $user = $this->getUser();
     $this->setHeaders();
     $this->outputHeader();
     $request = $this->getRequest();
     $this->submitClicked = $request->wasPosted() && $request->getBool('wpSubmit');
     # Handle our many different possible input types.
     $ids = $request->getVal('ids');
     if (!is_null($ids)) {
         # Allow CSV, for backwards compatibility, or a single ID for show/hide links
         $this->ids = explode(',', $ids);
     } else {
         # Array input
         $this->ids = array_keys($request->getArray('ids', array()));
     }
     // $this->ids = array_map( 'intval', $this->ids );
     $this->ids = array_unique(array_filter($this->ids));
     $this->typeName = $request->getVal('type');
     $this->targetObj = Title::newFromText($request->getText('target'));
     # For reviewing deleted files...
     $this->archiveName = $request->getVal('file');
     $this->token = $request->getVal('token');
     if ($this->archiveName && $this->targetObj) {
         $this->tryShowFile($this->archiveName);
         return;
     }
     $this->typeName = RevisionDeleter::getCanonicalTypeName($this->typeName);
     # No targets?
     if (!$this->typeName || count($this->ids) == 0) {
         throw new ErrorPageError('revdelete-nooldid-title', 'revdelete-nooldid-text');
     }
     # Allow the list type to adjust the passed target
     $this->targetObj = RevisionDeleter::suggestTarget($this->typeName, $this->targetObj, $this->ids);
     # We need a target page!
     if ($this->targetObj === null) {
         $output->addWikiMsg('undelete-header');
         return;
     }
     $this->typeLabels = self::$UILabels[$this->typeName];
     $list = $this->getList();
     $list->reset();
     $bitfield = $list->current()->getBits();
     $this->mIsAllowed = $user->isAllowed(RevisionDeleter::getRestriction($this->typeName));
     $canViewSuppressedOnly = $this->getUser()->isAllowed('viewsuppressed') && !$this->getUser()->isAllowed('suppressrevision');
     $pageIsSuppressed = $bitfield & Revision::DELETED_RESTRICTED;
     $this->mIsAllowed = $this->mIsAllowed && !($canViewSuppressedOnly && $pageIsSuppressed);
     $this->otherReason = $request->getVal('wpReason');
     # Give a link to the logs/hist for this page
     $this->showConvenienceLinks();
     # Initialise checkboxes
     $this->checks = array(array($this->typeLabels['check-label'], 'wpHidePrimary', RevisionDeleter::getRevdelConstant($this->typeName)), array('revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT), array('revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER));
     if ($user->isAllowed('suppressrevision')) {
         $this->checks[] = array('revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED);
     }
     # Either submit or create our form
     if ($this->mIsAllowed && $this->submitClicked) {
         $this->submit($request);
     } else {
         $this->showForm();
     }
     $qc = $this->getLogQueryCond();
     # Show relevant lines from the deletion log
     $deleteLogPage = new LogPage('delete');
     $output->addHTML("<h2>" . $deleteLogPage->getName()->escaped() . "</h2>\n");
     LogEventsList::showLogExtract($output, 'delete', $this->targetObj, '', array('lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved));
     # Show relevant lines from the suppression log
     if ($user->isAllowed('suppressionlog')) {
         $suppressLogPage = new LogPage('suppress');
         $output->addHTML("<h2>" . $suppressLogPage->getName()->escaped() . "</h2>\n");
         LogEventsList::showLogExtract($output, 'suppress', $this->targetObj, '', array('lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved));
     }
 }
 protected function showHistory()
 {
     $this->checkReadOnly();
     $out = $this->getOutput();
     if ($this->mAllowed) {
         $out->addModules('mediawiki.special.undelete');
     }
     $out->wrapWikiMsg("<div class='mw-undelete-pagetitle'>\n\$1\n</div>\n", array('undeletepagetitle', wfEscapeWikiText($this->mTargetObj->getPrefixedText())));
     $archive = new PageArchive($this->mTargetObj, $this->getConfig());
     Hooks::run('UndeleteForm::showHistory', array(&$archive, $this->mTargetObj));
     /*
     $text = $archive->getLastRevisionText();
     if( is_null( $text ) ) {
     	$out->addWikiMsg( 'nohistory' );
     	return;
     }
     */
     $out->addHTML('<div class="mw-undelete-history">');
     if ($this->mAllowed) {
         $out->addWikiMsg('undeletehistory');
         $out->addWikiMsg('undeleterevdel');
     } else {
         $out->addWikiMsg('undeletehistorynoadmin');
     }
     $out->addHTML('</div>');
     # List all stored revisions
     $revisions = $archive->listRevisions();
     $files = $archive->listFiles();
     $haveRevisions = $revisions && $revisions->numRows() > 0;
     $haveFiles = $files && $files->numRows() > 0;
     # Batch existence check on user and talk pages
     if ($haveRevisions) {
         $batch = new LinkBatch();
         foreach ($revisions as $row) {
             $batch->addObj(Title::makeTitleSafe(NS_USER, $row->ar_user_text));
             $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->ar_user_text));
         }
         $batch->execute();
         $revisions->seek(0);
     }
     if ($haveFiles) {
         $batch = new LinkBatch();
         foreach ($files as $row) {
             $batch->addObj(Title::makeTitleSafe(NS_USER, $row->fa_user_text));
             $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->fa_user_text));
         }
         $batch->execute();
         $files->seek(0);
     }
     if ($this->mAllowed) {
         $action = $this->getPageTitle()->getLocalURL(array('action' => 'submit'));
         # Start the form here
         $top = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'undelete'));
         $out->addHTML($top);
     }
     # Show relevant lines from the deletion log:
     $deleteLogPage = new LogPage('delete');
     $out->addHTML(Xml::element('h2', null, $deleteLogPage->getName()->text()) . "\n");
     LogEventsList::showLogExtract($out, 'delete', $this->mTargetObj);
     # Show relevant lines from the suppression log:
     $suppressLogPage = new LogPage('suppress');
     if ($this->getUser()->isAllowed('suppressionlog')) {
         $out->addHTML(Xml::element('h2', null, $suppressLogPage->getName()->text()) . "\n");
         LogEventsList::showLogExtract($out, 'suppress', $this->mTargetObj);
     }
     if ($this->mAllowed && ($haveRevisions || $haveFiles)) {
         # Format the user-visible controls (comment field, submission button)
         # in a nice little table
         if ($this->getUser()->isAllowed('suppressrevision')) {
             $unsuppressBox = "<tr>\n\t\t\t\t\t\t<td>&#160;</td>\n\t\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel($this->msg('revdelete-unsuppress')->text(), 'wpUnsuppress', 'mw-undelete-unsuppress', $this->mUnsuppress) . "</td>\n\t\t\t\t\t</tr>";
         } else {
             $unsuppressBox = '';
         }
         $table = Xml::fieldset($this->msg('undelete-fieldset-title')->text()) . Xml::openElement('table', array('id' => 'mw-undelete-table')) . "<tr>\n\t\t\t\t\t<td colspan='2' class='mw-undelete-extrahelp'>" . $this->msg('undeleteextrahelp')->parseAsBlock() . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('undeletecomment')->text(), 'wpComment') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('wpComment', 50, $this->mComment, array('id' => 'wpComment', 'autofocus' => '')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>&#160;</td>\n\t\t\t\t<td class='mw-submit'>" . Xml::submitButton($this->msg('undeletebtn')->text(), array('name' => 'restore', 'id' => 'mw-undelete-submit')) . ' ' . Xml::submitButton($this->msg('undeleteinvert')->text(), array('name' => 'invert', 'id' => 'mw-undelete-invert')) . "</td>\n\t\t\t</tr>" . $unsuppressBox . Xml::closeElement('table') . Xml::closeElement('fieldset');
         $out->addHTML($table);
     }
     $out->addHTML(Xml::element('h2', null, $this->msg('history')->text()) . "\n");
     if ($haveRevisions) {
         # The page's stored (deleted) history:
         $out->addHTML('<ul>');
         $remaining = $revisions->numRows();
         $earliestLiveTime = $this->mTargetObj->getEarliestRevTime();
         foreach ($revisions as $row) {
             $remaining--;
             $out->addHTML($this->formatRevisionRow($row, $earliestLiveTime, $remaining));
         }
         $revisions->free();
         $out->addHTML('</ul>');
     } else {
         $out->addWikiMsg('nohistory');
     }
     if ($haveFiles) {
         $out->addHTML(Xml::element('h2', null, $this->msg('filehist')->text()) . "\n");
         $out->addHTML('<ul>');
         foreach ($files as $row) {
             $out->addHTML($this->formatFileRow($row));
         }
         $files->free();
         $out->addHTML('</ul>');
     }
     if ($this->mAllowed) {
         # Slip in the hidden controls here
         $misc = Html::hidden('target', $this->mTarget);
         $misc .= Html::hidden('wpEditToken', $this->getUser()->getEditToken());
         $misc .= Xml::closeElement('form');
         $out->addHTML($misc);
     }
     return true;
 }
Esempio n. 9
0
 /**
  * Get an UploadForm instance with title and text properly set.
  *
  * @param string $message HTML string to add to the form
  * @param string $sessionKey Session key in case this is a stashed upload
  * @param bool $hideIgnoreWarning Whether to hide "ignore warning" check box
  * @return UploadForm
  */
 protected function getUploadForm($message = '', $sessionKey = '', $hideIgnoreWarning = false)
 {
     # Initialize form
     $context = new DerivativeContext($this->getContext());
     $context->setTitle($this->getPageTitle());
     // Remove subpage
     $form = new UploadForm(array('watch' => $this->getWatchCheck(), 'forreupload' => $this->mForReUpload, 'sessionkey' => $sessionKey, 'hideignorewarning' => $hideIgnoreWarning, 'destwarningack' => (bool) $this->mDestWarningAck, 'description' => $this->mComment, 'texttop' => $this->uploadFormTextTop, 'textaftersummary' => $this->uploadFormTextAfterSummary, 'destfile' => $this->mDesiredDestName), $context);
     # Check the token, but only if necessary
     if (!$this->mTokenOk && !$this->mCancelUpload && ($this->mUpload && $this->mUploadClicked)) {
         $form->addPreText($this->msg('session_fail_preview')->parse());
     }
     # Give a notice if the user is uploading a file that has been deleted or moved
     # Note that this is independent from the message 'filewasdeleted' that requires JS
     $desiredTitleObj = Title::makeTitleSafe(NS_FILE, $this->mDesiredDestName);
     $delNotice = '';
     // empty by default
     if ($desiredTitleObj instanceof Title && !$desiredTitleObj->exists()) {
         LogEventsList::showLogExtract($delNotice, array('delete', 'move'), $desiredTitleObj, '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('upload-recreate-warning')));
     }
     $form->addPreText($delNotice);
     # Add text to form
     $form->addPreText('<div id="uploadtext">' . $this->msg('uploadtext', array($this->mDesiredDestName))->parseAsBlock() . '</div>');
     # Add upload error message
     $form->addPreText($message);
     # Add footer to form
     $uploadFooter = $this->msg('uploadfooter');
     if (!$uploadFooter->isDisabled()) {
         $form->addPostText('<div id="mw-upload-footer-message">' . $uploadFooter->parseAsBlock() . "</div>\n");
     }
     return $form;
 }
Esempio n. 10
0
 /**
  * Show a rights log fragment for the specified user
  *
  * @param $user User to show log for
  * @param $output OutputPage to use
  */
 protected function showLogFragment($user, $output)
 {
     $output->addHTML(Xml::element('h2', null, LogPage::logName('rights') . "\n"));
     LogEventsList::showLogExtract($output, 'rights', $user->getUserPage()->getPrefixedText());
 }
Esempio n. 11
0
 function showLogFragment($title, &$out)
 {
     $out->addHTML(Xml::element('h2', null, LogPage::logName('move')));
     LogEventsList::showLogExtract($out, 'move', $title->getPrefixedText());
 }
Esempio n. 12
0
 /**
  * Add footer elements to the form
  * @return string
  */
 protected function postText()
 {
     # Link to the user's contributions, if applicable
     if ($this->target instanceof User) {
         $contribsPage = SpecialPage::getTitleFor('Contributions', $this->target->getName());
         $links[] = Linker::link($contribsPage, $this->msg('ipb-blocklist-contribs', $this->target->getName())->escaped());
     }
     # Link to unblock the specified user, or to a blank unblock form
     if ($this->target instanceof User) {
         $message = $this->msg('ipb-unblock-addr', $this->target->getName())->parse();
         $list = SpecialPage::getTitleFor('Unblock', $this->target->getName());
     } else {
         $message = $this->msg('ipb-unblock')->parse();
         $list = SpecialPage::getTitleFor('Unblock');
     }
     $links[] = Linker::linkKnown($list, $message, array());
     # Link to the block list
     $links[] = Linker::linkKnown(SpecialPage::getTitleFor('BlockList'), $this->msg('ipb-blocklist')->escaped());
     $user = $this->getUser();
     # Link to edit the block dropdown reasons, if applicable
     if ($user->isAllowed('editinterface')) {
         $links[] = Linker::link(Title::makeTitle(NS_MEDIAWIKI, 'Ipbreason-dropdown'), $this->msg('ipb-edit-dropdown')->escaped(), array(), array('action' => 'edit'));
     }
     $text = Html::rawElement('p', array('class' => 'mw-ipb-conveniencelinks'), $this->getLanguage()->pipeList($links));
     if ($this->target instanceof User) {
         # Get relevant extracts from the block and suppression logs, if possible
         $userpage = $this->target->getUserPage();
         $out = '';
         LogEventsList::showLogExtract($out, 'block', $userpage, '', array('lim' => 10, 'msgKey' => array('blocklog-showlog', $userpage->getText()), 'showIfEmpty' => false));
         $text .= $out;
         # Add suppression block entries if allowed
         if ($user->isAllowed('suppressionlog')) {
             LogEventsList::showLogExtract($out, 'suppress', $userpage, '', array('lim' => 10, 'conds' => array('log_action' => array('block', 'reblock', 'unblock')), 'msgKey' => array('blocklog-showsuppresslog', $userpage->getText()), 'showIfEmpty' => false));
             $text .= $out;
         }
     }
     return $text;
 }
Esempio n. 13
0
 /**
  * @param $username Title
  * @param $type
  * @param $out OutputPage
  */
 function showLogExtract($username, $type, &$out)
 {
     # Show relevant lines from the logs:
     $out->addHTML(Xml::element('h2', null, LogPage::logName($type)) . "\n");
     LogEventsList::showLogExtract($out, $type, $username->getPrefixedText());
 }
 /**
  * Show the last 50 log entries
  */
 function showLogExtract()
 {
     $text = '';
     $numRows = LogEventsList::showLogExtract($text, array('globalauth', 'suppress'), '', '', array('conds' => array('log_action' => 'setstatus'), 'showIfEmpty' => true));
     if ($numRows) {
         $this->getOutput()->addHTML(Xml::fieldset($this->msg('centralauth-admin-logsnippet')->text(), $text));
     }
 }
Esempio n. 15
0
 private function showLogFragment($out, $title)
 {
     global $wgUser;
     // Used to support GENDER in 'blocklog-showlog' and 'blocklog-showsuppresslog'
     $userBlocked = $title->getText();
     LogEventsList::showLogExtract($out, 'block', $title->getPrefixedText(), '', array('lim' => 10, 'msgKey' => array('blocklog-showlog', $userBlocked), 'showIfEmpty' => false));
     // Add suppression block entries if allowed
     if ($wgUser->isAllowed('hideuser')) {
         LogEventsList::showLogExtract($out, 'suppress', $title->getPrefixedText(), '', array('lim' => 10, 'conds' => array('log_action' => array('block', 'reblock', 'unblock')), 'msgKey' => array('blocklog-showsuppresslog', $userBlocked), 'showIfEmpty' => false));
     }
 }
Esempio n. 16
0
 function showLogFragment($title)
 {
     $moveLogPage = new LogPage('move');
     $out = $this->getOutput();
     $out->addHTML(Xml::element('h2', null, $moveLogPage->getName()->text()));
     LogEventsList::showLogExtract($out, 'move', $title);
 }
Esempio n. 17
0
    /**
     * Replace entire showEditForm, need to add our own textbox and stuff
     */
    function showEditForm($formCallback = null)
    {
        global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle, $wgRequest;
        # If $wgTitle is null, that means we're in API mode.
        # Some hook probably called this function  without checking
        # for is_null($wgTitle) first. Bail out right here so we don't
        # do lots of work just to discard it right after.
        if (is_null($wgTitle)) {
            return;
        }
        $fname = 'EditPage::showEditForm';
        wfProfileIn($fname);
        $sk = $wgUser->getSkin();
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        #need to parse the preview early so that we know which templates are used,
        #otherwise users with "show preview after edit box" will get a blank list
        #we parse this near the beginning so that setHeaders can do the title
        #setting work instead of leaving it in getPreviewText
        $previewOutput = '';
        if ($this->formtype == 'preview') {
            $previewOutput = $this->getPreviewText();
        }
        $this->setHeaders();
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($this->isConflict) {
            $wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1</div>", 'explainconflict');
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->getContent();
            $this->edittime = $this->mArticle->getTimestamp();
            # MeanEditor: too complicated for visual editing
            $this->noVisualEditor = false;
        } else {
            if ($this->section != '' && $this->section != 'new') {
                $matches = array();
                if (!$this->summary && !$this->preview && !$this->diff) {
                    preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
                    if (!empty($matches[2])) {
                        global $wgParser;
                        $this->summary = "/* " . $wgParser->stripSectionName(trim($matches[2])) . " */ ";
                    }
                }
            }
            if ($this->missingComment) {
                $wgOut->wrapWikiMsg('<div id="mw-missingcommenttext">$1</div>', 'missingcommenttext');
            }
            if ($this->missingSummary && $this->section != 'new') {
                $wgOut->wrapWikiMsg('<div id="mw-missingsummary">$1</div>', 'missingsummary');
            }
            if ($this->missingSummary && $this->section == 'new') {
                $wgOut->wrapWikiMsg('<div id="mw-missingcommentheader">$1</div>', 'missingcommentheader');
            }
            if ($this->hookError !== '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiMsg('nonunicodebrowser');
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision)) {
                // Let sysop know that this will make private content public if saved
                if (!$this->mArticle->mRevision->userCan(Revision::DELETED_TEXT)) {
                    $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-permission');
                } else {
                    if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
                        $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view');
                    }
                }
                if (!$this->mArticle->mRevision->isCurrent()) {
                    $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                    $wgOut->addWikiMsg('editingold');
                }
            }
        }
        if (wfReadOnly()) {
            $wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
            # MeanEditor: visual editing makes no sense here
            $this->noVisualEditor = true;
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->wrapWikiMsg('<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning');
        } else {
            if ($this->isCssJsSubpage) {
                # Check the skin exists
                if ($this->isValidCssJsSubpage) {
                    if ($this->formtype !== 'preview') {
                        $wgOut->addWikiMsg('usercssjsyoucanpreview');
                    }
                } else {
                    $wgOut->addWikiMsg('userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage());
                }
            }
        }
        $classes = array();
        // Textarea CSS
        if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
        } elseif ($this->mTitle->isProtected('edit')) {
            # Is the title semi-protected?
            if ($this->mTitle->isSemiProtected()) {
                $noticeMsg = 'semiprotectedpagewarning';
                $classes[] = 'mw-textarea-sprotected';
            } else {
                # Then it must be protected based on static groups (regular)
                $noticeMsg = 'protectedpagewarning';
                $classes[] = 'mw-textarea-protected';
            }
            $wgOut->addHTML("<div class='mw-warning-with-logexcerpt'>\n");
            $wgOut->addWikiMsg($noticeMsg);
            LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1);
            $wgOut->addHTML("</div>\n");
        }
        if ($this->mTitle->isCascadeProtected()) {
            # Is this page under cascading protection from some source pages?
            list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
            $notice = "<div class='mw-cascadeprotectedwarning'>\$1\n";
            $cascadeSourcesCount = count($cascadeSources);
            if ($cascadeSourcesCount > 0) {
                # Explain, and list the titles responsible
                foreach ($cascadeSources as $page) {
                    $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
                }
            }
            $notice .= '</div>';
            $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', $cascadeSourcesCount));
        }
        if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create')) {
            $wgOut->wrapWikiMsg('<div class="mw-titleprotectedwarning">$1</div>', 'titleprotectedwarning');
        }
        if ($this->kblength === false) {
            # MeanEditor: the length will probably be different in HTML
            $this->kblength = (int) (strlen($this->textbox1) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addHTML("<div class='error' id='mw-edit-longpageerror'>\n");
            $wgOut->addWikiMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgLang->formatNum($wgMaxArticleSize));
            $wgOut->addHTML("</div>\n");
        } elseif ($this->kblength > 29) {
            $wgOut->addHTML("<div id='mw-edit-longpagewarning'>\n");
            $wgOut->addWikiMsg('longpagewarning', $wgLang->formatNum($this->kblength));
            $wgOut->addHTML("</div>\n");
        }
        $q = 'action=' . $this->action;
        #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        $action = $wgTitle->escapeLocalURL($q);
        $summary = wfMsg('summary');
        $subject = wfMsg('subject');
        $cancel = $sk->makeKnownLink($wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')));
        $separator = wfMsgExt('pipe-separator', 'escapenoentities');
        $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        if ($wgRightsText) {
            $copywarnMsg = array('copyrightwarning', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText);
        } else {
            $copywarnMsg = array('copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]');
        }
        /* MeanEditor: always disable the toolbar */
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = '';
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            # Sort out the "watch" checkbox
            if ($wgUser->getOption('watchdefault')) {
                # Watch all edits
                $this->watchthis = true;
            } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) {
                # Watch creations
                $this->watchthis = true;
            } elseif ($this->mTitle->userIsWatching()) {
                # Already watched
                $this->watchthis = true;
            }
            # May be overriden by request parameters
            if ($wgRequest->getBool('watchthis')) {
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
            # MeanEditor: User preference
            if ($wgUser->getOption('prefer_traditional_editor')) {
                $this->userWantsTraditionalEditor = true;
            }
        }
        $wgOut->addHTML($this->editFormPageTop);
        if ($wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, true);
        }
        $wgOut->addHTML($this->editFormTextTop);
        # if this is a comment, show a subject line at the top, which is also the edit summary.
        # Otherwise, show a summary field at the bottom
        $summarytext = $wgContLang->recodeForEdit($this->summary);
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        #####
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in the hidden field wpAutoSummary.
        $summaryhiddens = '';
        if ($this->missingSummary) {
            $summaryhiddens .= Xml::hidden('wpIgnoreBlankSummary', true);
        }
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $summaryhiddens .= Xml::hidden('wpAutoSummary', $autosumm);
        if ($this->section == 'new') {
            $commentsubject = '';
            if (!$wgRequest->getBool('nosummary')) {
                # Add a class if 'missingsummary' is triggered to allow styling of the summary line
                $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
                $commentsubject = Xml::tags('label', array('for' => 'wpSummary'), $subject);
                $commentsubject = Xml::tags('span', array('class' => $summaryClass, 'id' => "wpSummaryLabel"), $commentsubject);
                $commentsubject .= '&nbsp;';
                $commentsubject .= Xml::input('wpSummary', 60, $summarytext, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1'));
            }
            $editsummary = "<div class='editOptions'>\n";
            global $wgParser;
            $formattedSummary = wfMsgForContent('newsectionsummary', $wgParser->stripSectionName($this->summary));
            $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('subject-preview') . $sk->commentBlock($formattedSummary, $this->mTitle, true) . "</div>\n" : '';
            $summarypreview = '';
        } else {
            $commentsubject = '';
            # Add a class if 'missingsummary' is triggered to allow styling of the summary line
            $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
            $editsummary = Xml::tags('label', array('for' => 'wpSummary'), $summary);
            $editsummary = Xml::tags('span', array('class' => $summaryClass, 'id' => "wpSummaryLabel"), $editsummary) . ' ';
            $editsummary .= Xml::input('wpSummary', 60, $summarytext, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1'));
            // No idea where this is closed.
            $editsummary = Xml::openElement('div', array('class' => 'editOptions')) . $editsummary . '<br/>';
            $summarypreview = '';
            if ($summarytext && $this->preview) {
                $summarypreview = Xml::tags('div', array('class' => 'mw-summary-preview'), wfMsg('summary-preview') . $sk->commentBlock($this->summary, $this->mTitle));
            }
            $subjectpreview = '';
        }
        $commentsubject .= $summaryhiddens;
        # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display
        if (!$this->preview && !$this->diff) {
            $wgOut->setOnloadHandler('document.editform.wpTextbox1.focus()');
        }
        $templates = $this->getTemplates();
        $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != '');
        $hiddencats = $this->mArticle->getHiddenCategories();
        $formattedhiddencats = $sk->formatHiddenCategories($hiddencats);
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $top = wfMsgWikiHtml('metadata_help');
            /* ToDo: Replace with clean code */
            $ew = $wgUser->getOption('editwidth');
            if ($ew) {
                $ew = " style=\"width:100%\"";
            } else {
                $ew = '';
            }
            $cols = $wgUser->getIntOption('cols');
            /* /ToDo */
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $recreate = '';
        if ($this->wasDeletedSinceLastEdit()) {
            if ('save' != $this->formtype) {
                $wgOut->wrapWikiMsg("<div class='error mw-deleted-while-editing'>\n\$1</div>", 'deletedwhileediting');
            } else {
                // Hide the toolbar and edit area, user can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $recreate = '<div class="mw-confirm-recreate">' . $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)) . Xml::checkLabel(wfMsg('recreate'), 'wpRecreate', 'wpRecreate', false, array('title' => $sk->titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>';
            }
        }
        $tabindex = 2;
        $checkboxes = $this->getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis, 'want_traditional_editor' => $this->userWantsTraditionalEditor));
        $checkboxhtml = implode($checkboxes, "\n");
        $buttons = $this->getEditButtons($tabindex);
        $buttonshtml = implode($buttons, "\n");
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Xml::hidden('safemode', '1');
        $wgOut->addHTML(<<<END
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
END
);
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
        // Put these up at the top to ensure they aren't lost on early form submission
        $this->showFormBeforeText();
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
{$this->editFormTextBeforeContent}
END
);
        if ($this->isConflict || $this->diff) {
            # MeanEditor: should be redundant, but let's be sure
            $this->noVisualEditor = true;
        }
        # MeanEditor: also apply htmlspecialchars? See $encodedtext
        $html_text = $this->safeUnicodeOutput($this->textbox1);
        if (!($this->noVisualEditor || $this->userWantsTraditionalEditor)) {
            $this->noVisualEditor = wfRunHooks('EditPage::wiki2html', array($this->mArticle, $wgUser, &$this, &$html_text));
        }
        if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
            $this->noVisualEditor = wfRunHooks('EditPage::showBox', array(&$this, $html_text, $rows, $cols, $ew));
        }
        if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
            $wgOut->addHTML("<input type='hidden' value=\"0\" name=\"wpNoVisualEditor\" />\n");
        } else {
            $wgOut->addHTML("<input type='hidden' value=\"1\" name=\"wpNoVisualEditor\" />\n");
            $this->showTextbox1($classes);
        }
        $wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg);
        $wgOut->addHTML(<<<END
{$this->editFormTextAfterWarn}
{$metadata}
{$editsummary}
{$summarypreview}
{$checkboxhtml}
{$safemodehtml}
END
);
        $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        /**
         * To make it harder for someone to slip a user a page
         * which submits an edit form to the wiki without their
         * knowledge, a random token is associated with the login
         * session. If it's not passed back with the submission,
         * we won't save the page, or render user JavaScript and
         * CSS previews.
         *
         * For anon editors, who may not have a session, we just
         * include the constant suffix to prevent editing from
         * broken text-mangling proxies.
         */
        $token = htmlspecialchars($wgUser->editToken());
        $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        $this->showEditTools();
        $wgOut->addHTML(<<<END
{$this->editFormTextAfterTools}
<div class='templatesUsed'>
{$formattedtemplates}
</div>
<div class='hiddencats'>
{$formattedhiddencats}
</div>
END
);
        if ($this->isConflict && wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) {
            $wgOut->wrapWikiMsg('==$1==', "yourdiff");
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->textbox1);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->wrapWikiMsg('==$1==', "yourtext");
            $this->showTextbox2();
        }
        $wgOut->addHTML($this->editFormTextBottom);
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, false);
        }
        wfProfileOut($fname);
    }
Esempio n. 18
0
 public function execute($par)
 {
     global $wgOut, $wgUser, $wgRequest;
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     if (!$wgUser->isAllowed('deleterevision')) {
         $wgOut->permissionRequired('deleterevision');
         return;
     }
     $this->skin =& $wgUser->getSkin();
     # Set title and such
     $this->setHeaders();
     $this->outputHeader();
     $this->wasPosted = $wgRequest->wasPosted();
     # Handle our many different possible input types
     $this->target = $wgRequest->getText('target');
     $this->oldids = $wgRequest->getArray('oldid');
     $this->artimestamps = $wgRequest->getArray('artimestamp');
     $this->logids = $wgRequest->getArray('logid');
     $this->oldimgs = $wgRequest->getArray('oldimage');
     $this->fileids = $wgRequest->getArray('fileid');
     # For reviewing deleted files...
     $this->file = $wgRequest->getVal('file');
     # Only one target set at a time please!
     $i = (bool) $this->file + (bool) $this->oldids + (bool) $this->logids + (bool) $this->artimestamps + (bool) $this->fileids + (bool) $this->oldimgs;
     # No targets?
     if ($i == 0) {
         $wgOut->showErrorPage('notargettitle', 'notargettext');
         return;
     }
     # Too many targets?
     if ($i !== 1) {
         $wgOut->showErrorPage('revdelete-toomanytargets-title', 'revdelete-toomanytargets-text');
         return;
     }
     $this->page = Title::newFromUrl($this->target);
     # If we have revisions, get the title from the first one
     # since they should all be from the same page. This allows
     # for more flexibility with page moves...
     if (count($this->oldids) > 0) {
         $rev = Revision::newFromId($this->oldids[0]);
         $this->page = $rev ? $rev->getTitle() : $this->page;
     }
     # We need a target page!
     if (is_null($this->page)) {
         $wgOut->addWikiMsg('undelete-header');
         return;
     }
     # Logs must have a type given
     if ($this->logids && !strpos($this->page->getDBKey(), '/')) {
         $wgOut->showErrorPage('revdelete-nologtype-title', 'revdelete-nologtype-text');
         return;
     }
     # For reviewing deleted files...show it now if allowed
     if ($this->file) {
         $oimage = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName($this->page, $this->file);
         $oimage->load();
         // Check if user is allowed to see this file
         if (!$oimage->userCan(File::DELETED_FILE)) {
             $wgOut->permissionRequired('suppressrevision');
         } else {
             $this->showFile($this->file);
         }
         return;
     }
     # Give a link to the logs/hist for this page
     if (!is_null($this->page) && $this->page->getNamespace() > -1) {
         $links = array();
         $logtitle = SpecialPage::getTitleFor('Log');
         $links[] = $this->skin->makeKnownLinkObj($logtitle, wfMsgHtml('viewpagelogs'), wfArrayToCGI(array('page' => $this->page->getPrefixedUrl())));
         # Give a link to the page history
         $links[] = $this->skin->makeKnownLinkObj($this->page, wfMsgHtml('pagehist'), wfArrayToCGI(array('action' => 'history')));
         # Link to deleted edits
         if ($wgUser->isAllowed('undelete')) {
             $undelete = SpecialPage::getTitleFor('Undelete');
             $links[] = $this->skin->makeKnownLinkObj($undelete, wfMsgHtml('deletedhist'), wfArrayToCGI(array('target' => $this->page->getPrefixedDBkey())));
         }
         # Logs themselves don't have histories or archived revisions
         $wgOut->setSubtitle('<p>' . implode($links, ' / ') . '</p>');
     }
     # Lock the operation and the form context
     $this->secureOperation();
     # Either submit or create our form
     if ($this->wasPosted) {
         $this->submit($wgRequest);
     } else {
         if ($this->deleteKey == 'oldid' || $this->deleteKey == 'artimestamp') {
             $this->showRevs();
         } else {
             if ($this->deleteKey == 'fileid' || $this->deleteKey == 'oldimage') {
                 $this->showImages();
             } else {
                 if ($this->deleteKey == 'logid') {
                     $this->showLogItems();
                 }
             }
         }
     }
     # Show relevant lines from the deletion log. This will show even if said ID
     # does not exist...might be helpful
     $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n");
     LogEventsList::showLogExtract($wgOut, 'delete', $this->page->getPrefixedText());
     if ($wgUser->isAllowed('suppressionlog')) {
         $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('suppress')) . "</h2>\n");
         LogEventsList::showLogExtract($wgOut, 'suppress', $this->page->getPrefixedText());
     }
 }
 /**
  * Print the history page for an article.
  */
 function onView()
 {
     $out = $this->getOutput();
     $request = $this->getRequest();
     /**
      * Allow client caching.
      */
     if ($out->checkLastModified($this->page->getTouched())) {
         return;
         // Client cache fresh and headers sent, nothing more to do.
     }
     wfProfileIn(__METHOD__);
     $this->preCacheMessages();
     $config = $this->context->getConfig();
     # Fill in the file cache if not set already
     $useFileCache = $config->get('UseFileCache');
     if ($useFileCache && HTMLFileCache::useFileCache($this->getContext())) {
         $cache = HTMLFileCache::newFromTitle($this->getTitle(), 'history');
         if (!$cache->isCacheGood()) {
             ob_start(array(&$cache, 'saveToFileCache'));
         }
     }
     // Setup page variables.
     $out->setFeedAppendQuery('action=history');
     $out->addModules('mediawiki.action.history');
     if ($config->get('UseMediaWikiUIEverywhere')) {
         $out = $this->getOutput();
         $out->addModuleStyles(array('mediawiki.ui.input', 'mediawiki.ui.checkbox'));
     }
     // Handle atom/RSS feeds.
     $feedType = $request->getVal('feed');
     if ($feedType) {
         $this->feed($feedType);
         wfProfileOut(__METHOD__);
         return;
     }
     // Fail nicely if article doesn't exist.
     if (!$this->page->exists()) {
         $out->addWikiMsg('nohistory');
         # show deletion/move log if there is an entry
         LogEventsList::showLogExtract($out, array('delete', 'move'), $this->getTitle(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
         wfProfileOut(__METHOD__);
         return;
     }
     /**
      * Add date selector to quickly get to a certain time
      */
     $year = $request->getInt('year');
     $month = $request->getInt('month');
     $tagFilter = $request->getVal('tagfilter');
     $tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
     /**
      * Option to show only revisions that have been (partially) hidden via RevisionDelete
      */
     if ($request->getBool('deleted')) {
         $conds = array('rev_deleted != 0');
     } else {
         $conds = array();
     }
     if ($this->getUser()->isAllowed('deletedhistory')) {
         $checkDeleted = Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deleted', 'mw-show-deleted-only', $request->getBool('deleted')) . "\n";
     } else {
         $checkDeleted = '';
     }
     // Add the general form
     $action = htmlspecialchars(wfScript());
     $out->addHTML("<form action=\"{$action}\" method=\"get\" id=\"mw-history-searchform\">" . Xml::fieldset($this->msg('history-fieldset-title')->text(), false, array('id' => 'mw-history-search')) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . "\n" . Html::hidden('action', 'history') . "\n" . Xml::dateMenu($year == null ? MWTimestamp::getLocalInstance()->format('Y') : $year, $month) . '&#160;' . ($tagSelector ? implode('&#160;', $tagSelector) . '&#160;' : '') . $checkDeleted . Xml::submitButton($this->msg('allpagessubmit')->text()) . "\n" . '</fieldset></form>');
     wfRunHooks('PageHistoryBeforeList', array(&$this->page, $this->getContext()));
     // Create and output the list.
     $pager = new HistoryPager($this, $year, $month, $tagFilter, $conds);
     $out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
     $out->preventClickjacking($pager->getPreventClickjacking());
     wfProfileOut(__METHOD__);
 }
Esempio n. 20
0
 /**
  * Perform a deletion and output success or failure messages
  */
 public function doDelete($reason, $suppress = false)
 {
     global $wgOut, $wgUser;
     $id = $this->mTitle->getArticleID(Title::GAID_FOR_UPDATE);
     $error = '';
     if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error))) {
         if ($this->doDeleteArticle($reason, $suppress, $id)) {
             $deleted = $this->mTitle->getPrefixedText();
             $wgOut->setPagetitle(wfMsg('actioncomplete'));
             $wgOut->setRobotPolicy('noindex,nofollow');
             $loglink = '[[Special:Log/delete|' . wfMsgNoTrans('deletionlog') . ']]';
             $wgOut->addWikiMsg('deletedtext', $deleted, $loglink);
             $wgOut->returnToMain(false);
             wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id));
         }
     } else {
         if ($error == '') {
             $wgOut->showFatalError(Html::rawElement('div', array('class' => 'error mw-error-cannotdelete'), wfMsgExt('cannotdelete', array('parse'), $this->mTitle->getPrefixedText())));
             $wgOut->addHTML(Xml::element('h2', null, LogPage::logName('delete')));
             LogEventsList::showLogExtract($wgOut, 'delete', $this->mTitle->getPrefixedText());
         } else {
             $wgOut->showFatalError($error);
         }
     }
 }
Esempio n. 21
0
 /**
  * Perform a deletion and output success or failure messages
  * @param string $reason
  * @param bool $suppress
  */
 public function doDelete($reason, $suppress = false)
 {
     $error = '';
     $context = $this->getContext();
     $outputPage = $context->getOutput();
     $user = $context->getUser();
     $status = $this->mPage->doDeleteArticleReal($reason, $suppress, 0, true, $error, $user);
     if ($status->isGood()) {
         $deleted = $this->getTitle()->getPrefixedText();
         $outputPage->setPageTitle(wfMessage('actioncomplete'));
         $outputPage->setRobotPolicy('noindex,nofollow');
         $loglink = '[[Special:Log/delete|' . wfMessage('deletionlog')->text() . ']]';
         $outputPage->addWikiMsg('deletedtext', wfEscapeWikiText($deleted), $loglink);
         Hooks::run('ArticleDeleteAfterSuccess', array($this->getTitle(), $outputPage));
         $outputPage->returnToMain(false);
     } else {
         $outputPage->setPageTitle(wfMessage('cannotdelete-title', $this->getTitle()->getPrefixedText()));
         if ($error == '') {
             $outputPage->addWikiText("<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>");
             $deleteLogPage = new LogPage('delete');
             $outputPage->addHTML(Xml::element('h2', null, $deleteLogPage->getName()->text()));
             LogEventsList::showLogExtract($outputPage, 'delete', $this->getTitle());
         } else {
             $outputPage->addHTML($error);
         }
     }
 }
Esempio n. 22
0
 /**
  * Generates the subheading with links
  * @param $userObj User object for the target
  * @return String: appropriately-escaped HTML to be output literally
  * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
  */
 protected function contributionsSub($userObj)
 {
     if ($userObj->isAnon()) {
         $user = htmlspecialchars($userObj->getName());
     } else {
         $user = Linker::link($userObj->getUserPage(), htmlspecialchars($userObj->getName()));
     }
     $nt = $userObj->getUserPage();
     $talk = $userObj->getTalkPage();
     $links = '';
     if ($talk) {
         $tools = $this->getUserLinks($nt, $talk, $userObj);
         $links = $this->getLanguage()->pipeList($tools);
         // Show a note if the user is blocked and display the last block log entry.
         // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
         // and also this will display a totally irrelevant log entry as a current block.
         if ($userObj->isBlocked() && $userObj->getBlock()->getType() != Block::TYPE_AUTO) {
             $out = $this->getOutput();
             // showLogExtract() wants first parameter by reference
             LogEventsList::showLogExtract($out, 'block', $nt, '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array($userObj->isAnon() ? 'sp-contributions-blocked-notice-anon' : 'sp-contributions-blocked-notice', $userObj->getName()), 'offset' => ''));
         }
     }
     // Old message 'contribsub' had one parameter, but that doesn't work for
     // languages that want to put the "for" bit right after $user but before
     // $links.  If 'contribsub' is around, use it for reverse compatibility,
     // otherwise use 'contribsub2'.
     // @todo Should this be removed at some point?
     $oldMsg = $this->msg('contribsub');
     if ($oldMsg->exists()) {
         $linksWithParentheses = $this->msg('parentheses')->rawParams($links)->escaped();
         return $oldMsg->rawParams("{$user} {$linksWithParentheses}");
     } else {
         return $this->msg('contribsub2')->rawParams($user, $links);
     }
 }
 /**
  * Display form for approving/denying request or process form submission.
  *
  * @param GlobalRenameRequest $req Pending request
  */
 protected function doShowProcessForm(GlobalRenameRequest $req)
 {
     $this->commonPreamble('globalrenamequeue-request-title', array($req->getName()));
     $form = HTMLForm::factory('vform', array('rid' => array('default' => $req->getId(), 'name' => 'rid', 'type' => 'hidden'), 'comments' => array('default' => $this->getRequest()->getVal('comments'), 'id' => 'mw-renamequeue-comments', 'label-message' => 'globalrenamequeue-request-comments-label', 'name' => 'comments', 'type' => 'textarea', 'rows' => 5), 'reason' => array('id' => 'mw-renamequeue-reason', 'label-message' => 'globalrenamequeue-request-reason-label', 'name' => 'reason', 'type' => 'text'), 'movepages' => array('id' => 'mw-renamequeue-movepages', 'name' => 'movepages', 'label-message' => 'globalrenamequeue-request-movepages', 'type' => 'check', 'default' => 1), 'suppressredirects' => array('id' => 'mw-renamequeue-suppressredirects', 'name' => 'suppressredirects', 'label-message' => 'globalrenamequeue-request-suppressredirects', 'type' => 'check')), $this->getContext(), 'globalrenamequeue');
     $form->suppressDefaultSubmit();
     $form->addButton('approve', $this->msg('globalrenamequeue-request-approve-text')->text(), 'mw-renamequeue-approve', array('class' => 'mw-ui-constructive mw-ui-flush-right'));
     $form->addButton('deny', $this->msg('globalrenamequeue-request-deny-text')->text(), 'mw-renamequeue-deny', array('class' => 'mw-ui-destructive mw-ui-flush-right'));
     $form->addButton('cancel', $this->msg('globalrenamequeue-request-cancel-text')->text(), 'mw-renamequeue-cancel', array('class' => 'mw-ui-quiet mw-ui-flush-left'));
     $form->setId('mw-globalrenamequeue-request');
     if ($req->userIsGlobal()) {
         $globalUser = new CentralAuthUser($req->getName());
         $homeWiki = $globalUser->getHomeWiki();
         $infoMsgKey = 'globalrenamequeue-request-userinfo-global';
     } else {
         $homeWiki = $req->getWiki();
         $infoMsgKey = 'globalrenamequeue-request-userinfo-local';
     }
     $headerMsg = $this->msg('globalrenamequeue-request-header', WikiMap::getForeignURL($homeWiki, "User:{$req->getName()}"), $req->getName(), $req->getNewName());
     $form->addHeaderText('<span class="plainlinks">' . $headerMsg->parseAsBlock() . '</span>');
     $homeWikiWiki = WikiMap::getWiki($homeWiki);
     $infoMsg = $this->msg($infoMsgKey, $req->getName(), $homeWikiWiki ? $homeWikiWiki->getDisplayName() : $homeWiki, $req->getNewName());
     $form->addHeaderText($infoMsg->parseAsBlock());
     if (class_exists('CentralAuthSpoofUser')) {
         $spoofUser = new CentralAuthSpoofUser($req->getNewName());
         // @todo move this code somewhere else
         $specialGblRename = new SpecialGlobalRenameUser();
         $specialGblRename->setContext($this->getContext());
         $conflicts = $specialGblRename->processAntiSpoofConflicts($req->getName(), $spoofUser->getConflicts());
         if ($conflicts) {
             $form->addHeaderText($this->msg('globalrenamequeue-request-antispoof-conflicts', $this->getLanguage()->commaList($conflicts))->numParams(count($conflicts))->parse());
         }
     }
     // Show a log entry of previous renames under the requesting user's username
     $caTitle = Title::makeTitleSafe(NS_SPECIAL, 'CentralAuth/' . $req->getName());
     $extract = '';
     $extractCount = LogEventsList::showLogExtract($extract, 'gblrename', $caTitle, '', array('showIfEmpty' => false));
     if ($extractCount) {
         $form->addHeaderText(Xml::fieldset($this->msg('globalrenamequeue-request-previous-renames')->numParams($extractCount)->text(), $extract));
     }
     $reason = $req->getReason() ?: $this->msg('globalrenamequeue-request-reason-sul')->parseAsBlock();
     $form->addHeaderText($this->msg('globalrenamequeue-request-reason', $reason)->parseAsBlock());
     $form->setSubmitCallback(array($this, 'onProcessSubmit'));
     $out = $this->getOutput();
     $out->addModuleStyles(array('mediawiki.ui', 'mediawiki.ui.button', 'mediawiki.ui.input', 'ext.centralauth.globalrenamequeue.styles'));
     $out->addModules('ext.centralauth.globalrenamequeue');
     $status = $form->show();
     if ($status instanceof Status && $status->isOk()) {
         $this->getOutput()->redirect($this->getPageTitle(self::PAGE_PROCESS_REQUEST . "/{$req->getId()}/{$status->value}")->getFullURL());
     }
 }
Esempio n. 24
0
    private function showHistory()
    {
        $this->showMergeForm();
        # List all stored revisions
        $revisions = new MergeHistoryPager($this, [], $this->mTargetObj, $this->mDestObj);
        $haveRevisions = $revisions && $revisions->getNumRows() > 0;
        $out = $this->getOutput();
        $titleObj = $this->getPageTitle();
        $action = $titleObj->getLocalURL(['action' => 'submit']);
        # Start the form here
        $top = Xml::openElement('form', ['method' => 'post', 'action' => $action, 'id' => 'merge']);
        $out->addHTML($top);
        if ($haveRevisions) {
            # Format the user-visible controls (comment field, submission button)
            # in a nice little table
            $table = Xml::openElement('fieldset') . $this->msg('mergehistory-merge', $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText())->parse() . Xml::openElement('table', ['id' => 'mw-mergehistory-table']) . '<tr>
						<td class="mw-label">' . Xml::label($this->msg('mergehistory-reason')->text(), 'wpComment') . '</td>
					<td class="mw-input">' . Xml::input('wpComment', 50, $this->mComment, ['id' => 'wpComment']) . '</td>
					</tr>
					<tr>
						<td>&#160;</td>
						<td class="mw-submit">' . Xml::submitButton($this->msg('mergehistory-submit')->text(), ['name' => 'merge', 'id' => 'mw-merge-submit']) . '</td>
					</tr>' . Xml::closeElement('table') . Xml::closeElement('fieldset');
            $out->addHTML($table);
        }
        $out->addHTML('<h2 id="mw-mergehistory">' . $this->msg('mergehistory-list')->escaped() . "</h2>\n");
        if ($haveRevisions) {
            $out->addHTML($revisions->getNavigationBar());
            $out->addHTML('<ul>');
            $out->addHTML($revisions->getBody());
            $out->addHTML('</ul>');
            $out->addHTML($revisions->getNavigationBar());
        } else {
            $out->addWikiMsg('mergehistory-empty');
        }
        # Show relevant lines from the merge log:
        $mergeLogPage = new LogPage('merge');
        $out->addHTML('<h2>' . $mergeLogPage->getName()->escaped() . "</h2>\n");
        LogEventsList::showLogExtract($out, 'merge', $this->mTargetObj);
        # When we submit, go by page ID to avoid some nasty but unlikely collisions.
        # Such would happen if a page was renamed after the form loaded, but before submit
        $misc = Html::hidden('targetID', $this->mTargetObj->getArticleID());
        $misc .= Html::hidden('destID', $this->mDestObj->getArticleID());
        $misc .= Html::hidden('target', $this->mTarget);
        $misc .= Html::hidden('dest', $this->mDest);
        $misc .= Html::hidden('wpEditToken', $this->getUser()->getEditToken());
        $misc .= Xml::closeElement('form');
        $out->addHTML($misc);
        return true;
    }
Esempio n. 25
0
 /**
  * Show protection long extracts for this page
  *
  * @param $out OutputPage
  * @access private
  */
 function showLogExtract(&$out)
 {
     # Show relevant lines from the protection log:
     $protectLogPage = new LogPage('protect');
     $out->addHTML(Xml::element('h2', null, $protectLogPage->getName()->text()));
     LogEventsList::showLogExtract($out, 'protect', $this->mTitle);
     # Let extensions add other relevant log extracts
     wfRunHooks('ProtectionForm::showLogExtract', array($this->mArticle, $out));
 }
	/**
	 * Generates the subheading with links
	 * @param $userObj User object for the target
	 * @return String: appropriately-escaped HTML to be output literally
	 * @todo FIXME: Almost the same as contributionsSub in SpecialContributions.php. Could be combined.
	 */
	function getSubTitle( $userObj ) {
		if ( $userObj->isAnon() ) {
			$user = htmlspecialchars( $userObj->getName() );
		} else {
			$user = Linker::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
		}
		$links = '';
		$nt = $userObj->getUserPage();
		$id = $userObj->getID();
		$talk = $nt->getTalkPage();
		if ( $talk ) {
			# Talk page link
			$tools[] = Linker::link( $talk, $this->msg( 'sp-contributions-talk' )->escaped() );
			if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) {
				# Block / Change block / Unblock links
				if ( $this->getUser()->isAllowed( 'block' ) ) {
					if ( $userObj->isBlocked() ) {
						$tools[] = Linker::linkKnown( # Change block link
							SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ),
							$this->msg( 'change-blocklink' )->escaped()
						);
						$tools[] = Linker::linkKnown( # Unblock link
							SpecialPage::getTitleFor( 'BlockList' ),
							$this->msg( 'unblocklink' )->escaped(),
							array(),
							array(
								'action' => 'unblock',
								'ip' => $nt->getDBkey()
							)
						);
					} else {
						# User is not blocked
						$tools[] = Linker::linkKnown( # Block link
							SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ),
							$this->msg( 'blocklink' )->escaped()
						);
					}
				}
				# Block log link
				$tools[] = Linker::linkKnown(
					SpecialPage::getTitleFor( 'Log' ),
					$this->msg( 'sp-contributions-blocklog' )->escaped(),
					array(),
					array(
						'type' => 'block',
						'page' => $nt->getPrefixedText()
					)
				);
			}

			# Uploads
			$tools[] = Linker::linkKnown(
				SpecialPage::getTitleFor( 'Listfiles', $userObj->getName() ),
				$this->msg( 'sp-contributions-uploads' )->escaped()
			);

			# Other logs link
			$tools[] = Linker::linkKnown(
				SpecialPage::getTitleFor( 'Log' ),
				$this->msg( 'sp-contributions-logs' )->escaped(),
				array(),
				array( 'user' => $nt->getText() )
			);
			# Link to contributions
			$tools[] = Linker::linkKnown(
				SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ),
				$this->msg( 'sp-deletedcontributions-contribs' )->escaped()
			);

			# Add a link to change user rights for privileged users
			$userrightsPage = new UserrightsPage();
			$userrightsPage->setContext( $this->getContext() );
			if ( $userrightsPage->userCanChangeRights( $userObj ) ) {
				$tools[] = Linker::linkKnown(
					SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ),
					$this->msg( 'sp-contributions-userrights' )->escaped()
				);
			}

			wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) );

			$links = $this->getLanguage()->pipeList( $tools );

			// Show a note if the user is blocked and display the last block log entry.
			if ( $userObj->isBlocked() ) {
				// LogEventsList::showLogExtract() wants the first parameter by ref
				$out = $this->getOutput();
				LogEventsList::showLogExtract(
					$out,
					'block',
					$nt,
					'',
					array(
						'lim' => 1,
						'showIfEmpty' => false,
						'msgKey' => array(
							'sp-contributions-blocked-notice',
							$nt->getText() # Support GENDER in 'sp-contributions-blocked-notice'
						),
						'offset' => '' # don't use $this->getRequest() parameter offset
					)
				);
			}
		}

		return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
	}
 function showLogFragment($title)
 {
     $moveLogPage = new LogPage('pagelang');
     $out1 = Xml::element('h2', null, $moveLogPage->getName()->text());
     $out2 = '';
     LogEventsList::showLogExtract($out2, 'pagelang', $title);
     return $out1 . $out2;
 }
Esempio n. 28
0
 public function execute($par)
 {
     $this->checkPermissions();
     $this->checkReadOnly();
     $output = $this->getOutput();
     $user = $this->getUser();
     $request = $this->getRequest();
     // Check blocks
     if ($user->isBlocked()) {
         throw new UserBlockedError($user->getBlock());
     }
     $this->setHeaders();
     $this->outputHeader();
     $this->getOutput()->addModules(['mediawiki.special.edittags', 'mediawiki.special.edittags.styles']);
     $this->submitClicked = $request->wasPosted() && $request->getBool('wpSubmit');
     // Handle our many different possible input types
     $ids = $request->getVal('ids');
     if (!is_null($ids)) {
         // Allow CSV from the form hidden field, or a single ID for show/hide links
         $this->ids = explode(',', $ids);
     } else {
         // Array input
         $this->ids = array_keys($request->getArray('ids', []));
     }
     $this->ids = array_unique(array_filter($this->ids));
     // No targets?
     if (count($this->ids) == 0) {
         throw new ErrorPageError('tags-edit-nooldid-title', 'tags-edit-nooldid-text');
     }
     $this->typeName = $request->getVal('type');
     $this->targetObj = Title::newFromText($request->getText('target'));
     // sanity check of parameter
     switch ($this->typeName) {
         case 'logentry':
         case 'logging':
             $this->typeName = 'logentry';
             break;
         default:
             $this->typeName = 'revision';
             break;
     }
     // Allow the list type to adjust the passed target
     // Yuck! Copied straight out of SpecialRevisiondelete, but it does exactly
     // what we want
     $this->targetObj = RevisionDeleter::suggestTarget($this->typeName === 'revision' ? 'revision' : 'logging', $this->targetObj, $this->ids);
     $this->isAllowed = $user->isAllowed('changetags');
     $this->reason = $request->getVal('wpReason');
     // We need a target page!
     if (is_null($this->targetObj)) {
         $output->addWikiMsg('undelete-header');
         return;
     }
     // Give a link to the logs/hist for this page
     $this->showConvenienceLinks();
     // Either submit or create our form
     if ($this->isAllowed && $this->submitClicked) {
         $this->submit();
     } else {
         $this->showForm();
     }
     // Show relevant lines from the tag log
     $tagLogPage = new LogPage('tag');
     $output->addHTML("<h2>" . $tagLogPage->getName()->escaped() . "</h2>\n");
     LogEventsList::showLogExtract($output, 'tag', $this->targetObj, '', ['lim' => 25, 'conds' => [], 'useMaster' => $this->wasSaved]);
 }
 /**
  * @param $group
  * @param $output OutputPage
  */
 protected function showLogFragment($group, $output)
 {
     $title = SpecialPage::getTitleFor('GlobalUsers', $group);
     $logPage = new LogPage('gblrights');
     $output->addHTML(Xml::element('h2', null, $logPage->getName()->text() . "\n"));
     LogEventsList::showLogExtract($output, 'gblrights', $title->getPrefixedText());
 }
Esempio n. 30
0
 private function showHistory()
 {
     global $wgLang, $wgContLang, $wgUser, $wgOut;
     $this->sk = $wgUser->getSkin();
     $wgOut->setPagetitle(wfMsg("mergehistory"));
     $this->showMergeForm();
     # List all stored revisions
     $revisions = new MergeHistoryPager($this, array(), $this->mTargetObj, $this->mDestObj);
     $haveRevisions = $revisions && $revisions->getNumRows() > 0;
     $titleObj = SpecialPage::getTitleFor("Mergehistory");
     $action = $titleObj->getLocalURL("action=submit");
     # Start the form here
     $top = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'merge'));
     $wgOut->addHTML($top);
     if ($haveRevisions) {
         # Format the user-visible controls (comment field, submission button)
         # in a nice little table
         $align = $wgContLang->isRtl() ? 'left' : 'right';
         $table = Xml::openElement('fieldset') . Xml::openElement('table') . "<tr>\n\t\t\t\t\t\t<td colspan='2'>" . wfMsgExt('mergehistory-merge', array('parseinline'), $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText()) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='{$align}'>" . Xml::label(wfMsg('undeletecomment'), 'wpComment') . "</td>\n\t\t\t\t\t\t<td>" . Xml::input('wpComment', 50, $this->mComment) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t\t<td>" . Xml::submitButton(wfMsg('mergehistory-submit'), array('name' => 'merge', 'id' => 'mw-merge-submit')) . "</td>\n\t\t\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('fieldset');
         $wgOut->addHTML($table);
     }
     $wgOut->addHTML("<h2 id=\"mw-mergehistory\">" . wfMsgHtml("mergehistory-list") . "</h2>\n");
     if ($haveRevisions) {
         $wgOut->addHTML($revisions->getNavigationBar());
         $wgOut->addHTML("<ul>");
         $wgOut->addHTML($revisions->getBody());
         $wgOut->addHTML("</ul>");
         $wgOut->addHTML($revisions->getNavigationBar());
     } else {
         $wgOut->addWikiMsg("mergehistory-empty");
     }
     # Show relevant lines from the deletion log:
     $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('merge')) . "</h2>\n");
     LogEventsList::showLogExtract($wgOut, 'merge', $this->mTargetObj->getPrefixedText());
     # When we submit, go by page ID to avoid some nasty but unlikely collisions.
     # Such would happen if a page was renamed after the form loaded, but before submit
     $misc = Xml::hidden('targetID', $this->mTargetObj->getArticleID());
     $misc .= Xml::hidden('destID', $this->mDestObj->getArticleID());
     $misc .= Xml::hidden('target', $this->mTarget);
     $misc .= Xml::hidden('dest', $this->mDest);
     $misc .= Xml::hidden('wpEditToken', $wgUser->editToken());
     $misc .= Xml::closeElement('form');
     $wgOut->addHTML($misc);
     return true;
 }