r21203 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21202‎ | r21203 | r21204 >
Date:19:38, 12 April 2007
Author:hashar
Status:old
Tags:
Comment:
clean up white space, comments end at 80
Modified paths:
  • /trunk/phase3/includes/Categoryfinder.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Categoryfinder.php
@@ -1,15 +1,16 @@
22 <?php
33
44 /**
5 - * The "Categoryfinder" class takes a list of articles, creates an internal representation of all their parent
6 - * categories (as well as parents of parents etc.). From this representation, it determines which of these articles
7 - * are in one or all of a given subset of categories.
8 - *
 5+ * The "Categoryfinder" class takes a list of articles, creates an internal
 6+ * representation of all their parent categories (as well as parents of
 7+ * parents etc.). From this representation, it determines which of these
 8+ * articles are in one or all of a given subset of categories.
 9+ *
910 * Example use :
10 - *
 11+ *
1112 * # Determines wether the article with the page_id 12345 is in both
1213 * # "Category 1" and "Category 2" or their subcategories, respectively
13 - *
 14+ *
1415 * $cf = new Categoryfinder ;
1516 * $cf->seed (
1617 * array ( 12345 ) ,
@@ -18,8 +19,8 @@
1920 * ) ;
2021 * $a = $cf->run() ;
2122 * print implode ( "," , $a ) ;
22 - *
23 - *
 23+ *
 24+ *
2425 */
2526 class Categoryfinder {
2627
@@ -90,13 +91,13 @@
9192 function check ( $id , &$conds ) {
9293 # Shortcut (runtime paranoia): No contitions=all matched
9394 if ( count ( $conds ) == 0 ) return true ;
94 -
 95+
9596 if ( !isset ( $this->parents[$id] ) ) return false ;
9697
9798 # iterate through the parents
9899 foreach ( $this->parents[$id] AS $p ) {
99100 $pname = $p->cl_to ;
100 -
 101+
101102 # Is this a condition?
102103 if ( isset ( $conds[$pname] ) ) {
103104 # This key is in the category list!
@@ -113,7 +114,7 @@
114115 }
115116 }
116117 }
117 -
 118+
118119 # Not done yet, try sub-parents
119120 if ( !isset ( $this->name2id[$pname] ) ) {
120121 # No sub-parent
@@ -133,7 +134,7 @@
134135 */
135136 function scan_next_layer () {
136137 $fname = "Categoryfinder::scan_next_layer" ;
137 -
 138+
138139 # Find all parents of the article currently in $this->next
139140 $layer = array () ;
140141 $res = $this->dbr->select(
@@ -161,7 +162,7 @@
162163 $this->dbr->freeResult( $res ) ;
163164
164165 $this->next = array() ;
165 -
 166+
166167 # Find the IDs of all category pages in $layer, if they exist
167168 if ( count ( $layer ) > 0 ) {
168169 $res = $this->dbr->select(