http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73603

Revision: 73603
Author:   yaron
Date:     2010-09-23 14:10:09 +0000 (Thu, 23 Sep 2010)

Log Message:
-----------
Tag for version 0.3.1

Modified Paths:
--------------
    tags/extensions/ApprovedRevs/REL_0_3_1/AR_ApprovedPages.php
    tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.alias.php
    tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.hooks.php
    tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.php
    tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs_body.php

Added Paths:
-----------
    tags/extensions/ApprovedRevs/REL_0_3_1/

Modified: tags/extensions/ApprovedRevs/REL_0_3_1/AR_ApprovedPages.php
===================================================================
--- trunk/extensions/ApprovedRevs/AR_ApprovedPages.php  2010-09-23 06:49:42 UTC 
(rev 73595)
+++ tags/extensions/ApprovedRevs/REL_0_3_1/AR_ApprovedPages.php 2010-09-23 
14:10:09 UTC (rev 73603)
@@ -12,8 +12,8 @@
        /**
         * Constructor
         */
-       function __construct() {
-               parent::__construct( 'ApprovedPages' );
+       function ARApprovedPages() {
+               SpecialPage::SpecialPage( 'ApprovedPages' );
                wfLoadExtensionMessages( 'ApprovedRevs' );
        }
 

Modified: tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.alias.php
===================================================================
--- trunk/extensions/ApprovedRevs/ApprovedRevs.alias.php        2010-09-23 
06:49:42 UTC (rev 73595)
+++ tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.alias.php       
2010-09-23 14:10:09 UTC (rev 73603)
@@ -4,15 +4,10 @@
  *
  */
 
-$specialPageAliases = array();
+$aliases = array();
 
 /** English
  */
-$specialPageAliases['en'] = array(
+$aliases['en'] = array(
        'ApprovedPages' => array( 'ApprovedPages' ),
-);
-
-/**
- * For backwards compatibility with MediaWiki 1.15 and earlier.
- */
-$aliases =& $specialPageAliases;
+);
\ No newline at end of file

Modified: tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.hooks.php
===================================================================
--- trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php        2010-09-23 
06:49:42 UTC (rev 73595)
+++ tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.hooks.php       
2010-09-23 14:10:09 UTC (rev 73603)
@@ -14,6 +14,11 @@
 
 class ApprovedRevsHooks {
 
+       /**
+        * If the page is being saved, set the text of the approved revision
+        * as the text to be parsed, for correct saving of categories,
+        * Semantic MediaWiki properties, etc.
+        */
        static public function setApprovedRevForParsing( &$parser, &$text, 
&$stripState ) {
                global $wgRequest;
                $action = $wgRequest->getVal( 'action' );
@@ -23,6 +28,18 @@
                        if ( !is_null( $approvedText ) ) {
                                $text = $approvedText;
                        }
+                       // if there's no approved revision, and
+                       // 'BLANKIFUNAPPROVED' is set on this page, set the
+                       // text to blank
+                       print 'a';
+                       if ( is_null( $approvedText ) ) {
+                       print 'b';
+                               if ( ApprovedRevs::isPagePropertySet( $title, 
'blank_if_unapproved' ) ) {
+                       print 'c';
+                                       $text = '__BLANKIFUNAPPROVED__';
+                               }
+                       }
+                       //die;
                }
                return true;
        }
@@ -34,9 +51,15 @@
         */
        static function showApprovedRevision( &$title, &$article ) {
                // if a revision ID is set, exit
+               /*
                if ( $title->mArticleID > -1 ) {
                        return true;
                }
+                */
+               global $wgRequest;
+               if ( $wgRequest->getCheck( 'oldid' ) ) {
+                       return true;
+               }
                // if it's any action other than viewing, exit
                global $wgRequest;
                if ( $wgRequest->getCheck( 'action' ) &&
@@ -53,6 +76,28 @@
                return true;
        }
 
+       public static function showBlankIfUnapproved( &$article, &$content ) {
+               global $wgRequest;
+               if ( $wgRequest->getCheck( 'oldid' ) ) {
+                       return true;
+               }
+               // if it's any action other than viewing, exit
+               global $wgRequest;
+               if ( $wgRequest->getCheck( 'action' ) &&
+                       $wgRequest->getVal( 'action' ) != 'view' &&
+                       $wgRequest->getVal( 'action' ) != 'purge' &&
+                       $wgRequest->getVal( 'action' ) != 'render' ) {
+                               return true;
+               }
+
+               $title = $article->getTitle();
+               if ( ApprovedRevs::isPagePropertySet( $title, 
'blank_if_unapproved' ) ) {
+                       //$article = new Article( $title, -1 );
+                       $content = '';
+               }
+               return true;
+       }
+
        /**
         * If user is viewing the page via its main URL, and what they're
         * seeing is the approved revision of the page, remove the standard
@@ -266,7 +311,7 @@
        }
 
        /**
-        * Deletes the approval record in the database if the page itself is
+        * Delete the approval record in the database if the page itself is
         * deleted.
         */
        static function deleteRevisionApproval( &$article, &$user, $reason, $id 
) {
@@ -279,6 +324,7 @@
         */
        static function addMagicWordVariableIDs( &$magicWordVariableIDs ) {
                $magicWordVariableIDs[] = 'MAG_APPROVEDREVS';
+               $magicWordVariableIDs[] = 'MAG_BLANKIFUNAPPROVED';
                return true;
        }
  
@@ -289,24 +335,29 @@
                switch( $langCode ) {
                default:
                        $magicWords['MAG_APPROVEDREVS'] = array( 0, 
'__APPROVEDREVS__' );
+                       $magicWords['MAG_BLANKIFUNAPPROVED'] = array( 0, 
'__BLANKIFUNAPPROVED__' );
                }
                return true;
        }
 
        /**
         * Set values in the page_props table based on the presence of the
-        * 'APPROVEDREVS' magic word in a page
+        * 'APPROVEDREVS' and 'BLANKIFUNAPPROVED' magic words in a page
         */
        static function handleMagicWords( &$parser, &$text ) {
                $mw_hide = MagicWord::get( 'MAG_APPROVEDREVS' );
                if ( $mw_hide->matchAndRemove( $text ) ) {
                        $parser->mOutput->setProperty( 'approvedrevs', 'y' );
                }
+               $mw_hide = MagicWord::get( 'MAG_BLANKIFUNAPPROVED' );
+               if ( $mw_hide->matchAndRemove( $text ) ) {
+                       $parser->mOutput->setProperty( 'blank_if_unapproved', 
'y' );
+               }
                return true;
        }
 
        /**
-        * Adds a link to 'Special:ApprovedPages' to the the page
+        * Add a link to 'Special:ApprovedPages' to the the page
         * 'Special:AdminLinks', defined by the Admin Links extension.
         */
        function addToAdminLinks( &$admin_links_tree ) {
@@ -326,6 +377,7 @@
                $dir = dirname( __FILE__ );
 
                // DB updates
+               // For now, there's just a single SQL file for all DB types.
                //if ( $wgDBtype == 'mysql' ) {
                        $wgExtNewTables[] = array( 'approved_revs', 
"$dir/ApprovedRevs.sql" );
                //}

Modified: tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.php
===================================================================
--- trunk/extensions/ApprovedRevs/ApprovedRevs.php      2010-09-23 06:49:42 UTC 
(rev 73595)
+++ tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs.php     2010-09-23 
14:10:09 UTC (rev 73603)
@@ -39,6 +39,7 @@
 // hooks
 $wgHooks['ParserBeforeInternalParse'][] = 
'ApprovedRevsHooks::setApprovedRevForParsing';
 $wgHooks['ArticleFromTitle'][] = 'ApprovedRevsHooks::showApprovedRevision';
+$wgHooks['ArticleAfterFetchContent'][] = 
'ApprovedRevsHooks::showBlankIfUnapproved';
 $wgHooks['DisplayOldSubtitle'][] = 'ApprovedRevsHooks::setSubtitle';
 $wgHooks['SkinTemplateNavigation'][] = 'ApprovedRevsHooks::changeEditLink';
 $wgHooks['PageHistoryBeforeList'][] = 
'ApprovedRevsHooks::storeApprovedRevisionForHistoryPage';
@@ -65,5 +66,3 @@
 $wgGroupPermissions['sysop']['approverevisions'] = true;
 $wgAvailableRights[] = 'viewlinktolatest';
 $wgGroupPermissions['*']['viewlinktolatest'] = true;
-
-$wgPageProps['approvedrevs'] = 'Whether or not the page is approvable';

Modified: tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs_body.php
===================================================================
--- trunk/extensions/ApprovedRevs/ApprovedRevs_body.php 2010-09-23 06:49:42 UTC 
(rev 73595)
+++ tags/extensions/ApprovedRevs/REL_0_3_1/ApprovedRevs_body.php        
2010-09-23 14:10:09 UTC (rev 73603)
@@ -45,6 +45,24 @@
        }
 
        /**
+        * Helper function - determine whether a boolean page property is
+        * set; the regular getProperty() function isn't working here, for
+        * some reason, so just make a database call.
+        */
+       public static function isPagePropertySet( $title, $propName ) {
+               $dbr = wfGetDB( DB_SLAVE );
+               $res = $dbr->select( 'page_props', 'COUNT(*)',
+                       array(
+                               'pp_page' => $title->getArticleID(),
+                               'pp_propname' => $propName,
+                               'pp_value' => 'y'
+                       )
+               );
+               $row = $dbr->fetchRow( $res );
+               return ( $row[0] == 1 );
+       }
+
+       /**
         * Returns whether this page can be approved - either because it's in
         * a supported namespace, or because it's been specially marked as
         * approvable. Also stores the boolean answer as a field in the page
@@ -65,19 +83,8 @@
                }
 
                // it's not in an included namespace, so check for the page
-               // property - for some reason, calling the standard
-               // getProperty() function doesn't work, so we just do a DB
-               // query on the page_props table
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select( 'page_props', 'COUNT(*)',
-                       array(
-                               'pp_page' => $title->getArticleID(),
-                               'pp_propname' => 'approvedrevs',
-                               'pp_value' => 'y'
-                       )
-               );
-               $row = $dbr->fetchRow( $res );
-               $isApprovable = ( $row[0] == '1' );
+               // property.
+               $isApprovable = self::isPagePropertySet( $title, 'approvedrevs' 
);
                $title->isApprovable = $isApprovable;
                return $isApprovable;
        }



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

Reply via email to