r24955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24954‎ | r24955 | r24956 >
Date:15:55, 20 August 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Changed special page registration to use $wgSpecialPages and $wgAutoloadClasses. Average setup time of SMW now is well below 5ms :-)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SpecialPage.php (added) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SpecialPages.php (deleted) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/ExportRDF/SMW_SpecialExportRDF.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialProperties.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialTypes.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialUnusedProperties.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialWantedProperties.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/specials/AskSpecial/SMW_SpecialAsk.php
@@ -8,9 +8,21 @@
99
1010 if (!defined('MEDIAWIKI')) die();
1111
12 -class SMW_AskPage {
 12+global $IP;
 13+include_once($IP . '/includes/SpecialPage.php');
1314
14 - static function execute() {
 15+class SMWAskPage extends SpecialPage {
 16+
 17+ /**
 18+ * Constructor
 19+ */
 20+ public function __construct() {
 21+ smwfInitUserMessages();
 22+ parent::__construct('Ask');
 23+ }
 24+
 25+ function execute() {
 26+ wfProfileIn('doSpecialAsk (SMW)');
1527 global $wgRequest, $wgOut, $smwgQEnabled, $smwgQMaxLimit, $wgUser, $smwgQSortingSupport, $smwgIP;
1628
1729 $skin = $wgUser->getSkin();
@@ -88,6 +100,7 @@
89101 $html .= '<br />' . wfMsgForContent('smw_iq_disabled');
90102 }
91103 $wgOut->addHTML($html);
 104+ wfProfileOut('doSpecialAsk (SMW)');
92105 }
93106
94107 }
Index: trunk/extensions/SemanticMediaWiki/specials/SMWAdmin/SMW_SpecialSMWAdmin.php
@@ -9,81 +9,98 @@
1010
1111 if (!defined('MEDIAWIKI')) die();
1212
13 -function smwfSMWAdmin($par = null) {
14 - global $IP;
15 - require_once($IP . '/includes/SpecialPage.php' );
16 - require_once($IP . '/includes/Title.php' );
 13+global $IP;
 14+include_once($IP . '/includes/SpecialPage.php');
1715
18 - global $wgOut, $wgRequest;
19 - global $wgServer; // "http://www.yourserver.org"
20 - // (should be equal to 'http://'.$_SERVER['SERVER_NAME'])
21 - global $wgScript; // "/subdirectory/of/wiki/index.php"
22 - global $wgUser;
 16+class SMWAdmin extends SpecialPage {
2317
24 - if ( ! $wgUser->isAllowed('delete') ) {
25 - $wgOut->sysopRequired();
26 - return;
 18+ /**
 19+ * Constructor
 20+ */
 21+ public function __construct() {
 22+ smwfInitUserMessages();
 23+ global $wgMessageCache; ///TODO: should these be messages?
 24+ $wgMessageCache->addMessages(array('smwadmin' => 'Admin functions for Semantic MediaWiki'));
 25+ parent::__construct('SMWAdmin', 'delete');
2726 }
2827
29 - $wgOut->setPageTitle(wfMsg('smwadmin'));
30 -
31 - /**** Execute actions if any ****/
32 -
33 - $action = $wgRequest->getText( 'action' );
34 - if ( $action=='updatetables' ) {
35 - $sure = $wgRequest->getText( 'udsure' );
36 - if ($sure == 'yes') {
37 - $wgOut->disable(); // raw output
38 - ob_start();
39 - print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\" dir=\"ltr\">\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Setting up Storage for Semantic MediaWiki</title></head><body><p><pre>";
40 - header( "Content-type: text/html; charset=UTF-8" );
41 - $result = smwfGetStore()->setup();
42 - print '</pre></p>';
43 - if ($result === true) {
44 - print '<p><b>The storage engine was set up successfully.</b></p>';
45 - }
46 - print '<p> Return to <a href="' . $wgServer . $wgScript . '/Special:SMWAdmin">Special:SMWAdmin</a></p>';
47 - print '</body></html>';
48 - ob_flush();
49 - flush();
 28+ public function execute($par = null) {
 29+ global $IP;
 30+ require_once($IP . '/includes/SpecialPage.php' );
 31+ require_once($IP . '/includes/Title.php' );
 32+
 33+ global $wgOut, $wgRequest;
 34+ global $wgServer; // "http://www.yourserver.org"
 35+ // (should be equal to 'http://'.$_SERVER['SERVER_NAME'])
 36+ global $wgScript; // "/subdirectory/of/wiki/index.php"
 37+ global $wgUser;
 38+
 39+ if ( ! $wgUser->isAllowed('delete') ) {
 40+ $wgOut->sysopRequired();
5041 return;
5142 }
 43+
 44+ $wgOut->setPageTitle(wfMsg('smwadmin'));
 45+
 46+ /**** Execute actions if any ****/
 47+
 48+ $action = $wgRequest->getText( 'action' );
 49+ if ( $action=='updatetables' ) {
 50+ $sure = $wgRequest->getText( 'udsure' );
 51+ if ($sure == 'yes') {
 52+ $wgOut->disable(); // raw output
 53+ ob_start();
 54+ print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\" dir=\"ltr\">\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Setting up Storage for Semantic MediaWiki</title></head><body><p><pre>";
 55+ header( "Content-type: text/html; charset=UTF-8" );
 56+ $result = smwfGetStore()->setup();
 57+ print '</pre></p>';
 58+ if ($result === true) {
 59+ print '<p><b>The storage engine was set up successfully.</b></p>';
 60+ }
 61+ print '<p> Return to <a href="' . $wgServer . $wgScript . '/Special:SMWAdmin">Special:SMWAdmin</a></p>';
 62+ print '</body></html>';
 63+ ob_flush();
 64+ flush();
 65+ return;
 66+ }
 67+ }
 68+
 69+ /**** Normal output ****/
 70+
 71+ $html = '<p>This special page helps you during installation and upgrade of
 72+ Semantic MediaWiki. Remember to backup valuable data before
 73+ executing administrative functions.</p>' . "\n";
 74+ // creating tables and converting contents from older versions
 75+ $html .= '<form name="buildtables" action="" method="POST">' . "\n" .
 76+ '<input type="hidden" name="action" value="updatetables" />' . "\n";
 77+ $html .= '<h2>Preparing database for Semantic MediaWiki</h2>' . "\n" .
 78+ '<p>Semantic MediaWiki requires some minor extensions to the MediaWiki database in
 79+ order to store the semantic data. The below function ensures that your database is
 80+ set up properly. The changes made in this step do not affect the rest of the
 81+ MediaWiki database, and can easily be undone if desired. This setup function
 82+ can be executed multiple times without doing any harm, but it is needed only once on
 83+ installation or upgrade.<p/>' . "\n";
 84+ $html .= '<p>If the operation fails with obscure SQL errors, the database user employed
 85+ by your wiki (check your LocalSettings.php) probably does not have sufficient
 86+ permissions. Either grant this user additional persmissions to create and delete
 87+ tables, or temporarily enter the login of your database root in LocalSettings.php.<p/>' .
 88+ "\n" . '<input type="hidden" name="udsure" value="yes"/>' .
 89+ '<input type="submit" value="Initialise or upgrade tables"/>' . "\n";
 90+
 91+ $html .= '<h2>Getting support</h2>' . "\n" .
 92+ '<p>Various resources might help you in case of problems:</p>
 93+ <ul>
 94+ <li> If you experience problems with your installation, start by checking the guidelines in the <a href="http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SemanticMediaWiki/INSTALL">INSTALL file</a>.</li>
 95+ <li>The complete user documentation to Semantic MediaWiki is at <a href="http://ontoworld.org/wiki/Help:Semantics">ontoworld.org</a>.</li>
 96+ <li>Bugs can be reported to <a href="http://bugzilla.wikimedia.org/">MediaZilla</a>.</li>
 97+ <li>If you have further questions or suggestions, join the discussion on <a href="mailto:semediawiki-user@lists.sourceforge.net">semediawiki-user@lists.sourceforge.net</a>.</li>
 98+ <ul/>' . "\n";
 99+ $html .= '</form>';
 100+
 101+ $wgOut->addHTML($html);
 102+ return true;
52103 }
53104
54 - /**** Normal output ****/
55 -
56 - $html = '<p>This special page helps you during installation and upgrade of
57 - Semantic MediaWiki. Remember to backup valuable data before
58 - executing administrative functions.</p>' . "\n";
59 - // creating tables and converting contents from older versions
60 - $html .= '<form name="buildtables" action="" method="POST">' . "\n" .
61 - '<input type="hidden" name="action" value="updatetables" />' . "\n";
62 - $html .= '<h2>Preparing database for Semantic MediaWiki</h2>' . "\n" .
63 - '<p>Semantic MediaWiki requires some minor extensions to the MediaWiki database in
64 - order to store the semantic data. The below function ensures that your database is
65 - set up properly. The changes made in this step do not affect the rest of the
66 - MediaWiki database, and can easily be undone if desired. This setup function
67 - can be executed multiple times without doing any harm, but it is needed only once on
68 - installation or upgrade.<p/>' . "\n";
69 - $html .= '<p>If the operation fails with obscure SQL errors, the database user employed
70 - by your wiki (check your LocalSettings.php) probably does not have sufficient
71 - permissions. Either grant this user additional persmissions to create and delete
72 - tables, or temporarily enter the login of your database root in LocalSettings.php.<p/>' .
73 - "\n" . '<input type="hidden" name="udsure" value="yes"/>' .
74 - '<input type="submit" value="Initialise or upgrade tables"/>' . "\n";
75 -
76 - $html .= '<h2>Getting support</h2>' . "\n" .
77 - '<p>Various resources might help you in case of problems:</p>
78 - <ul>
79 - <li> If you experience problems with your installation, start by checking the guidelines in the <a href="http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SemanticMediaWiki/INSTALL">INSTALL file</a>.</li>
80 - <li>The complete user documentation to Semantic MediaWiki is at <a href="http://ontoworld.org/wiki/Help:Semantics">ontoworld.org</a>.</li>
81 - <li>Bugs can be reported to <a href="http://bugzilla.wikimedia.org/">MediaZilla</a>.</li>
82 - <li>If you have further questions or suggestions, join the discussion on <a href="mailto:semediawiki-user@lists.sourceforge.net">semediawiki-user@lists.sourceforge.net</a>.</li>
83 - <ul/>' . "\n";
84 - $html .= '</form>';
85 -
86 - $wgOut->addHTML($html);
87 - return true;
88105 }
89106
90107 // // Special function for fixing development testing DBs after messing around ...
Index: trunk/extensions/SemanticMediaWiki/specials/URIResolver/SMW_SpecialURIResolver.php
@@ -9,10 +9,22 @@
1010
1111 if (!defined('MEDIAWIKI')) die();
1212
13 -class SMW_URIResolver {
 13+global $IP;
 14+include_once($IP . '/includes/SpecialPage.php');
1415
15 - static function execute($query = '') {
 16+class SMWURIResolver extends SpecialPage {
 17+
 18+ /**
 19+ * Constructor
 20+ */
 21+ public function __construct() {
 22+ smwfInitUserMessages();
 23+ parent::__construct('URIResolver', '', false);
 24+ }
 25+
 26+ function execute($query = '') {
1627 global $wgOut, $smwgIP;
 28+ wfProfileIn('SpecialURIResolver::execute (SMW)');
1729 require_once( $smwgIP . '/specials/ExportRDF/SMW_SpecialExportRDF.php' );
1830 if ('' == $query) {
1931 $wgOut->addHTML(wfMsg('smw_uri_doc'));
@@ -34,5 +46,6 @@
3547 else
3648 header('Location: ' . $t);
3749 }
 50+ wfProfileOut('SpecialURIResolver::execute (SMW)');
3851 }
3952 }
Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialTypes.php
@@ -13,12 +13,20 @@
1414
1515 if (!defined('MEDIAWIKI')) die();
1616
17 -global $IP, $smwgIP;
18 -include_once($IP . '/includes/SpecialPage.php');
19 -include_once($IP . '/includes/Title.php');
 17+global $IP;
2018 include_once($IP . '/includes/QueryPage.php');
21 -include_once($smwgIP . '/includes/SMW_DataValueFactory.php');
2219
 20+function smwfDoSpecialTypes() {
 21+ wfProfileIn('smwfDoSpecialTypes (SMW)');
 22+ global $smwgIP;
 23+ include_once($smwgIP . '/includes/SMW_DataValueFactory.php');
 24+ list( $limit, $offset ) = wfCheckLimits();
 25+ $rep = new TypesPage();
 26+ $result = $rep->doQuery( $offset, $limit );
 27+ wfProfileOut('smwfDoSpecialTypes (SMW)');
 28+ return $result;
 29+}
 30+
2331 class TypesPage extends QueryPage {
2432
2533 function getName() {
Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialProperties.php
@@ -10,8 +10,17 @@
1111 global $smwgIP;
1212 include_once( "$smwgIP/specials/QueryPages/SMW_QueryPage.php" );
1313
14 -class PropertiesPage extends SMWQueryPage {
 14+function smwfDoSpecialProperties() {
 15+ wfProfileIn('smwfDoSpecialProperties (SMW)');
 16+ list( $limit, $offset ) = wfCheckLimits();
 17+ $rep = new SMWPropertiesPage();
 18+ $result = $rep->doQuery( $offset, $limit );
 19+ wfProfileOut('smwfDoSpecialProperties (SMW)');
 20+ return $result;
 21+}
1522
 23+class SMWPropertiesPage extends SMWQueryPage {
 24+
1625 function getName() {
1726 /// TODO: should probably use SMW prefix
1827 return "Properties";
Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialWantedProperties.php
@@ -10,8 +10,17 @@
1111 global $smwgIP;
1212 include_once( "$smwgIP/specials/QueryPages/SMW_QueryPage.php" );
1313
14 -class WantedPropertiesPage extends SMWQueryPage {
 14+function smwfDoSpecialWantedProperties() {
 15+ wfProfileIn('smwfDoSpecialWantedProperties (SMW)');
 16+ list( $limit, $offset ) = wfCheckLimits();
 17+ $rep = new SMWWantedPropertiesPage();
 18+ $result = $rep->doQuery( $offset, $limit );
 19+ wfProfileOut('smwfDoSpecialWantedProperties (SMW)');
 20+ return $result;
 21+}
1522
 23+class SMWWantedPropertiesPage extends SMWQueryPage {
 24+
1625 function getName() {
1726 /// TODO: should probably use SMW prefix
1827 return "WantedProperties";
Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialUnusedProperties.php
@@ -10,8 +10,17 @@
1111 global $smwgIP;
1212 include_once( "$smwgIP/specials/QueryPages/SMW_QueryPage.php" );
1313
14 -class UnusedPropertiesPage extends SMWQueryPage {
 14+function smwfDoSpecialUnusedProperties() {
 15+ wfProfileIn('smwfDoSpecialUnusedProperties (SMW)');
 16+ list( $limit, $offset ) = wfCheckLimits();
 17+ $rep = new SMWUnusedPropertiesPage();
 18+ $result = $rep->doQuery( $offset, $limit );
 19+ wfProfileOut('smwfDoSpecialUnusedProperties (SMW)');
 20+ return $result;
 21+}
1522
 23+class SMWUnusedPropertiesPage extends SMWQueryPage {
 24+
1625 function getName() {
1726 /// TODO: should probably use SMW prefix
1827 return "UnusedProperties";
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php
@@ -10,13 +10,22 @@
1111
1212 if (!defined('MEDIAWIKI')) die();
1313
14 -global $smwgIP;
15 -require_once( "$smwgIP/includes/storage/SMW_Store.php" );
 14+global $IP;
 15+include_once($IP . '/includes/SpecialPage.php');
1616
17 -class SMW_SearchByProperty {
 17+class SMWSearchByProperty extends SpecialPage {
1818
19 - static function execute($query = '') {
20 - global $wgRequest, $wgOut, $wgUser, $smwgQMaxInlineLimit;
 19+ /**
 20+ * Constructor
 21+ */
 22+ public function __construct() {
 23+ smwfInitUserMessages();
 24+ parent::__construct('SearchByProperty');
 25+ }
 26+
 27+ public function execute($query = '') {
 28+ global $wgRequest, $wgOut, $wgUser, $smwgQMaxInlineLimit, $smwgIP;
 29+ require_once( "$smwgIP/includes/storage/SMW_Store.php" );
2130 $skin = $wgUser->getSkin();
2231
2332 // get the GET parameters
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -9,19 +9,29 @@
1010
1111 if (!defined('MEDIAWIKI')) die();
1212
13 -global $smwgIP;
14 -include_once($smwgIP . '/includes/storage/SMW_Store.php');
15 -include_once($smwgIP . '/includes/SMW_DataValueFactory.php');
16 -include_once($smwgIP . '/includes/SMW_Infolink.php');
 13+global $IP;
 14+include_once($IP . '/includes/SpecialPage.php');
1715
1816 /**
1917 * A class to encapsulate the special page that allows browsing through
2018 * the knowledge structure of a Semantic MediaWiki.
2119 */
22 -class SMW_SpecialBrowse {
 20+class SMWSpecialBrowse extends SpecialPage {
2321
24 - static function execute($query = '') {
25 - global $wgRequest, $wgOut, $wgUser,$wgContLang;
 22+ /**
 23+ * Constructor
 24+ */
 25+ public function __construct() {
 26+ smwfInitUserMessages();
 27+ parent::__construct('Browse');
 28+ }
 29+
 30+ public function execute($query = '') {
 31+ global $wgRequest, $wgOut, $wgUser,$wgContLang, $smwgIP;
 32+ include_once($smwgIP . '/includes/storage/SMW_Store.php');
 33+ include_once($smwgIP . '/includes/SMW_DataValueFactory.php');
 34+ include_once($smwgIP . '/includes/SMW_Infolink.php');
 35+
2636 $skin = $wgUser->getSkin();
2737
2838 // get the GET parameters
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
@@ -13,15 +13,24 @@
1414
1515 if (!defined('MEDIAWIKI')) die();
1616
17 -global $IP, $smwgIP;
 17+global $IP;
1818 include_once( "$IP/includes/SpecialPage.php" );
19 -include_once( "$smwgIP/includes/storage/SMW_Store.php" );
20 -include_once($smwgIP . '/includes/SMW_Infolink.php');
2119
22 -class SMW_PageProperty {
 20+class SMWPageProperty extends SpecialPage {
2321
24 - static function execute($query = '') {
25 - global $wgRequest, $wgOut, $wgUser;
 22+ /**
 23+ * Constructor
 24+ */
 25+ public function __construct() {
 26+ smwfInitUserMessages();
 27+ parent::__construct('PageProperty', '', false);
 28+ }
 29+
 30+ public function execute($query = '') {
 31+ global $wgRequest, $wgOut, $wgUser, $smwgIP;
 32+ include_once($smwgIP . '/includes/storage/SMW_Store.php');
 33+ include_once($smwgIP . '/includes/SMW_Infolink.php');
 34+
2635 $skin = $wgUser->getSkin();
2736
2837 // get the GET parameters
Index: trunk/extensions/SemanticMediaWiki/specials/ExportRDF/SMW_SpecialExportRDF.php
@@ -10,13 +10,8 @@
1111
1212 if (!defined('MEDIAWIKI')) die();
1313
14 -// global $IP;
15 -// require_once( "$IP/includes/SpecialPage.php" );
1614
17 -//SpecialPage::addPage( new SpecialPage('ExportRDF','',true,'doSpecialExportRDF',false) );
18 -
19 -
20 -function smwfExportRDF($page = '') {
 15+function smwfDoSpecialExportRDF($page = '') {
2116 global $wgOut, $wgRequest, $wgUser, $smwgAllowRecursiveExport, $smwgExportBacklinks;
2217
2318 $recursive = 0; //default, no recursion
@@ -314,8 +309,7 @@
315310 */
316311 var $owlfull;
317312
318 - public function ExportRDF()
319 - {
 313+ public function ExportRDF() {
320314 global $smwgNamespace; // complete namespace for URIs (with protocol, usually http:/)
321315 // if not completed yet, it wll be prefixed with a dot. Check for that and complete
322316 global $wgServer; // actual server address (with http://)
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SpecialPages.php
@@ -1,185 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Methods for registering special pages without pulling in their code before it is
6 - * actually needed.
7 - *
8 - * @author Markus Krötzsch
9 - */
10 -
11 -global $IP;
12 -include_once( "$IP/includes/SpecialPage.php" );
13 -
14 -// Ask special
15 -
16 -SpecialPage::addPage( new SpecialPage('Ask','',true,'doSpecialAsk',false) );
17 -
18 -function doSpecialAsk() {
19 - smwfInitUserMessages();
20 - wfProfileIn('doSpecialAsk (SMW)');
21 - global $smwgIP;
22 - include_once($smwgIP . '/specials/AskSpecial/SMW_SpecialAsk.php');
23 - SMW_AskPage::execute();
24 - wfProfileOut('doSpecialAsk (SMW)');
25 -}
26 -
27 -// Browse special
28 -
29 -SpecialPage::addPage( new SpecialPage('Browse','',true,'doSpecialBrowse','default',true) );
30 -
31 -function doSpecialBrowse($query = '') {
32 - smwfInitUserMessages();
33 - wfProfileIn('doSpecialBrowse (SMW)');
34 - global $smwgIP;
35 - include_once($smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php');
36 - SMW_SpecialBrowse::execute($query);
37 - wfProfileOut('doSpecialBrowse (SMW)');
38 -}
39 -
40 -// Property value special
41 -
42 -SpecialPage::addPage( new SpecialPage('PageProperty','',FALSE,'doSpecialPageProperty',false) );
43 -
44 -function doSpecialPageProperty($query = '') {
45 - smwfInitUserMessages();
46 - wfProfileIn('doSpecialPageProperty (SMW)');
47 - global $smwgIP;
48 - include_once($smwgIP . '/specials/SearchTriple/SMW_SpecialPageProperty.php');
49 - SMW_PageProperty::execute($query);
50 - wfProfileOut('doSpecialPageProperty (SMW)');
51 -}
52 -
53 -// Property search special
54 -
55 -SpecialPage::addPage( new SpecialPage('SearchByProperty','',true,'doSpecialSearchByProperty',false) );
56 -
57 -function doSpecialSearchByProperty($query = '') {
58 - smwfInitUserMessages();
59 - wfProfileIn('doSpecialSearchByProperty (SMW)');
60 - global $smwgIP;
61 - include_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByProperty.php');
62 - SMW_SearchByProperty::execute($query);
63 - wfProfileOut('doSpecialSearchByProperty (SMW)');
64 -}
65 -
66 -// URI resolver special
67 -
68 -SpecialPage::addPage( new SpecialPage('URIResolver','',false,'doSpecialURIResolver',false) );
69 -
70 -function doSpecialURIResolver($name = '') {
71 - smwfInitUserMessages();
72 - wfProfileIn('doSpecialURIResolver (SMW)');
73 - global $smwgIP;
74 - include_once($smwgIP . '/specials/URIResolver/SMW_SpecialURIResolver.php');
75 - SMW_URIResolver::execute($name);
76 - wfProfileOut('doSpecialURIResolver (SMW)');
77 -}
78 -
79 -// RDF Export special
80 -
81 -SpecialPage::addPage( new SpecialPage('ExportRDF','',true,'doSpecialExportRDF',false) );
82 -
83 -function doSpecialExportRDF($page = '') {
84 - smwfInitUserMessages();
85 - wfProfileIn('doSpecialExportRDF (SMW)');
86 - global $smwgIP;
87 - include_once($smwgIP . '/specials/ExportRDF/SMW_SpecialExportRDF.php');
88 - smwfExportRDF($page);
89 - wfProfileOut('doSpecialExportRDF (SMW)');
90 -}
91 -
92 -// Semantic Statsitics Special
93 -
94 -SpecialPage::addPage( new SpecialPage('SemanticStatistics','',true,'doSpecialSemanticStatistics',false) );
95 -
96 -function doSpecialSemanticStatistics() {
97 - smwfInitUserMessages();
98 - wfProfileIn('doSpecialSemanticStatistics (SMW)');
99 - global $smwgIP;
100 - include_once($smwgIP . '/specials/Statistics/SMW_SpecialStatistics.php');
101 - smwfExecuteSemanticStatistics();
102 - wfProfileOut('doSpecialSemanticStatistics (SMW)');
103 -}
104 -
105 -// Properties special
106 -
107 -SpecialPage::addPage( new SpecialPage('Properties','',true,'doSpecialProperties',false) );
108 -
109 -function doSpecialProperties($par = null) {
110 - smwfInitUserMessages();
111 - wfProfileIn('doSpecialProperties (SMW)');
112 - global $smwgIP;
113 - include_once($smwgIP . '/specials/QueryPages/SMW_SpecialProperties.php');
114 - list( $limit, $offset ) = wfCheckLimits();
115 - $rep = new PropertiesPage();
116 - $result = $rep->doQuery( $offset, $limit );
117 - wfProfileOut('doSpecialProperties (SMW)');
118 - return $result;
119 -}
120 -
121 -// Unused Properties special
122 -
123 -SpecialPage::addPage( new SpecialPage('UnusedProperties','',true,'doSpecialUnusedProperties',false) );
124 -
125 -function doSpecialUnusedProperties($par = null) {
126 - smwfInitUserMessages();
127 - wfProfileIn('doSpecialUnusedProperties (SMW)');
128 - global $smwgIP;
129 - include_once($smwgIP . '/specials/QueryPages/SMW_SpecialUnusedProperties.php');
130 - list( $limit, $offset ) = wfCheckLimits();
131 - $rep = new UnusedPropertiesPage();
132 - $result = $rep->doQuery( $offset, $limit );
133 - wfProfileOut('doSpecialUnusedProperties (SMW)');
134 - return $result;
135 -}
136 -
137 -// Wanted Properties special
138 -
139 -SpecialPage::addPage( new SpecialPage('WantedProperties','',true,'doSpecialWantedProperties',false) );
140 -
141 -function doSpecialWantedProperties($par = null) {
142 - smwfInitUserMessages();
143 - wfProfileIn('doSpecialWantedProperties (SMW)');
144 - global $smwgIP;
145 - include_once($smwgIP . '/specials/QueryPages/SMW_SpecialWantedProperties.php');
146 - list( $limit, $offset ) = wfCheckLimits();
147 - $rep = new WantedPropertiesPage();
148 - $result = $rep->doQuery( $offset, $limit );
149 - wfProfileOut('doSpecialWantedProperties (SMW)');
150 - return $result;
151 -}
152 -
153 -// Types special
154 -
155 -SpecialPage::addPage( new SpecialPage('Types','',true,'doSpecialTypes',false) );
156 -
157 -function doSpecialTypes($par = null) {
158 - smwfInitUserMessages();
159 - wfProfileIn('doSpecialTypes (SMW)');
160 - global $smwgIP;
161 - include_once($smwgIP . '/specials/QueryPages/SMW_SpecialTypes.php');
162 - list( $limit, $offset ) = wfCheckLimits();
163 - $rep = new TypesPage();
164 - $result = $rep->doQuery( $offset, $limit );
165 - wfProfileOut('doSpecialTypes (SMW)');
166 - return $result;
167 -}
168 -
169 -
170 -
171 -// Admin special
172 -
173 -///TODO: should these be messages?
174 -global $wgMessageCache;
175 -$wgMessageCache->addMessages(array('smwadmin' => 'Admin functions for Semantic MediaWiki'));
176 -
177 -SpecialPage::addPage( new SpecialPage('SMWAdmin','delete',true,'doSpecialSMWAdmin',false) );
178 -
179 -function doSpecialSMWAdmin($par = null) {
180 - smwfInitUserMessages();
181 - wfProfileIn('doSpecialSMWAdmin (SMW)');
182 - global $smwgIP;
183 - include_once($smwgIP . '/specials/SMWAdmin/SMW_SpecialSMWAdmin.php');
184 - smwfSMWAdmin($par);
185 - wfProfileOut('doSpecialSMWAdmin (SMW)');
186 -}
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SpecialPage.php
@@ -0,0 +1,23 @@
 2+<?php
 3+
 4+if (!defined('MEDIAWIKI')) die();
 5+
 6+global $IP;
 7+include_once($IP . '/includes/SpecialPage.php');
 8+
 9+/**
 10+ * A simple extension of SpecialPage that ensures that all relevant SMW-user
 11+ * messages are loaded when the special page is initialised. This is especially
 12+ * relevant as an adaptor for query pages.
 13+ */
 14+class SMWSpecialPage extends SpecialPage {
 15+
 16+ /**
 17+ * Constructor
 18+ */
 19+ public function __construct($name, $function, $file = 'default', $listed=true, $restriction='') {
 20+ smwfInitUserMessages();
 21+ parent::__construct($name, $restriction, $listed, $function, $file);
 22+ }
 23+
 24+}
Property changes on: trunk/extensions/SemanticMediaWiki/includes/SMW_SpecialPage.php
___________________________________________________________________
Added: svn:eol-style
125 + native
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -3,7 +3,7 @@
44 * Global functions and constants for Semantic MediaWiki.
55 */
66
7 -define('SMW_VERSION','1.0prealpha-2');
 7+define('SMW_VERSION','1.0prealpha-3');
88
99 // constants for special properties, used for datatype assignment and storage
1010 define('SMW_SP_HAS_TYPE',1);
@@ -37,7 +37,7 @@
3838 * does not adhere to the naming conventions.
3939 */
4040 function enableSemantics($namespace = "", $complete = false) {
41 - global $smwgNamespace, $wgExtensionFunctions;
 41+ global $smwgNamespace, $wgExtensionFunctions, $wgHooks;
4242 $smwgNamespace = $namespace;
4343
4444 // The dot tells that the domain is not complete. It will be completed
@@ -54,7 +54,7 @@
5555 */
5656 function smwfSetupExtension() {
5757 wfProfileIn('smwfSetupExtension (SMW)');
58 - global $smwgVersion, $smwgNamespace, $smwgIP, $smwgStoreActive, $wgHooks, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore, $wgArticlePath, $wgScriptPath, $wgServer;
 58+ global $smwgIP, $smwgStoreActive, $wgHooks, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore, $wgSpecialPages, $wgAutoloadClasses;
5959
6060 /**
6161 * Setting this to false prevents any new data from being stored in
@@ -71,11 +71,30 @@
7272 $smwgStoreActive = true;
7373
7474 $smwgMasterStore = NULL;
75 - smwfInitUserMessages(); /// TODO: try to eliminate this. Problem are pages like Special:Specialpages that access our messages directly.
7675 smwfInitContentMessages();
7776
7877 ///// register specials /////
79 - include_once($smwgIP . '/includes/SMW_SpecialPages.php');
 78+ $wgAutoloadClasses['SMWAskPage'] = $smwgIP . '/specials/AskSpecial/SMW_SpecialAsk.php';
 79+ $wgSpecialPages['Ask'] = array('SMWAskPage');
 80+ $wgAutoloadClasses['SMWSpecialBrowse'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php';
 81+ $wgSpecialPages['Browse'] = array('SMWSpecialBrowse');
 82+ $wgAutoloadClasses['SMWPageProperty'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialPageProperty.php';
 83+ $wgSpecialPages['PageProperty'] = array('SMWPageProperty');
 84+ $wgAutoloadClasses['SMWSearchByProperty'] = $smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByProperty.php';
 85+ $wgSpecialPages['SearchByProperty'] = array('SMWSearchByProperty');
 86+ $wgAutoloadClasses['SMWURIResolver'] = $smwgIP . '/specials/URIResolver/SMW_SpecialURIResolver.php';
 87+ $wgSpecialPages['URIResolver'] = array('SMWURIResolver');
 88+ $wgAutoloadClasses['SMWAdmin'] = $smwgIP . '/specials/SMWAdmin/SMW_SpecialSMWAdmin.php';
 89+ $wgSpecialPages['SMWAdmin'] = array('SMWAdmin');
 90+
 91+ $wgAutoloadClasses['SMWSpecialPage'] = $smwgIP . '/includes/SMW_SpecialPage.php';
 92+ $wgSpecialPages['Properties'] = array('SMWSpecialPage','Properties', 'smwfDoSpecialProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialProperties.php');
 93+ $wgSpecialPages['UnusedProperties'] = array('SMWSpecialPage','UnusedProperties', 'smwfDoSpecialUnusedProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialUnusedProperties.php');
 94+ $wgSpecialPages['WantedProperties'] = array('SMWSpecialPage','WantedProperties', 'smwfDoSpecialWantedProperties', $smwgIP . '/specials/QueryPages/SMW_SpecialWantedProperties.php');
 95+ $wgSpecialPages['ExportRDF'] = array('SMWSpecialPage','ExportRDF', 'smwfDoSpecialExportRDF', $smwgIP . '/specials/ExportRDF/SMW_SpecialExportRDF.php');
 96+ $wgSpecialPages['SemanticStatistics'] = array('SMWSpecialPage','SemanticStatistics', 'smwfExecuteSemanticStatistics', $smwgIP . '/specials/Statistics/SMW_SpecialStatistics.php');
 97+ $wgSpecialPages['Types'] = array('SMWSpecialPage','Types', 'smwfDoSpecialTypes', $smwgIP . '/specials/QueryPages/SMW_SpecialTypes.php');
 98+
8099 //require_once($smwgIP . '/specials/OntologyImport/SMW_SpecialOntologyImport.php'); // broken, TODO: fix or delete
81100
82101 ///// register hooks /////
@@ -94,6 +113,7 @@
95114 $wgHooks['BeforePageDisplay'][]='smwfAddHTMLHeader';
96115 $wgHooks['ParserBeforeStrip'][] = 'smwfRegisterInlineQueries'; // a hook for registering the <ask> parser hook
97116 $wgHooks['ArticleFromTitle'][] = 'smwfShowListPage';
 117+ $wgHooks['LoadAllMessages'][] = 'smwfLoadAllMessages'; // enable a complete display of all messages when requested by MW
98118
99119 ///// credits (see "Special:Version") /////
100120 $wgExtensionCredits['parserhook'][]= array('name'=>'Semantic&nbsp;MediaWiki', 'version'=>SMW_VERSION, 'author'=>"Klaus&nbsp;Lassleben, Markus&nbsp;Kr&ouml;tzsch, Denny&nbsp;Vrandecic, S&nbsp;Page, and others. Maintained by [http://www.aifb.uni-karlsruhe.de/Forschungsgruppen/WBS/english AIFB Karlsruhe].", 'url'=>'http://ontoworld.org/wiki/Semantic_MediaWiki', 'description' => 'Making your wiki more accessible&nbsp;&ndash; for machines \'\'and\'\' humans. [http://ontoworld.org/wiki/Help:Semantics View online documentation.]');
@@ -322,7 +342,16 @@
323343 wfProfileOut('smwfInitUserMessages (SMW)');
324344 }
325345
 346+ /**
 347+ * Set up all messages if requested explicitly by MediaWiki.
 348+ */
 349+ function smwfLoadAllMessages($pagelist) {
 350+ smwfInitContentMessages();
 351+ smwfInitUserMessages();
 352+ return true;
 353+ }
326354
 355+
327356 /**********************************************/
328357 /***** other global helpers *****/
329358 /**********************************************/

Status & tagging log