SMWResultPrinter Class Reference
[SMWQuery]

Abstract base class for SMW's novel query printing mechanism. More...

Inherited by SMKMLPrinter, SMMapPrinter, SMWAggregatablePrinter, SMWCategoryResultPrinter, SMWCsvResultPrinter, SMWDSVResultPrinter, SMWEmbeddedResultPrinter, SMWJSONResultPrinter, SMWListResultPrinter, SMWRDFResultPrinter, SMWRSSResultPrinter, SMWTableResultPrinter, SRFArray, SRFBibTeX, SRFCalendar, SRFGallery, SRFGoogleBar, SRFGooglePie, SRFGraph, SRFiCalendar, SRFMath, SRFOutline, SRFPloticus, SRFProcess, SRFTagCloud, SRFTimeline, SRFValueRank, and SRFvCard.

List of all members.

Public Member Functions

 __construct ($format, $inline, $useValidator=false)
 Constructor.
 getResult (SMWQueryResult $results, array $params, $outputmode)
 Main entry point: takes an SMWQueryResult and parameters given as key-value-pairs in an array, and returns the serialised version of the results, formatted as HTML or Wiki or whatever is specified.
 getMimeType ($res)
 Some printers do not mainly produce embeddable HTML or Wikitext, but produce stand-alone files.
 getQueryMode ($context)
 This function determines the query mode that is to be used for this printer in various contexts.
 getFileName ($res)
 Some printers can produce not only embeddable HTML or Wikitext, but can also produce stand-alone files.
 getName ()
 Get a human readable label for this printer.
 getErrorString (SMWQueryResult $res)
 Provides a simple formatted string of all the error messages that occurred.
 setShowErrors ($show)
 Set whether errors should be shown.
 getValidatorParameters ()
 Returns the parameters from getParameters, but with all non-Validator parameters converted to Validator parameters.
 getParameters ()
 A function to describe the allowed parameters of a query using any specific format - most query printers should override this function.

Static Public Attributes

static $maxRecursionDepth = 2
 This public variable can be set to higher values to allow more recursion; do this at your own risk! This can be set in LocalSettings.php, but only after enableSemantics().

Protected Member Functions

 getResultText (SMWQueryResult $res, $outputmode)
 Return serialised results in specified format.
 handleNonFileResult ($result, SMWQueryResult $results, $outputmode)
 Continuation of getResult that only gets executed for non file outputs.
 handleParameters (array $params, $outputmode)
 Read an array of parameter values given as key-value-pairs and initialise internal member fields accordingly.
 getLinker ($firstcol=false)
 Depending on current linking settings, returns a linker object for making hyperlinks or NULL if no links should be created.
 escapeText ($text, $outputmode)
 If $outputmode is SMW_OUTPUT_HTML, escape special characters occuring in the given text.
 getSearchLabel ($outputmode)
 Get the string the user specified as a text for the "further results" link, properly escaped for the current output mode.
 linkFurtherResults ($results)
 Check whether a "further results" link would normally be generated for this result set with the given parameters.
 addError ($errorMessage)
 Adds an error message for a parameter handling error so a list of errors can be created later on.
 textDisplayParameters ()
 Return an array describing the parameters of specifically text-based formats, like 'list' and 'table', for use in their getParameters() functions.
 exportFormatParameters ()
 Return an array describing the parameters of the export formats like 'rss' and 'csv', for use in their getParameters() functions.
 toValidatorParam ($param)
 Returns a Validator style Parameter definition.

Protected Attributes

 $m_params
 $params
 $mIntro = ''
 Text to print *before* the output in case it is *not* empty; assumed to be wikitext.
 $mOutro = ''
 Text to print *after* the output in case it is *not* empty; assumed to be wikitext.
 $mSearchlabel = null
 Text to use for link to further results, or empty if link should not be shown.
 $mDefault = ''
 Default return value for empty queries.
 $mFormat
 $mLinkFirst
 $mLinkOthers
 $mShowHeaders = SMW_HEADERS_SHOW
 $mShowErrors = true
 $mInline
 $mLinker
 $mErrors = array()
 $isHTML = false
 If set, treat result as plain HTML.
 $hasTemplates = false
 If set, take the necessary steps to make sure that things like {{templatename| .

Static Private Attributes

static $mRecursionDepth = 0
 Incremented while expanding templates inserted during printout; stop expansion at some point.


Detailed Description

Abstract base class for SMW's novel query printing mechanism.

It implements part of the former functionality of SMWInlineQuery (everything related to output formatting and the correspoding parameters) and is subclassed by concrete printers that provide the main formatting functionality.

Definition at line 26 of file SMW_QueryPrinter.php.


Constructor & Destructor Documentation

SMWResultPrinter::__construct ( format,
inline,
useValidator = false 
)

Constructor.

The parameter $format is a format string that may influence the processing details.

Parameters:
string $format
$inline 
boolean $useValidator Deprecated since 1.6.2

TODO: how can we get the default or user skin here (depending on context)?

Reimplemented in SRFArray.

Definition at line 120 of file SMW_QueryPrinter.php.

References $smwgQDefaultLinking.


Member Function Documentation

SMWResultPrinter::getResultText ( SMWQueryResult res,
outputmode 
) [abstract, protected]

SMWResultPrinter::getResult ( SMWQueryResult results,
array $  params,
outputmode 
)

Main entry point: takes an SMWQueryResult and parameters given as key-value-pairs in an array, and returns the serialised version of the results, formatted as HTML or Wiki or whatever is specified.

Normally this is not overwritten by subclasses.

If the outputmode is SMW_OUTPUT_WIKI, then the function will return something that is suitable for being used in a MediaWiki parser function, i.e. a wikitext strong *or* an array with flags and the string as entry 0. See Parser::setFunctionHook() for documentation on this. In all other cases, the function returns just a string.

For outputs SMW_OUTPUT_WIKI and SMW_OUTPUT_HTML, error messages or standard "further results" links are directly generated and appended. For SMW_OUTPUT_FILE, only the plain generated text is returned.

Note:
A note on recursion: some query printers may return wiki code that comes from other pages, e.g. from templates that are used in formatting or from embedded result pages. Both kinds of pages may contain #ask queries that do again use new pages, so we must care about recursion. We do so by simply counting how often this method starts a subparse and stopping at depth 2. There is one special case: if this method is called outside parsing, and the concrete printer returns wiki text, and wiki text is requested, then we may return wiki text with sub-queries to the caller. If the caller parses this (which is likely) then this will again call us in parse-context and all recursion checks catch. Only the first level of parsing is done outside and thus not counted. Thus you effectively can get down to level 3. The basic maximal depth of 2 can be changed by setting the variable SMWResultPrinter::$maxRecursionDepth (in LocalSettings.php, after enableSemantics()). Do this at your own risk.
Parameters:
$results SMWQueryResult
$params array
$outputmode integer
Returns:
string

Reimplemented in SMMapPrinter, SRFCalendar, SRFGallery, and SRFMath.

Definition at line 161 of file SMW_QueryPrinter.php.

References escapeText(), getErrorString(), getMimeType(), SMWQueryResult::getQueryLink(), getResultText(), handleNonFileResult(), and handleParameters().

SMWResultPrinter::handleNonFileResult ( result,
SMWQueryResult results,
outputmode 
) [protected]

Continuation of getResult that only gets executed for non file outputs.

Since:
1.6
Parameters:
string $result
SMWQueryResult $results
integer $outputmode
Returns:
string

TODO: explain problem (too much recursive parses)

NOTE: as of MW 1.14SVN, there is apparently no better way to hide the TOC

TODO: explain problem (too much recursive parses)

Definition at line 218 of file SMW_QueryPrinter.php.

References $maxRecursionDepth, $mRecursionDepth, $wgTitle, getErrorString(), and SMWOutputs::requireFromParserOutput().

Referenced by getResult().

SMWResultPrinter::handleParameters ( array $  params,
outputmode 
) [protected]

Read an array of parameter values given as key-value-pairs and initialise internal member fields accordingly.

Possibly overwritten (extended) by subclasses.

Since:
1.6
Parameters:
array $params
$outputmode 

Reimplemented in SMKMLPrinter, SMWCategoryResultPrinter, SMWCsvResultPrinter, SMWDSVResultPrinter, SMWEmbeddedResultPrinter, SMWListResultPrinter, SMWRDFResultPrinter, SMWRSSResultPrinter, SMWTableResultPrinter, SRFArray, SRFHash, SRFCalendar, SRFGoogleBar, SRFGooglePie, SRFGraph, SRFProcess, SRFiCalendar, SRFjqPlotBar, SRFjqPlotPie, SRFOutline, SRFTagCloud, SRFTimeline, and SRFValueRank.

Definition at line 296 of file SMW_QueryPrinter.php.

Referenced by SRFMath::getResult(), SRFGallery::getResult(), getResult(), and SMMapPrinter::getResult().

SMWResultPrinter::getLinker ( firstcol = false  )  [protected]

Depending on current linking settings, returns a linker object for making hyperlinks or NULL if no links should be created.

Parameters:
$firstcol True of this is the first result column (having special linkage settings).

Definition at line 339 of file SMW_QueryPrinter.php.

Referenced by SRFGallery::addImagePages(), SRFGallery::addImageProperties(), SMWTableResultPrinter::getCellContent(), SMWAggregatablePrinter::getDistributionResults(), SMWCategoryResultPrinter::getResultText(), SRFTagCloud::getTags(), SRFValueRank::getVRValues(), SRFTimeline::handlePropertyValue(), and SMWListResultPrinter::printRow().

SMWResultPrinter::getMimeType ( res  ) 

Some printers do not mainly produce embeddable HTML or Wikitext, but produce stand-alone files.

An example is RSS or iCalendar. This function returns the mimetype string that this file would have, or FALSE if no standalone files are produced.

If this function returns something other than FALSE, then the printer will not be regarded as a printer that displays in-line results. This is used to determine if a file output should be generated in Special:Ask.

Reimplemented in SMKMLPrinter, SMWCsvResultPrinter, SMWDSVResultPrinter, SMWJSONResultPrinter, SMWRDFResultPrinter, SMWRSSResultPrinter, SRFBibTeX, SRFiCalendar, and SRFvCard.

Definition at line 357 of file SMW_QueryPrinter.php.

Referenced by getResult().

SMWResultPrinter::getQueryMode ( context  ) 

This function determines the query mode that is to be used for this printer in various contexts.

The query mode influences how queries to that printer should be processed to obtain a result. Possible values are SMWQuery::MODE_INSTANCES (retrieve instances), SMWQuery::MODE_NONE (do nothing), SMWQuery::MODE_COUNT (get number of results), SMWQuery::MODE_DEBUG (return debugging text). Possible values for context are SMWQueryProcessor::SPECIAL_PAGE, SMWQueryProcessor::INLINE_QUERY, SMWQueryProcessor::CONCEPT_DESC.

The default implementation always returns SMWQuery::MODE_INSTANCES. File exports like RSS will use MODE_INSTANCES on special pages (so that instances are retrieved for the export) and MODE_NONE otherwise (displaying just a download link).

Reimplemented in SMWCsvResultPrinter, SMWDSVResultPrinter, SMWJSONResultPrinter, SMWRDFResultPrinter, SMWRSSResultPrinter, SRFArray, SRFBibTeX, SRFiCalendar, and SRFvCard.

Definition at line 374 of file SMW_QueryPrinter.php.

References SMWQuery::MODE_INSTANCES.

SMWResultPrinter::getFileName ( res  ) 

Some printers can produce not only embeddable HTML or Wikitext, but can also produce stand-alone files.

An example is RSS or iCalendar. This function returns a filename that is to be sent to the caller in such a case (the default filename is created by browsers from the URL, and it is often not pretty).

See also SMWResultPrinter::getMimeType()

Reimplemented in SMKMLPrinter, SMWCsvResultPrinter, SMWDSVResultPrinter, SMWJSONResultPrinter, SMWRDFResultPrinter, SRFBibTeX, SRFiCalendar, and SRFvCard.

Definition at line 387 of file SMW_QueryPrinter.php.

SMWResultPrinter::getName (  ) 

Get a human readable label for this printer.

The default is to return just the format identifier. Concrete implementations may refer to messages here. The format name is normally not used in wiki text but only in forms etc. hence the user language should be used when retrieving messages.

Returns:
string

Reimplemented in SMKMLPrinter, SMMapPrinter, SMWCategoryResultPrinter, SMWCsvResultPrinter, SMWDSVResultPrinter, SMWEmbeddedResultPrinter, SMWJSONResultPrinter, SMWListResultPrinter, SMWRDFResultPrinter, SMWRSSResultPrinter, SMWTableResultPrinter, SRFArray, SRFBibTeX, SRFCalendar, SRFGallery, SRFGoogleBar, SRFGooglePie, SRFGraph, SRFiCalendar, SRFjqPlotBar, SRFjqPlotPie, SRFMath, SRFOutline, SRFTagCloud, SRFTimeline, SRFValueRank, and SRFvCard.

Definition at line 400 of file SMW_QueryPrinter.php.

SMWResultPrinter::getErrorString ( SMWQueryResult res  ) 

Provides a simple formatted string of all the error messages that occurred.

Can be used if not specific error formatting is desired. Compatible with HTML and Wiki.

Parameters:
SMWQueryResult $res
Returns:
string

Definition at line 413 of file SMW_QueryPrinter.php.

References smwfEncodeMessages().

Referenced by getResult(), and handleNonFileResult().

SMWResultPrinter::setShowErrors ( show  ) 

Set whether errors should be shown.

By default they are.

Parameters:
boolean $show

Definition at line 422 of file SMW_QueryPrinter.php.

SMWResultPrinter::escapeText ( text,
outputmode 
) [protected]

If $outputmode is SMW_OUTPUT_HTML, escape special characters occuring in the given text.

Otherwise return text as is.

Returns:
string

Definition at line 432 of file SMW_QueryPrinter.php.

Referenced by getResult(), and getSearchLabel().

SMWResultPrinter::getSearchLabel ( outputmode  )  [protected]

SMWResultPrinter::linkFurtherResults ( results  )  [protected]

Check whether a "further results" link would normally be generated for this result set with the given parameters.

Individual result printers may decide to create or hide such a link independent of that, but this is the default.

Returns:
boolean

Definition at line 453 of file SMW_QueryPrinter.php.

Referenced by SRFOutline::getResultText(), SMWTableResultPrinter::getResultText(), SMWListResultPrinter::getResultText(), SMWEmbeddedResultPrinter::getResultText(), and SMWCategoryResultPrinter::getResultText().

SMWResultPrinter::addError ( errorMessage  )  [protected]

Adds an error message for a parameter handling error so a list of errors can be created later on.

Since:
1.6
Parameters:
string $errorMessage

Definition at line 465 of file SMW_QueryPrinter.php.

SMWResultPrinter::textDisplayParameters (  )  [protected]

Return an array describing the parameters of specifically text-based formats, like 'list' and 'table', for use in their getParameters() functions.

Since:
1.5.0
Returns:
array of Parameter

Definition at line 478 of file SMW_QueryPrinter.php.

References $params.

Referenced by SMWCategoryResultPrinter::getParameters().

SMWResultPrinter::exportFormatParameters (  )  [protected]

SMWResultPrinter::getValidatorParameters (  ) 

Returns the parameters from getParameters, but with all non-Validator parameters converted to Validator parameters.

Since:
1.6
Returns:
array of Parameter

Definition at line 522 of file SMW_QueryPrinter.php.

References $params, getParameters(), and toValidatorParam().

SMWResultPrinter::toValidatorParam ( param  )  [protected]

Returns a Validator style Parameter definition.

SMW 1.5.x style definitions are converted.

Since:
1.6
Parameters:
mixed $param
Returns:
Parameter

Definition at line 543 of file SMW_QueryPrinter.php.

Referenced by getValidatorParameters().

SMWResultPrinter::getParameters (  ) 

A function to describe the allowed parameters of a query using any specific format - most query printers should override this function.

TODO: refactor non-printer params up to the query processor and do all param handling there.

Since:
1.5
Returns:
array of Parameter

Reimplemented in SMKMLPrinter, SMMapPrinter, SMWAggregatablePrinter, SMWCategoryResultPrinter, SMWCsvResultPrinter, SMWDSVResultPrinter, SMWEmbeddedResultPrinter, SMWJSONResultPrinter, SMWListResultPrinter, SMWRDFResultPrinter, SMWRSSResultPrinter, SMWTableResultPrinter, SRFArray, SRFHash, SRFBibTeX, SRFCalendar, SRFGallery, SRFGoogleBar, SRFGooglePie, SRFGraph, SRFProcess, SRFiCalendar, SRFjqPlotBar, SRFjqPlotPie, SRFMath, SRFOutline, SRFPloticus, SRFTagCloud, SRFTimeline, SRFValueRank, and SRFvCard.

Definition at line 585 of file SMW_QueryPrinter.php.

Referenced by getValidatorParameters().


Member Data Documentation

SMWResultPrinter::$m_params [protected]

Deprecated:
Use $params instead

Definition at line 31 of file SMW_QueryPrinter.php.

SMWResultPrinter::$params [protected]

SMWResultPrinter::$mIntro = '' [protected]

Text to print *before* the output in case it is *not* empty; assumed to be wikitext.

Normally this is handled in SMWResultPrinter and can be ignored by subclasses.

Definition at line 47 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mOutro = '' [protected]

Text to print *after* the output in case it is *not* empty; assumed to be wikitext.

Normally this is handled in SMWResultPrinter and can be ignored by subclasses.

Definition at line 53 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mSearchlabel = null [protected]

Text to use for link to further results, or empty if link should not be shown.

Unescaped! Use SMWResultPrinter::getSearchLabel() and SMWResultPrinter::linkFurtherResults() instead of accessing this directly.

Definition at line 60 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mDefault = '' [protected]

Default return value for empty queries.

Unescaped. Normally not used in sub-classes!

Definition at line 63 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mFormat [protected]

Definition at line 66 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mLinkFirst [protected]

Definition at line 67 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mLinkOthers [protected]

Definition at line 68 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mShowHeaders = SMW_HEADERS_SHOW [protected]

Definition at line 69 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mShowErrors = true [protected]

Definition at line 70 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mInline [protected]

Definition at line 71 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mLinker [protected]

Definition at line 72 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mErrors = array() [protected]

Definition at line 81 of file SMW_QueryPrinter.php.

SMWResultPrinter::$isHTML = false [protected]

If set, treat result as plain HTML.

Can be used by printer classes if wiki mark-up is not enough. This setting is used only after the result text was generated.

Note:
HTML query results cannot be used as parameters for other templates or in any other way in combination with other wiki text. The result will be inserted on the page literally.

Definition at line 89 of file SMW_QueryPrinter.php.

SMWResultPrinter::$hasTemplates = false [protected]

If set, take the necessary steps to make sure that things like {{templatename| .

..}} are properly processed if they occur in the result. Clearly, this is only relevant if the output is not HTML, i.e. it is ignored if SMWResultPrinter::$is_HTML is true. This setting is used only after the result text was generated.

Note:
This requires extra processing and may make the result less useful for being used as a parameter for further parser functions. Use only if required.

Definition at line 99 of file SMW_QueryPrinter.php.

SMWResultPrinter::$mRecursionDepth = 0 [static, private]

Incremented while expanding templates inserted during printout; stop expansion at some point.

Definition at line 101 of file SMW_QueryPrinter.php.

Referenced by handleNonFileResult().

SMWResultPrinter::$maxRecursionDepth = 2 [static]

This public variable can be set to higher values to allow more recursion; do this at your own risk! This can be set in LocalSettings.php, but only after enableSemantics().

Definition at line 104 of file SMW_QueryPrinter.php.

Referenced by handleNonFileResult().


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

Generated on Fri Feb 10 07:15:47 2012 for Semantic MediaWiki by  doxygen 1.5.6