function doBatchLookups() { $userIds = array(); $this->mResult->seek( 0 ); foreach ( $this->mResult as $row ) { $userIds[] = $row->img_user; } # Do a link batch query for names and userpages UserCache::singleton()->doQuery( $userIds, array( 'userpage' ), __METHOD__ ); }
/** * @param string $field * @param string $value * @return string HTML * @throws MWException */ function formatValue($field, $value) { /** @var $row object */ $row = $this->mCurrentRow; $formatted = ''; switch ($field) { case 'log_timestamp': // when timestamp is null, this is a old protection row if ($value === null) { $formatted = Html::rawElement('span', array('class' => 'mw-protectedpages-unknown'), $this->msg('protectedpages-unknown-timestamp')->escaped()); } else { $formatted = htmlspecialchars($this->getLanguage()->userTimeAndDate($value, $this->getUser())); } break; case 'pr_page': $title = Title::makeTitleSafe($row->page_namespace, $row->page_title); if (!$title) { $formatted = Html::element('span', array('class' => 'mw-invalidtitle'), Linker::getInvalidTitleDescription($this->getContext(), $row->page_namespace, $row->page_title)); } else { $formatted = Linker::link($title); } if (!is_null($row->page_len)) { $formatted .= $this->getLanguage()->getDirMark() . ' ' . Html::rawElement('span', array('class' => 'mw-protectedpages-length'), Linker::formatRevisionSize($row->page_len)); } break; case 'pr_expiry': $formatted = htmlspecialchars($this->getLanguage()->formatExpiry($value, true)); $title = Title::makeTitleSafe($row->page_namespace, $row->page_title); if ($this->getUser()->isAllowed('protect') && $title) { $changeProtection = Linker::linkKnown($title, $this->msg('protect_change')->escaped(), array(), array('action' => 'unprotect')); $formatted .= ' ' . Html::rawElement('span', array('class' => 'mw-protectedpages-actions'), $this->msg('parentheses')->rawParams($changeProtection)->escaped()); } break; case 'log_user': // when timestamp is null, this is a old protection row if ($row->log_timestamp === null) { $formatted = Html::rawElement('span', array('class' => 'mw-protectedpages-unknown'), $this->msg('protectedpages-unknown-performer')->escaped()); } else { $username = UserCache::singleton()->getProp($value, 'name'); if (LogEventsList::userCanBitfield($row->log_deleted, LogPage::DELETED_USER, $this->getUser())) { if ($username === false) { $formatted = htmlspecialchars($value); } else { $formatted = Linker::userLink($value, $username) . Linker::userToolLinks($value, $username); } } else { $formatted = $this->msg('rev-deleted-user')->escaped(); } if (LogEventsList::isDeleted($row, LogPage::DELETED_USER)) { $formatted = '<span class="history-deleted">' . $formatted . '</span>'; } } break; case 'pr_params': $params = array(); // Messages: restriction-level-sysop, restriction-level-autoconfirmed $params[] = $this->msg('restriction-level-' . $row->pr_level)->escaped(); if ($row->pr_cascade) { $params[] = $this->msg('protect-summary-cascade')->escaped(); } $formatted = $this->getLanguage()->commaList($params); break; case 'log_comment': // when timestamp is null, this is an old protection row if ($row->log_timestamp === null) { $formatted = Html::rawElement('span', array('class' => 'mw-protectedpages-unknown'), $this->msg('protectedpages-unknown-reason')->escaped()); } else { if (LogEventsList::userCanBitfield($row->log_deleted, LogPage::DELETED_COMMENT, $this->getUser())) { $formatted = Linker::formatComment($value !== null ? $value : ''); } else { $formatted = $this->msg('rev-deleted-comment')->escaped(); } if (LogEventsList::isDeleted($row, LogPage::DELETED_COMMENT)) { $formatted = '<span class="history-deleted">' . $formatted . '</span>'; } } break; default: throw new MWException("Unknown field '{$field}'"); } return $formatted; }
/** * Get the real name of a user given their user ID * * @param int $id User ID * @return string|bool The corresponding user's real name */ public static function whoIsReal($id) { return UserCache::singleton()->getProp($id, 'real_name'); }