Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php |
— | — | @@ -229,11 +229,15 @@ |
230 | 230 | * Return an array of records given type and other criteria |
231 | 231 | */ |
232 | 232 | function getRecords( $type, $posted, $wpTitle = '', $invert = false, $orderby = 'created desc' ) { |
| 233 | + |
| 234 | + # First get all the articles using the type's template |
233 | 235 | $records = array(); |
234 | 236 | $dbr = wfGetDB( DB_SLAVE ); |
235 | 237 | $tbl = $dbr->tableName( 'templatelinks' ); |
236 | 238 | $ty = $dbr->addQuotes( $type ); |
237 | 239 | $res = $dbr->select( $tbl, 'tl_from', "tl_namespace = 10 AND tl_title = $ty", __METHOD__ ); |
| 240 | + |
| 241 | + # Loop through them adding only those that match the regex fields |
238 | 242 | while ( $row = $dbr->fetchRow( $res ) ) { |
239 | 243 | $t = Title::newFromID( $row[0] ); |
240 | 244 | if ( empty( $wpTitle ) || eregi( $wpTitle, $t->getPrefixedText() ) ) { |
— | — | @@ -243,6 +247,7 @@ |
244 | 248 | $r = array( 0 => $t, 'title' => $t->getPrefixedText() ); |
245 | 249 | foreach ( array_keys( $this->types ) as $k ) { |
246 | 250 | $v = isset( $posted[$k] ) ? ( $this->types[$k] == 'bool' ? 'yes' : $posted[$k] ) : ''; |
| 251 | + if ( !preg_match( "|\s*\|\s*$k\s*=|", $text ) ) $text .= "\n|$k=|\n"; # Treat non-existent fields as existing but empty |
247 | 252 | $i = preg_match( "|\s*\|\s*$k\s*=\s*(.*?)\s*(?=[\|\}])|si", $text, $m ); |
248 | 253 | if ( $v && !( $i && eregi( $v, $m[1] ) ) ) $match = false; |
249 | 254 | $r[$k] = isset( $m[1] ) ? $m[1] : ''; |
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.5.5, 2009-03-09' ); |
| 15 | +define( 'RECORDADMIN_VERSION', '0.5.6, 2009-03-11' ); |
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 |