SMWExportController Class Reference
[Semantic MediaWiki]

Class for controlling the export of SMW page data, supporting high-level features such as recursive export and backlink inclusion. More...

List of all members.

Public Member Functions

 __construct (SMWSerializer $serializer, $enable_backlinks=false)
 Constructor.
 enableBacklinks ($enable)
 Enable or disable inclusion of backlinks into the output.
 printPages ($pages, $recursion=1, $revisiondate=false)
 This function prints all selected pages, specified as an array of page names (strings with namespace identifiers).
 printAll ($outfile, $ns_restriction=false, $delay, $delayeach)
 This function exports the semantic data for all pages within the wiki, and for all elements that are referred to in the exported data.
 printPageList ($offset=0, $limit=30)
 Print basic definitions a list of pages ordered by their page id.
 printWikiInfo ()
 Print basic information about this site.

Static Public Member Functions

static fitsNsRestriction ($res, $ns)
 This function checks whether some article fits into a given namespace restriction.

Public Attributes

const MAX_CACHE_SIZE = 5000
const CACHE_BACKJUMP = 500

Protected Member Functions

 prepareSerialization ($outfilename= '')
 Initialize all internal structures to begin with some serialization.
 serializePage (SMWDIWikiPage $diWikiPage, $recursiondepth=1)
 Serialize data associated to a specific page.
 queuePage (SMWDIWikiPage $diWikiPage, $recursiondepth)
 Add a given SMWDIWikiPage to the export queue if needed.
 markPageAsDone (SMWDIWikiPage $di, $recdepth)
 Mark an article as done while making sure that the cache used for this stays reasonably small.
 markHashAsDone ($hash, $recdepth)
 Mark a task as done while making sure that the cache used for this stays reasonably small.
 isPageDone (SMWDIWikiPage $di, $recdepth)
 Check if the given object has already been serialised at sufficient recursion depth.
 isHashDone ($hash, $recdepth)
 Check if the given task has already been completed at sufficient recursion depth.
 getSemanticData (SMWDIWikiPage $diWikiPage, $core_props_only)
 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).
 flush ($force=false)
 Send to the output what has been serialized so far.

Protected Attributes

 $serializer
 $element_queue
 An array that keeps track of the elements for which we still need to write auxiliary definitions/declarations.
 $element_done
 An array that keeps track of the recursion depth with which each object has been serialised.
 $add_backlinks
 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.
 $delay_flush
 Controls how long to wait until flushing content to output.
 $outputfile
 File handle for a potential output file to write to, or null if printing to standard output.


Detailed Description

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.

Definition at line 20 of file SMW_ExportController.php.


Constructor & Destructor Documentation

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

Constructor.

Parameters:
SMWSerializer $serializer defining the object used for syntactic serialization.
boolean $enable_backlinks defining if backlinks are included, see $add_backlinks for details.

Definition at line 70 of file SMW_ExportController.php.


Member Function Documentation

SMWExportController::enableBacklinks ( enable  ) 

Enable or disable inclusion of backlinks into the output.

Parameters:
boolean $enable

Definition at line 80 of file SMW_ExportController.php.

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 $outfilename URL of the file that output should be written to, or empty string for writting to the standard output.

Definition at line 91 of file SMW_ExportController.php.

Referenced by printAll(), printPageList(), printPages(), and printWikiInfo().

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 $diWikiPage specifying the page to be exported
integer $recursiondepth specifying the depth of recursion

Definition at line 121 of file SMW_ExportController.php.

References getSemanticData(), isPageDone(), SMWExporter::makeExportData(), markPageAsDone(), SMWPrintRequest::PRINT_THIS, queuePage(), and smwfGetStore().

Referenced by printAll(), printPageList(), and printPages().

SMWExportController::queuePage ( SMWDIWikiPage diWikiPage,
recursiondepth 
) [protected]

Add a given SMWDIWikiPage to the export queue if needed.

Definition at line 230 of file SMW_ExportController.php.

References SMWDataItem::getHash(), and isPageDone().

Referenced by printAll(), printPages(), and serializePage().

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.

Definition at line 241 of file SMW_ExportController.php.

References markHashAsDone().

Referenced by serializePage().

SMWExportController::markHashAsDone ( hash,
recdepth 
) [protected]

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

Definition at line 249 of file SMW_ExportController.php.

References isHashDone().

Referenced by markPageAsDone().

SMWExportController::isPageDone ( SMWDIWikiPage di,
recdepth 
) [protected]

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

Parameters:
SMWDIWikiPage $st specifying the object to check

Definition at line 267 of file SMW_ExportController.php.

References isHashDone().

Referenced by queuePage(), and serializePage().

SMWExportController::isHashDone ( hash,
recdepth 
) [protected]

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

Definition at line 275 of file SMW_ExportController.php.

Referenced by isPageDone(), and markHashAsDone().

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.

Definition at line 289 of file SMW_ExportController.php.

References smwfGetStore().

Referenced by serializePage().

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.

Definition at line 310 of file SMW_ExportController.php.

Referenced by printAll(), printPageList(), printPages(), and printWikiInfo().

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 $pages list of page names to export
integer $recursion determines 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 $revisiondate filter 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?

Definition at line 340 of file SMW_ExportController.php.

References $linkCache, SMWExporter::expandURI(), flush(), SMWExporter::getOntologyExpData(), SMWDIWikiPage::newFromTitle(), prepareSerialization(), queuePage(), and serializePage().

SMWExportController::printAll ( outfile,
ns_restriction = false,
delay,
delayeach 
)

This function exports the semantic data for all pages within the wiki, and for all elements that are referred to in the exported data.

Parameters:
string $outfile the output file URI, or false if printing to stdout
mixed $ns_restriction namespace restriction, see fitsNsRestriction()
integer $delay number of microseconds for which to sleep during export to reduce server load in long-running operations
integer $delayeach number of pages to process between two sleeps

Definition at line 392 of file SMW_ExportController.php.

References $db, $linkCache, fitsNsRestriction(), flush(), SMWExporter::getOntologyExpData(), SMWDIWikiPage::newFromTitle(), prepareSerialization(), queuePage(), serializePage(), and smwfIsSemanticsProcessed().

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 $offset the number of the first (existing) page to serialize a declaration for
integer $limit the number of pages to serialize

Definition at line 452 of file SMW_ExportController.php.

References $db, $linkCache, $smwgNamespacesWithSemanticLinks, SMWExporter::expandURI(), flush(), SMWExporter::getOntologyExpData(), SMWExporter::getSpecialNsResource(), prepareSerialization(), and serializePage().

SMWExportController::printWikiInfo (  ) 

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:
$res mixed encoding the restriction as described above
$ns integer the namespace constant to be checked

Definition at line 591 of file SMW_ExportController.php.

Referenced by printAll().


Member Data Documentation

Definition at line 21 of file SMW_ExportController.php.

Definition at line 22 of file SMW_ExportController.php.

SMWExportController::$serializer [protected]

Definition at line 28 of file SMW_ExportController.php.

SMWExportController::$element_queue [protected]

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

Definition at line 33 of file SMW_ExportController.php.

SMWExportController::$element_done [protected]

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

Definition at line 38 of file SMW_ExportController.php.

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".

Definition at line 48 of file SMW_ExportController.php.

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.

Definition at line 56 of file SMW_ExportController.php.

SMWExportController::$outputfile [protected]

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

Definition at line 61 of file SMW_ExportController.php.


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