TranslateLogFormatter.php

Go to the documentation of this file.
00001 <?php
00014 class TranslateLogFormatter extends LogFormatter {
00015 
00016     public function getMessageParameters() {
00017         $params = parent::getMessageParameters();
00018 
00019         $type = $this->entry->getFullType();
00020 
00021         if ( $type === 'translationreview/message' ) {
00022             $targetPage = $this->makePageLink(
00023                 $this->entry->getTarget(),
00024                 array( 'oldid' => $params[3] )
00025             );
00026 
00027             $params[2] = Message::rawParam( $targetPage );
00028         } elseif ( $type === 'translationreview/group' ) {
00029             /*
00030              * - 3: language code
00031              * - 4: label of the message group
00032              * - 5: old state
00033              * - 6: new state
00034              */
00035 
00036             $uiLanguage = $this->context->getLanguage();
00037             $language = $params[3];
00038 
00039             $targetPage = $this->makePageLinkWithText(
00040                 $this->entry->getTarget(),
00041                 $params[4],
00042                 array( 'language' => $language )
00043             );
00044 
00045             $params[2] = Message::rawParam( $targetPage );
00046             $params[3] = TranslateUtils::getLanguageName( $language, $uiLanguage->getCode() );
00047             $params[5] = $this->formatStateMessage( $params[5] );
00048             $params[6] = $this->formatStateMessage( $params[6] );
00049         }
00050 
00051         return $params;
00052     }
00053 
00054     protected function formatStateMessage( $value ) {
00055         $message = $this->msg( "translate-workflow-state-$value" );
00056 
00057         return $message->isBlank() ? $value : $message->text();
00058     }
00059 
00060     protected function makePageLinkWithText( Title $title = null, $text, $parameters = array() ) {
00061         if ( !$this->plaintext ) {
00062             $link = Linker::link( $title, htmlspecialchars( $text ), array(), $parameters );
00063         } else {
00064             $target = '***';
00065             if ( $title instanceof Title ) {
00066                 $target = $title->getPrefixedText();
00067             }
00068             $link = "[[$target|$text]]";
00069         }
00070 
00071         return $link;
00072     }
00073 }
Generated on Tue Oct 29 00:00:26 2013 for MediaWiki Translate Extension by  doxygen 1.6.3