本文整理汇总了PHP中SMWQueryProcessor::getProcessedParams方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryProcessor::getProcessedParams方法的具体用法?PHP SMWQueryProcessor::getProcessedParams怎么用?PHP SMWQueryProcessor::getProcessedParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWQueryProcessor
的用法示例。
在下文中一共展示了SMWQueryProcessor::getProcessedParams方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuery
/**
*
* @return SMWQuery
*/
protected function getQuery( $queryString, array $printouts ) {
SMWQueryProcessor::addThisPrintout( $printouts, $this->parameters );
return SMWQueryProcessor::createQuery(
$queryString,
SMWQueryProcessor::getProcessedParams( $this->parameters, $printouts ),
SMWQueryProcessor::SPECIAL_PAGE,
'',
$printouts
);
}
示例2: doCompoundQuery
/**
* Handler for the #compound_query parser function.
*
* @param Parser $parser
*
* @return string
*/
public static function doCompoundQuery(Parser &$parser)
{
global $smwgQEnabled, $smwgIQRunningNumber;
if (!$smwgQEnabled) {
return smwfEncodeMessages(array(wfMsgForContent('smw_iq_disabled')));
}
$smwgIQRunningNumber++;
$params = func_get_args();
array_shift($params);
// We already know the $parser.
$other_params = array();
$results = array();
$printRequests = array();
$queryParams = array();
foreach ($params as $param) {
// Very primitive heuristic - if the parameter
// includes a square bracket, then it's a
// sub-query; otherwise it's a regular parameter.
if (strpos($param, '[') !== false) {
$queryParams[] = $param;
} else {
$parts = explode('=', $param, 2);
if (count($parts) >= 2) {
$other_params[strtolower(trim($parts[0]))] = $parts[1];
// don't trim here, some params care for " "
}
}
}
foreach ($queryParams as $param) {
$subQueryParams = self::getSubParams($param);
if (array_key_exists('format', $other_params) && !array_key_exists('format', $subQueryParams)) {
$subQueryParams['format'] = $other_params['format'];
}
$next_result = self::getQueryResultFromFunctionParams($subQueryParams, SMW_OUTPUT_WIKI);
$results = self::mergeSMWQueryResults($results, $next_result->getResults());
$printRequests = self::mergeSMWPrintRequests($printRequests, $next_result->getPrintRequests());
}
// Sort results so that they'll show up by page name
uasort($results, array('SCQQueryProcessor', 'compareQueryResults'));
$query_result = new SCQQueryResult($printRequests, new SMWQuery(), $results, smwfGetStore());
if (version_compare(SMW_VERSION, '1.6.1', '>')) {
SMWQueryProcessor::addThisPrintout($printRequests, $other_params);
$other_params = parent::getProcessedParams($other_params, $printRequests);
}
return self::getResultFromQueryResult($query_result, $other_params, SMW_OUTPUT_WIKI);
}
示例3: 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;
}
示例4: execute
/**
* Executes the query.
*
* This method can be called once $queryString, $parameters, $printOuts
* are set either by using the setQueryString(), setParams() and
* setPrintOuts() followed by extractParameters(), or one of the static
* factory methods such as makeForInfoLink() or makeForUI().
*
* Errors, if any can be accessed from hasError() and getErrors().
*/
public function execute()
{
$errors = array();
if ($this->queryString !== '') {
// FIXME: this is a hack
SMWQueryProcessor::addThisPrintout($this->printOuts, $this->parameters);
$params = SMWQueryProcessor::getProcessedParams($this->parameters, $this->printOuts);
$this->parameters['format'] = $params['format'];
$this->params = $params;
$query = SMWQueryProcessor::createQuery($this->queryString, $params, SMWQueryProcessor::SPECIAL_PAGE, $this->parameters['format'], $this->printOuts);
$res = smwfGetStore()->getQueryResult($query);
$this->queryResult = $res;
$errors = array_merge($errors, $res->getErrors());
if (!empty($errors)) {
$this->errorsOccured = true;
$this->errors = array_merge($errors, $this->errors);
}
// BEGIN: Try to be smart for rss/ical if no description/title is given and we have a concept query
if ($this->parameters['format'] == 'rss') {
$descKey = 'rssdescription';
$titleKey = 'rsstitle';
} elseif ($this->parameters['format'] == 'icalendar') {
$descKey = 'icalendardescription';
$titleKey = 'icalendartitle';
} else {
$descKey = false;
}
if ($descKey && $query->getDescription() instanceof SMWConceptDescription && (!isset($this->parameters[$descKey]) || !isset($this->parameters[$titleKey]))) {
$concept = $query->getDescription()->getConcept();
if (!isset($this->parameters[$titleKey])) {
$this->parameters[$titleKey] = $concept->getText();
}
if (!isset($this->parameters[$descKey])) {
// / @bug The current SMWStore will never return SMWConceptValue (an SMWDataValue) here; it might return SMWDIConcept (an SMWDataItem)
$dv = end(smwfGetStore()->getPropertyValues(SMWWikiPageValue::makePageFromTitle($concept), new SMWDIProperty('_CONC')));
if ($dv instanceof SMWConceptValue) {
$this->parameters[$descKey] = $dv->getDocu();
}
}
}
// END: Try to be smart for rss/ical if no description/title is given and we have a concept query
/*
* If parameters have been passed in the infolink-style and the
* mimie-type of format is defined, generate the export, instead of
* showing more html.
*/
$printer = SMWQueryProcessor::getResultPrinter($this->parameters['format'], SMWQueryProcessor::SPECIAL_PAGE);
$resultMime = $printer->getMimeType($res);
if ($this->context == self::WIKI_LINK && $resultMime != false) {
global $wgOut;
$result = $printer->getResult($res, $this->parameters, SMW_OUTPUT_FILE);
$resultName = $printer->getFileName($res);
$wgOut->disable();
header("Content-type: {$resultMime}; charset=UTF-8");
if ($resultName !== false) {
header("content-disposition: attachment; filename={$resultName}");
}
echo $result;
}
}
}
示例5: getSearchQuery
/**
* @param String $term
*
* @return SMWQuery | null
*/
private function getSearchQuery($term)
{
if (!is_string($term) || trim($term) === '') {
return null;
}
if (!array_key_exists($term, $this->queryCache)) {
$params = \SMWQueryProcessor::getProcessedParams(array());
$query = \SMWQueryProcessor::createQuery($term, $params);
$description = $query->getDescription();
if ($description === null || is_a($description, 'SMWThingDescription')) {
$query = null;
}
$this->queryCache[$term] = $query;
}
return $this->queryCache[$term];
}
示例6: makeHTMLResult
/**
* TODO: document
*/
protected function makeHTMLResult()
{
global $wgOut;
// TODO: hold into account $smwgAutocompleteInSpecialAsk
$wgOut->addModules('ext.smw.ask');
$result = '';
$result_mime = false;
// output in MW Special page as usual
// build parameter strings for URLs, based on current settings
$urlArgs['q'] = $this->m_querystring;
$tmp_parray = array();
foreach ($this->m_params as $key => $value) {
if (!in_array($key, array('sort', 'order', 'limit', 'offset', 'title'))) {
$tmp_parray[$key] = $value;
}
}
$urlArgs['p'] = SMWInfolink::encodeParameters($tmp_parray);
$printoutstring = '';
/**
* @var SMWPrintRequest $printout
*/
foreach ($this->m_printouts as $printout) {
$printoutstring .= $printout->getSerialisation() . "\n";
}
if ($printoutstring !== '') {
$urlArgs['po'] = $printoutstring;
}
if (array_key_exists('sort', $this->m_params)) {
$urlArgs['sort'] = $this->m_params['sort'];
}
if (array_key_exists('order', $this->m_params)) {
$urlArgs['order'] = $this->m_params['order'];
}
if ($this->m_querystring !== '') {
// FIXME: this is a hack
SMWQueryProcessor::addThisPrintout($this->m_printouts, $this->m_params);
$params = SMWQueryProcessor::getProcessedParams($this->m_params, $this->m_printouts);
$this->m_params['format'] = $params['format']->getValue();
$this->params = $params;
$queryobj = SMWQueryProcessor::createQuery($this->m_querystring, $params, SMWQueryProcessor::SPECIAL_PAGE, $this->m_params['format'], $this->m_printouts);
/**
* @var SMWQueryResult $res
*/
// Determine query results
$res = $params['source']->getValue()->getQueryResult($queryobj);
// Try to be smart for rss/ical if no description/title is given and we have a concept query:
if ($this->m_params['format'] == 'rss') {
$desckey = 'rssdescription';
$titlekey = 'rsstitle';
} elseif ($this->m_params['format'] == 'icalendar') {
$desckey = 'icalendardescription';
$titlekey = 'icalendartitle';
} else {
$desckey = false;
}
if ($desckey && $queryobj->getDescription() instanceof SMWConceptDescription && (!isset($this->m_params[$desckey]) || !isset($this->m_params[$titlekey]))) {
$concept = $queryobj->getDescription()->getConcept();
if (!isset($this->m_params[$titlekey])) {
$this->m_params[$titlekey] = $concept->getText();
}
if (!isset($this->m_params[$desckey])) {
// / @bug The current SMWStore will never return SMWConceptValue (an SMWDataValue) here; it might return SMWDIConcept (an SMWDataItem)
$dv = end(smwfGetStore()->getPropertyValues(SMWWikiPageValue::makePageFromTitle($concept), new SMWDIProperty('_CONC')));
if ($dv instanceof SMWConceptValue) {
$this->m_params[$desckey] = $dv->getDocu();
}
}
}
$printer = SMWQueryProcessor::getResultPrinter($this->m_params['format'], SMWQueryProcessor::SPECIAL_PAGE);
global $wgRequest;
$hidequery = $wgRequest->getVal('eq') == 'no';
if (!$printer->isExportFormat()) {
if ($res->getCount() > 0) {
if ($this->m_editquery) {
$urlArgs['eq'] = 'yes';
} elseif ($hidequery) {
$urlArgs['eq'] = 'no';
}
$navigation = $this->getNavigationBar($res, $urlArgs);
$result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
$query_result = $printer->getResult($res, $params, SMW_OUTPUT_HTML);
if (is_array($query_result)) {
$result .= $query_result[0];
} else {
$result .= $query_result;
}
$result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
} else {
$result = '<div style="text-align: center;">' . wfMessage('smw_result_noresults')->escaped() . '</div>';
}
}
}
if (isset($printer) && $printer->isExportFormat()) {
$wgOut->disable();
/**
* @var SMWIExportPrinter $printer
*/
//.........这里部分代码省略.........
示例7: getQueryResults
/**
* This function returns to results of a certain query
* This functions is part of the extension Semantic Tasks by Steren Giannini & Ryan Lane
* released under GNU GPLv2 (or later)
* http://www.mediawiki.org/wiki/Extension:Semantic_Tasks
* @param $query_string String : the query
* @param $properties_to_display array(String): array of property names to display
* @param $display_title Boolean : add the page title in the result
* @return TODO
*/
static function getQueryResults($query_string, $properties_to_display, $display_title)
{
// We use the Semantic MediaWiki Processor
// $smwgIP is defined by Semantic MediaWiki, and we don't allow
// this file to be sourced unless Semantic MediaWiki is included.
global $smwgIP;
include_once $smwgIP . "/includes/query/SMW_QueryProcessor.php";
$params = array();
$inline = true;
$printlabel = "";
$printouts = array();
// add the page name to the printouts
if ($display_title) {
if (version_compare(SMW_VERSION, '1.7', '>')) {
SMWQueryProcessor::addThisPrintout($printouts, $params);
} else {
$to_push = new SMWPrintRequest(SMWPrintRequest::PRINT_THIS, $printlabel);
array_push($printouts, $to_push);
}
}
// Push the properties to display in the printout array.
foreach ($properties_to_display as $property) {
if (class_exists('SMWPropertyValue')) {
// SMW 1.4
$to_push = new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, $property, SMWPropertyValue::makeUserProperty($property));
} else {
$to_push = new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, $property, Title::newFromText($property, SMW_NS_PROPERTY));
}
array_push($printouts, $to_push);
}
if (version_compare(SMW_VERSION, '1.6.1', '>')) {
$params = SMWQueryProcessor::getProcessedParams($params, $printouts);
$format = null;
} else {
$format = 'auto';
}
$query = SMWQueryProcessor::createQuery($query_string, $params, $inline, $format, $printouts);
$results = smwfGetStore()->getQueryResult($query);
return $results;
}
示例8: getAllPagesForQuery
/**
* returns an array of pages that are result of the semantic query
* @param $rawQueryString string - the query string like [[Category:Trees]][[age::>1000]]
* @return array of SMWDIWikiPage objects representing the result
*/
public static function getAllPagesForQuery($rawQuery)
{
$rawQueryArray = array($rawQuery);
SMWQueryProcessor::processFunctionParams($rawQueryArray, $queryString, $processedParams, $printouts);
SMWQueryProcessor::addThisPrintout($printouts, $processedParams);
$processedParams = SMWQueryProcessor::getProcessedParams($processedParams, $printouts);
$queryObj = SMWQueryProcessor::createQuery($queryString, $processedParams, SMWQueryProcessor::SPECIAL_PAGE, '', $printouts);
$res = smwfGetStore()->getQueryResult($queryObj);
$pages = $res->getResults();
return $pages;
}
示例9: getNearbyResults
/**
* Returns all results that have a value near to the searched for value
* on the property, ordered, and sorted by ending with the smallest one.
*
* @param[in] $count int How many entities have the exact same value on the property?
* @param[in] $greater bool Should the values be bigger? Set false for smaller values
*
* @return array of array of SMWWikiPageValue, SMWDataValue with the first being the entity, and the second the value
*/
private function getNearbyResults($count, $greater = true)
{
$options = new SMWRequestOptions();
$options->limit = $this->limit + 1;
$options->sort = true;
// Note: printrequests change the caption of properties they get (they expect properties to be given to them)
// Since we want to continue using the property for our purposes, we give a clone to the print request.
$printrequest = new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, '', clone $this->property);
$params = array();
$params['format'] = 'ul';
$params['sort'] = $this->propertystring;
$params['order'] = 'DESC';
if ($greater) {
$params['order'] = 'ASC';
}
$cmp = '<';
if ($greater) {
$cmp = '>';
}
$querystring = '[[' . $this->propertystring . '::' . $cmp . $this->valuestring . ']]';
$printouts = array($printrequest);
SMWQueryProcessor::addThisPrintout($printouts, $params);
$params = SMWQueryProcessor::getProcessedParams($params, $printouts);
$queryobj = SMWQueryProcessor::createQuery($querystring, $params, SMWQueryProcessor::SPECIAL_PAGE, 'ul', $printouts);
$queryobj->querymode = SMWQuery::MODE_INSTANCES;
$queryobj->setLimit($this->limit);
$queryobj->setOffset($count);
$results = smwfGetStore()->getQueryResult($queryobj);
/* array of SMWResultArray */
$result = $results->getNext();
$ret = array();
while ($result) {
$r = array($result[0]->getNextDataValue());
if (array_key_exists(1, $result)) {
$r[] = $result[1]->getNextDataValue();
}
$ret[] = $r;
$result = $results->getNext();
}
if (!$greater) {
$ret = array_reverse($ret);
}
return $ret;
}
示例10: handleGetResult
/**
* Handles Ajax call
* @param integer $pageId
* @param type $template
* @param type $printrequests
* @return type
*/
public static function handleGetResult($pageId, $template, $printrequests)
{
$title = Title::newFromID($pageId)->getPrefixedText();
$rp = new SMWListResultPrinter('template', true);
$paramDefinitions = ParamDefinition::getCleanDefinitions($rp->getParamDefinitions(array()));
$params = array();
/**
* @param IParamDefinition $def
*/
foreach ($paramDefinitions as $def) {
$params[$def->getName()] = $def->getDefault();
}
$params = array_merge($params, array('format' => 'template', 'template' => $template, 'mainlabel' => '', 'sort' => '', 'order' => '', 'intro' => null, 'outro' => null, 'searchlabel' => null, 'link' => null, 'default' => null, 'headers' => null, 'introtemplate' => '', 'outrotemplate' => ''));
$params = SMWQueryProcessor::getProcessedParams($params, array());
$p = json_decode($printrequests, true);
$extraprintouts = array();
foreach ($p as $key => $prData) {
// if printout mode is PRINT_PROP
if ($prData[0] == SMWPrintRequest::PRINT_PROP) {
// create property from property key
$data = SMWPropertyValue::makeUserProperty($prData[2]);
} else {
$data = null;
}
// create printrequest from request mode, label, property name, output format, parameters
$extraprintouts[] = new SMWPrintRequest($prData[0], $prData[1], $data, $prData[3], $prData[4]);
}
return SMWQueryProcessor::getResultFromQueryString('[[' . $title . ']]', $params, $extraprintouts, SMW_OUTPUT_HTML, SMWQueryProcessor::INLINE_QUERY);
}
示例11: outputResults
/**
* Format and output report results using the given information plus
* OutputPage
*
* @param OutputPage $out OutputPage to print to
* @param Skin $skin User skin to use
* @param Database $dbr Database (read) connection to use
* @param int $res Result pointer
* @param int $num Number of available result rows
* @param int $offset Paging offset
*/
protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
{
global $wgContLang;
$all_display_params = SDUtils::getDisplayParamsForCategory($this->category);
$querystring = null;
$printouts = $params = array();
// only one set of params is handled for now
if (count($all_display_params) > 0) {
$display_params = array_map('trim', $all_display_params[0]);
SMWQueryProcessor::processFunctionParams($display_params, $querystring, $params, $printouts);
}
if (!empty($querystring)) {
$query = SMWQueryProcessor::createQuery($querystring, $params);
} else {
$query = new SMWQuery();
}
if (!array_key_exists('format', $params)) {
$params['format'] = 'category';
}
if (array_key_exists('mainlabel', $params)) {
$mainlabel = $params['mainlabel'];
} else {
$mainlabel = '';
}
$r = $this->addSemanticResultWrapper($dbr, $res, $num, $query, $mainlabel, $printouts);
$printer = SMWQueryProcessor::getResultPrinter($params['format'], SMWQueryProcessor::SPECIAL_PAGE, $r);
if (version_compare(SMW_VERSION, '1.6.1', '>')) {
SMWQueryProcessor::addThisPrintout($printouts, $params);
$params = SMWQueryProcessor::getProcessedParams($params, $printouts);
}
$prresult = $printer->getResult($r, $params, SMW_OUTPUT_HTML);
$prtext = is_array($prresult) ? $prresult[0] : $prresult;
SMWOutputs::commitToOutputPage($out);
// Crappy hack to get the contents of SMWOutputs::$mHeadItems,
// which may have been set in the result printer, and dump into
// headItems of $out.
// How else can we do this?
global $wgParser;
SMWOutputs::commitToParser($wgParser);
if (!is_null($wgParser->mOutput)) {
// getHeadItems() was added in MW 1.16
if (method_exists($wgParser->getOutput(), 'getHeadItems')) {
$headItems = $wgParser->getOutput()->getHeadItems();
} else {
$headItems = $wgParser->getOutput()->mHeadItems;
}
foreach ($headItems as $key => $item) {
$out->addHeadItem($key, $item);
}
// Force one more parser function, so links appear.
$wgParser->replaceLinkHolders($prtext);
}
$html = array();
$html[] = $prtext;
if (!$this->listoutput) {
$html[] = $this->closeList();
}
$html = $this->listoutput ? $wgContLang->listToText($html) : implode('', $html);
$out->addHTML($html);
}
示例12: getResults
protected function getResults($input)
{
$query = "[[Collection::" . $input . "]]|?Expression|?Language";
$rawParams = explode('|', $query);
list($queryString, $parameters, $printouts) = SMWQueryProcessor::getComponentsFromFunctionParams($rawParams, false);
SMWQueryProcessor::addThisPrintout($printouts, $parameters);
$smwQuery = SMWQueryProcessor::createQuery($queryString, SMWQueryProcessor::getProcessedParams($parameters, $printouts), SMWQueryProcessor::SPECIAL_PAGE, '', $printouts);
$smwQuery->setUnboundLimit(50000);
$smwQueryResult = smwfGetStore()->getQueryResult($smwQuery);
$results = $smwQueryResult->toArray()['results'];
$modified_results = array();
foreach (array_keys($results) as $key) {
$short_key = explode("#", $key)[0];
$lang = $results[$key]['printouts']['Language'][0];
$langs[$lang] = null;
$expression = explode(":", $results[$key]['printouts']['Expression'][0]['fulltext'])[1];
$modified_results[$short_key][$lang][] = $expression;
}
return array('data' => $modified_results, 'langs' => array_keys($langs));
}
示例13: getExtraDownloadLinks
private function getExtraDownloadLinks()
{
$downloadLinks = '';
if ($this->m_querystring === '') {
return $downloadLinks;
}
$params = $this->m_params;
$params = SMWQueryProcessor::getProcessedParams($params, $this->m_printouts);
$query = SMWQueryProcessor::createQuery($this->m_querystring, $params, SMWQueryProcessor::SPECIAL_PAGE, '', $this->m_printouts);
$link = QueryLinker::get($query);
$link->setParameter('true', 'prettyprint');
$link->setParameter('true', 'unescape');
$link->setParameter('json', 'format');
$link->setCaption('JSON');
$downloadLinks .= $link->getHtml();
$link = QueryLinker::get($query);
$link->setCaption('CSV');
$link->setParameter('csv', 'format');
$downloadLinks .= ' | ' . $link->getHtml();
$link = QueryLinker::get($query);
$link->setCaption('RSS');
$link->setParameter('rss', 'format');
$downloadLinks .= ' | ' . $link->getHtml();
$link = QueryLinker::get($query);
$link->setCaption('RDF');
$link->setParameter('rdf', 'format');
$downloadLinks .= ' | ' . $link->getHtml();
return '(' . $downloadLinks . ')';
}
示例14: makeHTMLResult
/**
* TODO: document
*/
protected function makeHTMLResult() {
global $wgOut, $smwgAutocompleteInSpecialAsk;
$delete_msg = wfMsg( 'delete' );
// Javascript code for the dynamic parts of the page
$javascript_text = <<<END
<script type="text/javascript">
function updateOtherOptions(strURL) {
jQuery.ajax({ url: strURL, context: document.body, success: function(data){
jQuery("#other_options").html(data);
}});
}
// code for handling adding and removing the "sort" inputs
var num_elements = {$this->m_num_sort_values};
function addInstance(starter_div_id, main_div_id) {
var starter_div = document.getElementById(starter_div_id);
var main_div = document.getElementById(main_div_id);
//Create the new instance
var new_div = starter_div.cloneNode(true);
var div_id = 'sort_div_' + num_elements;
new_div.className = 'multipleTemplate';
new_div.id = div_id;
new_div.style.display = 'block';
var children = new_div.getElementsByTagName('*');
var x;
for (x = 0; x < children.length; x++) {
if (children[x].name)
children[x].name = children[x].name.replace(/_num/, '[' + num_elements + ']');
}
//Create 'delete' link
var remove_button = document.createElement('span');
remove_button.innerHTML = '[<a href="javascript:removeInstance(\'sort_div_' + num_elements + '\')">{$delete_msg}</a>]';
new_div.appendChild(remove_button);
//Add the new instance
main_div.appendChild(new_div);
num_elements++;
}
function removeInstance(div_id) {
var olddiv = document.getElementById(div_id);
var parent = olddiv.parentNode;
parent.removeChild(olddiv);
}
</script>
END;
$wgOut->addScript( $javascript_text );
if ( $smwgAutocompleteInSpecialAsk ) {
self::addAutocompletionJavascriptAndCSS();
}
$result = '';
$result_mime = false; // output in MW Special page as usual
// build parameter strings for URLs, based on current settings
$urlArgs['q'] = $this->m_querystring;
$tmp_parray = array();
foreach ( $this->m_params as $key => $value ) {
if ( !in_array( $key, array( 'sort', 'order', 'limit', 'offset', 'title' ) ) ) {
$tmp_parray[$key] = $value;
}
}
$urlArgs['p'] = SMWInfolink::encodeParameters( $tmp_parray );
$printoutstring = '';
foreach ( $this->m_printouts as /* SMWPrintRequest */ $printout ) {
$printoutstring .= $printout->getSerialisation() . "\n";
}
if ( $printoutstring !== '' ) $urlArgs['po'] = $printoutstring;
if ( array_key_exists( 'sort', $this->m_params ) ) $urlArgs['sort'] = $this->m_params['sort'];
if ( array_key_exists( 'order', $this->m_params ) ) $urlArgs['order'] = $this->m_params['order'];
if ( $this->m_querystring !== '' ) {
// FIXME: this is a hack
SMWQueryProcessor::addThisPrintout( $this->m_printouts, $this->m_params );
$params = SMWQueryProcessor::getProcessedParams( $this->m_params, $this->m_printouts );
$this->m_params['format'] = $params['format'];
$queryobj = SMWQueryProcessor::createQuery(
$this->m_querystring,
$params,
SMWQueryProcessor::SPECIAL_PAGE ,
$this->m_params['format'],
$this->m_printouts
);
//.........这里部分代码省略.........