本文整理汇总了PHP中SMWOutputs::requireHeadItem方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWOutputs::requireHeadItem方法的具体用法?PHP SMWOutputs::requireHeadItem怎么用?PHP SMWOutputs::requireHeadItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWOutputs
的用法示例。
在下文中一共展示了SMWOutputs::requireHeadItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: getFormatOutput
/**
* Prepare data output
*
* @since 1.8
*
* @param array $data label => value
*/
protected function getFormatOutput(array $data)
{
static $statNr = 0;
$chartID = 'jqplot-' . $this->params['charttype'] . '-' . ++$statNr;
$this->isHTML = true;
// Prepare data objects
if (in_array($this->params['charttype'], array('bar', 'line'))) {
// Parse bar relevant data
$dataObject = $this->prepareBarData($data);
} elseif (in_array($this->params['charttype'], array('pie', 'donut'))) {
//Parse pie/donut relevant data
$dataObject = $this->preparePieData($data);
} else {
// Return with an error
return Html::rawElement('span', array('class' => "error"), wfMessage('srf-error-missing-layout')->inContentLanguage()->text());
}
// Encode data objects
$requireHeadItem = array($chartID => FormatJson::encode($dataObject));
SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
// Processing placeholder
$processing = SRFUtils::htmlProcessingElement($this->isHTML);
// Ensure right conversion
$width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none; width: {$width}; height: {$this->params['height']}px;"), null);
// Beautify class selector
$class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
$class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' jqplot-common';
// Chart/graph wrappper
return Html::rawElement('div', array('class' => 'srf-jqplot' . $class), $processing . $chart);
}
示例4: 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!
}
示例5: getResultText
/**
* Builds up and returns the HTML for the map, with the queried coordinate data on it.
*
* @param SMWQueryResult $res
* @param $outputmode
*
* @return array or string
*/
public final function getResultText( SMWQueryResult $res, $outputmode ) {
if ( $this->fatalErrorMsg === false ) {
global $wgParser;
$params = $this->params;
$queryHandler = new SMQueryHandler( $res, $outputmode );
$queryHandler->setShowSubject( $params['showtitle'] );
$queryHandler->setTemplate( $params['template'] );
$this->handleMarkerData( $params, $queryHandler->getLocations() );
$locationAmount = count( $params['locations'] );
if ( $params['forceshow'] || $locationAmount > 0 ) {
// We can only take care of the zoom defaulting here,
// as not all locations are available in whats passed to Validator.
if ( $params['zoom'] === false && $locationAmount <= 1 ) {
$params['zoom'] = $this->service->getDefaultZoom();
}
$mapName = $this->service->getMapId();
// MediaWiki 1.17 does not play nice with addScript, so add the vars via the globals hook.
if ( version_compare( $GLOBALS['wgVersion'], '1.18', '<' ) ) {
$GLOBALS['egMapsGlobalJSVars'] += $this->service->getConfigVariables();
}
SMWOutputs::requireHeadItem(
$mapName,
$this->service->getDependencyHtml() .
$configVars = Skin::makeVariablesScript( $this->service->getConfigVariables() )
);
foreach ( $this->service->getResourceModules() as $resourceModule ) {
SMWOutputs::requireResource( $resourceModule );
}
$result = $this->getMapHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName );
return array(
$result,
'noparse' => true,
'isHTML' => true
);
}
else {
return '';
}
}
else {
return $this->fatalErrorMsg;
}
}
示例6: getFormatOutput
/**
* Prepare data for the output
*
* @since 1.8
*
* @param array $data
*
* @return string
*/
protected function getFormatOutput(array $data)
{
$this->isHTML = true;
static $statNr = 0;
$chartID = 'jqplot-series-' . ++$statNr;
// Encoding
$requireHeadItem = array($chartID => FormatJson::encode($data));
SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
// Add RL resources
$this->addResources();
// Processing placeholder
$processing = SRFUtils::htmlProcessingElement($this->isHTML);
// Conversion due to a string as value that can contain %
$width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none; width: {$width}; height: {$this->params['height']}px;"), null);
// Beautify class selector
$class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
$class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' jqplot-common';
// Chart/graph wrappper
return Html::rawElement('div', array('class' => 'srf-jqplot' . $class), $processing . $chart);
}
示例7: includeJS
/**
* Includes the JavaScript required for the timeline and eventline formats.
*
* @since 1.5.3
*/
protected function includeJS() {
SMWOutputs::requireHeadItem( SMW_HEADER_STYLE );
// MediaWiki 1.17 introduces the Resource Loader.
$realFunction = array( 'SMWOutputs', 'requireResource' );
if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) && is_callable( $realFunction ) ) {
SMWOutputs::requireResource( 'ext.srf.timeline' );
}
else {
global $srfgScriptPath;
SMWOutputs::requireHeadItem(
'smw_tlhelper',
'<script type="text/javascript" src="' . $srfgScriptPath .
'/Timeline/SRF_timeline.js"></script>'
);
SMWOutputs::requireHeadItem(
'smw_tl',
'<script type="text/javascript" src="' . $srfgScriptPath .
'/Timeline/SimileTimeline/timeline-api.js"></script>'
);
}
}
示例8: includeJS
protected function includeJS()
{
SMWOutputs::requireHeadItem(SMW_HEADER_STYLE);
//$wgOut->addModules( 'ext.srf.jitgraph' );
global $srfgScriptPath;
SMWOutputs::requireHeadItem('smw_jgcss', '<link rel="stylesheet" type="text/css" href="' . $srfgScriptPath . '/JitGraph/base.css"></link>');
SMWOutputs::requireHeadItem('smw_jgloader', '<script type="text/javascript" src="' . $srfgScriptPath . '/JitGraph/jquery.progressbar.js"></script>');
SMWOutputs::requireHeadItem('smw_jg', '<script type="text/javascript" src="' . $srfgScriptPath . '/JitGraph/Jit/jit.js"></script>');
SMWOutputs::requireHeadItem('smw_jghelper', '<script type="text/javascript" src="' . $srfgScriptPath . '/JitGraph/SRF_JitGraph.js"></script>');
}
示例9: smwfAddDerivedFacts
/**
* Callback function for the hook 'smwShowFactbox'. It is called when SMW creates
* the factbox for an article.
* This method replaces the whole factbox with a tabbed version that contains
* the original factbox in one tab and the derived facts in another.
*
* @param string $text
* The HTML for the tabbed factbox is returned in this parameter
* @param SMWSemanticData $semdata
* All static facts for the article
* @return bool
* <false> : This means that SMW's factbox is completely replaced.
*/
function smwfAddDerivedFacts(&$text, $semdata)
{
global $smwgHaloScriptPath, $wgContLang;
wfLoadExtensionMessages('SemanticMediaWiki');
SMWOutputs::requireHeadItem(SMW_HEADER_STYLE);
$rdflink = SMWInfolink::newInternalLink(wfMsgForContent('smw_viewasrdf'), $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' . $semdata->getSubject()->getWikiValue(), 'rdflink');
$browselink = SMWInfolink::newBrowsingLink($semdata->getSubject()->getText(), $semdata->getSubject()->getWikiValue(), 'swmfactboxheadbrowse');
$fbText = '<div class="smwfact">' . '<span class="smwfactboxhead">' . wfMsgForContent('smw_factbox_head', $browselink->getWikiText()) . '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<table class="smwfacttable">' . "\n";
foreach ($semdata->getProperties() as $property) {
if (!$property->isShown()) {
// showing this is not desired, hide
continue;
} elseif ($property->isUserDefined()) {
// user defined property
$property->setCaption(preg_replace('/[ ]/u', ' ', $property->getWikiValue(), 2));
/// NOTE: the preg_replace is a slight hack to ensure that the left column does not get too narrow
$fbText .= '<tr><td class="smwpropname">' . $property->getLongWikiText(true) . '</td><td class="smwprops">';
} elseif ($property->isVisible()) {
// predefined property
$fbText .= '<tr><td class="smwspecname">' . $property->getLongWikiText(true) . '</td><td class="smwspecs">';
} else {
// predefined, internal property
continue;
}
$propvalues = $semdata->getPropertyValues($property);
$l = count($propvalues);
$i = 0;
foreach ($propvalues as $propvalue) {
if ($i != 0) {
if ($i > $l - 2) {
$fbText .= wfMsgForContent('smw_finallistconjunct') . ' ';
} else {
$fbText .= ', ';
}
}
$i += 1;
$fbText .= $propvalue->getLongWikiText(true) . $propvalue->getInfolinkText(SMW_OUTPUT_WIKI);
}
$fbText .= '</td></tr>';
}
$fbText .= '</table></div>';
$text = '<div id="smw_dft_rendered_boxcontent"> <br />' . '<table>' . '<tr>' . '<td id="dftTab1" class="dftTabActive">' . str_replace(' ', ' ', wfMsg('smw_df_static_tab')) . '</td>' . '<td class="dftTabSpacer"> </td>' . '<td id="dftTab2" class="dftTabInactive">' . str_replace(' ', ' ', wfMsg('smw_df_derived_tab')) . '</td>' . '<td class="dftTabSpacer" width="100%"></td>' . '</tr>' . '<tr>' . '<td colspan="4" class="dftTabCont">' . '<div id="dftTab1Content" >' . $fbText . '</div>' . '<div id="dftTab2Content" style="display:none">' . '<div id="dftTab2ContentInnerDiv">' . wfMsg('smw_df_loading_df') . '</div>' . '</div>' . '</td>' . '</tr>' . '</table>' . '</div>';
return false;
}
示例10: getFormatOutput
/**
* Prepare data for the output
*
* @since 1.8
*
* @param array $data
* @param array $options
*
* @return string
*/
protected function getFormatOutput($data, $options)
{
// The generated ID is to distinguish similar instances of the same
// printer that can appear within the same page
static $statNr = 0;
$ID = 'srf-boilerplate-' . ++$statNr;
// or use the PHP uniqid() to generate an unambiguous ID
// $ID = uniqid();
// Used to set that the output and being treated as HTML (opposed to plain wiki text)
$this->isHTML = true;
// Correct escaping is vital to minimize possibilites of malicious code snippets
// and also a coherent string evalution therefore it is recommended
// that data transferred to the JS plugin is JSON encoded
// Assign the ID to make a data instance readly available and distinguishable
// from other content within the same page
$requireHeadItem = array($ID => FormatJson::encode($data));
SMWOutputs::requireHeadItem($ID, Skin::makeVariablesScript($requireHeadItem));
// Add resource definitions that has been registered with SRF_Resource.php
// Resource definitions contain scripts, styles, messages etc.
// SMWOutputs::requireResource( 'ext.srf.boilerplate.namespace' );
SMWOutputs::requireResource('ext.srf.boilerplate.simple');
// Prepares an HTML element showing a rotating spinner indicating that something
// will appear at this placeholder. The element will be visible as for as
// long as jquery is not loaded and the JS plugin did not hide/removed the element.
$processing = SRFUtils::htmlProcessingElement();
// Add two elements a outer wrapper that is assigned a class which the JS plugin
// can select and will fetch all instances of the same result printer and an innner
// container which is set invisible (display=none) for as long as the JS plugin
// holds the content hidden. It is normally the place where the "hard work"
// is done hidden from the user until it is ready.
// The JS plugin can prepare the output within this container without presenting
// unfinished visual content, to avoid screen clutter and improve user experience.
return Html::rawElement('div', array('class' => 'srf-boilerplate'), $processing . Html::element('div', array('id' => $ID, 'class' => 'container', 'style' => 'display:none;'), null));
}
示例11: getResultText
protected function getResultText($res, $outputmode)
{
global $smwgIQRunningNumber;
SMWOutputs::requireHeadItem(SMW_HEADER_SORTTABLE);
// print header
if ('broadtable' == $this->mFormat) {
$widthpara = ' width="100%"';
} else {
$widthpara = '';
}
$result = "";
if (defined('SMW_UP_RATING_VERSION')) {
$result .= "UpRatingTable___" . $smwgIQRunningNumber . "___elbaTgnitaRpU";
}
$result .= "<table class=\"smwtable\"{$widthpara} id=\"querytable" . $smwgIQRunningNumber . "\">\n";
if ($this->mShowHeaders != SMW_HEADERS_HIDE) {
// building headers
$result .= "\t<tr>\n";
foreach ($res->getPrintRequests() as $pr) {
$result .= "\t\t<th>" . $pr->getText($outputmode, $this->mShowHeaders == SMW_HEADERS_PLAIN ? NULL : $this->mLinker) . "</th>\n";
}
$result .= "\t</tr>\n";
}
// print all result rows
while ($row = $res->getNext()) {
$result .= "\t<tr>\n";
$firstcol = true;
foreach ($row as $field) {
$result .= "\t\t<td>";
$first = true;
while (($object = $field->getNextObject()) !== false) {
if ($object->getTypeID() == '_wpg') {
// use shorter "LongText" for wikipage
$provURL = $object->getProvenance();
if ($firstcol && !is_null($provURL)) {
//$text = $this->createArticleLinkFromProvenance($provURL, $this->getLinker($firstcol));
$text = $object->getLongText($outputmode, $this->getLinker($firstcol));
} else {
$text = $object->getLongText($outputmode, $this->getLinker($firstcol));
if (strlen($text) > 0 && !is_null($provURL)) {
$text .= $this->createProvenanceLink($provURL);
}
}
} else {
$text = $object->getShortText($outputmode, $this->getLinker($firstcol));
if (strlen($text) > 0) {
$provURL = $object->getProvenance();
if (!is_null($provURL)) {
$text .= $this->createProvenanceLink($provURL);
}
}
}
if ($first) {
if ($object->isNumeric()) {
// use numeric sortkey
$result .= '<span class="smwsortkey">' . $object->getNumericValue() . '</span>';
}
$first = false;
} else {
$result .= '<br />';
}
$result .= $text;
}
$result .= "</td>\n";
$firstcol = false;
}
$result .= "\t</tr>\n";
}
// print further results footer
if ($this->linkFurtherResults($res)) {
$link = $res->getQueryLink();
if ($this->getSearchLabel($outputmode)) {
$link->setCaption($this->getSearchLabel($outputmode));
}
$result .= "\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . $res->getColumnCount() . '"> ' . $link->getText($outputmode, $this->mLinker) . "</td></tr>\n";
}
$result .= "</table>\n";
// print footer
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
// yes, our code can be viewed as HTML if requested, no more parsing needed
return $result;
}
示例12: getFormatOutput
/**
* Prepare data for the output
*
* @since 1.8
*
* @param array $data
*
* @return string
*/
protected function getFormatOutput(array $data, $options)
{
// Object count
static $statNr = 0;
$chartID = 'timeseries-' . ++$statNr;
$this->isHTML = true;
// Reorganize the raw data
foreach ($data as $key => $values) {
$dataObject[] = array('label' => $key, 'data' => $values);
}
// Series colour
$seriescolors = $this->params['chartcolor'] !== '' ? array_filter(explode(",", $this->params['chartcolor'])) : array();
// Prepare transfer array
$chartData = array('data' => $dataObject, 'fcolumntypeid' => '_dat', 'sask' => $options['sask'], 'parameters' => array('width' => $this->params['width'], 'height' => $this->params['height'], 'charttitle' => $this->params['charttitle'], 'charttext' => $this->params['charttext'], 'infotext' => $this->params['infotext'], 'charttype' => $this->params['charttype'], 'gridview' => $this->params['gridview'], 'zoom' => $this->params['zoompane'], 'seriescolors' => $seriescolors));
// Array encoding and output
$requireHeadItem = array($chartID => FormatJson::encode($chartData));
SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
// RL module
SMWOutputs::requireResource('ext.srf.timeseries.flot');
if ($this->params['gridview'] === 'tabs') {
SMWOutputs::requireResource('ext.srf.util.grid');
}
// Chart/graph placeholder
$chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none;"), null);
// Processing/loading image
$processing = SRFUtils::htmlProcessingElement($this->isHTML);
// Beautify class selector
$class = $this->params['class'] ? ' ' . $this->params['class'] : ' flot-chart-common';
// General output marker
return Html::rawElement('div', array('class' => 'srf-timeseries' . $class), $processing . $chart);
}
示例13: getResultText
protected function getResultText($res, $outputmode)
{
global $smwgIQRunningNumber;
SMWOutputs::requireHeadItem(SMW_HEADER_SORTTABLE);
$cols = array();
//Names of columns
// print header
if ('broadtable' == $this->mFormat) {
$widthpara = ' width="100%"';
} else {
$widthpara = '';
}
$result = "<table class=\"smwtable\"{$widthpara} id=\"querytable" . $smwgIQRunningNumber . "\">\n";
if ($this->mShowHeaders) {
// building headers
$result .= "\t<tr>\n";
foreach ($res->getPrintRequests() as $pr) {
$title = $pr->getData();
if ($title instanceof Title) {
array_push($cols, $title);
} else {
array_push($cols, "");
}
$result .= "\t\t<th>" . $pr->getText($outputmode, $this->mLinker) . "</th>\n";
}
$result .= "\t</tr>\n";
} else {
foreach ($res->getPrintRequests() as $pr) {
$title = $pr->getTitle();
if ($title instanceof Title) {
array_push($cols, $title);
} else {
array_push($cols, "");
}
}
}
// print all result rows
while ($row = $res->getNext()) {
$result .= "\t<tr>\n";
$firstcol = true;
$gIssues = null;
$act_column = 0;
foreach ($row as $field) {
$result .= "\t\t<td>";
$first = true;
while (($object = $field->getNextObject()) !== false) {
if ($object->getTypeID() == '_wpg') {
// use shorter "LongText" for wikipage
$text = $object->getLongText($outputmode, $this->getLinker($firstcol));
} else {
$text = $object->getShortText($outputmode, $this->getLinker($firstcol));
}
if ($first) {
$first = false;
} else {
$result .= '<br />';
}
$result .= $text;
}
$result .= "</td>\n";
$firstcol = false;
$act_column++;
}
$result .= "\t</tr>\n";
}
// print further results footer
if ($this->linkFurtherResults($res)) {
$link = $res->getQueryLink();
if ($this->getSearchLabel($outputmode)) {
$link->setCaption($this->getSearchLabel($outputmode));
}
$result .= "\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . $res->getColumnCount() . '"> ' . $link->getText($outputmode, $this->mLinker) . "</td></tr>\n";
}
$result .= "</table>\n";
// print footer
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
// yes, our code can be viewed as HTML if requested, no more parsing needed
return $result;
}
示例14: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
global $smwgIQRunningNumber, $wgScriptPath, $wgGoogleMapsKey, $srfgScriptPath;
if (defined('MW_SUPPORTS_RESOURCE_MODULES')) {
SMWOutputs::requireHeadItem('exhibit-compat', Html::linkedScript("{$wgScriptPath}/common/wikibits.js"));
}
// //////////////////////////////
// ///////REMOTE STUFF///////////
// //////////////////////////////
$remote = false;
// in case the remote parameter is set, a link to the JSON export of the remote wiki is included in the header as data source for Exhibit
// this section creates the link
if (array_key_exists('remote', $this->m_params) && srfgExhibitRemote == true) {
$remote = true;
// fetch interwiki link
$dbr =& wfGetDB(DB_SLAVE);
$cl = $dbr->tableName('interwiki');
$dbres = $dbr->select($cl, 'iw_url', "iw_prefix='" . $this->m_params['remote'] . "'", __METHOD__, array());
$row = $dbr->fetchRow($dbres);
$extlinkpattern = $row[iw_url];
$dbr->freeResult($dbres);
$newheader = '<link rel="exhibit/data" type="application/jsonp" href="';
$link = $res->getQueryLink('JSON Link');
$link->setParameter('json', 'format');
if (array_key_exists('callback', $this->m_params)) {
// check if a special name for the callback function is set, if not stick with 'callback'
$callbackfunc = $this->m_params['callback'];
} else {
$callbackfunc = 'callback';
}
if (array_key_exists('limit', $this->m_params)) {
$link->setParameter($this->m_params['limit'], 'limit');
}
$link->setParameter($callbackfunc, 'callback');
$link = $link->getText(2, $this->mLinker);
list($link, $trash) = explode('|', $link);
$link = str_replace('[[:', '', $link);
$newheader .= str_replace('$1', $link, $extlinkpattern);
$newheader .= '" ex:jsonp-callback="' . $callbackfunc . '"';
$newheader .= '/>';
SMWOutputs::requireHeadItem('REMOTE', $newheader);
}
// the following variables indicate the use of special views
// the variable's values define the way Exhibit is called
$timeline = false;
$map = false;
/*The javascript file adopted from Wibbit uses a bunch of javascript variables in the header to store information about the Exhibit markup.
The following code sequence creates these variables*/
// prepare sources (the sources holds information about the table which contains the information)
$colstack = array();
foreach ($res->getPrintRequests() as $pr) {
$colstack[] = $this->encodePropertyName($pr->getLabel()) . ':' . (array_key_exists($pr->getTypeID(), $this->m_types) ? $this->m_types[$pr->getTypeID()] : 'text');
}
array_shift($colstack);
array_unshift($colstack, 'label');
if (SRFExhibit::$exhibitRunningNumber == 0) {
$sourcesrc = "var ex_sources = { source" . ($smwgIQRunningNumber - 1) . ": { id: 'querytable" . $smwgIQRunningNumber . "' , columns: '" . implode(',', $colstack) . "'.split(','), hideTable: '1', type: 'Item', label: 'Item', pluralLabel: 'Items' } };";
} else {
$sourcesrc = "sources.source" . $smwgIQRunningNumber . " = { id: 'querytable" . $smwgIQRunningNumber . "' , columns: '" . implode(',', $colstack) . "'.split(','), hideTable: '1', type: 'Item', label: 'Item', pluralLabel: 'Items' };";
}
$sourcesrc = "<script type=\"text/javascript\">" . $sourcesrc . "</script>";
// prepare facets
$facetcounter = 0;
if (array_key_exists('facets', $this->m_params)) {
$facets = explode(',', $this->m_params['facets']);
$facetstack = array();
$params = array('height');
$facparams = array();
foreach ($params as $param) {
if (array_key_exists($param, $this->m_params)) {
$facparams[] = 'ex:' . $param . '="' . $this->encodePropertyName($this->m_params[$param]) . '" ';
}
}
foreach ($facets as $facet) {
$facet = trim($facet);
$fieldcounter = 0;
if (strtolower($facet) == "search") {
// special facet (text search)
$facetstack[] = ' facet' . $facetcounter++ . ': { position : "right", innerHTML: \'ex:role="facet" ex:showMissing="false" ex:facetClass="TextSearch" ex:facetLabel="' . $facet . '"\'}';
} else {
// usual facet
foreach ($res->getPrintRequests() as $pr) {
if ($this->encodePropertyName($pr->getLabel()) == $this->encodePropertyName($facet)) {
switch ($pr->getTypeID()) {
case '_num':
$facetstack[] = ' facet' . $facetcounter++ . ': { position : "right", innerHTML: \'ex:role="facet" ex:showMissing="false" ex:expression=".' . $this->encodePropertyName($facet) . '" ex:facetLabel="' . $facet . '" ex:facetClass="Slider"\'}';
break;
default:
$facetstack[] = ' facet' . $facetcounter++ . ': { position : "right", innerHTML: \'ex:role="facet" ex:showMissing="false" ' . implode(" ", $facparams) . ' ex:expression=".' . $this->encodePropertyName($facet) . '" ex:facetLabel="' . $facet . '"\'}';
}
}
}
}
$fieldcounter++;
}
$facetstring = implode(',', $facetstack);
} else {
$facetstring = '';
}
$facetsrc = "var ex_facets = {" . $facetstring . " };";
//.........这里部分代码省略.........
示例15: getResultText
//.........这里部分代码省略.........
// make RSS feed
if (!$smwgRSSEnabled) {
return '';
}
if ($this->m_title === '') {
$this->m_title = $wgSitename;
}
if ($this->m_description === '') {
$this->m_description = wfMsg('smw_rss_description', $wgSitename);
}
// cast printouts into "items"
$items = array();
$row = $res->getNext();
while ($row !== false) {
$creators = array();
$dates = array();
$wikipage = $row[0]->getNextDataValue();
// get the object
foreach ($row as $field) {
// for now we ignore everything but creator and date, later we may
// add more things like geolocs, categories, and even a generic
// mechanism to add whatever you want :)
$req = $field->getPrintRequest();
if (strtolower($req->getLabel()) == 'creator') {
while ($entry = $field->getNextDataValue()) {
$creators[] = $entry->getShortWikiText();
}
} elseif (strtolower($req->getLabel()) == 'date' && $req->getTypeID() == '_dat') {
while ($entry = $field->getNextDataValue()) {
$dates[] = $entry->getXMLSchemaDate();
}
}
}
if ($wikipage instanceof SMWWikiPageValue) {
// this should rarely fail, but better be carful
///TODO: It would be more elegant to have type chekcs initially
$items[] = new SMWRSSItem($wikipage->getTitle(), $creators, $dates);
}
$row = $res->getNext();
}
$result .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$result .= "<rdf:RDF\n";
$result .= "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
$result .= "\txmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n";
$result .= "\txmlns:admin=\"http://webns.net/mvcb/\"\n";
$result .= "\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
$result .= "\txmlns=\"http://purl.org/rss/1.0/\">\n";
$result .= "\t<channel rdf:about=\"" . str_replace('&', '&', $wgRequest->getFullRequestURL()) . "\">\n";
$result .= "\t\t<admin:generatorAgent rdf:resource=\"http://semantic-mediawiki.org/wiki/Special:URIResolver/Semantic_MediaWiki\"/>\n";
$result .= "\t\t<title>" . smwfXMLContentEncode($this->m_title) . "</title>\n";
$result .= "\t\t<link>{$wgServer}</link>\n";
$result .= "\t\t<description>" . smwfXMLContentEncode($this->m_description) . "</description>\n";
if (count($items) > 0) {
$result .= "\t\t<items>\n";
$result .= "\t\t\t<rdf:Seq>\n";
foreach ($items as $item) {
$result .= "\t\t\t\t<rdf:li rdf:resource=\"" . $item->uri() . "\"/>\n";
}
$result .= "\t\t\t</rdf:Seq>\n";
$result .= "\t\t</items>\n";
}
$result .= "\t</channel>\n";
foreach ($items as $item) {
$result .= $item->text();
}
$result .= '</rdf:RDF>';
} else {
// just make link to feed
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('smw_rss_link');
}
$link = $res->getQueryLink($label);
$link->setParameter('rss', 'format');
if ($this->m_title !== '') {
$link->setParameter($this->m_title, 'title');
}
if ($this->m_description !== '') {
$link->setParameter($this->m_description, 'description');
}
if (array_key_exists('limit', $this->m_params)) {
$link->setParameter($this->m_params['limit'], 'limit');
} else {
// use a reasonable deafult limit (10 is suggested by RSS)
$link->setParameter(10, 'limit');
}
foreach ($res->getPrintRequests() as $printout) {
// overwrite given "sort" parameter with printout of label "date"
if ($printout->getMode() == SMWPrintRequest::PRINT_PROP && strtolower($printout->getLabel()) == "date" && $printout->getTypeID() == "_dat") {
$link->setParameter($printout->getData()->getWikiValue(), 'sort');
}
}
$result .= $link->getText($outputmode, $this->mLinker);
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
// yes, our code can be viewed as HTML if requested, no more parsing needed
SMWOutputs::requireHeadItem('rss' . $smwgIQRunningNumber, '<link rel="alternate" type="application/rss+xml" title="' . $this->m_title . '" href="' . $link->getURL() . '" />');
}
return $result;
}