コード例 #1
0
ファイル: LogFormatter.php プロジェクト: D66Ha/mediawiki
 /**
  * Even uglier hack to maintain backwards compatibilty with IRC bots
  * (bug 34508).
  * @see getActionText()
  * @return string Text
  */
 public function getIRCActionText()
 {
     global $wgContLang;
     $this->plaintext = true;
     $this->irctext = true;
     $entry = $this->entry;
     $parameters = $entry->getParameters();
     // @see LogPage::actionText()
     // Text of title the action is aimed at.
     $target = $entry->getTarget()->getPrefixedText();
     $text = null;
     switch ($entry->getType()) {
         case 'move':
             switch ($entry->getSubtype()) {
                 case 'move':
                     $movesource = $parameters['4::target'];
                     $text = wfMessage('1movedto2')->rawParams($target, $movesource)->inContentLanguage()->escaped();
                     break;
                 case 'move_redir':
                     $movesource = $parameters['4::target'];
                     $text = wfMessage('1movedto2_redir')->rawParams($target, $movesource)->inContentLanguage()->escaped();
                     break;
                 case 'move-noredirect':
                     break;
                 case 'move_redir-noredirect':
                     break;
             }
             break;
         case 'delete':
             switch ($entry->getSubtype()) {
                 case 'delete':
                     $text = wfMessage('deletedarticle')->rawParams($target)->inContentLanguage()->escaped();
                     break;
                 case 'restore':
                     $text = wfMessage('undeletedarticle')->rawParams($target)->inContentLanguage()->escaped();
                     break;
                     // @codingStandardsIgnoreStart Long line
                     //case 'revision': // Revision deletion
                     //case 'event': // Log deletion
                     // see https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/LogPage.php?&pathrev=97044&r1=97043&r2=97044
                     //default:
                     // @codingStandardsIgnoreEnd
             }
             break;
         case 'patrol':
             // @codingStandardsIgnoreStart Long line
             // https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/PatrolLog.php?&pathrev=97495&r1=97494&r2=97495
             // @codingStandardsIgnoreEnd
             // Create a diff link to the patrolled revision
             if ($entry->getSubtype() === 'patrol') {
                 $diffLink = htmlspecialchars(wfMessage('patrol-log-diff', $parameters['4::curid'])->inContentLanguage()->text());
                 $text = wfMessage('patrol-log-line', $diffLink, "[[{$target}]]", "")->inContentLanguage()->text();
             } else {
                 // broken??
             }
             break;
         case 'protect':
             switch ($entry->getSubtype()) {
                 case 'protect':
                     $text = wfMessage('protectedarticle')->rawParams($target . ' ' . $parameters[0])->inContentLanguage()->escaped();
                     break;
                 case 'unprotect':
                     $text = wfMessage('unprotectedarticle')->rawParams($target)->inContentLanguage()->escaped();
                     break;
                 case 'modify':
                     $text = wfMessage('modifiedarticleprotection')->rawParams($target . ' ' . $parameters[0])->inContentLanguage()->escaped();
                     break;
             }
             break;
         case 'newusers':
             switch ($entry->getSubtype()) {
                 case 'newusers':
                 case 'create':
                     $text = wfMessage('newuserlog-create-entry')->inContentLanguage()->escaped();
                     break;
                 case 'create2':
                 case 'byemail':
                     $text = wfMessage('newuserlog-create2-entry')->rawParams($target)->inContentLanguage()->escaped();
                     break;
                 case 'autocreate':
                     $text = wfMessage('newuserlog-autocreate-entry')->inContentLanguage()->escaped();
                     break;
             }
             break;
         case 'upload':
             switch ($entry->getSubtype()) {
                 case 'upload':
                     $text = wfMessage('uploadedimage')->rawParams($target)->inContentLanguage()->escaped();
                     break;
                 case 'overwrite':
                     $text = wfMessage('overwroteimage')->rawParams($target)->inContentLanguage()->escaped();
                     break;
             }
             break;
         case 'rights':
             if (count($parameters['4::oldgroups'])) {
                 $oldgroups = implode(', ', $parameters['4::oldgroups']);
             } else {
                 $oldgroups = wfMessage('rightsnone')->inContentLanguage()->escaped();
             }
             if (count($parameters['5::newgroups'])) {
                 $newgroups = implode(', ', $parameters['5::newgroups']);
             } else {
                 $newgroups = wfMessage('rightsnone')->inContentLanguage()->escaped();
             }
             switch ($entry->getSubtype()) {
                 case 'rights':
                     $text = wfMessage('rightslogentry')->rawParams($target, $oldgroups, $newgroups)->inContentLanguage()->escaped();
                     break;
                 case 'autopromote':
                     $text = wfMessage('rightslogentry-autopromote')->rawParams($target, $oldgroups, $newgroups)->inContentLanguage()->escaped();
                     break;
             }
             break;
         case 'merge':
             $text = wfMessage('pagemerge-logentry')->rawParams($target, $parameters['4::dest'], $parameters['5::mergepoint'])->inContentLanguage()->escaped();
             break;
         case 'block':
             switch ($entry->getSubtype()) {
                 case 'block':
                     // Keep compatibility with extensions by checking for
                     // new key (5::duration/6::flags) or old key (0/optional 1)
                     if ($entry->isLegacy()) {
                         $rawDuration = $parameters[0];
                         $rawFlags = isset($parameters[1]) ? $parameters[1] : '';
                     } else {
                         $rawDuration = $parameters['5::duration'];
                         $rawFlags = $parameters['6::flags'];
                     }
                     $duration = $wgContLang->translateBlockExpiry($rawDuration);
                     $flags = BlockLogFormatter::formatBlockFlags($rawFlags, $wgContLang);
                     $text = wfMessage('blocklogentry')->rawParams($target, $duration, $flags)->inContentLanguage()->escaped();
                     break;
                 case 'unblock':
                     $text = wfMessage('unblocklogentry')->rawParams($target)->inContentLanguage()->escaped();
                     break;
                 case 'reblock':
                     $duration = $wgContLang->translateBlockExpiry($parameters['5::duration']);
                     $flags = BlockLogFormatter::formatBlockFlags($parameters['6::flags'], $wgContLang);
                     $text = wfMessage('reblock-logentry')->rawParams($target, $duration, $flags)->inContentLanguage()->escaped();
                     break;
             }
             break;
         case 'import':
             switch ($entry->getSubtype()) {
                 case 'upload':
                     $text = wfMessage('import-logentry-upload')->rawParams($target)->inContentLanguage()->escaped();
                     break;
                 case 'interwiki':
                     $text = wfMessage('import-logentry-interwiki')->rawParams($target)->inContentLanguage()->escaped();
                     break;
             }
             break;
             // case 'suppress' --private log -- aaron  (so we know who to blame in a few years :-D)
             // default:
     }
     if (is_null($text)) {
         $text = $this->getPlainActionText();
     }
     $this->plaintext = false;
     $this->irctext = false;
     return $text;
 }
コード例 #2
0
 /**
  * @param $row
  * @return String
  */
 private function formatBlockStatus($row)
 {
     $additionalHtml = '';
     if (isset($row['blocked']) && $row['blocked']) {
         $flags = array();
         foreach (array('anononly', 'nocreate', 'noautoblock', 'noemail', 'nousertalk') as $option) {
             if ($row['block-' . $option]) {
                 $flags[] = $option;
             }
         }
         $flags = implode(',', $flags);
         $optionMessage = BlockLogFormatter::formatBlockFlags($flags, $this->getLanguage());
         if ($row['block-expiry'] == 'infinity') {
             $text = $this->msg('centralauth-admin-blocked2-indef')->parse();
         } else {
             $expiry = $this->getLanguage()->timeanddate($row['block-expiry'], true);
             $expiryd = $this->getLanguage()->date($row['block-expiry'], true);
             $expiryt = $this->getLanguage()->time($row['block-expiry'], true);
             $text = $this->msg('centralauth-admin-blocked2', $expiry, $expiryd, $expiryt)->parse();
         }
         if ($flags) {
             $additionalHtml .= ' ' . $optionMessage;
         }
         if ($row['block-reason']) {
             $reason = Sanitizer::escapeHtmlAllowEntities($row['block-reason']);
             $reason = Linker::formatLinksInComment($reason, null, false, $row['wiki']);
             $msg = $this->msg('centralauth-admin-blocked-reason');
             $msg->rawParams('<span class="plainlinks">' . $reason . '</span>');
             $additionalHtml .= ' ' . $msg->parse();
         }
     } else {
         $text = $this->msg('centralauth-admin-notblocked')->parse();
     }
     return self::foreignLink($row['wiki'], 'Special:Log/block', $text, $this->msg('centralauth-admin-blocklog')->text(), 'page=User:' . urlencode($this->mUserName)) . $additionalHtml;
 }