本文整理汇总了PHP中SMWQueryProcessor类的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryProcessor类的具体用法?PHP SMWQueryProcessor怎么用?PHP SMWQueryProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMWQueryProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$params = $this->extractRequestParams();
$rawParams = preg_split("/(?<=[^\\|])\\|(?=[^\\|])/", $params['query']);
list($queryString, $this->parameters, $printouts) = SMWQueryProcessor::getComponentsFromFunctionParams($rawParams, false);
$queryResult = $this->getQueryResult($this->getQuery($queryString, $printouts));
$this->addQueryResult($queryResult);
}
开发者ID:yusufchang,项目名称:app,代码行数:8,代码来源:ApiAsk.php
示例2: doManipulation
/**
* @see ItemParameterManipulation::doManipulation
*
* @since 1.6.2
*/
public function doManipulation(&$value, Parameter $parameter, array &$parameters)
{
// Make sure the format value is valid.
$value = self::getValidFormatName($value);
// Add the formats parameters to the parameter list.
$queryPrinter = SMWQueryProcessor::getResultPrinter($value);
$parameters = array_merge($parameters, $queryPrinter->getValidatorParameters());
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:SMW_ParamFormat.php
示例3: execute
public function execute()
{
$params = $this->extractRequestParams();
// TODO: this prevents doing [[Category:Foo||bar||baz]], must document.
$rawParams = explode('|', $params['query']);
$queryString = '';
$printouts = array();
SMWQueryProcessor::processFunctionParams($rawParams, $queryString, $this->parameters, $printouts);
$queryResult = $this->getQueryResult($this->getQuery($queryString, $printouts));
$this->addQueryResult($queryResult);
}
开发者ID:nischayn22,项目名称:SemanticMediawiki,代码行数:11,代码来源:ApiAsk.php
示例4: execute
public function execute()
{
$params = $this->extractRequestParams();
$this->requireParameters($params, array('query'));
$rawParams = explode('|', $params['query']);
$queryString = '';
$printouts = array();
SMWQueryProcessor::processFunctionParams($rawParams, $queryString, $this->parameters, $printouts);
$queryResult = $this->getQueryResult($this->getQuery($queryString, $printouts));
$this->addQueryResult($queryResult);
}
开发者ID:rduecyg,项目名称:OU,代码行数:11,代码来源:ApiAsk.php
示例5: 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
);
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:ApiSMWQuery.php
示例6: testExcelQueryPrinter
function testExcelQueryPrinter()
{
$params = array();
$context = SMWQueryProcessor::INLINE_QUERY;
$format = "exceltable";
$extraprintouts = array();
$querystring = "[[Category:Car]]";
$query = SMWQueryProcessor::createQuery($querystring, $params, $context, $format, $extraprintouts);
$res = smwfGetStore()->getQueryResult($query);
$result = SMWQueryProcessor::getResultFromQuery($query, $params, $extraprintouts, SMW_OUTPUT_FILE, $context, $format);
$this->assertFileContentsIgnoringWhitespaces("testcases/resources/excel_qp_result.dat", $result);
}
开发者ID:seedbank,项目名称:old-repo,代码行数:12,代码来源:TestQueryPrinters.php
示例7: showFormatOptions
/**
* Display a form section showing the options for a given format,
* based on the getParameters() value for that format's query printer.
*
* @since 1.8
*
* @param string $format
* @param array $paramValues The current values for the parameters (name => value)
*
* @return string
*/
protected function showFormatOptions($format, array $paramValues)
{
$definitions = SMWQueryProcessor::getFormatParameters($format);
$optionsHtml = array();
/**
* @var ParamProcessor\ParamDefinition $definition
*/
foreach ($definitions as $name => $definition) {
// Ignore the format parameter, as we got a special control in the GUI for it already.
if ($name == 'format') {
continue;
}
// Maybe there is a better way but somehow I couldn't find one therefore
// 'source' display will be omitted where no alternative source was found or
// a source that was marked as default but had no other available options
$allowedValues = $definition->getAllowedValues();
if ($name == 'source' && (count($allowedValues) == 0 || in_array('default', $allowedValues) && count($allowedValues) < 2)) {
continue;
}
$currentValue = array_key_exists($name, $paramValues) ? $paramValues[$name] : false;
$dataInfo = $definition->getMessage() !== null ? $this->msg($definition->getMessage())->text() : '';
$optionsHtml[] = '<td>' . Html::rawElement('span', array('class' => $this->isTooltipDisplay() == true ? 'smw-ask-info' : '', 'word-wrap' => 'break-word', 'data-info' => $dataInfo), htmlspecialchars($name) . ': ') . '</td>' . $this->showFormatOption($definition, $currentValue);
}
$i = 0;
$n = 0;
$rowHtml = '';
$resultHtml = '';
// Top info text for a collapsed option box
if ($this->isTooltipDisplay() == true) {
$resultHtml .= Html::element('div', array('style' => 'margin-bottom:10px;'), wfMessage('smw-ask-otheroptions-info')->text());
}
// Table
$resultHtml .= Html::openElement('table', array('class' => 'smw-ask-otheroptions', 'width' => '100%'));
$resultHtml .= Html::openElement('tbody');
while ($option = array_shift($optionsHtml)) {
$i++;
// Collect elements for a row
$rowHtml .= $option;
// Create table row
if ($i % 3 == 0) {
$resultHtml .= Html::rawElement('tr', array('style' => 'background: ' . ($i % 6 == 0 ? 'white' : '#eee')), $rowHtml);
$rowHtml = '';
$n++;
}
}
// Ensure left over elements are collected as well
$resultHtml .= Html::rawElement('tr', array('style' => 'background: ' . ($n % 2 == 0 ? '#eee' : 'white')), $rowHtml);
$resultHtml .= Html::closeElement('tbody');
$resultHtml .= Html::closeElement('table');
return $resultHtml;
}
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:62,代码来源:SMW_QuerySpecialPage.php
示例8: 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;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:52,代码来源:SMW_Concept.php
示例9: getSemanticInternalObjects
/**
*
* Retrieve all internal objects and their properties.
* @param String $pagename
* @param String $internalproperty
* @return an array. Each element is an associative array and represents an internal object.
*
* E.G: {{#ptest:Chross|Is a parameter in an application}}
*
*/
public static function getSemanticInternalObjects($pagename, $internalproperty, $namespace = NS_MAIN)
{
$params = array("[[{$internalproperty}::{$pagename}]]", "format=list", "link=none", "headers=hide", "sep=;", "limit=5000");
$result = SMWQueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI);
$result = trim($result);
$sios = array();
if ($result) {
$sios = explode(";", $result);
}
$ret = array();
foreach ($sios as $sio) {
#remove namespace prefix.
$sio = preg_replace("/^[^:]+:/", "", $sio);
$sio = str_replace(" ", "_", $sio);
#remove fragment to -
#$sio=str_replace("#", "-23", $sio);
array_push($ret, self::loadSemanticProperties($sio, $namespace, true));
}
return $ret;
}
开发者ID:kghbln,项目名称:semanticaccesscontrol,代码行数:30,代码来源:SMWUtil.php
示例10: render
/**
* Method for handling the ask parser function.
*
* @since 1.5.3
*
* @param Parser $parser
*/
public static function render(Parser &$parser)
{
global $smwgQEnabled, $smwgIQRunningNumber, $wgTitle;
if ($smwgQEnabled) {
$smwgIQRunningNumber++;
$params = func_get_args();
array_shift($params);
// We already know the $parser ...
$result = SMWQueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI);
} else {
$result = smwfEncodeMessages(array(wfMessage('smw_iq_disabled')->inContentLanguage()->text()));
}
if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
global $wgOut;
SMWOutputs::commitToOutputPage($wgOut);
} else {
SMWOutputs::commitToParser($parser);
}
return $result;
}
开发者ID:nischayn22,项目名称:SemanticMediawiki,代码行数:27,代码来源:SMW_Ask.php
示例11: execute
function execute($p)
{
global $wgOut, $wgRequest, $smwgQEnabled, $smwgRSSEnabled, $smwgMW_1_14;
wfProfileIn('doSpecialAskTSC (SMWHalo)');
$this->extractQueryParameters($p);
$format = $this->getResultFormat($this->m_params);
$query = SMWSPARQLQueryProcessor::createQuery($this->m_querystring, $this->m_params, SMWQueryProcessor::SPECIAL_PAGE, $format, $this->m_printouts);
$res = smwfGetStore()->getQueryResult($query);
$printer = SMWQueryProcessor::getResultPrinter($format, SMWQueryProcessor::SPECIAL_PAGE, $res);
$result_mime = $printer->getMimeType($res);
if ($result_mime == false) {
if ($res->getCount() > 0) {
$result = '<div style="text-align: center;">';
$result .= '</div>' . $printer->getResult($res, $this->m_params, SMW_OUTPUT_HTML);
$result .= '<div style="text-align: center;"></div>';
} else {
$result = '<div style="text-align: center;">' . wfMsg('smw_result_noresults') . '</div>';
}
} else {
// make a stand-alone file
$result = $printer->getResult($res, $this->m_params, SMW_OUTPUT_FILE);
$result_name = $printer->getFileName($res);
// only fetch that after initialising the parameters
}
if ($result_mime == false) {
if ($this->m_querystring) {
$wgOut->setHTMLtitle($this->m_querystring);
} else {
$wgOut->setHTMLtitle(wfMsg('ask'));
}
$wgOut->addHTML($result);
} else {
$wgOut->disable();
header("Content-type: {$result_mime}; charset=UTF-8");
if ($result_name !== false) {
header("Content-Disposition: attachment; filename={$result_name}");
}
print $result;
}
wfProfileOut('doSpecialAskTSC (SMWHalo)');
}
开发者ID:seedbank,项目名称:old-repo,代码行数:41,代码来源:SMW_AskTSC.php
示例12: render
/**
* Method for handling the show parser function.
*
* @since 1.5.3
*
* @param Parser $parser
*/
public static function render(Parser &$parser)
{
global $smwgQEnabled, $smwgIQRunningNumber, $wgTitle;
if ($smwgQEnabled) {
$smwgIQRunningNumber++;
$rawParams = func_get_args();
array_shift($rawParams);
// We already know the $parser ...
list($query, $params) = SMWQueryProcessor::getQueryAndParamsFromFunctionParams($rawParams, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY, true);
$result = SMWQueryProcessor::getResultFromQuery($query, $params, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY);
$queryKey = hash('md4', implode('|', $rawParams), false);
SMWAsk::addQueryData($queryKey, $query, $params, $parser);
} else {
$result = smwfEncodeMessages(array(wfMessage('smw_iq_disabled')->inContentLanguage()->text()));
}
if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
global $wgOut;
SMWOutputs::commitToOutputPage($wgOut);
} else {
SMWOutputs::commitToParser($parser);
}
return $result;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:SMW_Show.php
示例13: get_ask_feed
function get_ask_feed() {
global $wgSitename, $wgTitle, $wgRequest;
// check for semantic wiki:
if ( !defined( 'SMW_VERSION' ) ) {
return false;
}
// bootstrap off of SMWAskPage:
$SMWAskPage = new SMWAskPage();
$SMWAskPage->extractQueryParameters( $wgRequest->getVal( 'q' ) );
// print 'query string: ' . $SMWAskPage->m_querystring . "\n<br />";
// print 'm_params: ' . print_r($SMWAskPage->m_params) . "\n<br />";
// print 'print outs: ' .print_r($SMWAskPage->m_printouts) . "\n<br />";
// set up the feed:
$this->feed = new mvRSSFeed(
$wgSitename . ' - ' . wfMsg( 'mediasearch' ) . ' : ' . strip_tags( $SMWAskPage->m_querystring ), // title
strip_tags( $SMWAskPage->m_querystring ), // description
$wgTitle->getFullUrl() // link
);
$this->feed->outHeader();
$queryobj = SMWQueryProcessor::createQuery( $SMWAskPage->m_querystring, $SMWAskPage->m_params, false, '', $SMWAskPage->m_printouts );
$res = smwfGetStore()->getQueryResult( $queryobj );
$row = $res->getNext();
while ( $row !== false ) {
$wikititle = $row[0]->getNextObject();
$this->feed->outPutItem( $wikititle->getTitle() );
$row = $res->getNext();
}
$this->feed->outFooter();
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:31,代码来源:MV_SpecialExport.php
示例14: getAnnotations
function getAnnotations($annotatedImage)
{
global $wgExtensionCredits;
$new = false;
foreach ($wgExtensionCredits['semantic'] as $elem) {
if ($elem['name'] == 'Semantic MediaWiki') {
$vers = $elem['version'];
$new = version_compare($vers, '1.7', '>=');
}
}
$returnString = '{"shapes":[';
$queryString = '[[SIAannotatedImage::' . $annotatedImage . ']]';
$params = array();
$params['link'] = 'none';
$params['mainlabel'] = 'result';
#$params = ['order'];
#$params = ['sort'];
if ($new) {
$params['order'] = array('asc');
$params['sort'] = array('SIAannotatedImage');
} else {
$params['order'] = 'asc';
$params['sort'] = 'SIAannotatedImage';
}
//Generate all the extra printouts, eg all properties to retrieve:
$printmode = SMWPrintRequest::PRINT_PROP;
$customPrintouts = array('coordinates' => 'SIArectangleCoordinates', 'text' => 'ImageAnnotationText');
$extraprintouts = array();
foreach ($customPrintouts as $label => $property) {
$extraprintouts[] = new SMWPrintRequest($printmode, $label, SMWPropertyValue::makeUserProperty($property));
}
$format = 'table';
$context = SMWQueryProcessor::INLINE_QUERY;
$query = SMWQueryProcessor::createQuery($queryString, $params, $context, $format, $extraprintouts);
$store = smwfGetStore();
// default store
$res = $store->getQueryResult($query);
$shapeCounter = 0;
while (($resArrayArray = $res->getNext()) != false) {
//Array of SMWResultArray Objects, eg. all retrieved Pages
$shapeCounter++;
if ($shapeCounter > 1) {
$returnString .= ',';
}
$returnString .= '{';
foreach ($resArrayArray as $resArray) {
//SMWResultArray-Object, column of resulttable (pagename or propertyvalue)
$currentPrintRequestLabel = $resArray->getPrintRequest()->getLabel();
//The label as defined in the above array
if ($currentPrintRequestLabel == 'coordinates') {
$currentResultPage = $resArray->getResultSubject();
$currentID = $currentResultPage->getTitle()->getFullText();
$currentCoords = $resArray->getNextDataItem()->getSerialization();
$returnString .= '"coords":"' . $currentCoords . '","id":"' . $currentID . '"';
}
}
$returnString .= '}';
}
$returnString .= ']}';
return $returnString;
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:61,代码来源:SIA_AjaxFunctions.php
示例15: getResultText
/**
* This method renders the result set provided by SMW according to the printer
*
* @param res SMWQueryResult, result set of the ask query provided by SMW
* @param outputmode ?
* @return String, rendered HTML output of this printer for the ask-query
*
*/
protected function getResultText($res, $outputmode)
{
global $wgContLang;
// content language object
$result = '';
$m_outlineLevel = 0;
$hasChildren = array();
$m_outlineLevel++;
$m_seedCategory = "";
$m_seedName = "";
$m_categories = $this->m_projectmanagementclass->getCategories();
$m_properties = $this->m_projectmanagementclass->getProperties();
if ($outputmode == SMW_OUTPUT_FILE) {
$queryparts = preg_split("/]]/", $res->getQueryString());
$taskname = str_replace("[[", "", $queryparts[0]);
if (strpos($taskname, "Category:") === false) {
//case: [[{{PAGENAME}}]]
if ($res->getCount() == 1) {
$m_seedName = trim(str_replace("[[", "", str_replace("]]", "", $res->getQueryString())));
$firstQuery = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[' . $m_seedName . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
//$firstQuery = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[Part of::'.$m_seedName.']]',array(),SMWQueryProcessor::INLINE_QUERY,'',$res->getPrintRequests()));
} else {
return "<html><body>ERROR: Query: " . $res->getQueryString() . "is invalid! Valid formats: [[Category:SampleCategory]] or: [[{{PAGENAME}}]]</body></html>";
}
} else {
$m_seedCategory = trim(str_replace("Category:", "", $taskname));
if (in_array($m_seedCategory, $m_categories)) {
$firstQuery = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[Category:' . $m_seedCategory . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
} else {
return "<html><body>ERROR: Category: " . $m_seedCategory . " has not been defined on Special:SemanticProjectManagement </body></html>";
}
}
$this->m_projectmanagementclass->setName("ProjectManagementClass");
// echo "First Query: ".$firstQuery->getQueryString()."<br/>";
//generate seed task
$task = $this->m_projectmanagementclass->makeTask("seed", 0);
$task->addWBS(0, 0);
$task->setUid(0);
$hasChildren = $this->m_projectmanagementclass->getTaskResults($firstQuery, $outputmode, $m_outlineLevel, $task);
$processedChildren = array();
$hasChild = true;
while ($hasChild) {
$hasChild = false;
$allTempChildren = array();
$m_outlineLevel++;
foreach ($hasChildren as $child) {
if (in_array($child, $processedChildren)) {
} else {
if (isset($m_properties[$child->getLevel()]) && isset($m_categories[$child->getLevel()])) {
//build new Query
if ($child->getLevel() != 0) {
$res2 = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[Category:' . $m_categories[$child->getLevel()] . ']] [[' . $m_properties[$child->getLevel()] . '::' . $child->getPage() . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
} else {
if (isset($m_properties[1])) {
$res2 = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[Category:' . $m_categories[0] . ']] [[' . $m_properties[1] . '::' . $child->getPage() . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
} else {
$res2 = smwfGetStore()->getQueryResult(SMWQueryProcessor::createQuery('[[' . $child->getPage() . ']]', array(), SMWQueryProcessor::INLINE_QUERY, '', $res->getPrintRequests()));
}
}
// echo "Next Query: ".$res2->getQueryString()." Level: ".$m_outlineLevel."<br/>";
$queryresults = $this->m_projectmanagementclass->getTaskResults($res2, $outputmode, $m_outlineLevel, $child);
$processedChildren[] = $child;
foreach ($queryresults as $temp) {
$allTempChildren[] = $temp;
}
}
}
}
$hasChildren = $allTempChildren;
if (count($hasChildren) > 0) {
$hasChild = true;
}
}
$task->addWBS(1, 0);
$result .= $this->m_projectmanagementclass->getXML();
} else {
// just make xml file
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('spm_wbs_link');
}
$link = $res->getQueryLink($label);
$link->setParameter('wbs', 'format');
if ($this->getSearchLabel(SMW_OUTPUT_WIKI) != '') {
$link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
}
if (array_key_exists('limit', $this->m_params)) {
$link->setParameter($this->m_params['limit'], 'limit');
} else {
// use a reasonable default limit
$link->setParameter(500, 'limit');
//.........这里部分代码省略.........
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:101,代码来源:SPM_WBS.php
示例16: getHTMLResult
/**
* Returns the results in HTML, or in case of exports, a link to the
* result.
*
* This method can only be called after execute() has been called.
*
* @return string of all the HTML generated
*/
public function getHTMLResult()
{
$result = '';
$res = $this->queryResult;
$printer = SMWQueryProcessor::getResultPrinter($this->parameters['format'], SMWQueryProcessor::SPECIAL_PAGE);
if ($res->getCount() > 0) {
$queryResult = $printer->getResult($res, $this->params, SMW_OUTPUT_HTML);
if (is_array($queryResult)) {
$result .= $queryResult[0];
} else {
$result .= $queryResult;
}
} else {
$result = wfMsg('smw_result_noresults');
}
return $result;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:SMW_QueryUIHelper.php
示例17: 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];
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:21,代码来源:Search.php
示例18: getFormatParameters
/**
* @param string $format
*
* @return array of IParamDefinition
*/
protected function getFormatParameters($format)
{
if (array_key_exists($format, $GLOBALS['smwgResultFormats'])) {
return ParamDefinition::getCleanDefinitions(SMWQueryProcessor::getResultPrinter($format)->getParamDefinitions(SMWQueryProcessor::getParameters()));
} else {
return array();
}
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:SMW_SMWDoc.php
示例19: 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;
}
开发者ID:ATCARES,项目名称:TaskManagement,代码行数:50,代码来源:TaskManagementUtils.php
示例20: getFormatSelection
/**
* Build the format drop down
*
* @param array
*
* @return string
*/
protected static function getFormatSelection($params)
{
$result = '';
$printer = SMWQueryProcessor::getResultPrinter('broadtable', SMWQueryProcessor::SPECIAL_PAGE);
$url = SpecialPage::getSafeTitleFor('Ask')->getLocalURL('showformatoptions=this.value');
foreach ($params as $param => $value) {
if ($param !== 'format') {
$url .= '¶ms[' . rawurlencode($param) . ']=' . rawurlencode($value);
}
}
$result .= '<br /><span style=vertical-align:middle;">' . wfMessage('smw_ask_format_as')->text() . ' <input type="hidden" name="eq" value="yes"/>' . "\n" . Html::openElement('select', array('id' => 'formatSelector', 'name' => 'p[format]', 'data-url' => $url)) . "\n" . ' <option value="broadtable"' . ($params['format'] == 'broadtable' ? ' selected' : '') . '>' . $printer->getName() . ' (' . wfMessage('smw_ask_defaultformat')->text() . ')</option>' . "\n";
$formats = array();
foreach (array_keys($GLOBALS['smwgResultFormats']) as $format) {
// Special formats "count" and "debug" currently not supported.
if ($format != 'broadtable' && $format != 'count' && $format != 'debug') {
$printer = SMWQueryProcessor::getResultPrinter($format, SMWQueryProcessor::SPECIAL_PAGE);
$formats[$format] = $printer->getName();
}
}
natcasesort($formats);
foreach ($formats as $format => $name) {
$result .= ' <option value="' . $format . '"' . ($params['format'] == $format ? ' selected' : '') . '>' . $name . "</option>\n";
}
$result .= "</select></span>\n";
return $result;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:33,代码来源:SMW_SpecialAsk.php
注:本文中的SMWQueryProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论