MediaWiki  REL1_24
RightsLogFormatter.php
Go to the documentation of this file.
00001 <?php
00031 class RightsLogFormatter extends LogFormatter {
00032     protected function makePageLink( Title $title = null, $parameters = array() ) {
00033         global $wgContLang, $wgUserrightsInterwikiDelimiter;
00034 
00035         if ( !$this->plaintext ) {
00036             $text = $wgContLang->ucfirst( $title->getText() );
00037             $parts = explode( $wgUserrightsInterwikiDelimiter, $text, 2 );
00038 
00039             if ( count( $parts ) === 2 ) {
00040                 $titleLink = WikiMap::foreignUserLink( $parts[1], $parts[0],
00041                     htmlspecialchars( $title->getPrefixedText() ) );
00042 
00043                 if ( $titleLink !== false ) {
00044                     return $titleLink;
00045                 }
00046             }
00047         }
00048 
00049         return parent::makePageLink( $title, $parameters );
00050     }
00051 
00052     protected function getMessageKey() {
00053         $key = parent::getMessageKey();
00054         $params = $this->getMessageParameters();
00055         if ( !isset( $params[3] ) && !isset( $params[4] ) ) {
00056             $key .= '-legacy';
00057         }
00058 
00059         return $key;
00060     }
00061 
00062     protected function getMessageParameters() {
00063         $params = parent::getMessageParameters();
00064 
00065         // Really old entries
00066         if ( !isset( $params[3] ) && !isset( $params[4] ) ) {
00067             return $params;
00068         }
00069 
00070         $oldGroups = $params[3];
00071         $newGroups = $params[4];
00072 
00073         // Less old entries
00074         if ( $oldGroups === '' ) {
00075             $oldGroups = array();
00076         } elseif ( is_string( $oldGroups ) ) {
00077             $oldGroups = array_map( 'trim', explode( ',', $oldGroups ) );
00078         }
00079         if ( $newGroups === '' ) {
00080             $newGroups = array();
00081         } elseif ( is_string( $newGroups ) ) {
00082             $newGroups = array_map( 'trim', explode( ',', $newGroups ) );
00083         }
00084 
00085         $userName = $this->entry->getTarget()->getText();
00086         if ( !$this->plaintext && count( $oldGroups ) ) {
00087             foreach ( $oldGroups as &$group ) {
00088                 $group = User::getGroupMember( $group, $userName );
00089             }
00090         }
00091         if ( !$this->plaintext && count( $newGroups ) ) {
00092             foreach ( $newGroups as &$group ) {
00093                 $group = User::getGroupMember( $group, $userName );
00094             }
00095         }
00096 
00097         $lang = $this->context->getLanguage();
00098         if ( count( $oldGroups ) ) {
00099             $params[3] = $lang->listToText( $oldGroups );
00100         } else {
00101             $params[3] = $this->msg( 'rightsnone' )->text();
00102         }
00103         if ( count( $newGroups ) ) {
00104             // Array_values is used here because of bug 42211
00105             // see use of array_unique in UserrightsPage::doSaveUserGroups on $newGroups.
00106             $params[4] = $lang->listToText( array_values( $newGroups ) );
00107         } else {
00108             $params[4] = $this->msg( 'rightsnone' )->text();
00109         }
00110 
00111         return $params;
00112     }
00113 }