/** * @covers LogFormatter::newFromEntry */ public function testNormalLogParams() { $entry = $this->newLogEntry('test', array()); $formatter = LogFormatter::newFromEntry($entry); $formatter->setContext($this->context); $formatter->setShowUserToolLinks(false); $paramsWithoutTools = $formatter->getMessageParametersForTesting(); unset($formatter->parsedParameters); $formatter->setShowUserToolLinks(true); $paramsWithTools = $formatter->getMessageParametersForTesting(); $userLink = Linker::userLink($this->user->getId(), $this->user->getName()); $userTools = Linker::userToolLinksRedContribs($this->user->getId(), $this->user->getName(), $this->user->getEditCount()); $titleLink = Linker::link($this->title, null, array(), array()); // $paramsWithoutTools and $paramsWithTools should be only different // in index 0 $this->assertEquals($paramsWithoutTools[1], $paramsWithTools[1]); $this->assertEquals($paramsWithoutTools[2], $paramsWithTools[2]); $this->assertEquals($userLink, $paramsWithoutTools[0]['raw']); $this->assertEquals($userLink . $userTools, $paramsWithTools[0]['raw']); $this->assertEquals($this->user->getName(), $paramsWithoutTools[1]); $this->assertEquals($titleLink, $paramsWithoutTools[2]['raw']); }
/** * @param string $name The database field name * @param string $value The value retrieved from the database * @return string HTML to place inside table cell */ public function formatValue($name, $value) { $user = $this->users[$this->mCurrentRow->utr_name]; $formatted = htmlspecialchars($value); switch ($name) { case 'utr_name': $formatted = Linker::userLink($user->getId(), $user->getName()) . Linker::userToolLinksRedContribs($user->getId(), $user->getName(), $user->getEditCount()); break; case 'user_registration': $regDate = $user->getRegistration(); if ($regDate === null) { $formatted = $this->msg('centralauth-uwbr-registration-nodate')->escaped(); } else { $formatted = $this->formatDateTime($regDate); } break; case 'user_editcount': $formatted = $this->getLanguage()->formatNum($user->getEditCount()); break; } return $formatted; }
/** * @param stdClass $row * @return string */ function formatRow($row) { if ($row->user_id == 0) { #Bug 16487 return ''; } $userName = $row->user_name; $ulinks = Linker::userLink($row->user_id, $userName); $ulinks .= Linker::userToolLinksRedContribs($row->user_id, $userName, (int) $row->edits); $lang = $this->getLanguage(); $groups = ''; $groups_list = self::getGroups(intval($row->user_id), $this->userGroupCache); if (!$this->including && count($groups_list) > 0) { $list = array(); foreach ($groups_list as $group) { $list[] = self::buildGroupLink($group, $userName); } $groups = $lang->commaList($list); } $item = $lang->specialList($ulinks, $groups); if ($row->ipb_deleted) { $item = "<span class=\"deleted\">{$item}</span>"; } $edits = ''; if (!$this->including && $this->getConfig()->get('Edititis')) { $count = $this->msg('usereditcount')->numParams($row->edits)->escaped(); $edits = $this->msg('word-separator')->escaped() . $this->msg('brackets', $count)->escaped(); } $created = ''; # Some rows may be null if (!$this->including && $row->creation) { $user = $this->getUser(); $d = $lang->userDate($row->creation, $user); $t = $lang->userTime($row->creation, $user); $created = $this->msg('usercreated', $d, $t, $row->user_name)->escaped(); $created = ' ' . $this->msg('parentheses')->rawParams($created)->escaped(); } $blocked = !is_null($row->ipb_deleted) ? ' ' . $this->msg('listusers-blocked', $userName)->escaped() : ''; Hooks::run('SpecialListusersFormatRow', array(&$item, $row)); return Html::rawElement('li', array(), "{$item}{$edits}{$created}{$blocked}"); }
public function userToolLinksRedContribs($userId, $userText, $edits = null) { return Linker::userToolLinksRedContribs($userId, $userText, $edits); }
protected function makeUserLink(User $user) { if ($this->plaintext) { $element = $user->getName(); } else { $element = Linker::userLink($user->getId(), $user->getName()); if ($this->linkFlood) { $element .= Linker::userToolLinksRedContribs($user->getId(), $user->getName(), $user->getEditCount()); } } return $element; }