Semantic MediaWiki and related extensions
Functions
GlobalFunctions.php File Reference

Functions

 smwfIsSemanticsProcessed ($namespace)
 
 smwfNormalTitleDBKey ($text)
 
 smwfNormalTitleText ($text)
 
 smwfXMLContentEncode ($text)
 
 smwfHTMLtoUTF8 ($text)
 
 smwfNumberFormat ($value, $decplaces=3)
 
 smwfEncodeMessages (array $messages, $type= 'warning', $seperator= '<!--br-->', $escape=true)
 
smwfGetStore ()
 
 smwfCacheKey ($namespace, $key)
 
smwfGetSparqlDatabase ()
 
 smwfGetLinker ()
 
 enableSemantics ($namespace=null, $complete=false)
 
 disableSemantics ()
 

Function Documentation

disableSemantics ( )

To disable Semantic MediaWiki's operational functionality

Note
This function can be used to temporary disable SMW but it is paramount that after SMW is re-enabled to run rebuildData.php in order for data to represent a state that mirrors the actual environment (deleted, moved pages are not tracked when disabled).
enableSemantics (   $namespace = null,
  $complete = false 
)

Function to switch on Semantic MediaWiki. This function must be called in LocalSettings.php after including SMW_Settings.php. It is used to ensure that required parameters for SMW are really provided explicitly. For readability, this is the only global function that does not adhere to the naming conventions.

This function also sets up all autoloading, such that all SMW classes are available as early on. Moreover, jobs and special pages are registered.

Parameters
mixed$namespace
boolean$complete
Returns
true
smwfCacheKey (   $namespace,
  $key 
)
Since
3.0
Parameters
string$namespace
string$key
Returns
string
smwfEncodeMessages ( array  $messages,
  $type = 'warning',
  $seperator = ' <!--br-->',
  $escape = true 
)

Formats an array of message strings so that it appears as a tooltip. $icon should be one of: 'warning' (default), 'info'.

Parameters
array$messages
string$iconActs like an enum. Callers must ensure safety, since this value is used directly in the output.
string$seperator
boolean$escapeShould the messages be escaped or not (ie when they already are)
Returns
string
smwfGetLinker ( )

Compatibility helper for using Linker methods. MW 1.16 has a Linker with non-static methods, where in MW 1.19 they are static, and a DummyLinker class is introduced, which can be instantiated for compat reasons. As of MW 1.28, DummyLinker is being deprecated, so always use Linker.

Since
1.6
Returns
Linker
& smwfGetSparqlDatabase ( )

Get the SMWSparqlDatabase object to use for connecting to a SPARQL store, or null if no SPARQL backend has been set up.

Currently, it just returns one globally defined object, but the infrastructure allows to set up load balancing and task-dependent use of stores (e.g. using other stores for fast querying than for storing new facts), somewhat similar to MediaWiki's DB implementation.

Since
1.6
Returns
SMWSparqlDatabase or null
& smwfGetStore ( )

Returns an instance for the storage back-end

Returns
SMWStore
smwfHTMLtoUTF8 (   $text)

Decodes character references and inserts Unicode characters instead, using the MediaWiki Sanitizer.

Parameters
string$text
smwfNormalTitleDBKey (   $text)

Takes a title text and turns it safely into its DBKey. This function reimplements most of the title normalization as done in Title.php in order to achieve conversion with less overhead. The official code could be called here if more advanced normalization is needed.

Parameters
string$text
smwfNormalTitleText (   $text)

Takes a text and turns it into a normalised version. This function reimplements the title normalization as done in Title.php in order to achieve conversion with less overhead. The official code could be called here if more advanced normalization is needed.

Parameters
string$text
smwfNumberFormat (   $value,
  $decplaces = 3 
)
Deprecated:
since 2.1, use NumberFormatter instead
smwfXMLContentEncode (   $text)

Escapes text in a way that allows it to be used as XML content (e.g. as a string value for some property).

Parameters
string$text