Semantic MediaWiki and related extensions
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SMWExportController Class Reference

Public Member Functions

 __construct (SMWSerializer $serializer, $enable_backlinks=false)
 
 enableBacklinks ($enable)
 
 printPages ($pages, $recursion=1, $revisiondate=false)
 
 printAllToFile ($outfile, $ns_restriction=false, $delay, $delayeach)
 
 printAllToOutput ($ns_restriction=false, $delay, $delayeach)
 
 printPageList ($offset=0, $limit=30)
 
 printWikiInfo ()
 

Static Public Member Functions

static fitsNsRestriction ($res, $ns)
 

Public Attributes

const MAX_CACHE_SIZE = 5000
 
const CACHE_BACKJUMP = 500
 

Protected Member Functions

 prepareSerialization ($outfilename= '')
 
 serializePage (SMWDIWikiPage $diWikiPage, $recursiondepth=1)
 
 queuePage (SMWDIWikiPage $diWikiPage, $recursiondepth)
 
 markPageAsDone (SMWDIWikiPage $di, $recdepth)
 
 markHashAsDone ($hash, $recdepth)
 
 isPageDone (SMWDIWikiPage $di, $recdepth)
 
 isHashDone ($hash, $recdepth)
 
 getSemanticData (SMWDIWikiPage $diWikiPage, $core_props_only)
 
 flush ($force=false)
 
 printAll ($ns_restriction=false, $delay, $delayeach)
 

Protected Attributes

 $serializer
 
 $element_queue
 
 $element_done
 
 $add_backlinks
 
 $delay_flush
 
 $outputfile
 

Detailed Description

File holding the SMWExportController class that provides basic functions for exporting pages to RDF and OWL.

Author
Markus Krötzsch Class for controlling the export of SMW page data, supporting high-level features such as recursive export and backlink inclusion. The class controls export independent of the serialisation syntax that is used.

Constructor & Destructor Documentation

SMWExportController::__construct ( SMWSerializer  $serializer,
  $enable_backlinks = false 
)

Constructor.

Parameters
SMWSerializer$serializerdefining the object used for syntactic serialization.
boolean$enable_backlinksdefining if backlinks are included, see $add_backlinks for details.

Member Function Documentation

SMWExportController::enableBacklinks (   $enable)

Enable or disable inclusion of backlinks into the output.

Parameters
boolean$enable
static SMWExportController::fitsNsRestriction (   $res,
  $ns 
)
static

This function checks whether some article fits into a given namespace restriction. Restrictions are encoded as follows: a non-negative number requires the namespace to be identical to the given number; "-1" requires the namespace to be different from Category, Property, and Type; "false" means "no restriction".

Parameters
$resmixed encoding the restriction as described above
$nsinteger the namespace constant to be checked
Returns
boolean
SMWExportController::flush (   $force = false)
protected

Send to the output what has been serialized so far. The flush might be deferred until later unless $force is true.

SMWExportController::getSemanticData ( SMWDIWikiPage  $diWikiPage,
  $core_props_only 
)
protected

Retrieve a copy of the semantic data for a wiki page, possibly filtering it so that only essential properties are included (in some cases, we only want to export stub information about a page). We make a copy of the object since we may want to add more data later on and we do not want to modify the store's result which may be used for caching purposes elsewhere.

SMWExportController::isHashDone (   $hash,
  $recdepth 
)
protected

Check if the given task has already been completed at sufficient recursion depth.

SMWExportController::isPageDone ( SMWDIWikiPage  $di,
  $recdepth 
)
protected

Check if the given object has already been serialised at sufficient recursion depth.

Parameters
SMWDIWikiPage$stspecifying the object to check
Returns
boolean
SMWExportController::markHashAsDone (   $hash,
  $recdepth 
)
protected

Mark a task as done while making sure that the cache used for this stays reasonably small.

SMWExportController::markPageAsDone ( SMWDIWikiPage  $di,
  $recdepth 
)
protected

Mark an article as done while making sure that the cache used for this stays reasonably small. Input is given as an SMWDIWikiPage object.

SMWExportController::prepareSerialization (   $outfilename = '')
protected

Initialize all internal structures to begin with some serialization. Returns true if initialization was successful (this means that the optional output file is writable).

Parameters
string$outfilenameURL of the file that output should be written to, or empty string for writting to the standard output.
Returns
boolean
SMWExportController::printAll (   $ns_restriction = false,
  $delay,
  $delayeach 
)
protected
Since
2.0 made protected; use printAllToFile or printAllToOutput
SMWExportController::printAllToFile (   $outfile,
  $ns_restriction = false,
  $delay,
  $delayeach 
)

Exports semantic data for all pages within the wiki and for all elements that are referred to a file resource

Since
2.0
Parameters
string$outfilethe output file URI, or false if printing to stdout
mixed$ns_restrictionnamespace restriction, see fitsNsRestriction()
integer$delaynumber of microseconds for which to sleep during export to reduce server load in long-running operations
integer$delayeachnumber of pages to process between two sleeps
SMWExportController::printAllToOutput (   $ns_restriction = false,
  $delay,
  $delayeach 
)

Exports semantic data for all pages within the wiki and for all elements that are referred to the stdout

Since
2.0
Parameters
mixed$ns_restrictionnamespace restriction, see fitsNsRestriction()
integer$delaynumber of microseconds for which to sleep during export to reduce server load in long-running operations
integer$delayeachnumber of pages to process between two sleeps
SMWExportController::printPageList (   $offset = 0,
  $limit = 30 
)

Print basic definitions a list of pages ordered by their page id. Offset and limit refer to the count of existing pages, not to the page id.

Parameters
integer$offsetthe number of the first (existing) page to serialize a declaration for
integer$limitthe number of pages to serialize
SMWExportController::printPages (   $pages,
  $recursion = 1,
  $revisiondate = false 
)

This function prints all selected pages, specified as an array of page names (strings with namespace identifiers).

Parameters
array$pageslist of page names to export
integer$recursiondetermines how pages are exported recursively: "0" means that referenced resources are only declared briefly, "1" means that all referenced resources are also exported recursively (propbably retrieving the whole wiki).
string$revisiondatefilter page list by including only pages that have been changed since this date; format "YmdHis"
Todo:
Consider dropping the $revisiondate filtering and all associated functionality. Is anybody using this?
SMWExportController::printWikiInfo ( )

Print basic information about this site.

SMWExportController::queuePage ( SMWDIWikiPage  $diWikiPage,
  $recursiondepth 
)
protected

Add a given SMWDIWikiPage to the export queue if needed.

SMWExportController::serializePage ( SMWDIWikiPage  $diWikiPage,
  $recursiondepth = 1 
)
protected

Serialize data associated to a specific page. This method works on the level of pages, i.e. it serialises parts of SMW content and implements features like recursive export or backlinks that are available for this type of data.

The recursion depth means the following. Depth of 1 or above means the object is serialised with all property values, and referenced objects are serialised with depth reduced by 1. Depth 0 means that only minimal declarations are serialised, so no dependencies are added. A depth of -1 encodes "infinite" depth, i.e. a complete recursive serialisation without limit.

Parameters
SMWDIWikiPage$diWikiPagespecifying the page to be exported
integer$recursiondepthspecifying the depth of recursion

Member Data Documentation

SMWExportController::$add_backlinks
protected

Boolean to indicate whether all objects that are exported in full (with all data) should also lead to the inclusion of all "inlinks" that they receive from other objects. If yes, these other objects are also serialised with at least the relevant inlinking properties included. Adding such dependencies counts as "recursive serialisation" and whether or not inlinking objects are included in full depends on the setting for recursion depth. Setting this to true enables "browsable RDF".

SMWExportController::$delay_flush
protected

Controls how long to wait until flushing content to output. Flushing early may reduce the memory footprint of serialization functions. Flushing later has some advantages for export formats like RDF/XML where global namespace declarations are only possible by modifying the header, so that only local declarations are possible after the first flush.

SMWExportController::$element_done
protected

An array that keeps track of the recursion depth with which each object has been serialised.

SMWExportController::$element_queue
protected

An array that keeps track of the elements for which we still need to write auxiliary definitions/declarations.

SMWExportController::$outputfile
protected

File handle for a potential output file to write to, or null if printing to standard output.

SMWExportController::$serializer
protected
const SMWExportController::CACHE_BACKJUMP = 500
const SMWExportController::MAX_CACHE_SIZE = 5000

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