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

Revision: 65353
Author:   nad
Date:     2010-04-21 02:29:59 +0000 (Wed, 21 Apr 2010)

Log Message:
-----------
add optional $count param to getRecordsByType()

Modified Paths:
--------------
    trunk/extensions/RecordAdmin/RecordAdmin.php
    trunk/extensions/RecordAdmin/RecordAdmin_body.php

Modified: trunk/extensions/RecordAdmin/RecordAdmin.php
===================================================================
--- trunk/extensions/RecordAdmin/RecordAdmin.php        2010-04-21 02:05:11 UTC 
(rev 65352)
+++ trunk/extensions/RecordAdmin/RecordAdmin.php        2010-04-21 02:29:59 UTC 
(rev 65353)
@@ -11,7 +11,7 @@
  * @licence GNU General Public Licence 2.0 or later
  */
 
-define( 'RECORDADMIN_VERSION', '0.11.10, 2010-04-11' );
+define( 'RECORDADMIN_VERSION', '0.11.11, 2010-04-21' );
 
 $wgRecordAdminUseNamespaces = false;     # Whether record articles should be 
in a namespace of the same name as their type
 $wgRecordAdminCategory      = 'Records'; # Category containing record types

Modified: trunk/extensions/RecordAdmin/RecordAdmin_body.php
===================================================================
--- trunk/extensions/RecordAdmin/RecordAdmin_body.php   2010-04-21 02:05:11 UTC 
(rev 65352)
+++ trunk/extensions/RecordAdmin/RecordAdmin_body.php   2010-04-21 02:29:59 UTC 
(rev 65353)
@@ -819,15 +819,21 @@
 
        /**
         * Return a list of title objects of a specified record type
+        * - set $count to true to return just the number of results
         */
-       static function getRecordsByType( $type ) {
+       static function getRecordsByType( $type, $count = false ) {
                $records = array();
                $dbr  = wfGetDB( DB_SLAVE );
                $tbl  = $dbr->tableName( 'templatelinks' );
                $ty   = $dbr->addQuotes( $type );
-               $res  = $dbr->select( $tbl, 'tl_from', "tl_namespace = 10 AND 
tl_title = $ty", __METHOD__ );
-               while ( $row = $dbr->fetchRow( $res ) ) $records[] = 
Title::newFromID( $row[0] );
-               $dbr->freeResult( $res );
+               if ( $count ) {
+                       $row = $dbr->selectRow( $tbl, 'count(0)', "tl_namespace 
= 10 AND tl_title = $ty", __METHOD__ );
+                       $records = $row[0];
+               } else {
+                       $res  = $dbr->select( $tbl, 'tl_from', "tl_namespace = 
10 AND tl_title = $ty", __METHOD__ );
+                       while ( $row = $dbr->fetchRow( $res ) ) $records[] = 
Title::newFromID( $row[0] );
+                       $dbr->freeResult( $res );
+               }
                return $records;
        }
 



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

Reply via email to