r26434 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26433‎ | r26434 | r26435 >
Date:08:55, 5 October 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
More autoloading, document autoloading in class docu
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Error.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_OldDataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Embedded.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_List.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Table.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Template.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Timeline.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SpecialPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/URIResolver/SMW_SpecialURIResolver.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_OldDataValue.php
@@ -1,7 +1,6 @@
22 <?php
33
44 require_once('SMW_Datatype.php');
5 -require_once('SMW_DataValue.php');
65
76 /**
87 * Objects of this type represent all that is known about
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php
@@ -4,6 +4,8 @@
55 * Objects of this type represent all that is known about
66 * a certain user-provided data value, especially its various
77 * representations as strings, tooltips, numbers, etc.
 8+ *
 9+ * @note AUTOLOADED
810 */
911 abstract class SMWDataValue {
1012
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_List.php
@@ -11,6 +11,8 @@
1212 * in between their elements depending on whether the element is the first that is
1313 * printed, the first that is printed in parentheses, or the last that will be printed.
1414 * Maybe one could further simplify this.
 15+ *
 16+ * @note AUTOLOADED
1517 */
1618 class SMWListResultPrinter extends SMWResultPrinter {
1719
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Error.php
@@ -1,12 +1,10 @@
22 <?php
33
4 -global $smwgIP;
5 -include_once($smwgIP . '/includes/SMW_DataValue.php');
6 -
74 /**
85 * This datavalue implements Error-Datavalues.
9 - *
10 - * @author: Nikolas Iwan
 6+ *
 7+ * @author Nikolas Iwan
 8+ * @note AUTOLOADED
119 */
1210 class SMWErrorValue extends SMWDataValue {
1311
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Table.php
@@ -6,6 +6,8 @@
77
88 /**
99 * New implementation of SMW's printer for result tables.
 10+ *
 11+ * @note AUTOLOADED
1012 */
1113 class SMWTableResultPrinter extends SMWResultPrinter {
1214
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php
@@ -4,8 +4,9 @@
55 * This datavalue implements URL/URI/ANNURI/EMAIL-Datavalues suitable for defining
66 * the respective types of properties.
77 *
8 - * @author: Nikolas Iwan
9 - * @author: Markus Krötzsch
 8+ * @author Nikolas Iwan
 9+ * @author Markus Krötzsch
 10+ * @note AUTOLOADED
1011 */
1112
1213 define('SMW_URI_MODE_EMAIL',1);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Embedded.php
@@ -12,6 +12,7 @@
1313 * If "titlestyle" is not specified, a <h1> tag is used.
1414 * @author Fernando Correia
1515 * @author Markus Krötzsch
 16+ * @note AUTOLOADED
1617 */
1718 class SMWEmbeddedResultPrinter extends SMWResultPrinter {
1819
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php
@@ -1,13 +1,12 @@
22 <?php
33
4 -global $smwgIP;
5 -include_once($smwgIP . '/includes/SMW_DataValue.php');
6 -
74 /**
85 * This datavalue implements String-Datavalues suitable for defining
96 * String-types of properties.
107 *
11 - * @author: Nikolas Iwan
 8+ * @author Nikolas Iwan
 9+ * @author Markus Krötzsch
 10+ * @note AUTOLOADED
1211 */
1312 class SMWStringValue extends SMWDataValue {
1413
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Timeline.php
@@ -7,6 +7,8 @@
88
99 /**
1010 * New implementation of SMW's printer for timeline data.
 11+ *
 12+ * @note AUTOLOADED
1113 */
1214 class SMWTimelineResultPrinter extends SMWResultPrinter {
1315
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Template.php
@@ -7,6 +7,8 @@
88 /**
99 * Printer for template data. Passes a result row as anonymous parameters to
1010 * a given template (which might ignore them or not) and prints the result.
 11+ *
 12+ * @note AUTOLOADED
1113 */
1214 class SMWTemplateResultPrinter extends SMWResultPrinter {
1315
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SpecialPage.php
@@ -9,6 +9,8 @@
1010 * A simple extension of SpecialPage that ensures that all relevant SMW-user
1111 * messages are loaded when the special page is initialised. This is especially
1212 * relevant as an adaptor for query pages.
 13+ *
 14+ * @note AUTOLOAD
1315 */
1416 class SMWSpecialPage extends SpecialPage {
1517
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -55,36 +55,44 @@
5656 }
5757 $wgExtensionFunctions[] = 'smwfSetupExtension';
5858
59 - ///// setup some autoloading /////
 59+ ///// Set up autoloading
 60+ ///// All classes registered for autoloading here should be tagged with this information:
 61+ ///// Add "@note AUTOLOADED" to their class documentation. This avoids useless includes.
 62+
 63+ // printers
6064 $wgAutoloadClasses['SMWResultPrinter'] = $smwgIP . '/includes/SMW_QueryPrinter.php';
6165 $wgAutoloadClasses['SMWTableResultPrinter'] = $smwgIP . '/includes/SMW_QP_Table.php';
6266 $wgAutoloadClasses['SMWListResultPrinter'] = $smwgIP . '/includes/SMW_QP_List.php';
6367 $wgAutoloadClasses['SMWTimelineResultPrinter'] = $smwgIP . '/includes/SMW_QP_Timeline.php';
6468 $wgAutoloadClasses['SMWEmbeddedResultPrinter'] = $smwgIP . '/includes/SMW_QP_Embedded.php';
6569 $wgAutoloadClasses['SMWTemplateResultPrinter'] = $smwgIP . '/includes/SMW_QP_Template.php';
 70+ // datavalues
 71+ $wgAutoloadClasses['SMWDataValue'] = $smwgIP . '/includes/SMW_DataValue.php';
 72+ // the builtin types are registered by SMWDataValueFactory if needed, will be reliably available
 73+ // to other DV-implementations that register to the factory.
6674
67 - ///// register specials, do that early on in case some other extension calls "addPage" /////
68 - $wgAutoloadClasses['SMWAskPage'] = $smwgIP . '/specials/AskSpecial/SMW_SpecialAsk.php';
69 - $wgSpecialPages['Ask'] = array('SMWAskPage');
70 - $wgAutoloadClasses['SMWSpecialBrowse'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php';
71 - $wgSpecialPages['Browse'] = array('SMWSpecialBrowse');
72 - $wgAutoloadClasses['SMWPageProperty'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialPageProperty.php';
73 - $wgSpecialPages['PageProperty'] = array('SMWPageProperty');
 75+ ///// Register specials, do that early on in case some other extension calls "addPage" /////
 76+ $wgAutoloadClasses['SMWAskPage'] = $smwgIP . '/specials/AskSpecial/SMW_SpecialAsk.php';
 77+ $wgSpecialPages['Ask'] = array('SMWAskPage');
 78+ $wgAutoloadClasses['SMWSpecialBrowse'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php';
 79+ $wgSpecialPages['Browse'] = array('SMWSpecialBrowse');
 80+ $wgAutoloadClasses['SMWPageProperty'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialPageProperty.php';
 81+ $wgSpecialPages['PageProperty'] = array('SMWPageProperty');
7482 $wgAutoloadClasses['SMWSearchByProperty'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByProperty.php';
75 - $wgSpecialPages['SearchByProperty'] = array('SMWSearchByProperty');
76 - $wgAutoloadClasses['SMWURIResolver'] = $smwgIP . '/specials/URIResolver/SMW_SpecialURIResolver.php';
77 - $wgSpecialPages['URIResolver'] = array('SMWURIResolver');
78 - $wgAutoloadClasses['SMWAdmin'] = $smwgIP . '/specials/SMWAdmin/SMW_SpecialSMWAdmin.php';
79 - $wgSpecialPages['SMWAdmin'] = array('SMWAdmin');
 83+ $wgSpecialPages['SearchByProperty'] = array('SMWSearchByProperty');
 84+ $wgAutoloadClasses['SMWURIResolver'] = $smwgIP . '/specials/URIResolver/SMW_SpecialURIResolver.php';
 85+ $wgSpecialPages['URIResolver'] = array('SMWURIResolver');
 86+ $wgAutoloadClasses['SMWAdmin'] = $smwgIP . '/specials/SMWAdmin/SMW_SpecialSMWAdmin.php';
 87+ $wgSpecialPages['SMWAdmin'] = array('SMWAdmin');
 88+ // suboptimal special pages using the SMWSpecialPage wrapper class:
 89+ $wgAutoloadClasses['SMWSpecialPage'] = $smwgIP . '/includes/SMW_SpecialPage.php';
 90+ $wgSpecialPages['Properties'] = array('SMWSpecialPage','Properties', 'smwfDoSpecialProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialProperties.php');
 91+ $wgSpecialPages['UnusedProperties'] = array('SMWSpecialPage','UnusedProperties', 'smwfDoSpecialUnusedProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialUnusedProperties.php');
 92+ $wgSpecialPages['WantedProperties'] = array('SMWSpecialPage','WantedProperties', 'smwfDoSpecialWantedProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialWantedProperties.php');
 93+ $wgSpecialPages['ExportRDF'] = array('SMWSpecialPage','ExportRDF', 'smwfDoSpecialExportRDF', $smwgIP . '/specials/ExportRDF/SMW_SpecialExportRDF.php');
 94+ $wgSpecialPages['SemanticStatistics'] = array('SMWSpecialPage','SemanticStatistics', 'smwfExecuteSemanticStatistics', $smwgIP . '/specials/Statistics/SMW_SpecialStatistics.php');
 95+ $wgSpecialPages['Types'] = array('SMWSpecialPage','Types', 'smwfDoSpecialTypes', $smwgIP . '/specials/QueryPages/SMW_SpecialTypes.php');
8096
81 - $wgAutoloadClasses['SMWSpecialPage'] = $smwgIP . '/includes/SMW_SpecialPage.php';
82 - $wgSpecialPages['Properties'] = array('SMWSpecialPage','Properties', 'smwfDoSpecialProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialProperties.php');
83 - $wgSpecialPages['UnusedProperties'] = array('SMWSpecialPage','UnusedProperties', 'smwfDoSpecialUnusedProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialUnusedProperties.php');
84 - $wgSpecialPages['WantedProperties'] = array('SMWSpecialPage','WantedProperties', 'smwfDoSpecialWantedProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialWantedProperties.php');
85 - $wgSpecialPages['ExportRDF'] = array('SMWSpecialPage','ExportRDF', 'smwfDoSpecialExportRDF', $smwgIP . '/specials/ExportRDF/SMW_SpecialExportRDF.php');
86 - $wgSpecialPages['SemanticStatistics'] = array('SMWSpecialPage','SemanticStatistics', 'smwfExecuteSemanticStatistics', $smwgIP . '/specials/Statistics/SMW_SpecialStatistics.php');
87 - $wgSpecialPages['Types'] = array('SMWSpecialPage','Types', 'smwfDoSpecialTypes', $smwgIP . '/specials/QueryPages/SMW_SpecialTypes.php');
88 -
8997 return true;
9098 }
9199
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php
@@ -1,8 +1,5 @@
22 <?php
33
4 -global $smwgIP;
5 -include_once($smwgIP . '/includes/SMW_DataValue.php');
6 -
74 /**
85 * This datavalue implements special processing suitable for defining
96 * wikipages as values of properties. This value container currently
@@ -12,6 +9,7 @@
1310 *
1411 * @author Nikolas Iwan
1512 * @author Markus Krötzsch
 13+ * @note AUTOLOADED
1614 */
1715 class SMWWikiPageValue extends SMWDataValue {
1816
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php
@@ -1,8 +1,5 @@
22 <?php
33
4 -global $smwgIP;
5 -include_once($smwgIP . '/includes/SMW_DataValue.php');
6 -
74 /**
85 * This datavalue implements special processing suitable for defining
96 * types of properties (n-ary or binary).
@@ -11,6 +8,9 @@
129 * - to efficiently be generated from XSD values and to provide according
1310 * wiki values, in order to support speedy creation of datavalues in
1411 * SMWDataValueFactory.
 12+ *
 13+ * @author Markus Krötzsch
 14+ * @note AUTOLOADED
1515 */
1616 class SMWTypesValue extends SMWDataValue {
1717
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php
@@ -1,14 +1,12 @@
22 <?php
33
44 /**
5 - * The SMWDataValue in this file implements the handling of n-ary relations.
 5+ * SMWDataValue implements the handling of n-ary relations.
 6+ *
67 * @author Jörg Heizmann
78 * @author Markus Krötzsch
 9+ * @note AUTOLOADED
810 */
9 -
10 -global $smwgIP;
11 -include_once($smwgIP . '/includes/SMW_DataValue.php');
12 -
1311 class SMWNAryValue extends SMWDataValue {
1412
1513 private $m_scount = 0;
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -15,6 +15,8 @@
1616 /**
1717 * A class to encapsulate the special page that allows browsing through
1818 * the knowledge structure of a Semantic MediaWiki.
 19+ *
 20+ * @note AUTOLOAD
1921 */
2022 class SMWSpecialBrowse extends SpecialPage {
2123
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
@@ -8,7 +8,7 @@
99 * This will be assumedly seldomly used.
1010 *
1111 * FIXME: Actually this is currently not used anywhere.
12 - * FIXME: The result-page browsing is broken, showing the last result on one page as the first resutl of the next.
 12+ * FIXME: The result-page browsing is broken, showing the last result on one page as the first result of the next.
1313 */
1414
1515 if (!defined('MEDIAWIKI')) die();
@@ -16,6 +16,9 @@
1717 global $IP;
1818 include_once( "$IP/includes/SpecialPage.php" );
1919
 20+/**
 21+ * @note AUTOLOAD
 22+ */
2023 class SMWPageProperty extends SpecialPage {
2124
2225 /**
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php
@@ -1,4 +1,10 @@
22 <?php
 3+
 4+if (!defined('MEDIAWIKI')) die();
 5+
 6+global $IP;
 7+include_once($IP . '/includes/SpecialPage.php');
 8+
39 /**
410 * @author Denny Vrandecic
511 *
@@ -6,13 +12,9 @@
713 * view on a relation-object pair, i.e. a typed baclink.
814 * For example, it shows me all persons born in Croatia,
915 * or all winners of the Academy Award for best actress.
 16+ *
 17+ * @note AUTOLOAD
1018 */
11 -
12 -if (!defined('MEDIAWIKI')) die();
13 -
14 -global $IP;
15 -include_once($IP . '/includes/SpecialPage.php');
16 -
1719 class SMWSearchByProperty extends SpecialPage {
1820
1921 /**
Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -1,16 +1,18 @@
22 <?php
 3+
 4+if (!defined('MEDIAWIKI')) die();
 5+
 6+global $IP;
 7+include_once($IP . '/includes/SpecialPage.php');
 8+
39 /**
410 * @author Markus Krötzsch
511 *
612 * This special page for MediaWiki implements a customisable form for
713 * executing queries outside of articles.
 14+ *
 15+ * @note AUTOLOAD
816 */
9 -
10 -if (!defined('MEDIAWIKI')) die();
11 -
12 -global $IP;
13 -include_once($IP . '/includes/SpecialPage.php');
14 -
1517 class SMWAskPage extends SpecialPage {
1618
1719 /**
Index: trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php
@@ -1,17 +1,19 @@
22 <?php
 3+
 4+if (!defined('MEDIAWIKI')) die();
 5+
 6+global $IP;
 7+include_once($IP . '/includes/SpecialPage.php');
 8+
39 /**
410 * @author Markus Krötzsch
511 *
612 * This special page for MediaWiki provides an administrative interface
713 * that allows to execute certain functions related to the maintainance
814 * of the semantic database. It is restricted to users with siteadmin status.
 15+ *
 16+ * @note AUTOLOAD
917 */
10 -
11 -if (!defined('MEDIAWIKI')) die();
12 -
13 -global $IP;
14 -include_once($IP . '/includes/SpecialPage.php');
15 -
1618 class SMWAdmin extends SpecialPage {
1719
1820 /**
Index: trunk/extensions/SemanticMediaWiki/specials/URIResolver/SMW_SpecialURIResolver.php
@@ -1,17 +1,19 @@
22 <?php
 3+
 4+if (!defined('MEDIAWIKI')) die();
 5+
 6+global $IP;
 7+include_once($IP . '/includes/SpecialPage.php');
 8+
39 /**
410 * @author Denny Vrandecic
511 *
6 - * This special page solves with the URI crisis
 12+ * This special page solves the URI crisis
713 * without the need of changing code deep in
814 * MediaWiki were no hook has ever seen light.
 15+ *
 16+ * @note AUTOLOAD
917 */
10 -
11 -if (!defined('MEDIAWIKI')) die();
12 -
13 -global $IP;
14 -include_once($IP . '/includes/SpecialPage.php');
15 -
1618 class SMWURIResolver extends SpecialPage {
1719
1820 /**

Status & tagging log