/** * this methods constructs the special page webservice repository * */ public function execute($par) { global $wgRequest, $wgOut; $wgOut->setPageTitle("Data Import Repository"); $webTestDebug = $wgRequest->getVal('webTestDebug'); if (!is_null($webTestDebug)) { $webTestDebug = true; } global $wgCookiePrefix; global $wgArticlePath; $gardeningURL = Title::makeTitleSafe(NS_SPECIAL, "Gardening")->getFullURL(); $allowed = false; global $wgUser; $user = $wgUser; if ($user != null) { $groupsOfUser = $user->getGroups(); foreach ($groupsOfUser as $key => $group) { if ($group == SMW_WS_SYSOP) { $allowed = true; } } } $html = ""; $html .= "<table id=\"menue\" class=\"TabContainer\"><tr>"; $html .= "<td id=\"web-service-tab\" class=\"ActiveTab\" onclick=\"webServiceRepSpecial.displayWebServiceTab()\">Web Service definitions</td>"; $html .= "<td></td>"; $html .= "<td id=\"term-import-tab\" class=\"InactiveTab\" onclick=\"webServiceRepSpecial.displayTermImportTab()\" onmouseover=\"webServiceRepSpecial.highlightTab(event)\">Term Import definitions</td>"; $html .= "<td></td></tr></table>"; global $smwgDIIP; // handle web service repository require_once $smwgDIIP . '/specials/WebServices/SMW_WSStorage.php'; $webServices = WSStorage::getDatabase()->getWebServices(); ksort($webServices); $html .= "<span id=\"web-service-tab-content\">"; $html .= "<h2><span class=\"mw-headline\">" . wfMsg('smw_wwsr_intro') . "</span></h2>"; $html .= "<p>" . wfMsg('smw_wwsr_rep_intro') . "</p>"; $html .= '<p><a href="' . Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . '">' . wfMsg('smw_wwsr_rep_create_link') . '</a></p>'; if ($allowed) { $html .= "<table id=\"webservicetable\" 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><th style=\"text-align: center\">" . wfMsg('smw_wwsr_confirm') . "</th></tr>"; } else { $html .= "<table id=\"webservicetable\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_rep_edit') . "</th></tr>"; } foreach ($webServices as $ws) { $title = Title::newFromID($ws->getArticleID()); if (!is_null($title)) { $wsUrl = $title->getFullURL(); $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); }
/** * 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); }
/** * 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); }
/** * 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); }
function test() { $querystring = 'Status::Incomplete'; SMWQueryProcessor::getResultFromQueryString($querystring, $params, $extraprintouts, $outputmode, true); }
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' ); } }
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); }
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; }
function smwf_qi_QIAccess($method, $params) { $p_array = explode(",", $params); global $smwgQEnabled; if ($method == "getPropertyInformation") { return qiGetPropertyInformation($p_array[0]); } else { if ($method == "getPropertyTypes") { $p_array = func_get_args(); $types = "<propertyTypes>"; for ($i = 1; $i < count($p_array); $i++) { $types .= qiGetPropertyInformation($p_array[$i]); } $types .= "</propertyTypes>"; return $types; } else { if ($method == "getNumericTypes") { $numtypes = array(); $types = SMWDataValueFactory::getKnownTypeLabels(); foreach ($types as $v) { $id = SMWDataValueFactory::findTypeID($v); if (SMWDataValueFactory::newTypeIDValue($id)->isNumeric()) { array_push($numtypes, strtolower($v)); } } return implode(",", $numtypes); } else { if ($method == "getQueryResult") { $result = "null"; if ($smwgQEnabled) { // read fix parameters from QI GUI $params = count($p_array) > 1 ? explode("|", $p_array[1]) : array(); $fixparams = array(); foreach ($params as $p) { if (strlen($p) > 0 && strpos($p, "=") !== false) { list($key, $value) = explode("=", $p); $fixparams[trim($key)] = str_replace('%2C', ',', $value); } } // indicate that it comes from an ajax call $fixparams['ajaxCall'] = true; // fix bug 10812: if query string contains a , $p_array[0] = str_replace('%2C', ',', $p_array[0]); // read query with printouts and (possibly) other parameters like sort, order, limit, etc... $pos = strpos($p_array[0], "|?"); if ($pos > 0) { $rawparams[] = trim(substr($p_array[0], 0, $pos)); $ps = explode("|?", trim(substr($p_array[0], $pos + 2))); foreach ($ps as $param) { $rawparams[] = "?" . trim($param); } } else { $ps = preg_split('/[^\\|]{1}\\|{1}(?!\\|)/s', $p_array[0]); if (count($ps) > 1) { // last char of query condition is missing (matched with [^\|]{1}) therefore copy from original $rawparams[] = trim(substr($p_array[0], 0, strlen($ps[0]) + 1)); array_shift($ps); // remove the query condition // add other params for formating etc. foreach ($ps as $param) { $rawparams[] = trim($param); } } else { $rawparams[] = trim($p_array[0]); } } $rawparams = array_merge($rawparams, $fixparams); // set some default values, if params are not set if (!in_array('reasoner', array_keys($fixparams))) { $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: } $result = parseWikiText($result); // add target="_new" for all links $pattern = "|<a|i"; $result = preg_replace($pattern, '<a target="_new"', $result); return $result; } } else { if ($method == "getQueryResultForDownload") { $result = "null"; if ($smwgQEnabled) { $params = array('format' => $p_array[1], 'link' => $p_array[2], 'intro' => $p_array[3], 'sort' => $p_array[4], 'limit' => $p_array[5], 'mainlabel' => $p_array[6], 'order' => $p_array[7], 'default' => $p_array[8], 'headers' => $p_array[9]); $result = applyQueryHighlighting($p_array[0], $params); // add target="_new" for all links $pattern = "|<a|i"; $result = preg_replace($pattern, '<a target="_new"', $result); } if ($result != "null" && $result != "") { global $request_query; $request_query = true; } return $result; } else { if ($method == "getSupportedParameters") { global $smwgResultFormats; wfLoadExtensionMessages('SemanticMediaWiki'); $format = $p_array[0]; if (array_key_exists($format, $smwgResultFormats)) { $formatclass = $smwgResultFormats[$format]; } else { $formatclass = "SMWListResultPrinter"; } // fix for missing parameter order $order_missing = true; $intro_missing = true; $outro_missing = true; $qp = new $formatclass($format, false); $params = $qp->getParameters(); // repair some misplaced parameters for ($i = 0; $i < count($params); $i++) { switch ($params[$i]['name']) { case "order": $order_missing = false; break; case "template": if ($format != "template") { array_splice($params, $i, 1); } break; case "intro": if (substr($format, 0, 4) != "ofc-") { $intro_missing = false; } break; case "outro": if (substr($format, 0, 4) != "ofc-") { $outro_missing = false; } break; case "headers": if ($format != "table" && $format != "broadtable") { array_splice($params, $i, 1); } break; } } if ($order_missing) { $params[] = array('name' => 'order', 'type' => 'enumeration', 'description' => wfMsg('smw_qi_tt_order'), 'values' => array('ascending', 'descending')); } if ($intro_missing) { $params[] = array('name' => 'intro', 'type' => 'string', 'description' => wfMsg('smw_qi_tt_intro')); } if ($outro_missing) { $params[] = array('name' => 'outro', 'type' => 'string', 'description' => wfMsg('smw_qi_tt_outro')); } $jsonEnc = new Services_JSON(); return $jsonEnc->encode($params); } else { return "false"; } } } } } } }