Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php |
— | — | @@ -1,460 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Global functions used for setting up the Semantic MediaWiki extension as a |
5 | | - * "light" version with only essential features enabled. This file is not used |
6 | | - * by default but is part of a dedicated SMWLight release of SMW. It is also |
7 | | - * possible to switch any SMW to the light version by replacing SMW_Setup.php |
8 | | - * with SMW_SetupLight.php in SMW_Settings.php (or, of course, on disk). |
9 | | - * |
10 | | - * If used, this file replaces SMW_Setup.php. The files are never used together |
11 | | - * since they define some functions of the same name. |
12 | | - * |
13 | | - * SMWLight does not support versions of MediaWiki older than 1.15.0. |
14 | | - * @file |
15 | | - * @ingroup SMW |
16 | | - */ |
17 | | - |
18 | | -define( 'SMW_VERSION', '1.7 light' ); |
19 | | - |
20 | | -require_once( 'SMW_GlobalFunctions.php' ); |
21 | | - |
22 | | -// Overwrite the normal default to use the lighter store not optimised for querying but for simple read/write: |
23 | | -global $smwgDefaultStore; |
24 | | -$smwgDefaultStore = "SMWSQLStoreLight"; |
25 | | - |
26 | | -/** |
27 | | - * Function to switch on Semantic MediaWiki. This function must be called in |
28 | | - * LocalSettings.php after including SMW_Settings.php. It is used to ensure |
29 | | - * that required parameters for SMW are really provided explicitly. For |
30 | | - * readability, this is the only global function that does not adhere to the |
31 | | - * naming conventions. |
32 | | - * |
33 | | - * This function also sets up all autoloading, such that all SMW classes are |
34 | | - * available as early on. Moreover, jobs and special pages are registered. |
35 | | - */ |
36 | | -function enableSemantics( $namespace = null, $complete = false ) { |
37 | | - global $smwgIP, $wgServer, $smwgNamespace, $wgExtensionFunctions; |
38 | | - global $wgAutoloadClasses, $wgSpecialPages, $wgSpecialPageGroups; |
39 | | - global $wgHooks, $wgExtensionMessagesFiles, $wgJobClasses, $wgExtensionAliasesFiles; |
40 | | - global $wgResourceModules, $smwgScriptPath; |
41 | | - |
42 | | - // The dot tells that the domain is not complete. It will be completed |
43 | | - // in the Export since we do not want to create a title object here when |
44 | | - // it is not needed in many cases. |
45 | | - if ( $namespace === null ) { |
46 | | - wfWarn( 'You should be providing the domain name to enableSemantics()' ); |
47 | | - $namespace = parse_url( $wgServer, PHP_URL_HOST ); |
48 | | - } |
49 | | - if ( !$complete && ( $smwgNamespace !== '' ) ) { |
50 | | - $smwgNamespace = '.' . $namespace; |
51 | | - } else { |
52 | | - $smwgNamespace = $namespace; |
53 | | - } |
54 | | - |
55 | | - $wgExtensionFunctions[] = 'smwfSetupExtension'; |
56 | | - // FIXME: Can be removed when new style magic words are used (introduced in r52503) |
57 | | - $wgHooks['LanguageGetMagic'][] = 'smwfAddMagicWords'; // setup names for parser functions (needed here) |
58 | | - $wgExtensionMessagesFiles['SemanticMediaWiki'] = $smwgIP . 'languages/SMW_Messages.php'; // register messages (requires MW=>1.11) |
59 | | - |
60 | | - $wgHooks['ParserTestTables'][] = 'smwfOnParserTestTables'; |
61 | | - //$wgHooks['AdminLinks'][] = 'smwfAddToAdminLinks'; |
62 | | - |
63 | | - // Register client-side modules |
64 | | - $moduleTemplate = array( |
65 | | - 'localBasePath' => $smwgIP . '/skins', |
66 | | - 'remoteBasePath' => $smwgScriptPath . '/skins', |
67 | | - 'group' => 'ext.smw' |
68 | | - ); |
69 | | - $wgResourceModules['ext.smw.style'] = $moduleTemplate + array( |
70 | | - 'styles' => 'SMW_custom.css' |
71 | | - ); |
72 | | - $wgResourceModules['ext.smw.tooltips'] = $moduleTemplate + array( |
73 | | - 'scripts' => 'SMW_tooltip.js', |
74 | | - 'dependencies' => array( |
75 | | - 'mediawiki.legacy.wikibits', |
76 | | - 'ext.smw.style' |
77 | | - ) |
78 | | - ); |
79 | | - |
80 | | - // Register special pages aliases file |
81 | | - $wgExtensionAliasesFiles['SemanticMediaWiki'] = $smwgIP . 'languages/SMW_Aliases.php'; |
82 | | - |
83 | | - // Set up autoloading; essentially all classes should be autoloaded! |
84 | | - $wgAutoloadClasses['SMWParserExtensions'] = $smwgIP . 'includes/SMW_ParserExtensions.php'; |
85 | | - $wgAutoloadClasses['SMWInfolink'] = $smwgIP . 'includes/SMW_Infolink.php'; |
86 | | - $wgAutoloadClasses['SMWCompatibilityHelpers'] = $smwgIP . 'includes/SMW_CompatibilityHelpers.php'; |
87 | | - $wgAutoloadClasses['SMWDataValueFactory'] = $smwgIP . 'includes/SMW_DataValueFactory.php'; |
88 | | -// $wgAutoloadClasses['SMWFactbox'] = $smwgIP . 'includes/SMW_Factbox.php'; |
89 | | - $wgAutoloadClasses['SMWParseData'] = $smwgIP . 'includes/SMW_ParseData.php'; |
90 | | - $wgAutoloadClasses['SMWOutputs'] = $smwgIP . 'includes/SMW_Outputs.php'; |
91 | | - $wgAutoloadClasses['SMWSemanticData'] = $smwgIP . 'includes/SMW_SemanticData.php'; |
92 | | - $wgAutoloadClasses['SMWOrderedListPage'] = $smwgIP . 'includes/articlepages/SMW_OrderedListPage.php'; |
93 | | - $wgAutoloadClasses['SMWPropertyPage'] = $smwgIP . 'includes/articlepages/SMW_PropertyPage.php'; |
94 | | -// $wgAutoloadClasses['SMWConceptPage'] = $smwgIP . 'includes/articlepages/SMW_ConceptPage.php'; |
95 | | - $wgAutoloadClasses['SMWQueryLanguage'] = $smwgIP . 'includes/SMW_QueryLanguage.php'; |
96 | | - |
97 | | - // Data items |
98 | | - $diDir = $smwgIP . 'includes/dataitems/'; |
99 | | - $wgAutoloadClasses['SMWDataItem'] = $diDir . 'SMW_DataItem.php'; |
100 | | - $wgAutoloadClasses['SMWDataItemException'] = $diDir . 'SMW_DataItem.php'; |
101 | | - $wgAutoloadClasses['SMWDIProperty'] = $diDir . 'SMW_DI_Property.php'; |
102 | | -// $wgAutoloadClasses['SMWDIBoolean'] = $diDir . 'SMW_DI_Bool.php'; |
103 | | - $wgAutoloadClasses['SMWDINumber'] = $diDir . 'SMW_DI_Number.php'; |
104 | | - $wgAutoloadClasses['SMWDIBlob'] = $diDir . 'SMW_DI_Blob.php'; |
105 | | - $wgAutoloadClasses['SMWDIString'] = $diDir . 'SMW_DI_String.php'; |
106 | | - $wgAutoloadClasses['SMWStringLengthException'] = $diDir . 'SMW_DI_String.php'; |
107 | | - $wgAutoloadClasses['SMWDIUri'] = $diDir . 'SMW_DI_URI.php'; |
108 | | - $wgAutoloadClasses['SMWDIWikiPage'] = $diDir . 'SMW_DI_WikiPage.php'; |
109 | | - $wgAutoloadClasses['SMWDITime'] = $diDir . 'SMW_DI_Time.php'; |
110 | | -// $wgAutoloadClasses['SMWDIConcept'] = $diDir . 'SMW_DI_Concept.php'; |
111 | | - $wgAutoloadClasses['SMWDIError'] = $diDir . 'SMW_DI_Error.php'; |
112 | | - |
113 | | - // Datavalues |
114 | | - $dvDir = $smwgIP . 'includes/datavalues/'; |
115 | | - $wgAutoloadClasses['SMWDataValue'] = $dvDir . 'SMW_DataValue.php'; |
116 | | -// $wgAutoloadClasses['SMWRecordValue'] = $dvDir . 'SMW_DV_Record.php'; |
117 | | - $wgAutoloadClasses['SMWErrorValue'] = $dvDir . 'SMW_DV_Error.php'; |
118 | | - $wgAutoloadClasses['SMWStringValue'] = $dvDir . 'SMW_DV_String.php'; |
119 | | - $wgAutoloadClasses['SMWWikiPageValue'] = $dvDir . 'SMW_DV_WikiPage.php'; |
120 | | - $wgAutoloadClasses['SMWPropertyValue'] = $dvDir . 'SMW_DV_Property.php'; |
121 | | - $wgAutoloadClasses['SMWURIValue'] = $dvDir . 'SMW_DV_URI.php'; |
122 | | - $wgAutoloadClasses['SMWTypesValue'] = $dvDir . 'SMW_DV_Types.php'; |
123 | | -// $wgAutoloadClasses['SMWTypeListValue'] = $dvDir . 'SMW_DV_TypeList.php'; |
124 | | - $wgAutoloadClasses['SMWNumberValue'] = $dvDir . 'SMW_DV_Number.php'; |
125 | | -// $wgAutoloadClasses['SMWTemperatureValue'] = $dvDir . 'SMW_DV_Temperature.php'; |
126 | | -// $wgAutoloadClasses['SMWQuantityValue'] = $dvDir . 'SMW_DV_Quantity.php'; |
127 | | - $wgAutoloadClasses['SMWTimeValue'] = $dvDir . 'SMW_DV_Time.php'; |
128 | | -// $wgAutoloadClasses['SMWBoolValue'] = $dvDir . 'SMW_DV_Bool.php'; |
129 | | -// $wgAutoloadClasses['SMWConceptValue'] = $dvDir . 'SMW_DV_Concept.php'; |
130 | | -// $wgAutoloadClasses['SMWImportValue'] = $dvDir . 'SMW_DV_Import.php'; |
131 | | - |
132 | | - // Some files refer to classes of the full SMW distribution. Give them a fallback to load: |
133 | | - $wgAutoloadClasses['SMWRecordValue'] = $dvDir . 'SMW_DV_Error.php'; |
134 | | - $wgAutoloadClasses['SMWBoolValue'] = $dvDir . 'SMW_DV_Error.php'; |
135 | | - $wgAutoloadClasses['SMWConceptValue'] = $dvDir . 'SMW_DV_Error.php'; |
136 | | - $wgAutoloadClasses['SMWImportValue'] = $dvDir . 'SMW_DV_Error.php'; |
137 | | - $wgAutoloadClasses['SMWTypeListValue'] = $dvDir . 'SMW_DV_Error.php'; |
138 | | - $wgAutoloadClasses['SMWTemperatureValue'] = $dvDir . 'SMW_DV_Error.php'; |
139 | | - |
140 | | - |
141 | | - // Export |
142 | | -// $expDir = $smwgIP . 'includes/export/'; |
143 | | -// $wgAutoloadClasses['SMWExporter'] = $expDir . 'SMW_Exporter.php'; |
144 | | -// $wgAutoloadClasses['SMWExpData'] = $expDir . 'SMW_Exp_Data.php'; |
145 | | -// $wgAutoloadClasses['SMWExpElement'] = $expDir . 'SMW_Exp_Element.php'; |
146 | | -// $wgAutoloadClasses['SMWExpLiteral'] = $expDir . 'SMW_Exp_Element.php'; |
147 | | -// $wgAutoloadClasses['SMWExpResource'] = $expDir . 'SMW_Exp_Element.php'; |
148 | | -// $wgAutoloadClasses['SMWExportController'] = $expDir . 'SMW_ExportController.php'; |
149 | | -// $wgAutoloadClasses['SMWSerializer'] = $expDir . 'SMW_Serializer.php'; |
150 | | - |
151 | | - // Parser hooks |
152 | | - $phDir = $smwgIP . 'includes/parserhooks/'; |
153 | | - $wgAutoloadClasses['SMWSet'] = $phDir . 'SMW_Set.php'; |
154 | | - $wgAutoloadClasses['SMWDeclare'] = $phDir . 'SMW_Declare.php'; |
155 | | - |
156 | | - // Stores & queries |
157 | | -// $wgAutoloadClasses['SMWQueryProcessor'] = $smwgIP . 'includes/SMW_QueryProcessor.php'; |
158 | | -// $wgAutoloadClasses['SMWQueryParser'] = $smwgIP . 'includes/SMW_QueryParser.php'; |
159 | | -// $wgAutoloadClasses['SMWQuery'] = $smwgIP . 'includes/storage/SMW_Query.php'; |
160 | | -// $wgAutoloadClasses['SMWQueryResult'] = $smwgIP . 'includes/storage/SMW_QueryResult.php'; |
161 | | - $wgAutoloadClasses['SMWStore'] = $smwgIP . 'includes/storage/SMW_Store.php'; |
162 | | -// $wgAutoloadClasses['SMWStringCondition'] = $smwgIP . 'includes/storage/SMW_Store.php'; |
163 | | -// $wgAutoloadClasses['SMWRequestOptions'] = $smwgIP . 'includes/storage/SMW_Store.php'; |
164 | | -// $wgAutoloadClasses['SMWPrintRequest'] = $smwgIP . 'includes/storage/SMW_PrintRequest.php'; |
165 | | -// $wgAutoloadClasses['SMWThingDescription'] = $smwgIP . 'includes/storage/SMW_Description.php'; |
166 | | -// $wgAutoloadClasses['SMWClassDescription'] = $smwgIP . 'includes/storage/SMW_Description.php'; |
167 | | -// $wgAutoloadClasses['SMWConceptDescription'] = $smwgIP . 'includes/storage/SMW_Description.php'; |
168 | | -// $wgAutoloadClasses['SMWNamespaceDescription'] = $smwgIP . 'includes/storage/SMW_Description.php'; |
169 | | -// $wgAutoloadClasses['SMWValueDescription'] = $smwgIP . 'includes/storage/SMW_Description.php'; |
170 | | -// $wgAutoloadClasses['SMWConjunction'] = $smwgIP . 'includes/storage/SMW_Description.php'; |
171 | | -// $wgAutoloadClasses['SMWDisjunction'] = $smwgIP . 'includes/storage/SMW_Description.php'; |
172 | | -// $wgAutoloadClasses['SMWSomeProperty'] = $smwgIP . 'includes/storage/SMW_Description.php'; |
173 | | -// $wgAutoloadClasses['SMWSQLStore2'] = $smwgIP . 'includes/storage/SMW_SQLStore2.php'; |
174 | | - $wgAutoloadClasses['SMWSQLStoreLight'] = $smwgIP . 'includes/storage/SMW_SQLStoreLight.php'; |
175 | | - $wgAutoloadClasses['SMWSQLStore2Table'] = $smwgIP . 'includes/storage/SMW_SQLStore2Table.php'; |
176 | | - $wgAutoloadClasses['SMWSQLHelpers'] = $smwgIP . 'includes/storage/SMW_SQLHelpers.php'; |
177 | | - |
178 | | - // To ensure SMW remains compatible with pre 1.16. |
179 | | - if ( !class_exists( 'Html' ) ) { |
180 | | - $wgAutoloadClasses['Html'] = $smwgIP . 'compat/Html.php'; |
181 | | - } |
182 | | - |
183 | | - ///// Register specials, do that early on in case some other extension calls "addPage" ///// |
184 | | - $wgAutoloadClasses['SMWQueryPage'] = $smwgIP . 'specials/QueryPages/SMW_QueryPage.php'; |
185 | | -// $wgAutoloadClasses['SMWAskPage'] = $smwgIP . 'specials/AskSpecial/SMW_SpecialAsk.php'; |
186 | | -// $wgSpecialPages['Ask'] = 'SMWAskPage'; |
187 | | -// $wgSpecialPageGroups['Ask'] = 'smw_group'; |
188 | | - |
189 | | - $wgAutoloadClasses['SMWSpecialBrowse'] = $smwgIP . 'specials/SearchTriple/SMW_SpecialBrowse.php'; |
190 | | - $wgSpecialPages['Browse'] = 'SMWSpecialBrowse'; |
191 | | - $wgSpecialPageGroups['Browse'] = 'smw_group'; |
192 | | - |
193 | | - $wgAutoloadClasses['SMWPageProperty'] = $smwgIP . 'specials/SearchTriple/SMW_SpecialPageProperty.php'; |
194 | | - $wgSpecialPages['PageProperty'] = 'SMWPageProperty'; |
195 | | - $wgSpecialPageGroups['PageProperty'] = 'smw_group'; |
196 | | - |
197 | | - $wgAutoloadClasses['SMWSearchByProperty'] = $smwgIP . 'specials/SearchTriple/SMW_SpecialSearchByProperty.php'; |
198 | | - $wgSpecialPages['SearchByProperty'] = 'SMWSearchByProperty'; |
199 | | - $wgSpecialPageGroups['SearchByProperty'] = 'smw_group'; |
200 | | - |
201 | | -// $wgAutoloadClasses['SMWURIResolver'] = $smwgIP . 'specials/URIResolver/SMW_SpecialURIResolver.php'; |
202 | | -// $wgSpecialPages['URIResolver'] = 'SMWURIResolver'; |
203 | | - |
204 | | - $wgAutoloadClasses['SMWAdmin'] = $smwgIP . 'specials/SMWAdmin/SMW_SpecialSMWAdmin.php'; |
205 | | - $wgSpecialPages['SMWAdmin'] = 'SMWAdmin'; |
206 | | - $wgSpecialPageGroups['SMWAdmin'] = 'smw_group'; |
207 | | - |
208 | | -// $wgAutoloadClasses['SMWSpecialSemanticStatistics'] = $smwgIP . 'specials/Statistics/SMW_SpecialStatistics.php'; |
209 | | -// $wgSpecialPages['SemanticStatistics'] = 'SMWSpecialSemanticStatistics'; |
210 | | -// $wgSpecialPageGroups['SemanticStatistics'] = 'wiki'; // Similar to Special:Statistics |
211 | | -// |
212 | | -// $wgAutoloadClasses['SMWSpecialOWLExport'] = $smwgIP . 'specials/Export/SMW_SpecialOWLExport.php'; |
213 | | -// $wgSpecialPages['ExportRDF'] = 'SMWSpecialOWLExport'; |
214 | | -// $wgSpecialPageGroups['ExportRDF'] = 'smw_group'; |
215 | | -// |
216 | | -// $wgAutoloadClasses['SMWSpecialProperties'] = $smwgIP . 'specials/QueryPages/SMW_SpecialProperties.php'; |
217 | | -// $wgSpecialPages['Properties'] = 'SMWSpecialProperties'; |
218 | | -// $wgSpecialPageGroups['Properties'] = 'pages'; |
219 | | -// |
220 | | -// $wgAutoloadClasses['SMWSpecialTypes'] = $smwgIP . 'specials/QueryPages/SMW_SpecialTypes.php'; |
221 | | -// $wgSpecialPages['Types'] = 'SMWSpecialTypes'; |
222 | | -// $wgSpecialPageGroups['Types'] = 'pages'; |
223 | | -// |
224 | | -// $wgAutoloadClasses['SMWSpecialUnusedProperties'] = $smwgIP . 'specials/QueryPages/SMW_SpecialUnusedProperties.php'; |
225 | | -// $wgSpecialPages['UnusedProperties'] = 'SMWSpecialUnusedProperties'; |
226 | | -// $wgSpecialPageGroups['UnusedProperties'] = 'maintenance'; |
227 | | -// |
228 | | -// $wgAutoloadClasses['SMWSpecialWantedProperties'] = $smwgIP . 'specials/QueryPages/SMW_SpecialWantedProperties.php'; |
229 | | -// $wgSpecialPages['WantedProperties'] = 'SMWSpecialWantedProperties'; |
230 | | -// $wgSpecialPageGroups['WantedProperties'] = 'maintenance'; |
231 | | - |
232 | | - // Register Jobs |
233 | | - $wgJobClasses['SMWUpdateJob'] = 'SMWUpdateJob'; |
234 | | - $wgAutoloadClasses['SMWUpdateJob'] = $smwgIP . 'includes/jobs/SMW_UpdateJob.php'; |
235 | | - |
236 | | - $wgJobClasses['SMWRefreshJob'] = 'SMWRefreshJob'; |
237 | | - $wgAutoloadClasses['SMWRefreshJob'] = $smwgIP . 'includes/jobs/SMW_RefreshJob.php'; |
238 | | - |
239 | | - return true; |
240 | | -} |
241 | | - |
242 | | -/** |
243 | | - * Do the actual intialisation of the extension. This is just a delayed init |
244 | | - * that makes sure MediaWiki is set up properly before we add our stuff. |
245 | | - * |
246 | | - * The main things this function does are: register all hooks, set up extension |
247 | | - * credits, and init some globals that are not for configuration settings. |
248 | | - */ |
249 | | -function smwfSetupExtension() { |
250 | | - wfProfileIn( 'smwfSetupExtension (SMW)' ); |
251 | | - global $wgHooks, $smwgMasterStore, $smwgIQRunningNumber; |
252 | | - |
253 | | - $smwgMasterStore = null; |
254 | | - $smwgIQRunningNumber = 0; |
255 | | - |
256 | | - ///// register hooks ///// |
257 | | -// require_once( $smwgIP . 'includes/SMW_RefreshTab.php' ); |
258 | | - |
259 | | - $wgHooks['smwInitDatatypes'][] = 'smwfUnregisterDatatypes'; // remove registration for default datatypes that are not part of SMWLight |
260 | | - $wgHooks['InternalParseBeforeLinks'][] = 'SMWParserExtensions::onInternalParseBeforeLinks'; // parse annotations in [[link syntax]] |
261 | | - $wgHooks['ArticleDelete'][] = 'SMWParseData::onArticleDelete'; // delete annotations |
262 | | - $wgHooks['TitleMoveComplete'][] = 'SMWParseData::onTitleMoveComplete'; // move annotations |
263 | | - $wgHooks['LinksUpdateConstructed'][] = 'SMWParseData::onLinksUpdateConstructed'; // update data after template change and at save |
264 | | - $wgHooks['ParserAfterTidy'][] = 'SMWParseData::onParserAfterTidy'; // fetch some MediaWiki data for replication in SMW's store |
265 | | - $wgHooks['NewRevisionFromEditComplete'][] = 'SMWParseData::onNewRevisionFromEditComplete'; // fetch some MediaWiki data for replication in SMW's store |
266 | | -// $wgHooks['OutputPageParserOutput'][] = 'SMWFactbox::onOutputPageParserOutput'; // copy some data for later Factbox display |
267 | | - $wgHooks['ArticleFromTitle'][] = 'smwfOnArticleFromTitle'; // special implementations for property/type articles |
268 | | - $wgHooks['ParserFirstCallInit'][] = 'smwfRegisterParserFunctions'; |
269 | | - |
270 | | - wfProfileOut( 'smwfSetupExtension (SMW)' ); |
271 | | - return true; |
272 | | -} |
273 | | - |
274 | | -/** |
275 | | - * Unregister the classes that SMW (full) uses for some datatypes which are not |
276 | | - * supported in SMWLight. Doing this with a hook allows us to use more of the |
277 | | - * normal SMW files without modifications. In the long run, one would rather do |
278 | | - * it the other way around: register extra types only in SMW (full) instead of |
279 | | - * undoing the registration here. |
280 | | - */ |
281 | | -function smwfUnregisterDatatypes() { |
282 | | - SMWDataValueFactory::registerDatatype('_tem', 'SMWErrorValue'); |
283 | | - SMWDataValueFactory::registerDatatype('_boo', 'SMWErrorValue'); |
284 | | - SMWDataValueFactory::registerDatatype('_rec', 'SMWErrorValue'); |
285 | | - SMWDataValueFactory::registerDatatype('__tls', 'SMWErrorValue'); |
286 | | - SMWDataValueFactory::registerDatatype('__con', 'SMWErrorValue'); |
287 | | - SMWDataValueFactory::registerDatatype('__imp', 'SMWErrorValue'); |
288 | | - return true; |
289 | | -} |
290 | | - |
291 | | -/** |
292 | | - * Adds links to Admin Links page |
293 | | - ** |
294 | | -function smwfAddToAdminLinks( &$admin_links_tree ) { |
295 | | - $data_structure_section = new ALSection( wfMsg( 'smw_adminlinks_datastructure' ) ); |
296 | | -// $smw_row = new ALRow( 'smw' ); |
297 | | -// $smw_row->addItem( ALItem::newFromSpecialPage( 'Categories' ) ); |
298 | | -// $smw_row->addItem( ALItem::newFromSpecialPage( 'Properties' ) ); |
299 | | -// $smw_row->addItem( ALItem::newFromSpecialPage( 'UnusedProperties' ) ); |
300 | | -// $smw_row->addItem( ALItem::newFromSpecialPage( 'SemanticStatistics' ) ); |
301 | | -// $data_structure_section->addRow( $smw_row ); |
302 | | - $smw_admin_row = new ALRow( 'smw_admin' ); |
303 | | - $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'SMWAdmin' ) ); |
304 | | - $data_structure_section->addRow( $smw_admin_row ); |
305 | | - $smw_docu_row = new ALRow( 'smw_docu' ); |
306 | | - $smw_name = wfMsg( 'specialpages-group-smw_group' ); |
307 | | - $smw_docu_label = wfMsg( 'adminlinks_documentation', $smw_name ); |
308 | | - $smw_docu_row->addItem( AlItem::newFromExternalLink( "http://semantic-mediawiki.org/wiki/Help:User_manual", $smw_docu_label ) ); |
309 | | - $data_structure_section->addRow( $smw_docu_row ); |
310 | | - $admin_links_tree->addSection( $data_structure_section, wfMsg( 'adminlinks_browsesearch' ) ); |
311 | | - $smw_row = new ALRow( 'smw' ); |
312 | | - $displaying_data_section = new ALSection( wfMsg( 'smw_adminlinks_displayingdata' ) ); |
313 | | - $smw_row->addItem( AlItem::newFromExternalLink( "http://semantic-mediawiki.org/wiki/Help:Inline_queries", wfMsg( 'smw_adminlinks_inlinequerieshelp' ) ) ); |
314 | | - $displaying_data_section->addRow( $smw_row ); |
315 | | - $admin_links_tree->addSection( $displaying_data_section, wfMsg( 'adminlinks_browsesearch' ) ); |
316 | | - $browse_search_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_browsesearch' ) ); |
317 | | - $smw_row = new ALRow( 'smw' ); |
318 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'Browse' ) ); |
319 | | -// $smw_row->addItem( ALItem::newFromSpecialPage( 'Ask' ) ); |
320 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'SearchByProperty' ) ); |
321 | | - $browse_search_section->addRow( $smw_row ); |
322 | | - |
323 | | - return true; |
324 | | -} |
325 | | -*/ |
326 | | - |
327 | | -/** |
328 | | - * Register special classes for displaying semantic content on Property |
329 | | - * pages. |
330 | | - */ |
331 | | -function smwfOnArticleFromTitle( &$title, &$article ) { |
332 | | - if ( $title->getNamespace() == SMW_NS_PROPERTY ) { |
333 | | - $article = new SMWPropertyPage( $title ); |
334 | | - } |
335 | | - return true; |
336 | | -} |
337 | | - |
338 | | -/** |
339 | | - * Register tables to be added to temporary tables for parser tests. |
340 | | - * @todo Hard-coding this thwarts the modularity/exchangability of the SMW |
341 | | - * storage backend. The actual list of required tables depends on the backend |
342 | | - * implementation and cannot really be fixed here. |
343 | | - */ |
344 | | -function smwfOnParserTestTables( &$tables ) { |
345 | | - $tables[] = 'smw_ids'; |
346 | | - $tables[] = 'smw_redi2'; |
347 | | - $tables[] = 'smw_atts2'; |
348 | | - $tables[] = 'smw_rels2'; |
349 | | - $tables[] = 'smw_text2'; |
350 | | - $tables[] = 'smw_spec2'; |
351 | | - $tables[] = 'smw_inst2'; |
352 | | - $tables[] = 'smw_subs2'; |
353 | | - return true; |
354 | | -} |
355 | | - |
356 | | -/**********************************************/ |
357 | | -/***** namespace settings *****/ |
358 | | -/**********************************************/ |
359 | | - |
360 | | -/** |
361 | | - * Init the additional namepsaces used by Semantic MediaWiki. |
362 | | - * @todo Allow light version to register less namespaces. |
363 | | - */ |
364 | | -function smwfInitNamespaces() { |
365 | | - global $smwgNamespaceIndex, $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespacesWithSubpages, $wgLanguageCode, $smwgContLang; |
366 | | - |
367 | | - if ( !isset( $smwgNamespaceIndex ) ) { |
368 | | - $smwgNamespaceIndex = 100; |
369 | | - } |
370 | | - // 100 and 101 used to be occupied by SMW's now obsolete namespaces "Relation" and "Relation_Talk" |
371 | | - define( 'SMW_NS_PROPERTY', $smwgNamespaceIndex + 2 ); |
372 | | - define( 'SMW_NS_PROPERTY_TALK', $smwgNamespaceIndex + 3 ); |
373 | | - define( 'SMW_NS_TYPE', $smwgNamespaceIndex + 4 ); |
374 | | - define( 'SMW_NS_TYPE_TALK', $smwgNamespaceIndex + 5 ); |
375 | | - // 106 and 107 are occupied by the Semantic Forms, we define them here to offer some (easy but useful) support to SF |
376 | | - define( 'SF_NS_FORM', $smwgNamespaceIndex + 6 ); |
377 | | - define( 'SF_NS_FORM_TALK', $smwgNamespaceIndex + 7 ); |
378 | | - define( 'SMW_NS_CONCEPT', $smwgNamespaceIndex + 8 ); |
379 | | - define( 'SMW_NS_CONCEPT_TALK', $smwgNamespaceIndex + 9 ); |
380 | | - |
381 | | - smwfInitContentLanguage( $wgLanguageCode ); |
382 | | - |
383 | | - // Register namespace identifiers |
384 | | - if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); } |
385 | | - $wgExtraNamespaces = $wgExtraNamespaces + $smwgContLang->getNamespaces(); |
386 | | - $wgNamespaceAliases = $wgNamespaceAliases + $smwgContLang->getNamespaceAliases(); |
387 | | - |
388 | | - // Support subpages only for talk pages by default |
389 | | - $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array( |
390 | | - SMW_NS_PROPERTY_TALK => true, |
391 | | - SMW_NS_TYPE_TALK => true |
392 | | - ); |
393 | | - |
394 | | - // not modified for Semantic MediaWiki |
395 | | - /* $wgNamespacesToBeSearchedDefault = array( |
396 | | - NS_MAIN => true, |
397 | | - ); |
398 | | - */ |
399 | | -} |
400 | | - |
401 | | -/**********************************************/ |
402 | | -/***** language settings *****/ |
403 | | -/**********************************************/ |
404 | | - |
405 | | -/** |
406 | | - * Set up (possibly localised) names for SMW's parser functions. |
407 | | - * @todo Can be removed when new style magic words are used (introduced in r52503). |
408 | | - */ |
409 | | -function smwfAddMagicWords( &$magicWords, $langCode ) { |
410 | | -// $magicWords['ask'] = array( 0, 'ask' ); |
411 | | -// $magicWords['show'] = array( 0, 'show' ); |
412 | | -// $magicWords['info'] = array( 0, 'info' ); |
413 | | -// $magicWords['concept'] = array( 0, 'concept' ); |
414 | | - $magicWords['set'] = array( 0, 'set' ); |
415 | | - $magicWords['set_recurring_event'] = array( 0, 'set_recurring_event' ); |
416 | | - $magicWords['declare'] = array( 0, 'declare' ); |
417 | | -// $magicWords['SMW_NOFACTBOX'] = array( 0, '__NOFACTBOX__' ); |
418 | | -// $magicWords['SMW_SHOWFACTBOX'] = array( 0, '__SHOWFACTBOX__' ); |
419 | | - return true; |
420 | | -} |
421 | | - |
422 | | -/** |
423 | | - * Initialise a global language object for content language. This must happen |
424 | | - * early on, even before user language is known, to determine labels for |
425 | | - * additional namespaces. In contrast, messages can be initialised much later |
426 | | - * when they are actually needed. |
427 | | - */ |
428 | | -function smwfInitContentLanguage( $langcode ) { |
429 | | - global $smwgIP, $smwgContLang; |
430 | | - if ( !empty( $smwgContLang ) ) { return; } |
431 | | - wfProfileIn( 'smwfInitContentLanguage (SMW)' ); |
432 | | - |
433 | | - $smwContLangFile = 'SMW_Language' . str_replace( '-', '_', ucfirst( $langcode ) ); |
434 | | - $smwContLangClass = 'SMWLanguage' . str_replace( '-', '_', ucfirst( $langcode ) ); |
435 | | - if ( file_exists( $smwgIP . 'languages/' . $smwContLangFile . '.php' ) ) { |
436 | | - include_once( $smwgIP . 'languages/' . $smwContLangFile . '.php' ); |
437 | | - } |
438 | | - |
439 | | - // fallback if language not supported |
440 | | - if ( !class_exists( $smwContLangClass ) ) { |
441 | | - include_once( $smwgIP . 'languages/SMW_LanguageEn.php' ); |
442 | | - $smwContLangClass = 'SMWLanguageEn'; |
443 | | - } |
444 | | - $smwgContLang = new $smwContLangClass(); |
445 | | - |
446 | | - wfProfileOut( 'smwfInitContentLanguage (SMW)' ); |
447 | | -} |
448 | | - |
449 | | -/** |
450 | | - * This hook registers parser functions and hooks to the given parser. It is |
451 | | - * called during SMW initialisation. Note that parser hooks are something different |
452 | | - * than MW hooks in general, which explains the two-level registration. |
453 | | - * |
454 | | - * @since 1.5.3 |
455 | | - */ |
456 | | -function smwfRegisterParserFunctions( Parser &$parser ) { |
457 | | - $parser->setFunctionHook( 'set', array( 'SMWSet', 'render' ) ); |
458 | | - $parser->setFunctionHook( 'declare', array( 'SMWDeclare', 'render' ), SFH_OBJECT_ARGS ); |
459 | | - |
460 | | - return true; // Always return true, in order not to stop MW's hook processing! |
461 | | -} |