Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php |
— | — | @@ -819,15 +819,21 @@ |
820 | 820 | |
821 | 821 | /** |
822 | 822 | * Return a list of title objects of a specified record type |
| 823 | + * - set $count to true to return just the number of results |
823 | 824 | */ |
824 | | - static function getRecordsByType( $type ) { |
| 825 | + static function getRecordsByType( $type, $count = false ) { |
825 | 826 | $records = array(); |
826 | 827 | $dbr = wfGetDB( DB_SLAVE ); |
827 | 828 | $tbl = $dbr->tableName( 'templatelinks' ); |
828 | 829 | $ty = $dbr->addQuotes( $type ); |
829 | | - $res = $dbr->select( $tbl, 'tl_from', "tl_namespace = 10 AND tl_title = $ty", __METHOD__ ); |
830 | | - while ( $row = $dbr->fetchRow( $res ) ) $records[] = Title::newFromID( $row[0] ); |
831 | | - $dbr->freeResult( $res ); |
| 830 | + if ( $count ) { |
| 831 | + $row = $dbr->selectRow( $tbl, 'count(0)', "tl_namespace = 10 AND tl_title = $ty", __METHOD__ ); |
| 832 | + $records = $row[0]; |
| 833 | + } else { |
| 834 | + $res = $dbr->select( $tbl, 'tl_from', "tl_namespace = 10 AND tl_title = $ty", __METHOD__ ); |
| 835 | + while ( $row = $dbr->fetchRow( $res ) ) $records[] = Title::newFromID( $row[0] ); |
| 836 | + $dbr->freeResult( $res ); |
| 837 | + } |
832 | 838 | return $records; |
833 | 839 | } |
834 | 840 | |
Index: trunk/extensions/RecordAdmin/RecordAdmin.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * @licence GNU General Public Licence 2.0 or later |
13 | 13 | */ |
14 | 14 | |
15 | | -define( 'RECORDADMIN_VERSION', '0.11.10, 2010-04-11' ); |
| 15 | +define( 'RECORDADMIN_VERSION', '0.11.11, 2010-04-21' ); |
16 | 16 | |
17 | 17 | $wgRecordAdminUseNamespaces = false; # Whether record articles should be in a namespace of the same name as their type |
18 | 18 | $wgRecordAdminCategory = 'Records'; # Category containing record types |