https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114529

Revision: 114529
Author:   daniel
Date:     2012-03-27 16:49:19 +0000 (Tue, 27 Mar 2012)
Log Message:
-----------
minimize use of textual page content, clean up hooks for custom page rendering

Modified Paths:
--------------
    branches/Wikidata/phase3/includes/Article.php
    branches/Wikidata/phase3/includes/diff/DifferenceEngine.php

Modified: branches/Wikidata/phase3/includes/Article.php
===================================================================
--- branches/Wikidata/phase3/includes/Article.php       2012-03-27 16:43:32 UTC 
(rev 114528)
+++ branches/Wikidata/phase3/includes/Article.php       2012-03-27 16:49:19 UTC 
(rev 114529)
@@ -324,7 +324,7 @@
 
         $content = $this->fetchContentObject();
 
-        $this->mContent = ContentHandler::getContentText( $content );
+        $this->mContent = ContentHandler::getContentText( $content ); #FIXME: 
get rid of mContent everywhere!
                wfRunHooks( 'ArticleAfterFetchContent', array( &$this, 
&$this->mContent ) ); #BC cruft!
 
                wfProfileOut( __METHOD__ );
@@ -609,7 +609,10 @@
                                                wfDebug( __METHOD__ . ": 
showing CSS/JS source\n" );
                                                $this->showCssOrJsPage();
                                                $outputDone = true;
-                                       } elseif( !wfRunHooks( 
'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
+                    } elseif( !wfRunHooks( 'ArticleContentViewCustom', array( 
$this->fetchContentObject(), $this->getTitle(), $wgOut ) ) ) { #FIXME: document 
new hook!
+                        # Allow extensions do their own custom view for 
certain pages
+                        $outputDone = true;
+                                       } elseif( Hooks::isRegistered( 
'ArticleViewCustom' ) && !wfRunHooks( 'ArticleViewCustom', array( 
$this->fetchContent(), $this->getTitle(), $wgOut ) ) ) { #FIXME: fetchContent() 
is deprecated! #FIXME: deprecate hook!
                                                # Allow extensions do their own 
custom view for certain pages
                                                $outputDone = true;
                                        } else {
@@ -745,17 +748,17 @@
         * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of 
these
         * page views.
         */
-       protected function showCssOrJsPage() { #FIXME: move this to 
ContentHandler!
+       protected function showCssOrJsPage() {
                global $wgOut;
 
                $dir = $this->getContext()->getLanguage()->getDir();
                $lang = $this->getContext()->getLanguage()->getCode();
 
                $wgOut->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' 
dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
-                       'clearyourcache' ); #FIXME: do this in handler
+                       'clearyourcache' );
 
                // Give hooks a chance to customise the output
-               if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, 
$this->getTitle(), $wgOut ) ) ) {
+               if ( !Hooks::isRegistered('ShowRawCssJs') || wfRunHooks( 
'ShowRawCssJs', array( $this->fetchContent(), $this->getTitle(), $wgOut ) ) ) { 
#FIXME: fetchContent() is deprecated #FIXME: hook is deprecated
             $po = $this->mContentObject->getParserOutput();
                        $wgOut->addHTML( $po->getText() );
                }

Modified: branches/Wikidata/phase3/includes/diff/DifferenceEngine.php
===================================================================
--- branches/Wikidata/phase3/includes/diff/DifferenceEngine.php 2012-03-27 
16:43:32 UTC (rev 114528)
+++ branches/Wikidata/phase3/includes/diff/DifferenceEngine.php 2012-03-27 
16:49:19 UTC (rev 114529)
@@ -486,20 +486,21 @@
                        $out->setRevisionTimestamp( 
$this->mNewRev->getTimestamp() );
                        $out->setArticleFlag( true );
 
-                       if ( $this->mNewPage->isCssJsSubpage() || 
$this->mNewPage->isCssOrJsPage() ) { #FIXME: don't do this, use the content 
handler instead!!
+                       if ( $this->mNewPage->isCssJsSubpage() || 
$this->mNewPage->isCssOrJsPage() ) { #NOTE: only needed for B/C: custom 
rendering of JS/CSS via hook
                                // Stolen from Article::view --AG 2007-10-11
                                // Give hooks a chance to customise the output
                                // @TODO: standardize this crap into one 
function
-                               if ( wfRunHooks( 'ShowRawCssJs', array( 
$this->mNewtext, $this->mNewPage, $out ) ) ) { #FIXME: what to do with this 
hook??
-                                       // Wrap the whole lot in a <pre> and 
don't parse
-                                       $m = array();
-                                       preg_match( '!\.(css|js)$!u', 
$this->mNewPage->getText(), $m );
-                                       $out->addHTML( "<pre class=\"mw-code 
mw-{$m[1]}\" dir=\"ltr\">\n" );
-                                       $out->addHTML( htmlspecialchars( 
$this->mNewtext ) );
-                                       $out->addHTML( "\n</pre>\n" );
+                               if ( !Hook::isRegistered( 'ShowRawCssJs' )
+                    || wfRunHooks( 'ShowRawCssJs', array( 
ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) 
) { #NOTE: deperecated hook, B/C only
+                    // use the content object's own rendering
+                    $po = $this->mContentObject->getParserOutput();
+                    $out->addHTML( $po->getText() );
                                }
-                       } elseif ( !wfRunHooks( 'ArticleViewCustom', array( 
$this->mNewtext, $this->mNewPage, $out ) ) ) { #FIXME: what do we pass here
-                               // Handled by extension
+            } elseif( !wfRunHooks( 'ArticleContentViewCustom', array( 
$this->mNewContent, $this->mNewPage, $out ) ) ) {
+                // Handled by extension
+            } elseif( Hooks::isRegistered( 'ArticleViewCustom' )
+                    && !wfRunHooks( 'ArticleViewCustom', array( 
ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) 
) { #NOTE: deperecated hook, B/C only
+                // Handled by extension
                        } else {
                                // Normal page
                                if ( $this->getTitle()->equals( $this->mNewPage 
) ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to