本文整理汇总了PHP中SMWOutputs类的典型用法代码示例。如果您正苦于以下问题:PHP SMWOutputs类的具体用法?PHP SMWOutputs怎么用?PHP SMWOutputs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMWOutputs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormatOutput
/**
* Prepare data output
*
* @since 1.8
*
* @param array $data label => value
*/
protected function getFormatOutput(array $data)
{
//Init
$dataObject = array();
static $statNr = 0;
$chartID = 'sparkline-' . $this->params['charttype'] . '-' . ++$statNr;
$this->isHTML = true;
// Prepare data array
foreach ($data as $key => $value) {
if ($value >= $this->params['min']) {
$dataObject['label'][] = $key;
$dataObject['value'][] = $value;
}
}
$dataObject['charttype'] = $this->params['charttype'];
// Encode data objects
$requireHeadItem = array($chartID => FormatJson::encode($dataObject));
SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
// RL module
SMWOutputs::requireResource('ext.srf.sparkline');
// Processing placeholder
$processing = SRFUtils::htmlProcessingElement(false);
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none;"), null);
// Beautify class selector
$class = $this->params['class'] ? ' ' . $this->params['class'] : '';
// Chart/graph wrappper
return Html::rawElement('span', array('class' => 'srf-sparkline' . $class), $processing . $chart);
}
示例2: render
/**
* Method for handling the set_recurring_event parser function.
*
* @since 1.5.3
*
* @param Parser $parser
*/
public static function render( Parser &$parser ) {
$params = func_get_args();
array_shift( $params ); // We already know the $parser ...
// Almost all of the work gets done by
// getDatesForRecurringEvent().
$results = self::getDatesForRecurringEvent( $params );
if ( $results == null ) {
return null;
}
list( $property_name, $all_date_strings, $unused_params ) = $results;
// Do the actual saving of the data.
foreach ( $all_date_strings as $date_str ) {
SMWParseData::addProperty( $property_name, $date_str, false, $parser, true );
}
global $wgTitle;
if ( !is_null( $wgTitle ) && $wgTitle->isSpecialPage() ) {
global $wgOut;
SMWOutputs::commitToOutputPage( $wgOut );
}
else {
SMWOutputs::commitToParser( $parser );
}
}
示例3: onInternalParseBeforeLinks
/**
* This method will be called before an article is displayed or previewed.
* For display and preview we strip out the semantic properties and append them
* at the end of the article.
*
* @param Parser $parser
* @param string $text
*/
static public function onInternalParseBeforeLinks( &$parser, &$text ) {
global $smwgStoreAnnotations, $smwgLinksInValues;
SMWParseData::stripMagicWords( $text, $parser );
// Store the results if enabled (we have to parse them in any case,
// in order to clean the wiki source for further processing).
$smwgStoreAnnotations = smwfIsSemanticsProcessed( $parser->getTitle()->getNamespace() );
SMWParserExtensions::$mTempStoreAnnotations = true; // used for [[SMW::on]] and [[SMW:off]]
// Process redirects, if any (it seems that there is indeed no more direct way of getting this info from MW)
if ( $smwgStoreAnnotations ) {
$rt = Title::newFromRedirect( $text );
if ( !is_null( $rt ) ) {
$p = new SMWDIProperty( '_REDI' );
$di = SMWDIWikiPage::newFromTitle( $rt, '__red' );
SMWParseData::getSMWData( $parser )->addPropertyObjectValue( $p, $di );
}
}
// only used in subsequent callbacks, forgotten afterwards
SMWParserExtensions::$mTempParser = $parser;
// In the regexp matches below, leading ':' escapes the markup, as known for Categories.
// Parse links to extract semantic properties.
if ( $smwgLinksInValues ) { // More complex regexp -- lib PCRE may cause segfaults if text is long :-(
$semanticLinkPattern = '/\[\[ # Beginning of the link
(?:([^:][^]]*):[=:])+ # Property name (or a list of those)
( # After that:
(?:[^|\[\]] # either normal text (without |, [ or ])
|\[\[[^]]*\]\] # or a [[link]]
|\[[^]]*\] # or an [external link]
)*) # all this zero or more times
(?:\|([^]]*))? # Display text (like "text" in [[link|text]]), optional
\]\] # End of link
/xu';
$text = preg_replace_callback( $semanticLinkPattern, array( 'SMWParserExtensions', 'parsePropertiesCallback' ), $text );
} else { // Simpler regexps -- no segfaults found for those, but no links in values.
$semanticLinkPattern = '/\[\[ # Beginning of the link
(?:([^:][^]]*):[=:])+ # Property name (or a list of those)
([^\[\]]*) # content: anything but [, |, ]
\]\] # End of link
/xu';
$text = preg_replace_callback( $semanticLinkPattern, array( 'SMWParserExtensions', 'simpleParsePropertiesCallback' ), $text );
}
// Add link to RDF to HTML header.
// TODO: do escaping via Html or Xml class.
SMWOutputs::requireHeadItem(
'smw_rdf', '<link rel="alternate" type="application/rdf+xml" title="' .
htmlspecialchars( $parser->getTitle()->getPrefixedText() ) . '" href="' .
htmlspecialchars(
SpecialPage::getTitleFor( 'ExportRDF', $parser->getTitle()->getPrefixedText() )->getLocalUrl( 'xmlmime=rdf' )
) . "\" />"
);
SMWOutputs::commitToParser( $parser );
return true; // always return true, in order not to stop MW's hook processing!
}
示例4: getResultText
/**
* Return serialised results in specified format.
* Implemented by subclasses.
*/
protected function getResultText(SMWQueryResult $res, $outputmode)
{
$html = '';
$id = uniqid();
// build an array of article IDs contained in the result set
$objects = array();
foreach ($res->getResults() as $key => $object) {
$objects[] = array($object->getTitle()->getArticleId());
$html .= $key . ': ' . $object->getSerialization() . "<br>\n";
}
// build an array of data about the printrequests
$printrequests = array();
foreach ($res->getPrintRequests() as $key => $printrequest) {
$data = $printrequest->getData();
if ($data instanceof SMWPropertyValue) {
$name = $data->getDataItem()->getKey();
} else {
$name = null;
}
$printrequests[] = array($printrequest->getMode(), $printrequest->getLabel(), $name, $printrequest->getOutputFormat(), $printrequest->getParameters());
}
// write out results and query params into JS arrays
// Define the srf_filtered_values array
SMWOutputs::requireScript('srf_slideshow', Html::inlineScript('srf_slideshow = {};'));
SMWOutputs::requireScript('srf_slideshow' . $id, Html::inlineScript('srf_slideshow["' . $id . '"] = ' . json_encode(array($objects, $this->params['template'], $this->params['delay'] * 1000, $this->params['height'], $this->params['width'], $this->params['nav controls'], $this->params['effect'], json_encode($printrequests))) . ';'));
SMWOutputs::requireResource('ext.srf.slideshow');
if ($this->params['nav controls']) {
SMWOutputs::requireResource('jquery.ui.slider');
}
return Html::element('div', array('id' => $id, 'class' => 'srf-slideshow ' . $id . ' ' . $this->params['class']));
}
示例5: execute
/**
* Main entrypoint for the special page.
*
* @param string $p
*/
public function execute($p)
{
global $wgOut, $wgRequest, $smwgQEnabled;
$wgOut->addModules('ext.smw.style');
$wgOut->addModules('ext.smw.ask');
$wgOut->addModules('ext.smw.property');
$this->setHeaders();
if (!$smwgQEnabled) {
$wgOut->addHTML('<br />' . wfMessage('smw_iq_disabled')->escaped());
} else {
if ($wgRequest->getCheck('showformatoptions')) {
// handle Ajax action
$format = $wgRequest->getVal('showformatoptions');
$params = $wgRequest->getArray('params');
$wgOut->disable();
echo $this->showFormatOptions($format, $params);
} else {
$this->extractQueryParameters($p);
$this->makeHTMLResult();
}
}
$this->addExternalHelpLinkFor('smw_ask_doculink');
SMWOutputs::commitToOutputPage($wgOut);
// make sure locally collected output data is pushed to the output!
}
示例6: getFormatOutput
/**
* @see SMWResultPrinter::getFormatOutput
*
* @since 1.8
*
* @param array $data label => value
* @return string
*/
protected function getFormatOutput(array $data)
{
// Object count
static $statNr = 0;
$d3chartID = 'd3-chart-' . ++$statNr;
$this->isHTML = true;
// Reorganize the raw data
foreach ($data as $name => $value) {
if ($value >= $this->params['min']) {
$dataObject[] = array('label' => $name, 'value' => $value);
}
}
// Ensure right conversion
$width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
// Prepare transfer objects
$d3data = array('data' => $dataObject, 'parameters' => array('colorscheme' => $this->params['colorscheme'] ? $this->params['colorscheme'] : null, 'charttitle' => $this->params['charttitle'], 'charttext' => $this->params['charttext'], 'datalabels' => $this->params['datalabels']));
// Encoding
$requireHeadItem = array($d3chartID => FormatJson::encode($d3data));
SMWOutputs::requireHeadItem($d3chartID, Skin::makeVariablesScript($requireHeadItem));
// RL module
$resource = 'ext.srf.d3.chart.' . $this->params['charttype'];
SMWOutputs::requireResource($resource);
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $d3chartID, 'class' => 'container', 'style' => 'display:none;'), null);
// Processing placeholder
$processing = SRFUtils::htmlProcessingElement($this->isHTML);
// Beautify class selector
$class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
$class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' d3-chart-common';
// D3 wrappper
return Html::rawElement('div', array('class' => 'srf-d3-chart' . $class, 'style' => "width:{$width}; height:{$this->params['height']}px;"), $processing . $chart);
}
示例7: showList
/**
* Main method for adding all additional HTML to the output stream.
*/
protected function showList()
{
global $wgOut, $wgRequest;
$this->from = $wgRequest->getVal('from', '');
$this->until = $wgRequest->getVal('until', '');
if ($this->initParameters()) {
$wgOut->addHTML($this->getHtml());
SMWOutputs::commitToOutputPage($wgOut);
}
}
示例8: showList
/**
* Main method for adding all additional HTML to the output stream.
*/
protected function showList()
{
global $wgOut, $wgRequest;
wfProfileIn(__METHOD__ . ' (SMW)');
$this->from = $wgRequest->getVal('from', '');
$this->until = $wgRequest->getVal('until', '');
if ($this->initParameters()) {
$wgOut->addHTML("<br id=\"smwfootbr\"/>\n" . $this->getHtml());
SMWOutputs::commitToOutputPage($wgOut);
}
wfProfileOut(__METHOD__ . ' (SMW)');
}
示例9: execute
public function execute($param)
{
wfProfileIn('smwfDoSpecialUnusedProperties (SMW)');
global $wgOut;
$wgOut->setPageTitle(wfMsg('unusedproperties'));
$rep = new SMWUnusedPropertiesPage();
list($limit, $offset) = wfCheckLimits();
$rep->doQuery($offset, $limit);
// Ensure locally collected output data is pushed to the output!
SMWOutputs::commitToOutputPage($wgOut);
wfProfileOut('smwfDoSpecialUnusedProperties (SMW)');
}
示例10: render
/**
* Method for handling the declare parser function.
*
* @since 1.5.3
*
* @param Parser $parser
* @param PPFrame $frame
* @param array $args
*/
public static function render(Parser &$parser, PPFrame $frame, array $args)
{
if ($frame->isTemplate()) {
foreach ($args as $arg) {
if (trim($arg) !== '') {
$expanded = trim($frame->expand($arg));
$parts = explode('=', $expanded, 2);
if (count($parts) == 1) {
$propertystring = $expanded;
$argumentname = $expanded;
} else {
$propertystring = $parts[0];
$argumentname = $parts[1];
}
$property = SMWPropertyValue::makeUserProperty($propertystring);
$argument = $frame->getArgument($argumentname);
$valuestring = $frame->expand($argument);
if ($property->isValid()) {
$type = $property->getPropertyTypeID();
if ($type == '_wpg') {
$matches = array();
preg_match_all('/\\[\\[([^\\[\\]]*)\\]\\]/u', $valuestring, $matches);
$objects = $matches[1];
if (count($objects) == 0) {
if (trim($valuestring) !== '') {
SMWParseData::addProperty($propertystring, $valuestring, false, $parser, true);
}
} else {
foreach ($objects as $object) {
SMWParseData::addProperty($propertystring, $object, false, $parser, true);
}
}
} elseif (trim($valuestring) !== '') {
SMWParseData::addProperty($propertystring, $valuestring, false, $parser, true);
}
// $value = SMWDataValueFactory::newPropertyObjectValue( $property->getDataItem(), $valuestring );
// if (!$value->isValid()) continue;
}
}
}
} else {
// @todo Save as metadata
}
global $wgTitle;
if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
global $wgOut;
SMWOutputs::commitToOutputPage($wgOut);
} else {
SMWOutputs::commitToParser($parser);
}
return '';
}
示例11: getResultText
public function getResultText(SMWQueryResult $results, $outputmode)
{
global $wgUser, $wgParser;
$ig = new ImageGallery();
$ig->setShowBytes(false);
$ig->setShowFilename(false);
$ig->setParser($wgParser);
$ig->setCaption($this->mIntro);
// set caption to IQ header
if ($this->params['galleryformat'] == 'carousel') {
static $carouselNr = 0;
// Set attributes for jcarousel
$dataAttribs = array('wrap' => 'both', 'vertical' => 'false', 'rtl' => 'false');
// Use perrow parameter to determine the scroll sequence.
if (empty($this->params['perrow'])) {
$dataAttribs['scroll'] = 1;
// default 1
} else {
$dataAttribs['scroll'] = $this->params['perrow'];
$dataAttribs['visible'] = $this->params['perrow'];
}
$attribs = array('id' => 'carousel' . ++$carouselNr, 'class' => 'jcarousel jcarousel-skin-smw', 'style' => 'display:none;');
foreach ($dataAttribs as $name => $value) {
$attribs['data-' . $name] = $value;
}
$ig->setAttributes($attribs);
// Load javascript module
SMWOutputs::requireResource('ext.srf.jcarousel');
}
// In case galleryformat = carousel, perrow should not be set
if ($this->params['perrow'] !== '' && $this->params['galleryformat'] !== 'carousel') {
$ig->setPerRow($this->params['perrow']);
}
if ($this->params['widths'] !== '') {
$ig->setWidths($this->params['widths']);
}
if ($this->params['heights'] !== '') {
$ig->setHeights($this->params['heights']);
}
$printReqLabels = array();
foreach ($results->getPrintRequests() as $printReq) {
$printReqLabels[] = $printReq->getLabel();
}
if ($this->params['imageproperty'] !== '' && in_array($this->params['imageproperty'], $printReqLabels)) {
$this->addImageProperties($results, $ig, $this->params['imageproperty'], $this->params['captionproperty']);
} else {
$this->addImagePages($results, $ig);
}
return array($ig->toHTML(), 'nowiki' => true, 'isHTML' => true);
}
示例12: render
/**
* Renders and returns the output.
* @see ParserHook::render
*
* @since 1.7
*
* @param array $parameters
*
* @return string
*/
public function render(array $parameters)
{
/**
* Non-escaping is safe bacause a user's message is passed through parser, which will
* handle unsafe HTM elements.
*/
$result = smwfEncodeMessages(array($parameters['message']), $parameters['icon'], ' <!--br-->', false);
if (!is_null($this->parser->getTitle()) && $this->parser->getTitle()->isSpecialPage()) {
global $wgOut;
SMWOutputs::commitToOutputPage($wgOut);
} else {
SMWOutputs::commitToParser($this->parser);
}
return $result;
}
示例13: execute
public function execute($param)
{
global $wgOut;
$params = SMWInfolink::decodeParameters($param, false);
$typeLabel = reset($params);
if ($typeLabel == false) {
$wgOut->setPageTitle(wfMessage('types')->text());
$html = $this->getTypesList();
} else {
$typeName = str_replace('_', ' ', $typeLabel);
$wgOut->setPageTitle($typeName);
// Maybe add a better message for this
$html = $this->getTypeProperties($typeLabel);
}
$wgOut->addHTML($html);
SMWOutputs::commitToOutputPage($wgOut);
}
示例14: getResultText
/**
* @see SMWResultPrinter::getResultText
*
* @param SMWQueryResult $res
* @param $outputMode
*
* @return string
*/
protected function getResultText(SMWQueryResult $res, $outputMode)
{
// Initialize
static $statNr = 0;
// Get results from SMWListResultPrinter
$result = parent::getResultText($res, $outputMode);
// Count widgets
$widgetID = 'pagewidget-' . ++$statNr;
// Container items
$result = Html::rawElement('div', array('id' => $widgetID, 'class' => 'container', 'data-embedonly' => $this->params['embedonly'], 'style' => 'display:none;'), $result);
// Placeholder
$processing = SRFUtils::htmlProcessingElement($this->isHTML);
// RL module
SMWOutputs::requireResource('ext.srf.pagewidget.carousel');
// Beautify class selector
$class = $this->params['class'] ? ' ' . $this->params['class'] : '';
// Wrap results
return Html::rawElement('div', array('class' => 'srf-pagewidget' . $class), $processing . $result);
}
示例15: render
/**
* Method for handling the ask concept function.
*
* @todo The possible use of this in an HTML or Specal page context needs to be revisited. The code mentions it, but can this actually happen?
* @todo The escaping of symbols in concept queries needs to be revisited.
*
* @since 1.5.3
*
* @param Parser $parser
*/
public static function render(Parser &$parser)
{
global $wgContLang, $wgTitle;
$title = $parser->getTitle();
$pconc = new SMWDIProperty('_CONC');
if ($title->getNamespace() != SMW_NS_CONCEPT) {
$result = smwfEncodeMessages(array(wfMsgForContent('smw_no_concept_namespace')));
SMWOutputs::commitToParser($parser);
return $result;
} elseif (count(SMWParseData::getSMWdata($parser)->getPropertyValues($pconc)) > 0) {
$result = smwfEncodeMessages(array(wfMsgForContent('smw_multiple_concepts')));
SMWOutputs::commitToParser($parser);
return $result;
}
// process input:
$params = func_get_args();
array_shift($params);
// We already know the $parser ...
// Use first parameter as concept (query) string.
$concept_input = str_replace(array('>', '<'), array('>', '<'), array_shift($params));
// second parameter, if any, might be a description
$concept_docu = array_shift($params);
// NOTE: the str_replace above is required in MediaWiki 1.11, but not in MediaWiki 1.14
$query = SMWQueryProcessor::createQuery($concept_input, SMWQueryProcessor::getProcessedParams(array('limit' => 20, 'format' => 'list')), SMWQueryProcessor::CONCEPT_DESC);
$concept_text = $query->getDescription()->getQueryString();
if (!is_null(SMWParseData::getSMWData($parser))) {
$diConcept = new SMWDIConcept($concept_text, $concept_docu, $query->getDescription()->getQueryFeatures(), $query->getDescription()->getSize(), $query->getDescription()->getDepth());
SMWParseData::getSMWData($parser)->addPropertyObjectValue($pconc, $diConcept);
}
// display concept box:
$rdflink = SMWInfolink::newInternalLink(wfMsgForContent('smw_viewasrdf'), $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' . $title->getPrefixedText(), 'rdflink');
SMWOutputs::requireResource('ext.smw.style');
// TODO: escape output, preferably via Html or Xml class.
$result = '<div class="smwfact"><span class="smwfactboxhead">' . wfMsgForContent('smw_concept_description', $title->getText()) . (count($query->getErrors()) > 0 ? ' ' . smwfEncodeMessages($query->getErrors()) : '') . '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<br />' . ($concept_docu ? "<p>{$concept_docu}</p>" : '') . '<pre>' . str_replace('[', '[', $concept_text) . "</pre>\n</div>";
if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
global $wgOut;
SMWOutputs::commitToOutputPage($wgOut);
} else {
SMWOutputs::commitToParser($parser);
}
return $result;
}