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

Revision: 72227
Author:   reedy
Date:     2010-09-02 20:52:01 +0000 (Thu, 02 Sep 2010)

Log Message:
-----------
Per r72181, refactor isInCategory into ArticleAssessmentPilot

Modified Paths:
--------------
    trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php
    trunk/phase3/includes/Title.php

Modified: 
trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php
===================================================================
--- trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php    
2010-09-02 20:48:02 UTC (rev 72226)
+++ trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.hooks.php    
2010-09-02 20:52:01 UTC (rev 72227)
@@ -56,7 +56,8 @@
                global $wgArticleAssessmentCategory;
 
                // check if this page should have the form
-               if ( $wgArticleAssessmentCategory === '' || 
!$title->isInCategory( $wgArticleAssessmentCategory ) ) {
+               if ( $wgArticleAssessmentCategory === ''
+                               || !self::isInCategory( $title->getArticleId(), 
$wgArticleAssessmentCategory ) ) {
                        return true;
                }
 
@@ -116,6 +117,25 @@
                return true;
        }
 
+               /*
+        * Returns whether an article is in the specific category
+        *
+        * @param $articleId Integer: Article ID
+        * @param $category String: The category name (without Category: Prefix)
+        *
+        * @return bool
+        */
+       private static function isInCategory( $articleId, $category ) {
+               $dbr = wfGetDB( DB_SLAVE );
+               return (bool)$dbr->selectRow( 'categorylinks', '1',
+                       array(
+                               'cl_from' => $articleId,
+                               'cl_to' => $category,
+                       ),
+                       __METHOD__
+               );
+       }
+
        /**
         * Adds a reference to a javascript file to the head of the document
         * @param string $src Path to the file relative to this extension's 
folder

Modified: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php     2010-09-02 20:48:02 UTC (rev 72226)
+++ trunk/phase3/includes/Title.php     2010-09-02 20:52:01 UTC (rev 72227)
@@ -3530,24 +3530,6 @@
                return !$this->isExternal() && MWNamespace::isWatchable( 
$this->getNamespace() );
        }
 
-       /*
-        * Returns whether an article is in the specific category
-        *
-        * @param $category String: The category name (without Category: Prefix)
-        *
-        * @return bool
-        */
-       public function isInCategory( $category ) {
-               $dbr = wfGetDB( DB_SLAVE );
-               return (bool)$dbr->selectRow( 'categorylinks', '*',
-                       array(
-                               'cl_from' => $this->getArticleId(),
-                               'cl_to' => $category,
-                       ),
-                       __METHOD__
-               );
-       }
-
        /**
         * Get categories to which this Title belongs and return an array of
         * categories' names.



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

Reply via email to