Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -1153,6 +1153,19 @@ |
1154 | 1154 | |
1155 | 1155 | |
1156 | 1156 | |
| 1157 | +function pr_query_count( $dbr, $query, $cat ){ |
| 1158 | + $q = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( $cat ) ) ); |
| 1159 | + $res = $dbr->query( str_replace( '###', $q, $query) , __METHOD__ ); |
| 1160 | + if( $res && $dbr->numRows( $res ) > 0 ) { |
| 1161 | + $row = $dbr->fetchObject( $res ); |
| 1162 | + $n = $row->count; |
| 1163 | + $dbr->freeResult( $res ); |
| 1164 | + return $n; |
| 1165 | + } |
| 1166 | + return 0; |
| 1167 | +} |
| 1168 | + |
| 1169 | + |
1157 | 1170 | /* |
1158 | 1171 | * update the pr_index entry of an article |
1159 | 1172 | */ |
— | — | @@ -1190,53 +1203,29 @@ |
1191 | 1204 | if($page != $deletedpage) array_push( $pages, $page ); |
1192 | 1205 | } |
1193 | 1206 | } |
1194 | | - $n0 = $n1 = $n2 = $n3 = $n4 = 0; |
1195 | 1207 | |
1196 | 1208 | $dbr = wfGetDB( DB_SLAVE ); |
1197 | 1209 | $catlinks = $dbr->tableName( 'categorylinks' ); |
1198 | 1210 | $page = $dbr->tableName( 'page' ); |
1199 | 1211 | $pagelist = "'".implode( "', '", $pages)."'"; |
1200 | | - $query = "SELECT COUNT(page_id) AS count FROM $page LEFT JOIN $catlinks ON cl_from=page_id WHERE cl_to='###' AND page_namespace=$page_ns_index AND page_title IN ( $pagelist )" ; |
1201 | 1212 | |
1202 | | - $q0 = str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality0_category' ) ); |
1203 | | - $res = $dbr->query( str_replace( '###', $q0, $query) , __METHOD__ ); |
1204 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
1205 | | - $row = $dbr->fetchObject( $res ); |
1206 | | - $n0 = $row->count; |
1207 | | - $dbr->freeResult( $res ); |
1208 | | - } |
1209 | | - |
1210 | | - $q2 = str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality2_category' ) ); |
1211 | | - $res = $dbr->query( str_replace( '###', $q2, $query) , __METHOD__ ); |
1212 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
1213 | | - $row = $dbr->fetchObject( $res ); |
1214 | | - $n2 = $row->count; |
1215 | | - $dbr->freeResult( $res ); |
1216 | | - } |
1217 | | - |
1218 | | - $q3 = str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality3_category' ) ); |
1219 | | - $res = $dbr->query( str_replace( '###', $q3, $query) , __METHOD__ ); |
1220 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
1221 | | - $row = $dbr->fetchObject( $res ); |
1222 | | - $n3 = $row->count; |
1223 | | - $dbr->freeResult( $res ); |
1224 | | - } |
1225 | | - |
1226 | | - $q4 = str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality4_category' ) ); |
1227 | | - $res = $dbr->query( str_replace( '###', $q4, $query) , __METHOD__ ); |
1228 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
1229 | | - $row = $dbr->fetchObject( $res ); |
1230 | | - $n4 = $row->count; |
1231 | | - $dbr->freeResult( $res ); |
1232 | | - } |
1233 | | - |
1234 | 1213 | $query = "SELECT COUNT(page_id) AS count FROM $page WHERE page_namespace=$page_ns_index AND page_title IN ( $pagelist )" ; |
1235 | 1214 | $res = $dbr->query( $query , __METHOD__ ); |
1236 | 1215 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1237 | 1216 | $row = $dbr->fetchObject( $res ); |
1238 | | - $n1 = $row->count - $n0 - $n2 - $n3 - $n4; |
| 1217 | + $total = $row->count; |
1239 | 1218 | $dbr->freeResult( $res ); |
| 1219 | + } else { |
| 1220 | + return; |
1240 | 1221 | } |
| 1222 | + |
| 1223 | + # proofreading status of pages |
| 1224 | + $query = "SELECT COUNT(page_id) AS count FROM $page LEFT JOIN $catlinks ON cl_from=page_id WHERE cl_to='###' AND page_namespace=$page_ns_index AND page_title IN ( $pagelist )" ; |
| 1225 | + $n0 = pr_query_count( $dbr, $query, 'proofreadpage_quality0_category' ); |
| 1226 | + $n2 = pr_query_count( $dbr, $query, 'proofreadpage_quality2_category' ); |
| 1227 | + $n3 = pr_query_count( $dbr, $query, 'proofreadpage_quality3_category' ); |
| 1228 | + $n4 = pr_query_count( $dbr, $query, 'proofreadpage_quality4_category' ); |
| 1229 | + $n1 = $total - $n0 - $n2 - $n3 - $n4; |
1241 | 1230 | |
1242 | 1231 | $dbw = wfGetDB( DB_MASTER ); |
1243 | 1232 | $pr_index = $dbw->tableName( 'pr_index' ); |
— | — | @@ -1292,40 +1281,11 @@ |
1293 | 1282 | |
1294 | 1283 | # find the proofreading status of transclusions |
1295 | 1284 | $query = "SELECT COUNT(page_id) AS count FROM $templatelinks LEFT JOIN $page ON page_title=tl_title LEFT JOIN $catlinks ON cl_from=page_id where tl_from=$id and tl_namespace=$page_ns_index AND cl_to='###'"; |
1296 | | - |
1297 | | - $q4 = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality4_category' ) ) ); |
1298 | | - $res = $dbr->query( str_replace( '###', $q4, $query) , __METHOD__ ); |
1299 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
1300 | | - $row = $dbr->fetchObject( $res ); |
1301 | | - $n4 = $row->count; |
1302 | | - $dbr->freeResult( $res ); |
1303 | | - } |
1304 | | - |
1305 | | - $q3 = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality3_category' ) ) ); |
1306 | | - $res = $dbr->query( str_replace( '###', $q3, $query) , __METHOD__ ); |
1307 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
1308 | | - $row = $dbr->fetchObject( $res ); |
1309 | | - $n3 = $row->count; |
1310 | | - $dbr->freeResult( $res ); |
1311 | | - } |
1312 | | - |
1313 | | - $q2 = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality2_category' ) ) ); |
1314 | | - $res = $dbr->query( str_replace( '###', $q2, $query) , __METHOD__ ); |
1315 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
1316 | | - $row = $dbr->fetchObject( $res ); |
1317 | | - $n2 = $row->count; |
1318 | | - $dbr->freeResult( $res ); |
1319 | | - } |
1320 | | - |
1321 | | - $q0 = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality0_category' ) ) ); |
1322 | | - $res = $dbr->query( str_replace( '###', $q0, $query) , __METHOD__ ); |
1323 | | - if( $res && $dbr->numRows( $res ) > 0 ) { |
1324 | | - $row = $dbr->fetchObject( $res ); |
1325 | | - $n0 = $row->count; |
1326 | | - $dbr->freeResult( $res ); |
1327 | | - } |
1328 | | - |
1329 | | - # q1 is default value |
| 1285 | + $n0 = pr_query_count( $dbr, $query, 'proofreadpage_quality0_category' ); |
| 1286 | + $n2 = pr_query_count( $dbr, $query, 'proofreadpage_quality2_category' ); |
| 1287 | + $n3 = pr_query_count( $dbr, $query, 'proofreadpage_quality3_category' ); |
| 1288 | + $n4 = pr_query_count( $dbr, $query, 'proofreadpage_quality4_category' ); |
| 1289 | + # quality1 is the default value |
1330 | 1290 | $n1 = $n - $n0 - $n2 - $n3 - $n4; |
1331 | 1291 | |
1332 | 1292 | # find the index page |
Index: trunk/extensions/ProofreadPage/SpecialProofreadPages.php |
— | — | @@ -45,7 +45,6 @@ |
46 | 46 | $dbr = wfGetDB( DB_SLAVE ); |
47 | 47 | $page = $dbr->tableName( 'page' ); |
48 | 48 | $pr_index = $dbr->tableName( 'pr_index' ); |
49 | | - $name = $dbr->addQuotes( $this->getName() ); |
50 | 49 | |
51 | 50 | return |
52 | 51 | "SELECT pr_page_id as title, |