/**
  * @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());
 }
 function getLogTitle($rc)
 {
     $logtype = $rc->getAttribute('rc_log_type');
     $logpage = new LogPage($logtype);
     $logname = $logpage->getName()->escaped();
     $titleObj = SpecialPage::getTitleFor('Log', $logtype);
     return '(' . $this->skin->makeKnownLinkObj($titleObj, $logname) . ')';
 }
    public function showForm($err = null)
    {
        $out = $this->getOutput();
        $form = $this->form;
        // convenience
        $title = $this->form->getPage();
        $oldConfig = $form->getOldConfig();
        $s = '';
        // form HTML string
        # Add any error messages
        if ("" != $err) {
            $out->setSubtitle($this->msg('formerror'));
            $out->addHTML("<p class='error'>{$err}</p>\n");
        }
        # Add header text
        if (!$form->isAllowed()) {
            $s .= $this->msg('stabilization-perm', $title->getPrefixedText())->parseAsBlock();
        } else {
            $s .= $this->msg('stabilization-text', $title->getPrefixedText())->parseAsBlock();
        }
        # Traditionally, the list of reasons for stabilization is the same as
        # for protection.  In some cases, however, it might be desirable to
        # use a different list for stabilization.
        $defaultReasons = $this->msg('stabilization-dropdown');
        if ($defaultReasons->isDisabled()) {
            $defaultReasons = $this->msg('protect-dropdown');
        }
        $reasonDropDown = Xml::listDropDown('wpReasonSelection', $defaultReasons->inContentLanguage()->text(), $this->msg('protect-otherreason-op')->inContentLanguage()->text(), $form->getReasonSelection(), 'mwStabilize-reason', 4);
        $scExpiryOptions = $this->msg('protect-expiry-options')->inContentLanguage()->text();
        $showProtectOptions = $scExpiryOptions !== '-' && $form->isAllowed();
        $dropdownOptions = array();
        // array of <label,value>
        # Add the current expiry as a dropdown option
        if ($oldConfig['expiry'] && $oldConfig['expiry'] != 'infinity') {
            $timestamp = $this->getLanguage()->timeanddate($oldConfig['expiry']);
            $d = $this->getLanguage()->date($oldConfig['expiry']);
            $t = $this->getLanguage()->time($oldConfig['expiry']);
            $dropdownOptions[] = array($this->msg('protect-existing-expiry', $timestamp, $d, $t)->text(), 'existing');
        }
        # Add "other time" expiry dropdown option
        $dropdownOptions[] = array($this->msg('protect-othertime-op')->text(), 'othertime');
        # Add custom expiry dropdown options (from MediaWiki message)
        foreach (explode(',', $scExpiryOptions) as $option) {
            if (strpos($option, ":") === false) {
                $show = $value = $option;
            } else {
                list($show, $value) = explode(":", $option);
            }
            $dropdownOptions[] = array($show, $value);
        }
        # Actually build the options HTML...
        $expiryFormOptions = '';
        foreach ($dropdownOptions as $option) {
            $show = htmlspecialchars($option[0]);
            $value = htmlspecialchars($option[1]);
            $expiryFormOptions .= Xml::option($show, $value, $form->getExpirySelection() === $value) . "\n";
        }
        # Build up the form...
        $s .= Xml::openElement('form', array('name' => 'stabilization', 'action' => $this->getPageTitle()->getLocalUrl(), 'method' => 'post'));
        # Add stable version override and selection options
        $s .= Xml::fieldset($this->msg('stabilization-def')->text(), false) . "\n" . Xml::radioLabel($this->msg('stabilization-def1')->text(), 'wpStableconfig-override', 1, 'default-stable', 1 == $form->getOverride(), $this->disabledAttr()) . '<br />' . "\n" . Xml::radioLabel($this->msg('stabilization-def2')->text(), 'wpStableconfig-override', 0, 'default-current', 0 == $form->getOverride(), $this->disabledAttr()) . "\n" . Xml::closeElement('fieldset');
        # Add autoreview restriction select
        $s .= Xml::fieldset($this->msg('stabilization-restrict')->text(), false) . $this->buildSelector($form->getAutoreview()) . Xml::closeElement('fieldset') . Xml::fieldset($this->msg('stabilization-leg')->text(), false) . Xml::openElement('table');
        # Add expiry dropdown to form...
        if ($showProtectOptions && $form->isAllowed()) {
            $s .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('stabilization-expiry')->text(), 'mwStabilizeExpirySelection') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::tags('select', array('id' => 'mwStabilizeExpirySelection', 'name' => 'wpExpirySelection', 'onchange' => 'onFRChangeExpiryDropdown()') + $this->disabledAttr(), $expiryFormOptions) . "</td>\n\t\t\t\t</tr>";
        }
        # Add custom expiry field to form...
        $attribs = array('id' => "mwStabilizeExpiryOther", 'onkeyup' => 'onFRChangeExpiryField()') + $this->disabledAttr();
        $s .= "\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('stabilization-othertime')->text(), 'mwStabilizeExpiryOther') . '</td>
				<td class="mw-input">' . Xml::input("mwStabilize-expiry", 50, $form->getExpiryCustom(), $attribs) . '</td>
			</tr>';
        # Add comment input and submit button
        if ($form->isAllowed()) {
            $watchLabel = $this->msg('watchthis')->parse();
            $watchAttribs = array('accesskey' => $this->msg('accesskey-watch')->text(), 'id' => 'wpWatchthis');
            $watchChecked = $this->getUser()->getOption('watchdefault') || $title->userIsWatching();
            $reviewLabel = $this->msg('stabilization-review')->parse();
            $s .= ' <tr>
					<td class="mw-label">' . xml::label($this->msg('stabilization-comment')->text(), 'wpReasonSelection') . '</td>
					<td class="mw-input">' . $reasonDropDown . '</td>
				</tr>
				<tr>
					<td class="mw-label">' . Xml::label($this->msg('stabilization-otherreason')->text(), 'wpReason') . '</td>
					<td class="mw-input">' . Xml::input('wpReason', 70, $form->getReasonExtra(), array('id' => 'wpReason', 'maxlength' => 255)) . '</td>
				</tr>
				<tr>
					<td></td>
					<td class="mw-input">' . Xml::check('wpReviewthis', $form->getReviewThis(), array('id' => 'wpReviewthis')) . "<label for='wpReviewthis'>{$reviewLabel}</label>" . '&#160;&#160;&#160;&#160;&#160;' . Xml::check('wpWatchthis', $watchChecked, $watchAttribs) . "&#160;<label for='wpWatchthis' " . Xml::expandAttributes(array('title' => Linker::titleAttrib('watch', 'withaccess'))) . ">{$watchLabel}</label>" . '</td>
				</tr>
				<tr>
					<td></td>
					<td class="mw-submit">' . Xml::submitButton($this->msg('stabilization-submit')->text()) . '</td>
				</tr>' . Xml::closeElement('table') . Html::hidden('title', $this->getPageTitle()->getPrefixedDBKey()) . Html::hidden('page', $title->getPrefixedText()) . Html::hidden('wpEditToken', $this->getUser()->getEditToken());
        } else {
            $s .= Xml::closeElement('table');
        }
        $s .= Xml::closeElement('fieldset') . Xml::closeElement('form');
        $out->addHTML($s);
        $log = new LogPage('stable');
        $out->addHTML(Xml::element('h2', null, htmlspecialchars($log->getName())));
        LogEventsList::showLogExtract($out, 'stable', $title->getPrefixedText(), '', array('lim' => 25));
        # Add some javascript for expiry dropdowns
        $out->addScript("<script type=\"text/javascript\">\n\t\t\t\tfunction onFRChangeExpiryDropdown() {\n\t\t\t\t\tdocument.getElementById('mwStabilizeExpiryOther').value = '';\n\t\t\t\t}\n\t\t\t\tfunction onFRChangeExpiryField() {\n\t\t\t\t\tdocument.getElementById('mwStabilizeExpirySelection').value = 'othertime';\n\t\t\t\t}\n\t\t\t</script>");
    }
 /**
  * @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());
 }
    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;
    }
 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;
 }
Exemple #8
0
 /**
  * Set page title and show header for this log type
  * @param string $type
  * @since 1.19
  */
 protected function addHeader($type)
 {
     $page = new LogPage($type);
     $this->getOutput()->setPageTitle($page->getName());
     $this->getOutput()->addHTML($page->getDescription()->setContext($this->getContext())->parseAsBlock());
 }
Exemple #9
0
 /**
  * Returns log page selector.
  * @return XmlSelect
  * @since 1.19
  */
 public function getTypeSelector()
 {
     $typesByName = array();
     // Temporary array
     // First pass to load the log names
     foreach (LogPage::validTypes() as $type) {
         $page = new LogPage($type);
         $restriction = $page->getRestriction();
         if ($this->getUser()->isAllowed($restriction)) {
             $typesByName[$type] = $page->getName()->text();
         }
     }
     // Second pass to sort by name
     asort($typesByName);
     // Always put "All public logs" on top
     $public = $typesByName[''];
     unset($typesByName['']);
     $typesByName = array('' => $public) + $typesByName;
     $select = new XmlSelect('type');
     foreach ($typesByName as $type => $name) {
         $select->addOption($name, $type);
     }
     return $select;
 }
 /**
  * @param $username Title
  * @param $type
  * @param $out OutputPage
  */
 function showLogExtract($username, $type, &$out)
 {
     # Show relevant lines from the logs:
     $logPage = new LogPage($type);
     $out->addHTML(Xml::element('h2', null, $logPage->getName()->text()) . "\n");
     LogEventsList::showLogExtract($out, $type, $username->getPrefixedText());
 }
 private function getLogLink($logType)
 {
     $logtitle = SpecialPage::getTitleFor('Log', $logType);
     $logpage = new LogPage($logType);
     $logname = $logpage->getName()->escaped();
     $logLink = $this->context->msg('parentheses')->rawParams(Linker::linkKnown($logtitle, $logname))->escaped();
     return $logLink;
 }
Exemple #12
0
 /**
  * Format a line for enhanced recentchange (aka with javascript and block of lines).
  *
  * @param $baseRC RecentChange
  * @param $watched bool
  *
  * @return string
  */
 public function recentChangesLine(&$baseRC, $watched = false)
 {
     wfProfileIn(__METHOD__);
     # Create a specialised object
     $rc = RCCacheEntry::newFromParent($baseRC);
     # If it's a new day, add the headline and flush the cache
     $date = $this->getLanguage()->date($rc->mAttribs['rc_timestamp'], true);
     $ret = '';
     if ($date != $this->lastdate) {
         # Process current cache
         $ret = $this->recentChangesBlock();
         $this->rc_cache = array();
         $ret .= Xml::element('h4', null, $date) . "\n";
         $this->lastdate = $date;
     }
     # Should patrol-related stuff be shown?
     $rc->unpatrolled = $this->showAsUnpatrolled($rc);
     $linksCache = $this->lineLinksCache($rc, $rc->unpatrolled);
     $showdifflinks = true;
     # Make article link
     $type = $rc->mAttribs['rc_type'];
     $logType = $rc->mAttribs['rc_log_type'];
     // Page moves, very old style, not supported anymore
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         // New unpatrolled pages
     } elseif ($rc->unpatrolled && $type == RC_NEW) {
         $clink = $linksCache['clink_unpatrolled'];
         // Log entries
     } elseif ($type == RC_LOG) {
         if ($logType) {
             $logtitle = SpecialPage::getTitleFor('Log', $logType);
             $logpage = new LogPage($logType);
             $logname = $logpage->getName()->escaped();
             $clink = '(' . Linker::linkKnown($logtitle, $logname) . ')';
         } else {
             $clink = $linksCache['clink'];
         }
         $watched = false;
         // Log entries (old format) and special pages
     } elseif ($rc->mAttribs['rc_namespace'] == NS_SPECIAL) {
         wfDebug("Unexpected special page in recentchanges\n");
         $clink = '';
         // Edits
     } else {
         $clink = $linksCache['clink'];
     }
     # Don't show unusable diff links
     if (!ChangesList::userCan($rc, Revision::DELETED_TEXT, $this->getUser())) {
         $showdifflinks = false;
     }
     $time = $this->getLanguage()->time($rc->mAttribs['rc_timestamp'], true, true);
     $rc->watched = $watched;
     $rc->link = $clink;
     $rc->timestamp = $time;
     $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
     if (!$showdifflinks) {
         $curLink = $this->message['cur'];
         $diffLink = $this->message['diff'];
     } else {
         $rc->curlink = $linksCache['cur'];
         $rc->difflink = $linksCache['diff'];
     }
     # Make "last" link
     if (!$showdifflinks || !$lastOldid) {
         $lastLink = $this->message['last'];
     } else {
         $rc->lastlink = $linksCache['last'];
     }
     # Make user links
     $rc->userlink = $linksCache['userlink'];
     $rc->usertalklink = $linksCache['usertalklink'];
     # Put accumulated information into the cache, for later display
     # Page moves go on their own line
     $title = $rc->getTitle();
     $secureName = $title->getPrefixedDBkey();
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         # Use an @ character to prevent collision with page names
         $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc);
     } else {
         # Logs are grouped by type
         if ($type == RC_LOG) {
             $secureName = SpecialPage::getTitleFor('Log', $logType)->getPrefixedDBkey();
         }
         // Start of Wikia change - @author unknown
         wfRunHooks('ChangesListMakeSecureName', array($this, &$secureName, $rc));
         // End of Wikia change
         if (!isset($this->rc_cache[$secureName])) {
             $this->rc_cache[$secureName] = array();
         }
         array_push($this->rc_cache[$secureName], $rc);
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
Exemple #13
0
 /**
  * @param string $s HTML to update
  * @param Title $title
  * @param string $logtype
  */
 public function insertLog(&$s, $title, $logtype)
 {
     $page = new LogPage($logtype);
     $logname = $page->getName()->setContext($this->getContext())->text();
     $s .= $this->msg('parentheses')->rawParams($this->linkRenderer->makeKnownLink($title, $logname))->escaped();
 }
 /**
  * @param string $number
  */
 protected function showLogFragment($number)
 {
     $title = SpecialPage::getTitleFor('WikiSets', $number);
     $logPage = new LogPage('gblrights');
     $out = $this->getOutput();
     $out->addHTML(Xml::element('h2', null, $logPage->getName()->text() . "\n"));
     LogEventsList::showLogExtract($out, 'gblrights', $title->getPrefixedText());
 }
 private function showHistory()
 {
     # List all stored revisions
     $revisions = new MergeHistoryPager($this, [], $this->mTargetObj, $this->mDestObj);
     $haveRevisions = $revisions && $revisions->getNumRows() > 0;
     $out = $this->getOutput();
     $header = '<h2 id="mw-mergehistory">' . $this->msg('mergehistory-list')->escaped() . "</h2>\n";
     if ($haveRevisions) {
         $hiddenFields = ['merge' => true, 'target' => $this->mOpts->getValue('target'), 'dest' => $this->mOpts->getValue('dest')];
         $formDescriptor = ['reason' => ['type' => 'text', 'name' => 'reason', 'label-message' => 'mergehistory-reason']];
         $mergeText = $this->msg('mergehistory-merge', $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText())->parse();
         $history = $header . $revisions->getNavigationBar() . '<ul>' . $revisions->getBody() . '</ul>' . $revisions->getNavigationBar();
         $form = HTMLForm::factory('ooui', $formDescriptor, $this->getContext())->addHiddenFields($hiddenFields)->setPreText($mergeText)->setFooterText($history)->setSubmitTextMsg('mergehistory-submit')->setMethod('post')->prepareForm()->displayForm(false);
     } else {
         $out->addHTML($header);
         $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);
 }
	/**
	 * Enhanced RC ungrouped line.
	 *
	 * @param $rcObj RecentChange
	 * @return String: a HTML formatted line (generated using $r)
	 */
	protected function recentChangesBlockLine( $rcObj ) {
		global $wgRCShowChangedSize;

		wfProfileIn( __METHOD__ );
		$query['curid'] = $rcObj->mAttribs['rc_cur_id'];

		$type = $rcObj->mAttribs['rc_type'];
		$logType = $rcObj->mAttribs['rc_log_type'];
		$classes = array( 'mw-enhanced-rc' );
		if ( $logType ) {
			# Log entry
+			$classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
		} else {
			$classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
					$rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
		}
		$classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
			? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
		$r = Html::openElement( 'table', array( 'class' => $classes ) ) .
			Html::openElement( 'tr' );

		$r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
		# Flag and Timestamp
		if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
			$r .= $this->recentChangesFlags( array() ); // no flags, but need the placeholders
		} else {
			$r .= $this->recentChangesFlags( array(
				'newpage' => $type == RC_NEW,
				'minor' => $rcObj->mAttribs['rc_minor'],
				'unpatrolled' => $rcObj->unpatrolled,
				'bot' => $rcObj->mAttribs['rc_bot'],
			) );
		}
		$r .= '&#160;' . $rcObj->timestamp . '&#160;</td><td>';
		# Article or log link
		if ( $logType ) {
			$logPage = new LogPage( $logType );
			$logTitle = SpecialPage::getTitleFor( 'Log', $logType );
			$logName = $logPage->getName()->escaped();
			$r .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $logTitle, $logName ) )->escaped();
		} else {
			$this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
		}
		# Diff and hist links
		if ( $type != RC_LOG ) {
			$query['action'] = 'history';
			$r .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown(
				$rcObj->getTitle(),
				$this->message['hist'],
				array(),
				$query
			) )->escaped();
		}
		$r .= ' <span class="mw-changeslist-separator">. .</span> ';
		# Character diff
		if ( $wgRCShowChangedSize ) {
			$cd = $this->formatCharacterDifference( $rcObj );
			if ( $cd !== '' ) {
				$r .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
			}
		}

		if ( $type == RC_LOG ) {
			$r .= $this->insertLogEntry( $rcObj );
		} else {
			$r .= ' ' . $rcObj->userlink . $rcObj->usertalklink;
			$r .= $this->insertComment( $rcObj );
			$this->insertRollback( $r, $rcObj );
		}

		# Tags
		$this->insertTags( $r, $rcObj, $classes );
		# Show how many people are watching this if enabled
		$r .= $this->numberofWatchingusers( $rcObj->numberofWatchingusers );

		$r .= "</td></tr></table>\n";

		wfProfileOut( __METHOD__ );

		return $r;
	}
 function showLogFragment($title)
 {
     $moveLogPage = new LogPage('move');
     $out = $this->getOutput();
     $out->addHTML(Xml::element('h2', null, $moveLogPage->getName()->text()));
     LogEventsList::showLogExtract($out, 'move', $title);
 }
 /**
  * Show a rights log fragment for the specified user
  *
  * @param User $user User to show log for
  * @param OutputPage $output OutputPage to use
  */
 protected function showLogFragment($user, $output)
 {
     $rightsLogPage = new LogPage('rights');
     $output->addHTML(Xml::element('h2', null, $rightsLogPage->getName()->text()));
     LogEventsList::showLogExtract($output, 'rights', $user->getUserPage());
 }
 function showLogFragment($title)
 {
     $moveLogPage = new LogPage('pagelang');
     $out1 = Xml::element('h2', null, $moveLogPage->getName()->text());
     $out2 = '';
     LogEventsList::showLogExtract($out2, 'pagelang', $title);
     return $out1 . $out2;
 }
 /**
  * Show deletion log fragments pertaining to the current file
  */
 private function showLogEntries()
 {
     global $wgOut;
     $deleteLogPage = new LogPage('delete');
     $wgOut->addHTML('<h2>' . $deleteLogPage->getName()->escaped() . "</h2>\n");
     LogEventsList::showLogExtract($wgOut, 'delete', $this->title);
 }
Exemple #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);
         }
     }
 }
Exemple #22
0
 /**
  * TODO document
  * @param  $type String
  * @param  $lang Language or null
  * @param  $title Title
  * @param  $params Array
  * @return String
  */
 protected static function getTitleLink($type, $lang, $title, &$params)
 {
     if (!$lang) {
         return $title->getPrefixedText();
     }
     switch ($type) {
         case 'move':
             $titleLink = Linker::link($title, htmlspecialchars($title->getPrefixedText()), array(), array('redirect' => 'no'));
             $targetTitle = Title::newFromText($params[0]);
             if (!$targetTitle) {
                 # Workaround for broken database
                 $params[0] = htmlspecialchars($params[0]);
             } else {
                 $params[0] = Linker::link($targetTitle, htmlspecialchars($params[0]));
             }
             break;
         case 'block':
             if (substr($title->getText(), 0, 1) == '#') {
                 $titleLink = $title->getText();
             } else {
                 // @todo Store the user identifier in the parameters
                 // to make this faster for future log entries
                 $id = User::idFromName($title->getText());
                 $titleLink = Linker::userLink($id, $title->getText()) . Linker::userToolLinks($id, $title->getText(), false, Linker::TOOL_LINKS_NOBLOCK);
             }
             break;
         case 'merge':
             $titleLink = Linker::link($title, $title->getPrefixedText(), array(), array('redirect' => 'no'));
             $params[0] = Linker::link(Title::newFromText($params[0]), htmlspecialchars($params[0]));
             $params[1] = $lang->timeanddate($params[1]);
             break;
         default:
             if ($title->isSpecialPage()) {
                 list($name, $par) = SpecialPageFactory::resolveAlias($title->getDBkey());
                 # Use the language name for log titles, rather than Log/X
                 if ($name == 'Log') {
                     $logPage = new LogPage($par);
                     $titleLink = Linker::link($title, $logPage->getName()->escaped());
                     $titleLink = wfMessage('parentheses')->inLanguage($lang)->rawParams($titleLink)->escaped();
                 } else {
                     $titleLink = Linker::link($title);
                 }
             } else {
                 $titleLink = Linker::link($title);
             }
     }
     return $titleLink;
 }
 /**
  * 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));
 }
Exemple #24
0
 /**
  * @param string $s HTML to update
  * @param Title $title
  * @param string $logtype
  */
 public function insertLog(&$s, $title, $logtype)
 {
     $page = new LogPage($logtype);
     $logname = $page->getName()->escaped();
     $s .= $this->msg('parentheses')->rawParams(Linker::linkKnown($title, $logname))->escaped();
 }
 public function execute($par)
 {
     $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));
     if ($request->getVal('action') == 'historysubmit' || $request->getVal('action') == 'revisiondelete') {
         // For show/hide form submission from history page
         // Since we are access through index.php?title=XXX&action=historysubmit
         // getFullTitle() will contain the target title and not our title
         $this->targetObj = $this->getFullTitle();
         $this->typeName = 'revision';
     } else {
         $this->typeName = $request->getVal('type');
         $this->targetObj = Title::newFromText($request->getText('target'));
         if ($this->targetObj && $this->targetObj->isSpecial('Log') && count($this->ids) !== 0) {
             $result = wfGetDB(DB_SLAVE)->select('logging', 'log_type', array('log_id' => $this->ids), __METHOD__, array('DISTINCT'));
             if ($result->numRows() == 1) {
                 // If there's only one type, the target can be set to include it.
                 $this->targetObj = SpecialPage::getTitleFor('Log', $result->current()->log_type);
             }
         }
     }
     # For reviewing deleted files...
     $this->archiveName = $request->getVal('file');
     $this->token = $request->getVal('token');
     if ($this->archiveName && $this->targetObj) {
         $this->tryShowFile($this->archiveName);
         return;
     }
     if (isset(self::$deprecatedTypeMap[$this->typeName])) {
         $this->typeName = self::$deprecatedTypeMap[$this->typeName];
     }
     # No targets?
     if (!isset(self::$allowedTypes[$this->typeName]) || count($this->ids) == 0) {
         throw new ErrorPageError('revdelete-nooldid-title', 'revdelete-nooldid-text');
     }
     $this->typeInfo = self::$allowedTypes[$this->typeName];
     $this->mIsAllowed = $user->isAllowed($this->typeInfo['permission']);
     # 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 ($this->typeName == 'revision') {
         $rev = Revision::newFromId($this->ids[0]);
         $this->targetObj = $rev ? $rev->getTitle() : $this->targetObj;
     }
     $this->otherReason = $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();
     # Initialise checkboxes
     $this->checks = array(array($this->typeInfo['check-label'], 'wpHidePrimary', $this->typeInfo['deletion-bits']), 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));
     # 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));
     }
 }
 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]);
 }
 /**
  * Format a line for enhanced recentchange (aka with javascript and block of lines).
  *
  * @param $baseRC RecentChange
  * @param $watched bool
  *
  * @return string
  */
 public function recentChangesLine(&$baseRC, $watched = false)
 {
     wfProfileIn(__METHOD__);
     # Create a specialised object
     $rc = RCCacheEntry::newFromParent($baseRC);
     $curIdEq = array('curid' => $rc->mAttribs['rc_cur_id']);
     # If it's a new day, add the headline and flush the cache
     $date = $this->getLanguage()->date($rc->mAttribs['rc_timestamp'], true);
     $ret = '';
     if ($date != $this->lastdate) {
         # Process current cache
         $ret = $this->recentChangesBlock();
         $this->rc_cache = array();
         $ret .= Xml::element('h4', null, $date) . "\n";
         $this->lastdate = $date;
     }
     # Should patrol-related stuff be shown?
     $rc->unpatrolled = $this->showAsUnpatrolled($rc);
     $showdifflinks = true;
     # Make article link
     $type = $rc->mAttribs['rc_type'];
     $logType = $rc->mAttribs['rc_log_type'];
     // Page moves, very old style, not supported anymore
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         // New unpatrolled pages
     } elseif ($rc->unpatrolled && $type == RC_NEW) {
         $clink = Linker::linkKnown($rc->getTitle(), null, array(), array('rcid' => $rc->mAttribs['rc_id']));
         // Log entries
     } elseif ($type == RC_LOG) {
         if ($logType) {
             $logtitle = SpecialPage::getTitleFor('Log', $logType);
             $logpage = new LogPage($logType);
             $logname = $logpage->getName()->escaped();
             $clink = '(' . Linker::linkKnown($logtitle, $logname) . ')';
         } else {
             $clink = Linker::link($rc->getTitle());
         }
         $watched = false;
         // Log entries (old format) and special pages
     } elseif ($rc->mAttribs['rc_namespace'] == NS_SPECIAL) {
         wfDebug("Unexpected special page in recentchanges\n");
         $clink = '';
         // Edits
     } else {
         $clink = Linker::linkKnown($rc->getTitle());
     }
     # Don't show unusable diff links
     if (!ChangesList::userCan($rc, Revision::DELETED_TEXT, $this->getUser())) {
         $showdifflinks = false;
     }
     $time = $this->getLanguage()->time($rc->mAttribs['rc_timestamp'], true, true);
     $rc->watched = $watched;
     $rc->link = $clink;
     $rc->timestamp = $time;
     $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
     # Make "cur" and "diff" links.  Do not use link(), it is too slow if
     # called too many times (50% of CPU time on RecentChanges!).
     $thisOldid = $rc->mAttribs['rc_this_oldid'];
     $lastOldid = $rc->mAttribs['rc_last_oldid'];
     if ($rc->unpatrolled) {
         $rcIdQuery = array('rcid' => $rc->mAttribs['rc_id']);
     } else {
         $rcIdQuery = array();
     }
     $querycur = $curIdEq + array('diff' => '0', 'oldid' => $thisOldid);
     $querydiff = $curIdEq + array('diff' => $thisOldid, 'oldid' => $lastOldid) + $rcIdQuery;
     if (!$showdifflinks) {
         $curLink = $this->message['cur'];
         $diffLink = $this->message['diff'];
     } elseif (in_array($type, array(RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT))) {
         if ($type != RC_NEW) {
             $curLink = $this->message['cur'];
         } else {
             $curUrl = htmlspecialchars($rc->getTitle()->getLinkURL($querycur));
             $curLink = "<a href=\"{$curUrl}\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
         }
         $diffLink = $this->message['diff'];
     } else {
         $diffUrl = htmlspecialchars($rc->getTitle()->getLinkURL($querydiff));
         $curUrl = htmlspecialchars($rc->getTitle()->getLinkURL($querycur));
         $diffLink = "<a href=\"{$diffUrl}\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
         $curLink = "<a href=\"{$curUrl}\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
     }
     # Make "last" link
     if (!$showdifflinks || !$lastOldid) {
         $lastLink = $this->message['last'];
     } elseif (in_array($type, array(RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT))) {
         $lastLink = $this->message['last'];
     } else {
         $lastLink = Linker::linkKnown($rc->getTitle(), $this->message['last'], array(), $curIdEq + array('diff' => $thisOldid, 'oldid' => $lastOldid) + $rcIdQuery);
     }
     # Make user links
     if ($this->isDeleted($rc, Revision::DELETED_USER)) {
         $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
     } else {
         $rc->userlink = Linker::userLink($rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text']);
         $rc->usertalklink = Linker::userToolLinks($rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text']);
     }
     $rc->lastlink = $lastLink;
     $rc->curlink = $curLink;
     $rc->difflink = $diffLink;
     # Put accumulated information into the cache, for later display
     # Page moves go on their own line
     $title = $rc->getTitle();
     $secureName = $title->getPrefixedDBkey();
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         # Use an @ character to prevent collision with page names
         $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc);
     } else {
         # Logs are grouped by type
         if ($type == RC_LOG) {
             $secureName = SpecialPage::getTitleFor('Log', $logType)->getPrefixedDBkey();
         }
         if (!isset($this->rc_cache[$secureName])) {
             $this->rc_cache[$secureName] = array();
         }
         array_push($this->rc_cache[$secureName], $rc);
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
Exemple #28
0
 /**
  * @todo Document
  * @param string $type
  * @param Language|null $lang
  * @param Title $title
  * @param array $params
  * @return string
  */
 protected static function getTitleLink($type, $lang, $title, &$params)
 {
     if (!$lang) {
         return $title->getPrefixedText();
     }
     if ($title->isSpecialPage()) {
         list($name, $par) = SpecialPageFactory::resolveAlias($title->getDBkey());
         # Use the language name for log titles, rather than Log/X
         if ($name == 'Log') {
             $logPage = new LogPage($par);
             $titleLink = Linker::link($title, $logPage->getName()->escaped());
             $titleLink = wfMessage('parentheses')->inLanguage($lang)->rawParams($titleLink)->escaped();
         } else {
             $titleLink = Linker::link($title);
         }
     } else {
         $titleLink = Linker::link($title);
     }
     return $titleLink;
 }
 /**
  * Enhanced RC ungrouped line.
  *
  * @param RecentChange|RCCacheEntry $rcObj
  * @return string A HTML formatted line (generated using $r)
  */
 protected function recentChangesBlockLine($rcObj)
 {
     $data = array();
     $query['curid'] = $rcObj->mAttribs['rc_cur_id'];
     $type = $rcObj->mAttribs['rc_type'];
     $logType = $rcObj->mAttribs['rc_log_type'];
     $classes = array('mw-enhanced-rc');
     if ($logType) {
         # Log entry
         $classes[] = Sanitizer::escapeClass('mw-changeslist-log-' . $logType);
     } else {
         $classes[] = Sanitizer::escapeClass('mw-changeslist-ns' . $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title']);
     }
     $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
     # Flag and Timestamp
     $data['recentChangesFlags'] = array('newpage' => $type == RC_NEW, 'minor' => $rcObj->mAttribs['rc_minor'], 'unpatrolled' => $rcObj->unpatrolled, 'bot' => $rcObj->mAttribs['rc_bot']);
     // timestamp is not really a link here, but is called timestampLink
     // for consistency with EnhancedChangesListModifyLineData
     $data['timestampLink'] = $rcObj->timestamp;
     # Article or log link
     if ($logType) {
         $logPage = new LogPage($logType);
         $logTitle = SpecialPage::getTitleFor('Log', $logType);
         $logName = $logPage->getName()->escaped();
         $data['logLink'] = $this->msg('parentheses')->rawParams(Linker::linkKnown($logTitle, $logName))->escaped();
     } else {
         $data['articleLink'] = $this->getArticleLink($rcObj, $rcObj->unpatrolled, $rcObj->watched);
     }
     # Diff and hist links
     if ($type != RC_LOG) {
         $query['action'] = 'history';
         $data['historyLink'] = ' ' . $this->msg('parentheses')->rawParams($rcObj->difflink . $this->message['pipe-separator'] . Linker::linkKnown($rcObj->getTitle(), $this->message['hist'], array(), $query))->escaped();
     }
     $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator">. .</span> ';
     # Character diff
     if ($this->getConfig()->get('RCShowChangedSize')) {
         $cd = $this->formatCharacterDifference($rcObj);
         if ($cd !== '') {
             $data['characterDiff'] = $cd;
             $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator">. .</span> ';
         }
     }
     if ($type == RC_LOG) {
         $data['logEntry'] = $this->insertLogEntry($rcObj);
     } else {
         $data['userLink'] = $rcObj->userlink;
         $data['userTalkLink'] = $rcObj->usertalklink;
         $data['comment'] = $this->insertComment($rcObj);
         $data['rollback'] = $this->getRollback($rcObj);
     }
     # Tags
     $data['tags'] = $this->getTags($rcObj, $classes);
     # Show how many people are watching this if enabled
     $data['watchingUsers'] = $this->numberofWatchingusers($rcObj->numberofWatchingusers);
     // give the hook a chance to modify the data
     $success = Hooks::run('EnhancedChangesListModifyBlockLineData', array($this, &$data, $rcObj));
     if (!$success) {
         // skip entry if hook aborted it
         return '';
     }
     $line = Html::openElement('table', array('class' => $classes)) . Html::openElement('tr');
     $line .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
     if (isset($data['recentChangesFlags'])) {
         $line .= $this->recentChangesFlags($data['recentChangesFlags']);
         unset($data['recentChangesFlags']);
     }
     if (isset($data['timestampLink'])) {
         $line .= '&#160;' . $data['timestampLink'];
         unset($data['timestampLink']);
     }
     $line .= '&#160;</td><td>';
     // everything else: makes it easier for extensions to add or remove data
     $line .= implode('', $data);
     $line .= "</td></tr></table>\n";
     return $line;
 }
 public static function insertStabilityLog(Page $article, OutputPage $out)
 {
     if (!$article->exists()) {
         return true;
         // nothing to do
     } elseif (!FlaggedRevs::inReviewNamespace($article->getTitle())) {
         return true;
         // not a reviewable page
     }
     # Show relevant lines from the stability log:
     $logPage = new LogPage('stable');
     $out->addHTML(Xml::element('h2', null, $logPage->getName()));
     LogEventsList::showLogExtract($out, 'stable', $article->getTitle()->getPrefixedText());
     return true;
 }