Typo
[lhc/web/wiklou.git] / includes / EditPage.php
index fc5fa43..4133c0f 100644 (file)
@@ -110,7 +110,7 @@ class EditPage {
         * @private
         */
        function getContent( $def_text = '' ) {
-               global $wgOut, $wgRequest, $wgParser, $wgMessageCache;
+               global $wgOut, $wgRequest, $wgParser, $wgContLang, $wgMessageCache;
 
                wfProfileIn( __METHOD__ );
                # Get variables from query string :P
@@ -124,9 +124,12 @@ class EditPage {
                // For other non-existent articles, use preload text if any.
                if ( !$this->mTitle->exists() ) {
                        if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                               $wgMessageCache->loadAllMessages();
                                # If this is a system message, get the default text.
-                               $text = wfMsgWeirdKey( $this->mTitle->getText() ) ;
+                               list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
+                               $wgMessageCache->loadAllMessages( $lang );
+                               $text = wfMsgGetKey( $message, false, $lang, false );
+                               if( wfEmptyMsg( $message, $text ) )
+                                       $text = '';
                        } else {
                                # If requested, preload some text.
                                $text = $this->getPreloadedText( $preload );
@@ -231,93 +234,87 @@ class EditPage {
         *  and set $wgMetadataWhitelist to the *full* title of the template whitelist
         */
        function extractMetaDataFromArticle () {
-               global $wgUseMetadataEdit , $wgMetadataWhitelist , $wgLang ;
-               $this->mMetaData = '' ;
-               if ( !$wgUseMetadataEdit ) return ;
-               if ( $wgMetadataWhitelist == '' ) return ;
-               $s = '' ;
+               global $wgUseMetadataEdit, $wgMetadataWhitelist, $wgContLang;
+               $this->mMetaData = '';
+               if ( !$wgUseMetadataEdit ) return;
+               if ( $wgMetadataWhitelist == '' ) return;
+               $s = '';
                $t = $this->getContent();
 
                # MISSING : <nowiki> filtering
 
                # Categories and language links
-               $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 ) );
                                }
                        }
                }
-               if ( count ( $cat ) ) $s .= implode ( ' ' , $cat ) . "\n" ;
-               if ( count ( $ll ) ) $s .= implode ( ' ' , $ll ) . "\n" ;
-               $t = implode ( "\n" , $t ) ;
+               if ( count ( $cat ) ) $s .= implode ( ' ' , $cat ) . "\n";
+               if ( count ( $ll ) ) $s .= implode ( ' ' , $ll ) . "\n";
+               $t = implode ( "\n" , $t );
 
                # Load whitelist
                $sat = array () ; # stand-alone-templates; must be lowercase
-               $wl_title = Title::newFromText ( $wgMetadataWhitelist ) ;
-               $wl_article = new Article ( $wl_title ) ;
-               $wl = explode ( "\n" , $wl_article->getContent() ) ;
-               foreach ( $wl AS $x )
-               {
-                       $isentry = false ;
-                       $x = trim ( $x ) ;
-                       while ( substr ( $x , 0 , 1 ) == '*' )
-                       {
-                               $isentry = true ;
-                               $x = trim ( substr ( $x , 1 ) ) ;
+               $wl_title = Title::newFromText ( $wgMetadataWhitelist );
+               $wl_article = new Article ( $wl_title );
+               $wl = explode ( "\n" , $wl_article->getContent() );
+               foreach ( $wl AS $x ) {
+                       $isentry = false;
+                       $x = trim ( $x );
+                       while ( substr ( $x , 0 , 1 ) == '*' ) {
+                               $isentry = true;
+                               $x = trim ( substr ( $x , 1 ) );
                        }
-                       if ( $isentry )
-                       {
-                               $sat[] = strtolower ( $x ) ;
+                       if ( $isentry ) {
+                               $sat[] = strtolower ( $x );
                        }
 
                }
 
                # Templates, but only some
-               $t = explode ( '{{' , $t ) ;
+               $t = explode ( '{{' , $t );
                $tl = array () ;
-               foreach ( $t AS $key => $x )
-               {
-                       $y = explode ( '}}' , $x , 2 ) ;
-                       if ( count ( $y ) == 2 )
-                       {
-                               $z = $y[0] ;
-                               $z = explode ( '|' , $z ) ;
-                               $tn = array_shift ( $z ) ;
-                               if ( in_array ( strtolower ( $tn ) , $sat ) )
-                               {
-                                       $tl[] = '{{' . $y[0] . '}}' ;
-                                       $t[$key] = $y[1] ;
-                                       $y = explode ( '}}' , $y[1] , 2 ) ;
+               foreach ( $t AS $key => $x ) {
+                       $y = explode ( '}}' , $x , 2 );
+                       if ( count ( $y ) == 2 ) {
+                               $z = $y[0];
+                               $z = explode ( '|' , $z );
+                               $tn = array_shift ( $z );
+                               if ( in_array ( strtolower ( $tn ) , $sat ) ) {
+                                       $tl[] = '{{' . $y[0] . '}}';
+                                       $t[$key] = $y[1];
+                                       $y = explode ( '}}' , $y[1] , 2 );
                                }
-                               else $t[$key] = '{{' . $x ;
+                               else $t[$key] = '{{' . $x;
                        }
-                       else if ( $key != 0 ) $t[$key] = '{{' . $x ;
-                       else $t[$key] = $x ;
+                       else if ( $key != 0 ) $t[$key] = '{{' . $x;
+                       else $t[$key] = $x;
                }
-               if ( count ( $tl ) ) $s .= implode ( ' ' , $tl ) ;
-               $t = implode ( '' , $t ) ;
+               if ( count ( $tl ) ) $s .= implode ( ' ' , $tl );
+               $t = implode ( '' , $t );
 
-               $t = str_replace ( "\n\n\n" , "\n" , $t ) ;
-               $this->mArticle->mContent = $t ;
-               $this->mMetaData = $s ;
+               $t = str_replace ( "\n\n\n" , "\n" , $t );
+               $this->mArticle->mContent = $t;
+               $this->mMetaData = $s;
        }
 
        /* 
@@ -332,8 +329,8 @@ class EditPage {
                if ( $this->mTitle->isDeleted() ) {
                        $this->lastDelete = $this->getLastDelete();
                        if ( $this->lastDelete ) {
-                               $deletetime = $this->lastDelete->log_timestamp;
-                               if ( ($deletetime - $this->starttime) > 0 ) {
+                               $deleteTime = wfTimestamp( TS_MW, $this->lastDelete->log_timestamp );
+                               if ( $deleteTime > $this->starttime ) {
                                        $this->deletedSinceEdit = true;
                                }
                        }
@@ -847,7 +844,6 @@ class EditPage {
                # If article is new, insert it.
                $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
                if ( 0 == $aid ) {
-
                        // Late check for create permission, just in case *PARANOIA*
                        if ( !$this->mTitle->userCan( 'create' ) ) {
                                wfDebug( "$fname: no create permission\n" );
@@ -857,8 +853,8 @@ class EditPage {
 
                        # Don't save a new article if it's blank.
                        if ( '' == $this->textbox1 ) {
-                                       wfProfileOut( $fname );
-                                       return self::AS_BLANK_ARTICLE;
+                               wfProfileOut( $fname );
+                               return self::AS_BLANK_ARTICLE;
                        }
 
                        // Run post-section-merge edit filter
@@ -952,7 +948,7 @@ class EditPage {
                }
 
                # Handle the user preference to force summaries here, but not for null edits
-               if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp($oldtext, $text) && 
+               if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp($oldtext, $text) &&
                        !is_object( Title::newFromRedirect( $text ) ) # check if it's not a redirect
                ) {
                        if ( md5( $this->summary ) == $this->autoSumm ) {
@@ -1051,11 +1047,8 @@ class EditPage {
         */
        function initialiseForm() {
                $this->edittime = $this->mArticle->getTimestamp();
-               $this->textbox1 = $this->getContent(false);
-               if ( $this->textbox1 === false) return false;
-
-               if ( !$this->mArticle->exists() && $this->mTitle->getNamespace() == NS_MEDIAWIKI )
-                       $this->textbox1 = wfMsgWeirdKey( $this->mTitle->getText() );
+               $this->textbox1 = $this->getContent( false );
+               if ( $this->textbox1 === false ) return false;
                wfProxyCheck();
                return true;
        }
@@ -1182,10 +1175,12 @@ class EditPage {
                } elseif ( $wgUser->isAnon() && $this->formtype != 'preview' ) {
                        $wgOut->wrapWikiMsg( '<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning' );
                } else {
-                       if ( $this->isCssJsSubpage && $this->formtype != 'preview' ) {
+                       if ( $this->isCssJsSubpage ) {
                                # Check the skin exists
                                if ( $this->isValidCssJsSubpage ) {
-                                       $wgOut->addWikiMsg( 'usercssjsyoucanpreview' );
+                                       if ( $this->formtype !== 'preview' ) {
+                                               $wgOut->addWikiMsg( 'usercssjsyoucanpreview' );
+                                       }
                                } else {
                                        $wgOut->addWikiMsg( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() );
                                }
@@ -1206,7 +1201,7 @@ class EditPage {
                                $noticeMsg = 'protectedpagewarning';
                                $classes[] = 'mw-textarea-protected';
                        }
-                       $wgOut->addHTML( "<div id='mw-edit-$noticeMsg'>\n" );
+                       $wgOut->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
                        $wgOut->addWikiMsg( $noticeMsg );
                        LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1 );
                        $wgOut->addHTML( "</div>\n" );
@@ -1346,6 +1341,7 @@ class EditPage {
                        $ew = $wgUser->getOption( 'editwidth' );
                        if ( $ew ) $ew = " style=\"width:100%\"";
                        else $ew = '';
+                       $cols = $wgUser->getIntOption( 'cols' );
                        /* /ToDo */
                        $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>" ;
                }
@@ -1651,9 +1647,8 @@ END
                                $previewtext = wfMsg('userjspreview');
                        }
                        $parserOptions->setTidy(true);
-                       $parserOutput = $wgParser->parse( $previewtext , $this->mTitle, $parserOptions );
-                       //$wgOut->addHTML( $parserOutput->mText );
-                       $previewHTML = '';
+                       $parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions );
+                       $previewHTML = $parserOutput->mText;
                } elseif ( $rt = Title::newFromRedirect( $this->textbox1 ) ) {
                        $previewHTML = $this->mArticle->viewRedirect( $rt, false );
                } else {
@@ -2346,17 +2341,29 @@ END
                global $wgUser;
                $loglist = new LogEventsList( $wgUser->getSkin(), $out );
                $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
-               if ( $pager->getNumRows() > 0 ) {
-                       $out->addHtml( '<div id="mw-recreate-deleted-warn">' );
+               $count = $pager->getNumRows();
+               if ( $count > 0 ) {
+                       $pager->mLimit = 10;
+                       $out->addHtml( '<div class="mw-warning-with-logexcerpt">' );
                        $out->addWikiMsg( 'recreate-deleted-warn' );
                        $out->addHTML(
                                $loglist->beginLogEventsList() .
                                $pager->getBody() .
                                $loglist->endLogEventsList()
                        );
+                       if($count > 10){
+                               $out->addHtml( $wgUser->getSkin()->link(
+                                       SpecialPage::getTitleFor( 'Log' ),
+                                       wfMsgHtml( 'deletelog-fulllog' ),
+                                       array(),
+                                       array(
+                                               'type' => 'delete',
+                                               'page' => $this->mTitle->getPrefixedText() ) ) );
+                       }
                        $out->addHtml( '</div>' );
                        return true;
                }
+               
                return false;
        }