SMWParseData Class Reference
[Semantic MediaWiki]

Static class for managing semantic data collected during parsing, including some hooks that can be used for updating and storing the data for some article. More...

List of all members.

Static Public Member Functions

static stripMagicWords (&$text, Parser $parser)
 Remove relevant SMW magic words from the given text and return an array of the names of all discovered magic words.
static getSMWdata ($parser)
 This function retrieves the SMW data from a given parser, and creates a new empty container if it is not initiated yet.
static clearStorage (Parser $parser)
 Clear all stored data for a given parser.
static addProperty ($propertyName, $value, $caption, Parser $parser, $storeAnnotation=true)
 This method adds a new property with the given value to the storage.
static storeData ($parseroutput, Title $title, $makejobs=true)
 This function takes care of storing the collected semantic data and takes care of clearing out any outdated entries for the processed page.
static equalDatavalues ($dv1, $dv2)
 Helper function that compares two arrays of data values to check whether they contain the same content.
static onParserAfterTidy (&$parser, &$text)
 Hook function fetches category information and other final settings from parser output, so that they are also replicated in SMW for more efficient querying.
static onNewRevisionFromEditComplete ($article, Revision $rev, $baseID, User $user)
 Fetch additional information that is related to the saving that has just happened, e.g.
static onLinksUpdateConstructed ($links_update)
 Hook where the storage of data is triggered.
static onArticleDelete (&$article, &$user, &$reason)
 This method will be called whenever an article is deleted so that semantic properties are cleared appropriately.
static onTitleMoveComplete (&$old_title, &$new_title, &$user, $pageid, $redirid)
 This method will be called whenever an article is moved so that semantic properties are moved accordingly.

Static Protected Member Functions

static getDataItemFromMWTimestamp ($timestamp)
 Create an SMWDITime object from a MediaWiki timestamp.


Detailed Description

Static class for managing semantic data collected during parsing, including some hooks that can be used for updating and storing the data for some article.

All methods in this class are stateless: data is stored persistently only in a given parser output.

Author:
Markus Krötzsch

Definition at line 21 of file SMW_ParseData.php.


Member Function Documentation

static SMWParseData::stripMagicWords ( &$  text,
Parser $  parser 
) [static]

Remove relevant SMW magic words from the given text and return an array of the names of all discovered magic words.

Moreover, store this array in the current parser output, using the variable mSMWMagicWords.

Definition at line 29 of file SMW_ParseData.php.

Referenced by SMWParserExtensions::onInternalParseBeforeLinks().

static SMWParseData::getSMWdata ( parser  )  [static]

This function retrieves the SMW data from a given parser, and creates a new empty container if it is not initiated yet.

Returns:
SMWSemanticData

Definition at line 55 of file SMW_ParseData.php.

Referenced by SMWConcept::render().

static SMWParseData::clearStorage ( Parser $  parser  )  [static]

Clear all stored data for a given parser.

Parameters:
Parser $parser

Definition at line 77 of file SMW_ParseData.php.

static SMWParseData::addProperty ( propertyName,
value,
caption,
Parser $  parser,
storeAnnotation = true 
) [static]

This method adds a new property with the given value to the storage.

It is intended to be used on user input, and property and value are sepcified by strings as they might be found in a wiki. The function returns a datavalue object that contains the result of the operation.

Parameters:
string $propertyName
string $value
mixed $caption string or false
Parser $parser
boolean $storeAnnotation
Returns:
SMWDataValue

Definition at line 102 of file SMW_ParseData.php.

References SMWPropertyValue::makeUserProperty(), and SMWDataValueFactory::newPropertyObjectValue().

Referenced by SMWParserExtensions::parsePropertiesCallback(), SMWSetRecurringEvent::render(), SMWSet::render(), and SMWDeclare::render().

static SMWParseData::storeData ( parseroutput,
Title $  title,
makejobs = true 
) [static]

This function takes care of storing the collected semantic data and takes care of clearing out any outdated entries for the processed page.

It assume that parsing has happened and that all relevant data is contained in the provided parser output.

Optionally, this function also takes care of triggering indirect updates that might be needed for overall database consistency. If the saved page describes a property or data type, the method checks whether the property type, the data type, the allowed values, or the conversion factors have changed. If so, it triggers SMWUpdateJobs for the relevant articles, which then asynchronously update the semantic data in the database.

Parameters:
$parseroutput ParserOutput object that contains the results of parsing which will be stored.
$title Title object specifying the page that should be saved.
$makejobs Bool stating whether jobs should be created to trigger further updates if this appears to be necessary after this update.
Todo:
FIXME: Some job generations here might create too many jobs at once on a large wiki. Use incremental jobs instead.

FIXME: this will kill large wikis! Use incremental updates!

NOTE: this only happens if $smwgEnableUpdateJobs was true above

Definition at line 167 of file SMW_ParseData.php.

References $smwgDeclarationProperties, $smwgEnableUpdateJobs, $smwgPageSpecialProperties, $store, SMWDIWikiPage::newFromTitle(), SMWDataValueFactory::newTypeIdValue(), smwfGetStore(), and smwfIsSemanticsProcessed().

Referenced by SMWUpdateJob::run().

static SMWParseData::equalDatavalues ( dv1,
dv2 
) [static]

Helper function that compares two arrays of data values to check whether they contain the same content.

Returns true if the two arrays contain the same data values (irrespective of their order), false otherwise.

Definition at line 342 of file SMW_ParseData.php.

static SMWParseData::onParserAfterTidy ( &$  parser,
&$  text 
) [static]

Hook function fetches category information and other final settings from parser output, so that they are also replicated in SMW for more efficient querying.

Definition at line 370 of file SMW_ParseData.php.

References $smwgCategoriesAsInstances, and $smwgUseCategoryHierarchy.

static SMWParseData::onNewRevisionFromEditComplete ( article,
Revision $  rev,
baseID,
User $  user 
) [static]

Fetch additional information that is related to the saving that has just happened, e.g.

regarding the last edit date. In runs where this hook is not triggered, the last DB entry (of MW) will be used to fill such properties.

Note:
This method directly accesses a member of Article that is informally declared to be private. However, there is no way to otherwise access an article's parseroutput for the purpose of adding information there. If the private access ever becomes a problem, a global/static variable appears to be the only way to get more article data to LinksUpdate.
Parameters:
WikiPage|Article $article WikiPage on 1.19 and later
Revision $rev
integer $baseID
User $user
Returns:
true

Definition at line 424 of file SMW_ParseData.php.

References $smwgPageSpecialProperties, and SMWDIWikiPage::newFromTitle().

static SMWParseData::onLinksUpdateConstructed ( links_update  )  [static]

Hook where the storage of data is triggered.

This happens when saving an article but possibly also when running update jobs.

Definition at line 474 of file SMW_ParseData.php.

static SMWParseData::onArticleDelete ( &$  article,
&$  user,
&$  reason 
) [static]

This method will be called whenever an article is deleted so that semantic properties are cleared appropriately.

Definition at line 483 of file SMW_ParseData.php.

References smwfGetStore().

static SMWParseData::onTitleMoveComplete ( &$  old_title,
&$  new_title,
&$  user,
pageid,
redirid 
) [static]

This method will be called whenever an article is moved so that semantic properties are moved accordingly.

Definition at line 492 of file SMW_ParseData.php.

References smwfGetStore().

static SMWParseData::getDataItemFromMWTimestamp ( timestamp  )  [static, protected]

Create an SMWDITime object from a MediaWiki timestamp.

A timestamp is a 14 character string YYYYMMDDhhmmss.

Parameters:
$timestamp string MediaWiki timestamp
Returns:
SWMDITime object or null if errors occurred

Definition at line 504 of file SMW_ParseData.php.

References SMWDITime::CM_GREGORIAN.


The documentation for this class was generated from the following file:

Generated on Sun Mar 18 07:15:43 2012 for Semantic MediaWiki by  doxygen 1.5.6