r36913 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36912‎ | r36913 | r36914 >
Date:14:16, 2 July 2008
Author:yaron
Status:old
Tags:
Comment:
Improved SpecialPage initialization
Modified paths:
  • /trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/specials/SD_Filters.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/specials/SD_Filters.php
@@ -7,32 +7,22 @@
88
99 if (!defined('MEDIAWIKI')) die();
1010
11 -global $IP;
12 -require_once( "$IP/includes/SpecialPage.php" );
 11+class SDFilters extends SpecialPage {
1312
14 -global $sdgSpecialPagesSpecialInit;
15 -if ($sdgSpecialPagesSpecialInit) {
16 - global $wgSpecialPages;
17 - $wgSpecialPages['Filters'] = 'SDFilters';
 13+ /**
 14+ * Constructor
 15+ */
 16+ function SDFilters() {
 17+ SpecialPage::SpecialPage('Filters');
 18+ wfLoadExtensionMessages('SemanticDrilldown');
 19+ }
1820
19 - class SDFilters extends SpecialPage {
20 -
21 - /**
22 - * Constructor
23 - */
24 - public function __construct() {
25 - smwfInitUserMessages();
26 - parent::__construct('Filters', '', true);
27 - }
28 -
29 - function execute() {
30 - list( $limit, $offset ) = wfCheckLimits();
31 - $rep = new FiltersPage();
32 - return $rep->doQuery( $offset, $limit );
33 - }
 21+ function execute() {
 22+ $this->setHeaders();
 23+ list( $limit, $offset ) = wfCheckLimits();
 24+ $rep = new FiltersPage();
 25+ return $rep->doQuery( $offset, $limit );
3426 }
35 -} else {
36 - SpecialPage::addPage( new SpecialPage('Filters','',true,'doSpecialFilters',false) );
3727 }
3828
3929 class FiltersPage extends QueryPage {
@@ -75,9 +65,3 @@
7666 return $text;
7767 }
7868 }
79 -
80 -function doSpecialFilters() {
81 - list( $limit, $offset ) = wfCheckLimits();
82 - $rep = new FiltersPage();
83 - return $rep->doQuery( $offset, $limit );
84 -}
Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php
@@ -9,11 +9,22 @@
1010
1111 if (!defined('MEDIAWIKI')) die();
1212
13 -global $IP;
14 -require_once( "$IP/includes/SpecialPage.php" );
 13+class SDBrowseData extends SpecialPage {
1514
16 -SpecialPage::addPage( new SpecialPage('BrowseData','',true,'doSpecialBrowseData',false) );
 15+ /**
 16+ * Constructor
 17+ */
 18+ public function SDBrowseData() {
 19+ SpecialPage::SpecialPage('BrowseData');
 20+ wfLoadExtensionMessages('SemanticDrilldown');
 21+ }
1722
 23+ function execute() {
 24+ $this->setHeaders();
 25+ doSpecialBrowseData();
 26+ }
 27+}
 28+
1829 class BrowseDataPage extends QueryPage {
1930 var $category = "";
2031 var $subcategory = "";
@@ -524,7 +535,7 @@
525536 $property_field = 'attribute_title';
526537 $value_field = 'value_xsd';
527538 }
528 - if ($applied_filter->filter->time_period != NULL) {
 539+ if ($applied_filter->filter->time_period != NULL) {
529540 if ($applied_filter->filter->time_period == wfMsg('sd_filter_month')) {
530541 $value_field = "YEAR(value_xsd), MONTH(value_xsd)";
531542 } else {
@@ -566,7 +577,7 @@
567578 $property_table_nickname = "a";
568579 $value_field = 'value_xsd';
569580 }
570 - if ($applied_filter->filter->time_period != NULL) {
 581+ if ($applied_filter->filter->time_period != NULL) {
571582 if ($applied_filter->filter->time_period == wfMsg('sd_filter_month')) {
572583 $value_field = "YEAR(value_xsd), MONTH(value_xsd)";
573584 } else {
@@ -977,9 +988,9 @@
978989 return $sql;
979990 }
980991
981 - function getOrder() {
982 - return ' ORDER BY sortkey ';
983 - }
 992+ function getOrder() {
 993+ return ' ORDER BY sortkey ';
 994+ }
984995
985996 function formatResult($skin, $result) {
986997 $title = Title::makeTitle( $result->namespace, $result->value );
@@ -1097,7 +1108,7 @@
10981109 }
10991110
11001111 END;
1101 - $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n");
 1112+ $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n");
11021113
11031114 // set default
11041115 if ($sdgNumResultsPerPage == null)
@@ -1108,12 +1119,12 @@
11091120 // get information on current category, subcategory and filters that
11101121 // have already been applied from the query string
11111122 $category = str_replace('_', ' ', $wgRequest->getVal('_cat'));
1112 - // if query string did not contain this variables, try the URL
1113 - if (! $category) {
1114 - $queryparts = explode('/', $query, 1);
1115 - $category = isset($queryparts[0]) ? $queryparts[0] : '';
1116 - }
 1123+ // if query string did not contain this variables, try the URL
11171124 if (! $category) {
 1125+ $queryparts = explode('/', $query, 1);
 1126+ $category = isset($queryparts[0]) ? $queryparts[0] : '';
 1127+ }
 1128+ if (! $category) {
11181129 $category_title = wfMsg('browsedata');
11191130 } else {
11201131 $titles_for_category = sdfGetValuesForProperty($category, NS_CATEGORY, SD_SP_HAS_DRILLDOWN_TITLE, false, NS_MAIN);

Status & tagging log