MediaWiki  REL1_22
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         return $key;
00059     }
00060 
00061     protected function getMessageParameters() {
00062         $params = parent::getMessageParameters();
00063 
00064         // Really old entries
00065         if ( !isset( $params[3] ) && !isset( $params[4] ) ) {
00066             return $params;
00067         }
00068 
00069         $oldGroups = $params[3];
00070         $newGroups = $params[4];
00071 
00072         // Less old entries
00073         if ( $oldGroups === '' ) {
00074             $oldGroups = array();
00075         } elseif ( is_string( $oldGroups ) ) {
00076             $oldGroups = array_map( 'trim', explode( ',', $oldGroups ) );
00077         }
00078         if ( $newGroups === '' ) {
00079             $newGroups = array();
00080         } elseif ( is_string( $newGroups ) ) {
00081             $newGroups = array_map( 'trim', explode( ',', $newGroups ) );
00082         }
00083 
00084         $userName = $this->entry->getTarget()->getText();
00085         if ( !$this->plaintext && count( $oldGroups ) ) {
00086             foreach ( $oldGroups as &$group ) {
00087                 $group = User::getGroupMember( $group, $userName );
00088             }
00089         }
00090         if ( !$this->plaintext && count( $newGroups ) ) {
00091             foreach ( $newGroups as &$group ) {
00092                 $group = User::getGroupMember( $group, $userName );
00093             }
00094         }
00095 
00096         $lang = $this->context->getLanguage();
00097         if ( count( $oldGroups ) ) {
00098             $params[3] = $lang->listToText( $oldGroups );
00099         } else {
00100             $params[3] = $this->msg( 'rightsnone' )->text();
00101         }
00102         if ( count( $newGroups ) ) {
00103             // Array_values is used here because of bug 42211
00104             // see use of array_unique in UserrightsPage::doSaveUserGroups on $newGroups.
00105             $params[4] = $lang->listToText( array_values( $newGroups ) );
00106         } else {
00107             $params[4] = $this->msg( 'rightsnone' )->text();
00108         }
00109 
00110         return $params;
00111     }
00112 }