- $t = explode ( "\n" , $t ) ;
- $catlow = strtolower ( $wgLang->getNsText ( NS_CATEGORY ) ) ;
- $cat = $ll = array() ;
- foreach ( $t AS $key => $x )
- {
- $y = trim ( strtolower ( $x ) ) ;
- while ( substr ( $y , 0 , 2 ) == '[[' )
- {
- $y = explode ( ']]' , trim ( $x ) ) ;
- $first = array_shift ( $y ) ;
- $first = explode ( ':' , $first ) ;
- $ns = array_shift ( $first ) ;
- $ns = trim ( str_replace ( '[' , '' , $ns ) ) ;
- if ( strlen ( $ns ) == 2 OR strtolower ( $ns ) == $catlow )
- {
- $add = '[[' . $ns . ':' . implode ( ':' , $first ) . ']]' ;
- if ( strtolower ( $ns ) == $catlow ) $cat[] = $add ;
- else $ll[] = $add ;
- $x = implode ( ']]' , $y ) ;
- $t[$key] = $x ;
- $y = trim ( strtolower ( $x ) ) ;
+ $t = explode ( "\n" , $t );
+ $catlow = strtolower ( $wgContLang->getNsText( NS_CATEGORY ) );
+ $cat = $ll = array();
+ foreach ( $t AS $key => $x ) {
+ $y = trim ( strtolower ( $x ) );
+ while ( substr ( $y , 0 , 2 ) == '[[' ) {
+ $y = explode ( ']]' , trim ( $x ) );
+ $first = array_shift ( $y );
+ $first = explode ( ':' , $first );
+ $ns = array_shift ( $first );
+ $ns = trim ( str_replace ( '[' , '' , $ns ) );
+ if ( $wgContLang->getLanguageName( $ns ) || strtolower ( $ns ) == $catlow ) {
+ $add = '[[' . $ns . ':' . implode ( ':' , $first ) . ']]';
+ if ( strtolower ( $ns ) == $catlow ) $cat[] = $add;
+ else $ll[] = $add;
+ $x = implode ( ']]' , $y );
+ $t[$key] = $x;
+ $y = trim ( strtolower ( $x ) );
+ } else {
+ $x = implode ( ']]' , $y );
+ $y = trim ( strtolower ( $x ) );