PageTranslationLogFormatter.php

Go to the documentation of this file.
00001 <?php
00014 class PageTranslationLogFormatter extends LogFormatter {
00015     public function getMessageParameters() {
00016         $params = parent::getMessageParameters();
00017         $legacy = $this->entry->getParameters();
00018 
00019         $type = $this->entry->getFullType();
00020         switch ( $type ) {
00021             case 'pagetranslation/mark':
00022                 $revision = $legacy['revision'];
00023 
00024                 $targetPage = $this->makePageLink(
00025                     $this->entry->getTarget(),
00026                     array( 'oldid' => $revision )
00027                 );
00028 
00029                 $params[2] = Message::rawParam( $targetPage );
00030                 break;
00031 
00032             case 'pagetranslation/moveok':
00033             case 'pagetranslation/movenok':
00034             case 'pagetranslation/deletefnok':
00035             case 'pagetranslation/deletelnok':
00036                 $target = $legacy['target'];
00037 
00038                 $moveTarget = $this->makePageLink( Title::newFromText( $target ) );
00039                 $params[3] = Message::rawParam( $moveTarget );
00040                 break;
00041 
00042             case 'pagetranslation/prioritylanguages':
00043                 $params[3] = $legacy['force'];
00044                 $languages = $legacy['languages'];
00045                 if ( $languages !== false ) {
00046                     $lang = $this->context->getLanguage();
00047 
00048                     $languages = array_map(
00049                         'trim',
00050                         preg_split( '/,/', $languages, -1, PREG_SPLIT_NO_EMPTY )
00051                     );
00052                     $languages = array_map( function ( $code ) use ( $lang ) {
00053                         return TranslateUtils::getLanguageName( $code, $lang->getCode() );
00054                     }, $languages );
00055 
00056                     $params[4] = $lang->listToText( $languages );
00057                 }
00058                 break;
00059 
00060             case 'pagetranslation/associate':
00061             case 'pagetranslation/dissociate':
00062                 $params[3] = $legacy['aggregategroup'];
00063                 break;
00064         }
00065 
00066         return $params;
00067     }
00068 
00069     public function getComment() {
00070         $legacy = $this->entry->getParameters();
00071         if ( isset( $legacy['reason'] ) ) {
00072             $comment = Linker::commentBlock( $legacy['reason'] );
00073 
00074             // No hard coded spaces thanx
00075             return ltrim( $comment );
00076         }
00077 
00078         return parent::getComment();
00079     }
00080 
00081     protected function getMessageKey() {
00082         $key = parent::getMessageKey();
00083         $type = $this->entry->getFullType();
00084         if ( $type === 'pagetranslation/prioritylanguages' ) {
00085             $params = $this->getMessageParameters();
00086             if ( !isset( $params[4] ) ) {
00087                 $key .= '-unset';
00088             } elseif ( $params['3'] === 'on' ) {
00089                 $key .= '-force';
00090             }
00091         }
00092 
00093         return $key;
00094     }
00095 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3