r36914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36913‎ | r36914 | r36915 >
Date:14:18, 2 July 2008
Author:yaron
Status:old
Tags:
Comment:
Improved initialization of special pages to use autoloading
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php
@@ -7,7 +7,7 @@
88
99 if (!defined('MEDIAWIKI')) die();
1010
11 -define('SD_VERSION','0.4.4');
 11+define('SD_VERSION','0.4.5');
1212
1313 // constants for special properties
1414 define('SD_SP_HAS_FILTER', 1);
@@ -29,6 +29,17 @@
3030 $wgExtensionFunctions[] = 'sdfLoadMessagesManually';
3131 }
3232
 33+// register all special pages
 34+$wgSpecialPages['Filters'] = 'SDFilters';
 35+$wgSpecialPageGroups['Filters'] = 'users';
 36+$wgAutoloadClasses['SDFilters'] = $sdgIP . '/specials/SD_Filters.php';
 37+$wgSpecialPages['CreateFilter'] = 'SDCreateFilter';
 38+$wgSpecialPageGroups['CreateFilter'] = 'users';
 39+$wgAutoloadClasses['SDCreateFilter'] = $sdgIP . '/specials/SD_CreateFilter.php';
 40+$wgSpecialPages['BrowseData'] = 'SDBrowseData';
 41+$wgSpecialPageGroups['BrowseData'] = 'users';
 42+$wgAutoloadClasses['SDBrowseData'] = $sdgIP . '/specials/SD_BrowseData.php';
 43+
3344 /**
3445 * Do the actual intialization of the extension. This is just a delayed init that makes sure
3546 * MediaWiki is set up properly before we add our stuff.
@@ -44,18 +55,10 @@
4556 require_once($sdgIP . '/includes/SD_AppliedFilter.php');
4657
4758 /**********************************************/
48 - /***** register specials *****/
 59+ /***** register hooks *****/
4960 /**********************************************/
5061
51 - require_once($sdgIP . '/specials/SD_BrowseData.php');
52 - require_once($sdgIP . '/specials/SD_Filters.php');
53 - require_once($sdgIP . '/specials/SD_CreateFilter.php');
54 -
5562 /**********************************************/
56 - /***** register hooks *****/
57 - /**********************************************/
58 -
59 - /**********************************************/
6063 /***** create globals for outside hooks *****/
6164 /**********************************************/
6265
@@ -63,7 +66,7 @@
6467 /***** credits (see "Special:Version") *****/
6568 /**********************************************/
6669 $wgExtensionCredits['specialpage'][]= array(
67 - 'name' => 'Semantic Drilldown',
 70+ 'name' => 'Semantic Drilldown',
6871 'version' => SD_VERSION,
6972 'author' => 'Yaron Koren',
7073 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Drilldown',
@@ -189,20 +192,20 @@
190193 * children of some other category
191194 */
192195 function sdfGetTopLevelCategories() {
193 - $categories = array();
194 - $dbr = wfGetDB( DB_SLAVE );
 196+ $categories = array();
 197+ $dbr = wfGetDB( DB_SLAVE );
195198 $page = $dbr->tableName('page');
196199 $categorylinks = $dbr->tableName('categorylinks');
197200 $cat_ns = NS_CATEGORY;
198201 $sql = "SELECT page_title FROM $page p LEFT OUTER JOIN $categorylinks cl ON p.page_id = cl.cl_from WHERE p.page_namespace = $cat_ns AND cl.cl_to IS NULL";
199202 $res = $dbr->query($sql);
200 - if ($dbr->numRows( $res ) > 0) {
201 - while ($row = $dbr->fetchRow($res)) {
202 - $categories[] = str_replace('_', ' ', $row[0]);
203 - }
204 - }
205 - $dbr->freeResult($res);
206 - return $categories;
 203+ if ($dbr->numRows( $res ) > 0) {
 204+ while ($row = $dbr->fetchRow($res)) {
 205+ $categories[] = str_replace('_', ' ', $row[0]);
 206+ }
 207+ }
 208+ $dbr->freeResult($res);
 209+ return $categories;
207210 }
208211
209212 function sdfGetSemanticProperties_0_7() {

Status & tagging log