本文整理汇总了PHP中SMWQueryProcessor::getResultFromQueryString方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryProcessor::getResultFromQueryString方法的具体用法?PHP SMWQueryProcessor::getResultFromQueryString怎么用?PHP SMWQueryProcessor::getResultFromQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWQueryProcessor
的用法示例。
在下文中一共展示了SMWQueryProcessor::getResultFromQueryString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
//.........这里部分代码省略.........
$wsName = substr($ws->getName(), 11, strlen($ws->getName()));
$html .= "<tr id=\"ws-row-" . $ws->getArticleID() . "\"><td><a href=\"" . $wsUrl . "\">" . $wsName . "</a></td>";
$cacheResults = WSStorage::getDatabase()->getResultsFromCache($ws->getArticleID());
$oldestUpdate = "";
if (count($cacheResults) > 0) {
$oldestUpdate = $cacheResults[0]["lastUpdate"];
if (strlen($oldestUpdate) > 0) {
$oldestUpdate = wfTimestamp(TS_DB, $oldestUpdate);
}
}
$latestUpdate = "";
if (sizeof($cacheResults) > 1) {
$latestUpdate = $cacheResults[sizeof($cacheResults) - 1]["lastUpdate"];
if (strlen($latestUpdate) > 0) {
$latestUpdate = wfTimestamp(TS_DB, $cacheResults[sizeof($cacheResults) - 1]["lastUpdate"]);
if (strlen($oldestUpdate) > 0) {
$latestUpdate = " - " . $latestUpdate;
}
}
}
$html .= "<td>" . $oldestUpdate . $latestUpdate . "</td>";
if ($allowed) {
$wsUpdateBot = new WSUpdateBot();
$html .= "<td style=\"text-align: center\"><button id=\"update" . $ws->getArticleID() . "\" type=\"button\" name=\"update\" onclick=\"webServiceRepSpecial.updateCache('" . $wsUpdateBot->getBotID() . "', 'WS_WSID=" . $ws->getArticleID() . "')\" alt=\"" . wfMsg('smw_wwsr_update') . "\" title=\"" . wfMsg('smw_wwsr_update_tooltip') . "\">" . wfMsg('smw_wwsr_update') . "</button>";
$html .= "<div id=\"updating" . $ws->getArticleID() . "\" style=\"display: none; text-align: center\"><a href=\"" . $gardeningURL . "\">" . wfMsg('smw_wwsr_updating') . "</a></div></td>";
}
global $wgArticlePath;
if (strpos($wgArticlePath, "?") > 0) {
$url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . "&wwsdId=" . $ws->getArticleID();
} else {
$url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . "?wwsdId=" . $ws->getArticleID();
}
$html .= "<td style=\"text-align: center\"><button id=\"edit" . $ws->getArticleID() . "\" type=\"button\" name=\"edit\" onclick=\"window.location.href = '" . $url . "';\" alt=\"" . wfMsg('smw_wwsr_rep_edit') . "\" title=\"" . wfMsg('smw_wwsr_rep_edit_tooltip') . "\">" . wfMsg('smw_wwsr_rep_edit') . "</button>";
if ($allowed) {
$html .= "<td style=\"text-align: center\"> <button type=\"button\" onclick=\"webServiceRepSpecial.deleteWWSD(" . $ws->getArticleID() . ")\" alt=\"" . wfMsg('smw_wwsr_delete') . "\" title=\"" . wfMsg('smw_wwsr_delete_tooltip') . "\">" . wfMsg('smw_wwsr_delete') . "</button></td>";
}
if ($allowed) {
if ($ws->getConfirmationStatus() != "true") {
$html .= "<td style=\"text-align: center\" id=\"confirmText" . $ws->getArticleID() . "\"> <button type=\"button\" id=\"confirmButton" . $ws->getArticleID() . "\" onclick=\"webServiceRepSpecial.confirmWWSD(" . $ws->getArticleID() . ")\" alt=\"" . wfMsg('smw_wwsr_confirm') . "\" title=\"" . wfMsg('smw_wwsr_confirm_tooltip') . "\">" . wfMsg('smw_wwsr_confirm') . "</button></td></tr>";
} else {
$html .= "<td style=\"text-align: center\" alt=\"" . wfMsg('smw_wwsr_confirm') . "\" title=\"" . wfMsg('smw_wwsr_confirm_tooltip') . "\">" . wfMsg('smw_wwsr_confirmed') . "</td></tr>";
}
} else {
$html .= "</tr>";
}
}
}
$html .= "</table>";
$html .= "</span>";
//Term Import definition tab
$html .= "<span id=\"term-import-tab-content\" style=\"display: none\">";
$html .= "<h2><span class=\"mw-headline\">" . wfMsg('smw_tir_intro') . "</span></h2>";
$html .= "<p>" . wfMsg('smw_tir_rep_intro') . "</p>";
$html .= '<p><a href="' . Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . '">' . wfMsg('smw_tir_rep_create_link') . '</a></p>';
if ($allowed) {
$html .= "<table id=\"termimporttable\" width=\"100%\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_update_manual') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_rep_edit') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_delete') . "</th></tr>";
} else {
$html .= "<table id=\"termimporttable\" width=\"100%\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th></tr>";
}
$log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
SMWQueryProcessor::processFunctionParams(array("[[Category:TermImport]]"), $querystring, $params, $printouts);
$queryResult = explode("|", SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI));
unset($queryResult[0]);
foreach ($queryResult as $tiArticleName) {
$tiArticleName = substr($tiArticleName, 0, strpos($tiArticleName, "]]"));
$html .= "<tr id=\"ti-row-" . $tiArticleName . "\">";
$tiUrl = Title::newFromText("TermImport:" . $tiArticleName)->getFullURL();
$html .= "<td><a href=\"" . $tiUrl . "\">" . $tiArticleName . "</a></td>";
SMWQueryProcessor::processFunctionParams(array("[[belongsToTermImport::TermImport:" . $tiArticleName . "]]", "?hasImportDate", "limit=1", "sort=hasImportDate", "order=descending", "format=list", "mainlabel=-"), $querystring, $params, $printouts);
$queryResult = SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI);
// timestamp creation depends on property type (page or date)
$queryResult = trim(substr($queryResult, strpos($queryResult, "]]") + 2));
if (strpos($queryResult, "[[:") === 0) {
//type page
$queryResult = trim(substr($queryResult, strpos($queryResult, "|") + 1));
$queryResult = trim(substr($queryResult, 0, strpos($queryResult, "]")));
} else {
//type date
$queryResult = trim(substr($queryResult, 0, strpos($queryResult, "[")));
}
$html .= "<td>" . $queryResult . "</td>";
if ($allowed) {
$tiUpdateBot = new TermImportUpdateBot();
$html .= "<td style=\"text-align: center\"><button id=\"update-ti-" . $tiArticleName . "\" \r\n\t\t\t\t\ttype=\"button\" name=\"update-ti\" \r\n\t\t\t\t\tonclick=\"webServiceRepSpecial.updateTermImport('" . $tiArticleName . "')\" alt=\"" . wfMsg('smw_wwsr_update') . "\" title=\"" . wfMsg('smw_wwsr_update_tooltip_ti') . "\">" . wfMsg('smw_wwsr_update') . "</button>";
$html .= "<div id=\"updating-ti-" . $tiArticleName . "\" style=\"display: none; text-align: center\"><a href=\"" . $gardeningURL . "\">" . wfMsg('smw_wwsr_updating') . "</a></div></td>";
global $wgArticlePath;
if (strpos($wgArticlePath, "?") > 0) {
$url = Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . "&tiname=" . $tiArticleName;
} else {
$url = Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . "?tiname=" . $tiArticleName;
}
$html .= "<td style=\"text-align: center\"><button id=\"edit" . $tiArticleName . "\" type=\"button\" name=\"edit\" onclick=\"window.location.href = '" . $url . "';\" alt=\"" . wfMsg('smw_wwsr_rep_edit') . "\" title=\"" . wfMsg('smw_wwsr_rep_edit_tooltip_ti') . "\">" . wfMsg('smw_wwsr_rep_edit') . "</button></td>";
$html .= "<td style=\"text-align: center\"><button type=\"button\" name=\"delete\" onclick=\"webServiceRepSpecial.deleteTermImport('" . $tiArticleName . "')\" alt=\"" . wfMsg('smw_wwsr_delete') . "\" title=\"" . wfMsg('smw_wwsr_rep_delete_tooltip_ti') . "\">" . wfMsg('smw_wwsr_delete') . "</button></td>";
}
$html .= "</tr>";
}
$html .= "</table>";
$html .= "</span>";
$wgOut->addHTML($html);
}
示例2: doMissingValues
/**
* Function for handling the {{\#missingvalues }} parser function.
*/
public static function doMissingValues($parser, $querystring, $propertyname, $values)
{
$all_values = explode(',', $values);
$all_values_clean = array();
foreach ($all_values as $cur_value) {
// remove whitespaces
$cur_value = trim($cur_value);
// ignore a value if it's null
if ('' != $cur_value) {
$all_values_clean[] = $cur_value;
}
}
$params = array();
$params['format'] = 'list';
$params['link'] = 'none';
$params['mainlabel'] = '-';
$extraprintouts = array();
$printmode = SMWPrintRequest::PRINT_PROP;
$data = SMWPropertyValue::makeUserProperty(trim($propertyname));
$label = '';
$printout = new SMWPrintRequest($printmode, $label, $data);
$extraprintouts[] = $printout;
$outputmode = SMW_OUTPUT_WIKI;
$result = SMWQueryProcessor::getResultFromQueryString($querystring, $params, $extraprintouts, $outputmode);
$found_values = explode(', ', $result);
$missing_values = array_diff($all_values_clean, $found_values);
return join(', ', $missing_values);
}
示例3: 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);
}
示例4: answerASK
/**
* Answers a ASK query.
*
* @param string $rawQuery
* @return SPARQL XML string
*/
function answerASK($rawquery, $format = "xml")
{
// add desired query printer (SPARQL-XML)
if (property_exists('SMWQueryProcessor', 'formats')) {
// registration up to SMW 1.2.*
SMWQueryProcessor::$formats['xml'] = 'SMWXMLResultPrinter';
// overwrite SMW printer
} else {
// registration since SMW 1.3.*
global $smwgResultFormats;
$smwgResultFormats['xml'] = 'SMWXMLResultPrinter';
}
// add query as first rawparam
$paramPos = strpos($rawquery, "|");
$rawparams[] = $paramPos === false ? $rawquery : substr($rawquery, 0, $paramPos);
if ($paramPos !== false) {
// add other params
$ps = explode("|", substr($rawquery, $paramPos + 1));
foreach ($ps as $param) {
$param = trim($param);
$rawparams[] = $param;
}
}
// parse params and answer query
SMWQueryProcessor::processFunctionParams($rawparams, $querystring, $params, $printouts);
$params['format'] = $format;
return SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_FILE);
}
示例5: test
function test()
{
$querystring = 'Status::Incomplete';
SMWQueryProcessor::getResultFromQueryString($querystring, $params, $extraprintouts, $outputmode, true);
}
示例6: smwf_nm_NotifyAccess
function smwf_nm_NotifyAccess( $method, $params ) {
$p_array = explode( ",", $params );
global $smwgQEnabled;
$result = "Query disabled.";
if ( $method == "updateMail" ) {
global $wgUser;
$wgUser->setOption( 'enotifyme', $params );
$wgUser->saveSettings();
return wfMsg( 'smw_nm_ajax_mailupdate' );
}
elseif ( $method == "addNotify" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::addNotify( str_replace( '&', '&', str_replace( ',', ',', $p_array[0] ) ),
str_replace( '&', '&', str_replace( ',', ',', $p_array[3] ) ),
$p_array[1], $p_array[2], implode( ",", array_slice( $p_array, 4 ) ) );
}
return $result;
}
elseif ( $method == "getQueryResult" ) {
if ( $smwgQEnabled ) {
$params .= '
| format=table
| link=all';
// parse params and answer query
SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $params ), $querystring, $params, $printouts );
$result = SMWQueryProcessor::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI );
switch ( $params->format ) {
case 'timeline':
return $result;
break;
case 'eventline':
return $result;
break;
case 'googlepie':
return $result[0];
break;
case 'googlebar':
return $result[0];
break;
case 'exhibit':
return $result;
break;
default:
}
global $wgParser;
if ( ( $wgParser->getTitle() instanceof Title ) && ( $wgParser->getOptions() instanceof ParserOptions ) ) {
$result = $wgParser->recursiveTagParse( $result );
} else {
global $wgTitle;
$popt = new ParserOptions();
$popt->setEditSection( false );
$pout = $wgParser->parse( $result . '__NOTOC__', $wgTitle, $popt );
// / NOTE: as of MW 1.14SVN, there is apparently no better way to hide the TOC
SMWOutputs::requireFromParserOutput( $pout );
$result = $pout->getText();
}
// add target="_new" for all links
$pattern = "|<a|i";
$result = preg_replace( $pattern, '<a target="_new"', $result );
}
return $result;
}
elseif ( $method == "updateStates" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::updateStates( $p_array );
}
return $result;
}
elseif ( $method == "updateReportAll" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::updateReportAll( $p_array );
}
return $result;
}
elseif ( $method == "updateShowAll" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::updateShowAll( $p_array );
}
return $result;
}
elseif ( $method == "updateDelegates" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::updateDelegates( explode( "|", $params ) );
}
return $result;
}
elseif ( $method == "delNotify" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::delNotify( $p_array );
}
return $result;
}
else {
return wfMsg( 'smw_nm_ajax_fail' );
}
//.........这里部分代码省略.........
示例7: runASKQuery
private static function runASKQuery($rawquery, $column, $userInput)
{
global $smwgResultFormats, $smwgHaloIP;
require_once "{$smwgHaloIP}/includes/queryprinters/SMW_QP_XML.php";
$smwgResultFormats['xml'] = 'SMWXMLResultPrinter';
// add query as first rawparam
$rawparams[] = $rawquery;
if ($column != "_var0") {
$rawparams[] = "?{$column}";
}
// parse params and answer query
SMWQueryProcessor::processFunctionParams($rawparams, $querystring, $params, $printouts);
$params['format'] = "xml";
//$params['limit'] = SMW_AC_MAX_RESULTS;
if ($column != "_var0") {
$params['sort'] = $column;
}
$querystring = str_replace("{{USERINPUT}}", $userInput, $querystring);
return SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_FILE);
}
示例8: getNecessaryTermImports
private function getNecessaryTermImports()
{
require_once "SMW_TermImportDefinitionValidator.php";
$log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
SMWQueryProcessor::processFunctionParams(array("[[TermImport:+]] [[Category:TermImport]]"), $querystring, $params, $printouts);
$queryResult = explode("|", SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI));
unset($queryResult[0]);
$necessaryTermImports = array();
foreach ($queryResult as $tiArticleName) {
$tiArticleName = substr($tiArticleName, 0, strpos($tiArticleName, "]]"));
$xmlString = smwf_om_GetWikiText('TermImport:' . $tiArticleName);
$start = strpos($xmlString, "<ImportSettings>");
$end = strpos($xmlString, "</ImportSettings>") + 17 - $start;
$xmlString = substr($xmlString, $start, $end);
SMWQueryProcessor::processFunctionParams(array("[[belongsToTermImport::TermImport:" . $tiArticleName . "]]", "?hasImportDate", "limit=1", "sort=hasImportDate", "order=descending", "format=list", "mainlabel=-", "searchlabel="), $querystring, $params, $printouts);
$queryResult = SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI);
// timestamp creation depends on property type (page or date)
$queryResult = trim(substr($queryResult, strpos($queryResult, "]]") + 2));
if (strpos($queryResult, "[[:") === 0) {
//type page
$queryResult = trim(substr($queryResult, strpos($queryResult, "|") + 1));
$queryResult = trim(substr($queryResult, 0, strpos($queryResult, "]")));
} else {
//type date
$queryResult = trim(substr($queryResult, 0, strpos($queryResult, "[")));
}
$timestamp = strtotime($queryResult);
$tiDV = new SMWTermImportDefinitionValidator($xmlString);
if (!$tiDV->validate()) {
echo "\nThe Term Import definition of " . $tiArticleName . " is invalid.\n";
$title = Title::newFromText("TermImport:" . $tiArticleName);
$log->addGardeningIssueAboutArticle($this->id, SMW_GARDISSUE_UPDATE_FAILURE, $title);
continue;
}
$simpleXMLElement = new SimpleXMLElement($xmlString);
$maxAge = $simpleXMLElement->xpath("//UpdatePolicy/maxAge/@value");
//echo("\ntimestamp: ".$imestamp);
if ($maxAge != "") {
if ($timestamp == 0 || wfTime() - $timestamp - $maxAge[0]->value * 60 > 0) {
echo "\nRun this term import: " . $tiArticleName;
$necessaryTermImports[$tiArticleName] = $xmlString;
}
} else {
$title = Title::newFromText("TermImport:" . $tiArticleName);
$log->addGardeningIssueAboutArticle($this->id, SMW_GARDISSUE_UPDATE_NOT_NECESSARY, $title);
}
}
return $necessaryTermImports;
}
示例9: smwf_qi_QIAccess
//.........这里部分代码省略.........
$fixparams['reasoner'] = 'ask';
}
if (!in_array('format', array_keys($fixparams))) {
$fixparams['format'] = 'table';
}
// use SMW classes or TSC classes and parse params and answer query
if ($fixparams['reasoner'] == 'ask') {
SMWQueryProcessor::processFunctionParams($rawparams, $querystring, $params, $printouts);
} else {
if ($fixparams['reasoner'] == 'sparql') {
SMWSPARQLQueryProcessor::processFunctionParams($rawparams, $querystring, $params, $printouts);
}
}
// check if there is any result and if it corresponds to the selected format
$mainlabel = isset($rawparams['mainlabel']) && $rawparams['mainlabel'] == '-';
$invalidRes = smwf_qi_CheckValidResult($printouts, $fixparams['format'], $mainlabel);
if ($invalidRes != 0) {
return wfMsg('smw_qi_printout_err' . $invalidRes);
}
// quickfix: unset conflicting params for maps
if (in_array($fixparams['format'], array("map", "googlemaps2", "openlayers", "yahoomaps"))) {
if (isset($params['reasoner'])) {
unset($params['reasoner']);
}
if (isset($params['ajaxcall'])) {
unset($params['ajaxcall']);
}
if (isset($params['merge'])) {
unset($params['merge']);
}
}
// answer query using the SMW classes or TSC classes
if ($fixparams['reasoner'] == 'ask') {
$result = SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI);
} else {
if ($fixparams['reasoner'] == 'sparql') {
$result = SMWSPARQLQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI);
}
}
// check for empty result
if (is_array($result) && trim($result[0]) == '' || trim($result == '')) {
return wfMsg('smw_qi_printout_err4');
}
switch ($fixparams['format']) {
case 'timeline':
case 'exhibit':
case 'eventline':
return $result;
break;
case 'gallery':
case 'googlepie':
case 'googlebar':
case 'ofc-pie':
case 'ofc-bar':
case 'ofc-bar_3d':
case 'ofc-line':
case 'ofc-scatterline':
return is_array($result) ? $result[0] : $result;
break;
case 'map':
case 'googlemaps2':
case 'openlayers':
case 'yahoomaps':
return wfMsg('smw_qi_printout_notavailable');
default:
}