protected function getLocalWikiLink($name, $wiki)
 {
     $text = "User:{$name}@{$wiki}";
     if ($this->plaintext) {
         return "[[{$text}]]";
     }
     return Message::rawParam(WikiMap::foreignUserLink($wiki, $name, $text));
 }
コード例 #2
0
 protected function makePageLink(Title $title = null, $parameters = array())
 {
     global $wgContLang, $wgUserrightsInterwikiDelimiter;
     if (!$this->plaintext) {
         $text = $wgContLang->ucfirst($title->getText());
         $parts = explode($wgUserrightsInterwikiDelimiter, $text, 2);
         if (count($parts) === 2) {
             $titleLink = WikiMap::foreignUserLink($parts[1], $parts[0], htmlspecialchars($title->getPrefixedText()));
             if ($titleLink !== false) {
                 return $titleLink;
             }
         }
     }
     return parent::makePageLink($title, $parameters);
 }
 /**
  * @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)
 {
     $formatted = htmlspecialchars($value);
     switch ($name) {
         case 'rq_requested_ts':
         case 'rq_completed_ts':
             $formatted = $this->formatDateTime($value);
             break;
         case 'rq_name':
         case 'rq_newname':
             $title = SpecialPage::getTitleFor('CentralAuth', $value);
             $formatted = Linker::link($title, htmlspecialchars($value));
             break;
         case 'rq_performer':
             $steward = CentralAuthUser::newFromId($value);
             $formatted = '<span class="plainlinks">' . WikiMap::foreignUserLink($steward->getHomeWiki(), $steward->getName(), $steward->getName()) . '</span>';
             break;
         case 'row_actions':
             $formatted = $this->formatActionValue($this->mCurrentRow);
             break;
     }
     return $formatted;
 }
コード例 #4
0
ファイル: WikiMapTest.php プロジェクト: rugby110/mediawiki
 /**
  * @dataProvider provideForeignUserLink
  */
 public function testForeignUserLink($expected, $wikiId, $user, $text = null)
 {
     $this->assertEquals($expected, WikiMap::foreignUserLink($wikiId, $user, $text));
 }
コード例 #5
0
ファイル: LogPage.php プロジェクト: eFFemeer/seizamcore
 /**
  * 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)
 {
     global $wgContLang, $wgUserrightsInterwikiDelimiter;
     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 'rights':
             $text = $wgContLang->ucfirst($title->getText());
             $parts = explode($wgUserrightsInterwikiDelimiter, $text, 2);
             if (count($parts) == 2) {
                 $titleLink = WikiMap::foreignUserLink($parts[1], $parts[0], htmlspecialchars($title->getPrefixedText()));
                 if ($titleLink !== false) {
                     break;
                 }
             }
             $titleLink = Linker::link(Title::makeTitle(NS_USER, $text));
             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->getNamespace() == NS_SPECIAL) {
                 list($name, $par) = SpecialPageFactory::resolveAlias($title->getDBkey());
                 # Use the language name for log titles, rather than Log/X
                 if ($name == 'Log') {
                     $titleLink = '(' . Linker::link($title, LogPage::logName($par)) . ')';
                 } else {
                     $titleLink = Linker::link($title);
                 }
             } else {
                 $titleLink = Linker::link($title);
             }
     }
     return $titleLink;
 }
コード例 #6
0
 /**
  * @param $row
  * @param $isListItem bool
  * @return String
  */
 function formatRow($row, $isListItem = true)
 {
     $user = $this->getUser();
     $lang = $this->getLanguage();
     $actionLinks = array();
     $title = Title::makeTitle($row->afl_namespace, $row->afl_title);
     $diffLink = false;
     if (self::isHidden($row) && !$this->canSeeHidden()) {
         return '';
     }
     if (!$row->afl_wiki) {
         $pageLink = Linker::link($title);
         if ($row->afl_rev_id) {
             $diffLink = Linker::link($title, wfMessage('abusefilter-log-diff')->parse(), array(), array('diff' => 'prev', 'oldid' => $row->afl_rev_id));
         }
     } else {
         $pageLink = WikiMap::makeForeignLink($row->afl_wiki, $row->afl_title);
         if ($row->afl_rev_id) {
             $diffUrl = WikiMap::getForeignURL($row->afl_wiki, $row->afl_title);
             $diffUrl = wfAppendQuery($diffUrl, array('diff' => 'prev', 'oldid' => $row->afl_rev_id));
             $diffLink = Linker::makeExternalLink($diffUrl, wfMessage('abusefilter-log-diff')->parse());
         }
     }
     if (!$row->afl_wiki) {
         // Local user
         $userLink = Linker::userLink($row->afl_user, $row->afl_user_text) . Linker::userToolLinks($row->afl_user, $row->afl_user_text, true);
     } else {
         $userLink = WikiMap::foreignUserLink($row->afl_wiki, $row->afl_user_text);
         $userLink .= ' (' . WikiMap::getWikiName($row->afl_wiki) . ')';
     }
     $timestamp = $lang->timeanddate($row->afl_timestamp, true);
     $actions_taken = $row->afl_actions;
     if (!strlen(trim($actions_taken))) {
         $actions_taken = $this->msg('abusefilter-log-noactions')->text();
     } else {
         $actions = explode(',', $actions_taken);
         $displayActions = array();
         foreach ($actions as $action) {
             $displayActions[] = AbuseFilter::getActionDisplay($action);
         }
         $actions_taken = $lang->commaList($displayActions);
     }
     $globalIndex = AbuseFilter::decodeGlobalName($row->afl_filter);
     if ($globalIndex) {
         // Pull global filter description
         $parsed_comments = $this->getOutput()->parseInline(AbuseFilter::getGlobalFilterDescription($globalIndex));
         $filter_hidden = null;
     } else {
         $parsed_comments = $this->getOutput()->parseInline($row->af_public_comments);
         $filter_hidden = $row->af_hidden;
     }
     if (self::canSeeDetails($row->afl_filter, $filter_hidden)) {
         if ($isListItem) {
             $detailsLink = Linker::linkKnown($this->getPageTitle($row->afl_id), $this->msg('abusefilter-log-detailslink')->escaped());
             $actionLinks[] = $detailsLink;
         }
         $examineTitle = SpecialPage::getTitleFor('AbuseFilter', 'examine/log/' . $row->afl_id);
         $examineLink = Linker::link($examineTitle, $this->msg('abusefilter-changeslist-examine')->parse(), array());
         $actionLinks[] = $examineLink;
         if ($diffLink) {
             $actionLinks[] = $diffLink;
         }
         if ($user->isAllowed('abusefilter-hide-log')) {
             $hideLink = Linker::link($this->getPageTitle(), $this->msg('abusefilter-log-hidelink')->text(), array(), array('hide' => $row->afl_id));
             $actionLinks[] = $hideLink;
         }
         if ($globalIndex) {
             global $wgAbuseFilterCentralDB;
             $globalURL = WikiMap::getForeignURL($wgAbuseFilterCentralDB, 'Special:AbuseFilter/' . $globalIndex);
             $linkText = wfMessage('abusefilter-log-detailedentry-global')->numParams($globalIndex)->escaped();
             $filterLink = Linker::makeExternalLink($globalURL, $linkText);
         } else {
             $title = SpecialPage::getTitleFor('AbuseFilter', $row->afl_filter);
             $linkText = wfMessage('abusefilter-log-detailedentry-local')->numParams($row->afl_filter)->escaped();
             $filterLink = Linker::link($title, $linkText);
         }
         $description = $this->msg('abusefilter-log-detailedentry-meta')->rawParams($timestamp, $userLink, $filterLink, $row->afl_action, $pageLink, $actions_taken, $parsed_comments, $lang->pipeList($actionLinks), $row->afl_user_text)->parse();
     } else {
         if ($diffLink) {
             $msg = 'abusefilter-log-entry-withdiff';
         } else {
             $msg = 'abusefilter-log-entry';
         }
         $description = $this->msg($msg)->rawParams($timestamp, $userLink, $row->afl_action, $pageLink, $actions_taken, $parsed_comments, $diffLink)->parse();
     }
     if (self::isHidden($row) === true) {
         $description .= ' ' . $this->msg('abusefilter-log-hidden')->parse();
         $class = 'afl-hidden';
     } elseif (self::isHidden($row) === 'implicit') {
         $description .= ' ' . $this->msg('abusefilter-log-hidden-implicit')->parse();
     }
     if ($isListItem) {
         return Xml::tags('li', isset($class) ? array('class' => $class) : null, $description);
     } else {
         return Xml::tags('span', isset($class) ? array('class' => $class) : null, $description);
     }
 }
コード例 #7
0
 function formatRow($row, $li = true)
 {
     global $wgLang, $wgUser;
     # One-time setup
     static $sk = null;
     $actionLinks = array();
     if (is_null($sk)) {
         $sk = $wgUser->getSkin();
     }
     $title = Title::makeTitle($row->afl_namespace, $row->afl_title);
     if (!$row->afl_wiki) {
         $pageLink = $sk->link($title);
     } else {
         $pageLink = WikiMap::makeForeignLink($row->afl_wiki, $row->afl_title);
     }
     if (!$row->afl_wiki) {
         // Local user
         $user = $sk->userLink($row->afl_user, $row->afl_user_text) . $sk->userToolLinks($row->afl_user, $row->afl_user_text);
     } else {
         $user = WikiMap::foreignUserLink($row->afl_wiki, $row->afl_user_text);
         $user .= ' (' . WikiMap::getWikiName($row->afl_wiki) . ')';
     }
     $timestamp = $wgLang->timeanddate($row->afl_timestamp, true);
     $actions_taken = $row->afl_actions;
     if (!strlen(trim($actions_taken))) {
         $actions_taken = wfMsg('abusefilter-log-noactions');
     } else {
         $actions = explode(',', $actions_taken);
         $displayActions = array();
         foreach ($actions as $action) {
             $displayActions[] = AbuseFilter::getActionDisplay($action);
         }
         $actions_taken = $wgLang->commaList($displayActions);
     }
     $globalIndex = AbuseFilter::decodeGlobalName($row->afl_filter);
     global $wgOut;
     if ($globalIndex) {
         // Pull global filter description
         $parsed_comments = $wgOut->parseInline(AbuseFilter::getGlobalFilterDescription($globalIndex));
     } else {
         $parsed_comments = $wgOut->parseInline($row->af_public_comments);
     }
     if (self::canSeeDetails()) {
         $examineTitle = SpecialPage::getTitleFor('AbuseFilter', 'examine/log/' . $row->afl_id);
         $detailsLink = $sk->makeKnownLinkObj($this->getTitle($row->afl_id), wfMsg('abusefilter-log-detailslink'));
         $examineLink = $sk->link($examineTitle, wfMsgExt('abusefilter-changeslist-examine', 'parseinline'), array());
         $actionLinks[] = $detailsLink;
         $actionLinks[] = $examineLink;
         if ($wgUser->isAllowed('abusefilter-hide-log')) {
             $hideLink = $sk->link($this->getTitle(), wfMsg('abusefilter-log-hidelink'), array(), array('hide' => $row->afl_id));
             $actionLinks[] = $hideLink;
         }
         if ($globalIndex) {
             global $wgAbuseFilterCentralDB;
             $globalURL = WikiMap::getForeignURL($wgAbuseFilterCentralDB, 'Special:AbuseFilter/' . $globalIndex);
             $linkText = wfMsgExt('abusefilter-log-detailedentry-global', 'parseinline', array($globalIndex));
             $filterLink = $sk->makeExternalLink($globalURL, $linkText);
         } else {
             $title = SpecialPage::getTitleFor('AbuseFilter', $row->afl_filter);
             $linkText = wfMsgExt('abusefilter-log-detailedentry-local', 'parseinline', array($row->afl_filter));
             $filterLink = $sk->link($title, $linkText);
         }
         $description = wfMsgExt('abusefilter-log-detailedentry-meta', array('parseinline', 'replaceafter'), array($timestamp, $user, $filterLink, $row->afl_action, $pageLink, $actions_taken, $parsed_comments, $wgLang->pipeList($actionLinks)));
     } else {
         $description = wfMsgExt('abusefilter-log-entry', array('parseinline', 'replaceafter'), array($timestamp, $user, $row->afl_action, $sk->link($title), $actions_taken, $parsed_comments));
     }
     if ($row->afl_deleted) {
         $description .= ' ' . wfMsgExt('abusefilter-log-hidden', 'parseinline');
     }
     return $li ? Xml::tags('li', null, $description) : $description;
 }