Example #1
0
 /**
  * Constructor.
  * The first two parameters used to be $skin and $out, but now only a context
  * is needed, that's why there's a second unused parameter.
  *
  * @param IContextSource|Skin $context Context to use; formerly it was
  *   a Skin object. Use of Skin is deprecated.
  * @param null $unused Unused; used to be an OutputPage object.
  * @param int $flags Can be a combination of self::NO_ACTION_LINK,
  *   self::NO_EXTRA_USER_LINKS or self::USE_CHECKBOXES.
  */
 public function __construct($context, $unused = null, $flags = 0)
 {
     if ($context instanceof IContextSource) {
         $this->setContext($context);
     } else {
         // Old parameters, $context should be a Skin object
         $this->setContext($context->getContext());
     }
     $this->flags = $flags;
     $this->showTagEditUI = ChangeTags::showTagEditingUI($this->getUser());
 }
Example #2
0
 private function getActionButtons($formcontents)
 {
     $user = $this->getUser();
     $canRevDelete = $user->isAllowedAll('deletedhistory', 'deletelogentry');
     $showTagEditUI = ChangeTags::showTagEditingUI($user);
     # If the user doesn't have the ability to delete log entries nor edit tags,
     # don't bother showing them the button(s).
     if (!$canRevDelete && !$showTagEditUI) {
         return $formcontents;
     }
     # Show button to hide log entries and/or edit change tags
     $s = Html::openElement('form', array('action' => wfScript(), 'id' => 'mw-log-deleterevision-submit')) . "\n";
     $s .= Html::hidden('action', 'historysubmit') . "\n";
     $s .= Html::hidden('type', 'logging') . "\n";
     $buttons = '';
     if ($canRevDelete) {
         $buttons .= Html::element('button', array('type' => 'submit', 'name' => 'revisiondelete', 'value' => '1', 'class' => "deleterevision-log-submit mw-log-deleterevision-button"), $this->msg('showhideselectedlogentries')->text()) . "\n";
     }
     if ($showTagEditUI) {
         $buttons .= Html::element('button', array('type' => 'submit', 'name' => 'editchangetags', 'value' => '1', 'class' => "editchangetags-log-submit mw-log-editchangetags-button"), $this->msg('log-edit-tags')->text()) . "\n";
     }
     // Select: All, None, Invert
     $links = array();
     $links[] = Html::element('a', array('href' => '#', 'id' => 'checkbox-all'), $this->msg('checkbox-all')->text());
     $links[] = Html::element('a', array('href' => '#', 'id' => 'checkbox-none'), $this->msg('checkbox-none')->text());
     $links[] = Html::element('a', array('href' => '#', 'id' => 'checkbox-invert'), $this->msg('checkbox-invert')->text());
     $buttons .= Html::rawElement('p', array('class' => "mw-checkbox-toggle-controls"), $this->msg('checkbox-select')->rawParams($this->getLanguage()->commaList($links))->escaped());
     $this->getOutput()->addModules('mediawiki.checkboxtoggle');
     $this->getOutput()->addModuleStyles('mediawiki.checkboxtoggle.styles');
     $s .= $buttons . $formcontents . $buttons;
     $s .= Html::closeElement('form');
     return $s;
 }
Example #3
0
 private function getActionButtons($formcontents)
 {
     $user = $this->getUser();
     $canRevDelete = $user->isAllowedAll('deletedhistory', 'deletelogentry');
     $showTagEditUI = ChangeTags::showTagEditingUI($user);
     # If the user doesn't have the ability to delete log entries nor edit tags,
     # don't bother showing them the button(s).
     if (!$canRevDelete && !$showTagEditUI) {
         return $formcontents;
     }
     # Show button to hide log entries and/or edit change tags
     $s = Html::openElement('form', array('action' => wfScript(), 'id' => 'mw-log-deleterevision-submit')) . "\n";
     $s .= Html::hidden('action', 'historysubmit') . "\n";
     $s .= Html::hidden('type', 'logging') . "\n";
     $buttons = '';
     if ($canRevDelete) {
         $buttons .= Html::element('button', array('type' => 'submit', 'name' => 'revisiondelete', 'value' => '1', 'class' => "deleterevision-log-submit mw-log-deleterevision-button"), $this->msg('showhideselectedlogentries')->text()) . "\n";
     }
     if ($showTagEditUI) {
         $buttons .= Html::element('button', array('type' => 'submit', 'name' => 'editchangetags', 'value' => '1', 'class' => "editchangetags-log-submit mw-log-editchangetags-button"), $this->msg('log-edit-tags')->text()) . "\n";
     }
     $s .= $buttons . $formcontents . $buttons;
     $s .= Html::closeElement('form');
     return $s;
 }
Example #4
0
 /**
  * @param HistoryAction $historyPage
  * @param string $year
  * @param string $month
  * @param string $tagFilter
  * @param array $conds
  */
 function __construct($historyPage, $year = '', $month = '', $tagFilter = '', $conds = [])
 {
     parent::__construct($historyPage->getContext());
     $this->historyPage = $historyPage;
     $this->tagFilter = $tagFilter;
     $this->getDateCond($year, $month);
     $this->conds = $conds;
     $this->showTagEditUI = ChangeTags::showTagEditingUI($this->getUser());
 }
 /**
  * @param stdClass $row Row
  * @return string
  */
 private function getShowHideLinks($row)
 {
     // We don't want to see the links and
     if ($this->flags == self::NO_ACTION_LINK) {
         return '';
     }
     $user = $this->getUser();
     // If change tag editing is available to this user, return the checkbox
     if ($this->flags & self::USE_CHECKBOXES && ChangeTags::showTagEditingUI($user)) {
         return Xml::check('showhiderevisions', false, array('name' => 'ids[' . $row->log_id . ']'));
     }
     // no one can hide items from the suppress log.
     if ($row->log_type == 'suppress') {
         return '';
     }
     $del = '';
     // Don't show useless checkbox to people who cannot hide log entries
     if ($user->isAllowed('deletedhistory')) {
         $canHide = $user->isAllowed('deletelogentry');
         $canViewSuppressedOnly = $user->isAllowed('viewsuppressed') && !$user->isAllowed('suppressrevision');
         $entryIsSuppressed = self::isDeleted($row, LogPage::DELETED_RESTRICTED);
         $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
         if ($row->log_deleted || $canHide) {
             // Show checkboxes instead of links.
             if ($canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry) {
                 // If event was hidden from sysops
                 if (!self::userCan($row, LogPage::DELETED_RESTRICTED, $user)) {
                     $del = Xml::check('deleterevisions', false, array('disabled' => 'disabled'));
                 } else {
                     $del = Xml::check('showhiderevisions', false, array('name' => 'ids[' . $row->log_id . ']'));
                 }
             } else {
                 // If event was hidden from sysops
                 if (!self::userCan($row, LogPage::DELETED_RESTRICTED, $user)) {
                     $del = Linker::revDeleteLinkDisabled($canHide);
                 } else {
                     $query = array('target' => SpecialPage::getTitleFor('Log', $row->log_type)->getPrefixedDBkey(), 'type' => 'logging', 'ids' => $row->log_id);
                     $del = Linker::revDeleteLink($query, $entryIsSuppressed, $canHide && !$canViewThisSuppressedEntry);
                 }
             }
         }
     }
     return $del;
 }