本文整理汇总了PHP中SMWQueryProcessor::processFunctionParams方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryProcessor::processFunctionParams方法的具体用法?PHP SMWQueryProcessor::processFunctionParams怎么用?PHP SMWQueryProcessor::processFunctionParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWQueryProcessor
的用法示例。
在下文中一共展示了SMWQueryProcessor::processFunctionParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: updateData
public function updateData(SMWSemanticData $data, $store)
{
//get list of properties which are set by this article
//todo: think about only querying for modified properties
$properties = $data->getProperties();
foreach ($properties as $name => $property) {
//ignore internal properties
if (!$property->isUserDefined() || $name == QRC_HQID_LABEL) {
unset($properties[$name]);
}
}
//determine differences between the new and the original semantic data
global $wgTitle;
if ($wgTitle) {
$originalData = $store->getSemanticData($wgTitle);
foreach ($originalData->getProperties() as $oName => $oProperty) {
if (array_key_exists($oName, $properties)) {
$oValues = $originalData->getPropertyValues($oProperty);
$values = $data->getPropertyValues($properties[$oName]);
if (count($oValues) == count($values)) {
$oWikiValues = array();
foreach ($oValues as $key => $value) {
$oWikiValues[$value->getWikiValue()] = true;
}
$wikiValues = array();
foreach ($values as $key => $value) {
$wikiValues[$value->getWikiValue()] = true;
}
$unset = true;
foreach (array_keys($values) as $value) {
if (!array_key_exists($value, $oWikiValues)) {
$unset = false;
break;
}
}
if ($unset) {
unset($properties[$oName]);
}
}
//echo('<pre>'.print_r($oProperty, true).'</pre>');
//echo('<pre>'.print_r(, true).'</pre>');
} else {
if ($oProperty->isUserDefined() && $name != QRC_HQID_LABEL) {
$properties[$oName] = $oProperty;
}
}
}
}
//deal with categories and determine which queries to update
$categories = array();
global $wgParser;
if ($wgParser && $wgParser->getOutput() && $wgTitle) {
$categories = $wgParser->getOutput()->getCategories();
$originalCategories = $wgTitle->getParentCategories();
//echo('<pre>'.print_r($originalCategories, true).'</pre>');
foreach (array_keys($originalCategories) as $category) {
$category = substr($category, strpos($category, ':') + 1);
if (array_key_exists($category, $categories)) {
unset($categories[$category]);
} else {
$categories[$category] = true;
}
}
}
//echo('<pre>'.print_r(array_keys($categories), true).'</pre>');
//echo('<pre>'.print_r(array_keys($properties), true).'</pre>');
if (count($properties) > 0 || count($categories) > 0) {
//query for all articles that use a query which depends on one of the properties
$queryString = SMWQRCQueryManagementHandler::getInstance()->getSearchQueriesAffectedByDataModification(array_keys($properties), array_keys($categories));
SMWQueryProcessor::processFunctionParams(array($queryString), $queryString, $params, $printouts);
$query = SMWQueryProcessor::createQuery($queryString, $params);
$queryResults = $this->getQueryResult($query, true, false)->getResults();
//get query ids which have to be invalidated
$queryIds = array();
foreach ($queryResults as $queryResult) {
$semanticData = $store->getSemanticData($queryResult);
$invalidatePC = false;
$tQueryIds = SMWQRCQueryManagementHandler::getInstance()->getIdsOfQueriesUsingProperty($semanticData, $properties);
if (count($tQueryIds) > 0) {
$invalidatePC = true;
}
$queryIds = array_merge($queryIds, $tQueryIds);
$tQueryIds = SMWQRCQueryManagementHandler::getInstance()->getIdsOfQueriesUsingCategory($semanticData, $categories);
if (count($tQueryIds) > 0) {
$invalidatePC = true;
}
$queryIds = array_merge($queryIds, $tQueryIds);
global $invalidateParserCache, $showInvalidatedCacheEntries;
if ($invalidatePC && $invalidateParserCache && !$showInvalidatedCacheEntries) {
$title = $queryResult->getTitle();
$title->invalidateCache();
}
}
$qrcStore = SMWQRCStore::getInstance()->getDB();
$qrcStore->invalidateQueryData($queryIds);
}
return $store->doUpdateData($data);
}
示例4: rcDoOutputFeed
function rcDoOutputFeed(&$feed, $type, $id, $limit)
{
wfProfileIn(__METHOD__);
$feed->outHeader();
if ($type == "nid") {
$dbr = wfGetDB(DB_SLAVE);
$showall = $dbr->selectField('smw_nm_query', 'show_all', array('notify_id' => $id), 'NotifyMeRSS');
if ($showall) {
$query = $dbr->selectField('smw_nm_query', 'query', array('notify_id' => $id), 'NotifyMeRSS');
SMWQueryProcessor::processFunctionParams(SMWNotifyProcessor::getQueryRawParams($query), $querystring, $params, $printouts);
$query = SMWQueryProcessor::createQuery($querystring, $params, SMWQueryProcessor::INLINE_QUERY, 'auto', $printouts);
$res = smwfGetStore()->getQueryResult($query);
$items = array();
$labels = array();
foreach ($res->getPrintRequests() as $pr) {
$labels[] = $pr->getText(SMW_OUTPUT_WIKI);
}
$row = $res->getNext();
$linker = new Linker();
while ($row !== false) {
$wikipage = $row[0]->getNextObject();
// get the object
$a = new Article($wikipage->getTitle());
$description = "<table style=\"width: 60em; font-size: 90%; border: 1px solid #aaaaaa; background-color: #f9f9f9; color: black; margin-bottom: 0.5em; margin-left: 1em; padding: 0.2em; clear: right; text-align:left;\"><tr><th style=\"text-align: center; background-color:#ccccff;\" colspan=\"2\"><big>" . $wikipage->getText() . "</big></th></tr>";
$idx = 0;
foreach ($row as $field) {
$description .= "<tr><td>" . $labels[$idx] . "</td><td>";
$first_value = true;
while (($object = $field->getNextObject()) !== false) {
if ($first_value) {
$first_value = false;
} else {
$description .= ', ';
}
$description .= $object->getShortText(SMW_OUTPUT_HTML, $linker);
}
$description .= "</td></tr>";
$idx++;
}
$description .= "</table>";
$items[] = array('title' => $wikipage->getText(), 'notify' => $description, 'timestamp' => $a->getTimestamp());
$row = $res->getNext();
}
} else {
$items = NMStorage::getDatabase()->getNotifyRSS($type, $id, $limit);
}
} else {
$items = NMStorage::getDatabase()->getNotifyRSS($type, $id, $limit);
}
foreach ($items as $i) {
if (isset($i['link']) && $i['link']) {
$item = new FeedItem($i['title'], $i['notify'], $i['link'], $i['timestamp']);
} else {
$title = Title::makeTitle(NS_MAIN, $i['title']);
$talkpage = $title->getTalkPage();
$item = new FeedItem($title->getPrefixedText(), $i['notify'], $title->getFullURL(), $i['timestamp'], "", $talkpage->getFullURL());
}
$feed->outItem($item);
}
$feed->outFooter();
wfProfileOut(__METHOD__);
}
示例5: smwfProcessInlineQueryParserFunctionGTP
static function smwfProcessInlineQueryParserFunctionGTP( &$parser ) {
global $smwgQEnabled, $smwgIQRunningNumber;
if ( $smwgQEnabled ) {
$smwgIQRunningNumber++;
$rawparams = func_get_args();
array_shift( $rawparams ); // we already know the $parser ...
SMWQueryProcessor::processFunctionParams( $rawparams, &$querystring, &$params, &$printouts );
self::prequery( $params, $printouts, $label, $wom_id );
$query = SMWQueryProcessor::createQuery(
$querystring,
$params,
SMWQueryProcessor::INLINE_QUERY,
SMW_OUTPUT_WIKI,
$printouts
);
$res = smwfGetStore()->getQueryResult( $query );
while ( $row = $res->getNext() ) {
$firstcol = true;
foreach ( $row as $field ) {
$object = $field->getNextObject();
$text = $object->getWikiValue();
self::$queryProps[$wom_id][$label][] = $text;
// get the first column only
break;
}
}
}
return '';
}
示例6: extractQueryParameters
/**
* This code rather hacky since there are many ways to call that special page, the most involved of
* which is the way that this page calls itself when data is submitted via the form (since the shape
* of the parameters then is governed by the UI structure, as opposed to being governed by reason).
*
* TODO: most of this can probably be killed now we are using Validator
*
* @param string $p
*/
protected function extractQueryParameters($p)
{
global $wgRequest, $smwgQMaxInlineLimit;
// First make all inputs into a simple parameter list that can again be parsed into components later.
if ($wgRequest->getCheck('q')) {
// called by own Special, ignore full param string in that case
$query_val = $wgRequest->getVal('p');
if (!empty($query_val)) {
// p is used for any additional parameters in certain links.
$rawparams = SMWInfolink::decodeParameters($query_val, false);
} else {
$query_values = $wgRequest->getArray('p');
if (is_array($query_values)) {
foreach ($query_values as $key => $val) {
if (empty($val)) {
unset($query_values[$key]);
}
}
}
// p is used for any additional parameters in certain links.
$rawparams = SMWInfolink::decodeParameters($query_values, false);
}
} else {
// called from wiki, get all parameters
$rawparams = SMWInfolink::decodeParameters($p, true);
}
// Check for q= query string, used whenever this special page calls itself (via submit or plain link):
$this->m_querystring = $wgRequest->getText('q');
if ($this->m_querystring !== '') {
$rawparams[] = $this->m_querystring;
}
// Check for param strings in po (printouts), appears in some links and in submits:
$paramstring = $wgRequest->getText('po');
if ($paramstring !== '') {
// parameters from HTML input fields
$ps = explode("\n", $paramstring);
// params separated by newlines here (compatible with text-input for printouts)
foreach ($ps as $param) {
// add initial ? if omitted (all params considered as printouts)
$param = trim($param);
if ($param !== '' && $param[0] != '?') {
$param = '?' . $param;
}
$rawparams[] = $param;
}
}
// Now parse parameters and rebuilt the param strings for URLs.
SMWQueryProcessor::processFunctionParams($rawparams, $this->m_querystring, $this->m_params, $this->m_printouts);
// Try to complete undefined parameter values from dedicated URL params.
if (!array_key_exists('format', $this->m_params)) {
$this->m_params['format'] = 'broadtable';
}
if (!array_key_exists('order', $this->m_params)) {
$order_values = $wgRequest->getArray('order');
if (is_array($order_values)) {
$this->m_params['order'] = '';
foreach ($order_values as $order_value) {
if ($order_value === '') {
$order_value = 'ASC';
}
$this->m_params['order'] .= ($this->m_params['order'] !== '' ? ',' : '') . $order_value;
}
}
}
$this->m_num_sort_values = 0;
if (!array_key_exists('sort', $this->m_params)) {
$sort_values = $wgRequest->getArray('sort');
if (is_array($sort_values)) {
$this->m_params['sort'] = implode(',', $sort_values);
$this->m_num_sort_values = count($sort_values);
}
}
if (!array_key_exists('offset', $this->m_params)) {
$this->m_params['offset'] = $wgRequest->getVal('offset');
if ($this->m_params['offset'] === '') {
$this->m_params['offset'] = 0;
}
}
if (!array_key_exists('limit', $this->m_params)) {
$this->m_params['limit'] = $wgRequest->getVal('limit');
if ($this->m_params['limit'] === '') {
$this->m_params['limit'] = $this->m_params['format'] == 'rss' ? 10 : 20;
// Standard limit for RSS.
}
}
$this->m_params['limit'] = min($this->m_params['limit'], $smwgQMaxInlineLimit);
$this->m_editquery = $wgRequest->getVal('eq') == 'yes' || $this->m_querystring === '';
}
示例7: extractQueryParameters
protected function extractQueryParameters($p)
{
// This code rather hacky since there are many ways to call that special page, the most involved of
// which is the way that this page calls itself when data is submitted via the form (since the shape
// of the parameters then is governed by the UI structure, as opposed to being governed by reason).
global $wgRequest, $smwgIP;
// First make all inputs into a simple parameter list that can again be parsed into components later.
if ($wgRequest->getCheck('q')) {
// called by own Special, ignore full param string in that case
$rawparams = SMWInfolink::decodeParameters($wgRequest->getVal('p'), false);
// p is used for any additional parameters in certain links
} else {
// called from wiki, get all parameters
$rawparams = SMWInfolink::decodeParameters($p, true);
}
// Check for q= query string, used whenever this special page calls itself (via submit or plain link):
$this->m_querystring = $wgRequest->getText('q');
if ($this->m_querystring != '') {
$rawparams[] = $this->m_querystring;
}
// Check for param strings in po (printouts), appears in some links and in submits:
$paramstring = $wgRequest->getText('po');
if ($paramstring != '') {
// parameters from HTML input fields
$ps = explode("\n", $paramstring);
// params separated by newlines here (compatible with text-input for printouts)
foreach ($ps as $param) {
// add initial ? if omitted (all params considered as printouts)
$param = trim($param);
if ($param != '' && $param[0] != '?') {
$param = '?' . $param;
}
$rawparams[] = $param;
}
}
// Now parse parameters and rebuilt the param strings for URLs
include_once "{$smwgIP}/includes/SMW_QueryProcessor.php";
SMWQueryProcessor::processFunctionParams($rawparams, $this->m_querystring, $this->m_params, $this->m_printouts);
// Try to complete undefined parameter values from dedicated URL params
if (!array_key_exists('format', $this->m_params)) {
if (array_key_exists('rss', $this->m_params)) {
// backwards compatibility (SMW<=1.1 used this)
$this->m_params['format'] = 'rss';
} else {
// default
$this->m_params['format'] = 'broadtable';
}
}
$sortcount = $wgRequest->getVal('sc');
if (!is_numeric($sortcount)) {
$sortcount = 0;
}
if (!array_key_exists('order', $this->m_params)) {
$this->m_params['order'] = $wgRequest->getVal('order');
// basic ordering parameter (, separated)
for ($i = 0; $i < $sortcount; $i++) {
if ($this->m_params['order'] != '') {
$this->m_params['order'] .= ',';
}
$value = $wgRequest->getVal('order' . $i);
$value = $value == '' ? 'ASC' : $value;
$this->m_params['order'] .= $value;
}
}
if (!array_key_exists('sort', $this->m_params)) {
$this->m_params['sort'] = $wgRequest->getText('sort');
// basic sorting parameter (, separated)
for ($i = 0; $i < $sortcount; $i++) {
if ($this->m_params['sort'] != '' || $i > 0) {
// admit empty sort strings here
$this->m_params['sort'] .= ',';
}
$this->m_params['sort'] .= $wgRequest->getText('sort' . $i);
}
}
// Find implicit ordering for RSS -- needed for downwards compatibility with SMW <=1.1
if ($this->m_params['format'] == 'rss' && $this->m_params['sort'] == '' && $sortcount == 0) {
foreach ($this->m_printouts as $printout) {
if (strtolower($printout->getLabel()) == "date" && $printout->getTypeID() == "_dat") {
$this->m_params['sort'] = $printout->getTitle()->getText();
$this->m_params['order'] = 'DESC';
}
}
}
if (!array_key_exists('offset', $this->m_params)) {
$this->m_params['offset'] = $wgRequest->getVal('offset');
if ($this->m_params['offset'] == '') {
$this->m_params['offset'] = 0;
}
}
if (!array_key_exists('limit', $this->m_params)) {
$this->m_params['limit'] = $wgRequest->getVal('limit');
if ($this->m_params['limit'] == '') {
$this->m_params['limit'] = $this->m_params['format'] == 'rss' ? 10 : 20;
// standard limit for RSS
}
}
$this->m_editquery = $wgRequest->getVal('eq') != '' || '' == $this->m_querystring;
}
示例8: notifyUsers
public function notifyUsers() {
global $wgSitename, $wgSMTP, $wgEmergencyContact, $wgEnotifyMeJob;
$sStore = NMStorage::getDatabase();
$nm_send_jobs = array();
$id = 0;
if ( count( $this->m_notifyHtmlMsgs ) > 0 ) {
$notifications = $sStore->getNotifyMe( array_keys( $this->m_notifyHtmlMsgs ) );
}
$html_style = '';
// <style>
// table.smwtable{background-color: #EEEEFF;}
// table.smwtable th{background-color: #EEEEFF;text-align: left;}
// table.smwtable td{background-color: #FFFFFF;padding: 1px;padding-left: 5px;padding-right: 5px;text-align: left;vertical-align: top;}
// table.smwtable tr.smwfooter td{font-size: 90%;line-height: 1;background-color: #EEEEFF;padding: 0px;padding-left: 5px;padding-right: 5px;text-align: right;vertical-align: top;}
// </style>';
$html_showall = array();
foreach ( $this->m_notifyHtmlMsgs as $notify_id => $msg ) {
$html_msg = $html_style;
$showing_all = false;
if ( isset( $notifications[$notify_id] ) && $notifications[$notify_id]['show_all'] ) {
SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $notifications[$notify_id]['query'] ), $querystring, $params, $printouts );
$format = 'auto';
if ( array_key_exists( 'format', $params ) ) {
$format = strtolower( trim( $params['format'] ) );
global $smwgResultFormats;
if ( !array_key_exists( $format, $smwgResultFormats ) ) {
$format = 'auto';
}
}
$query = SMWQueryProcessor::createQuery( $querystring, $params, SMWQueryProcessor::INLINE_QUERY, $format, $printouts );
$res = smwfGetStore()->getQueryResult( $query );
$printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::INLINE_QUERY, $res );
$result = $printer->getResult( $res, $params, SMW_OUTPUT_HTML );
// FIXME: hardcode switch to full url
global $wgScriptPath, $wgServer;
$result = str_replace ( $wgScriptPath, $wgServer . $wgScriptPath, $result );
$html_msg .= $result . '<br/>';
$html_showall[$notify_id] = array ( 'name' => $notifications[$notify_id]['name'], 'html' => $result );
$showing_all = true;
$link = $res->getQueryLink()->getURL();
}
global $smwgNMHideDiffWhenShowAll;
if ( !( $smwgNMHideDiffWhenShowAll && $showing_all ) ) {
$html_msg .= wfMsg( 'smw_nm_hint_notification_html', $this->m_notifyHtmlMsgs[$notify_id] );
if ( isset( $this->m_notifyHtmlPropMsgs[$notify_id] ) ) {
$html_msg .= wfMsg( 'smw_nm_hint_nmtable_html', $this->m_notifyHtmlPropMsgs[$notify_id] );
}
}
if ( $showing_all ) {
$id = $sStore->addNotifyRSS( 'nid', $notify_id, "All current items, " . date( 'Y-m-d H:i:s', time() ), $this->applyStyle( $html_msg ), $link );
} else {
$id = $sStore->addNotifyRSS( 'nid', $notify_id, $this->m_title->getText(), $this->applyStyle( $html_msg ) );
}
}
foreach ( $this->m_userMsgs as $user_id => $msg ) {
// generate RSS items
$html_msg = $html_style;
foreach ( array_unique( $this->m_userNMs[$user_id] ) as $showall_nid ) {
if ( isset( $html_showall[$showall_nid] ) ) {
$html_msg .= wfMsg( 'smw_nm_hint_item_html', $html_showall[$showall_nid]['name'], $html_showall[$showall_nid]['html'] );
}
}
$html_msg .= wfMsg( 'smw_nm_hint_notification_html', $this->m_userHtmlNMMsgs[$user_id] );
if ( isset( $this->m_userHtmlPropMsgs[$user_id] ) ) {
$html_msg .= wfMsg( 'smw_nm_hint_nmtable_html', $this->m_userHtmlPropMsgs[$user_id] );
}
global $wgNMReportModifier, $wgUser;
if ( $wgNMReportModifier ) {
$userText = $wgUser->getName();
if ( $wgUser->getId() == 0 ) {
$page = SpecialPage::getTitleFor( 'Contributions', $userText );
} else {
$page = Title::makeTitle( NS_USER, $userText );
}
$l = '<a href="' . $page->getFullUrl() . '">' . htmlspecialchars( $userText ) . '</a>';
$html_msg .= wfMsg( 'smw_nm_hint_modifier_html', $l );
$msg .= wfMsg( 'smw_nm_hint_modifier', $wgUser->getName() );
}
$id = $sStore->addNotifyRSS( 'uid', $user_id, $this->m_title->getText(), $this->applyStyle( $html_msg ) );
if ( $wgEnotifyMeJob ) {
// send notifications by mail
$user_info = $sStore->getUserInfo( $user_id );
$user = User::newFromRow( $user_info );
if ( ( $user_info->user_email != '' ) && $user->getOption( 'enotifyme' ) ) {
$name = ( ( $user_info->user_real_name == '' ) ? $user_info->user_name:$user_info->user_real_name );
$params = array( 'to' => new MailAddress( $user_info->user_email, $name ),
'from' => new MailAddress( $wgEmergencyContact, 'Admin' ),
'subj' => wfMsg( 'smw_nm_hint_mail_title', $this->m_title->getText(), $wgSitename ),
'body' => wfMsg( 'smw_nm_hint_mail_body', $name, $msg ),
'replyto' => new MailAddress( $wgEmergencyContact, 'Admin' ) );
//.........这里部分代码省略.........
示例9: getSemanticQuery
/**
*
* @param <String> $query (e.g. [[ChangeSet:+]][[inPullFeed::Pullfeed:xxxxx]])
* @param <String> $paramstring Printout parameters (e.g. ?hasPatch?changeSetID)
* @return <Object> SMWQueryResult object
*/
public static function getSemanticQuery($query, $paramstring = '')
{
$printouts = array();
$rawparams = array();
$params = array('format' => ' ', 'sort' => ' ', 'offset' => 0);
$rawparams[] = $query;
if ($paramstring != '') {
$ps = explode("\n", $paramstring);
foreach ($ps as $param) {
$param = trim($param);
if ($param != '' && $param[0] != '?') {
$param = '?' . $param;
}
$rawparams[] = $param;
}
}
SMWQueryProcessor::processFunctionParams($rawparams, $query, $params, $printouts);
$queryobj = SMWQueryProcessor::createQuery($query, $params, SMWQueryProcessor::SPECIAL_PAGE, '', $printouts);
$queryobj->setLimit(5000);
$res = smwfGetStore()->getQueryResult($queryobj);
if (!$res instanceof SMWQueryResult) {
return false;
}
return $res;
}
示例10: 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);
}
示例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: 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' );
}
//.........这里部分代码省略.........
示例13: 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);
}
示例14: 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;
}
示例15: ask
/**
* #ask itself.
* Delegate the treatments to SMWQueryProcessor
*
* @var SMWQueryProcessor
* @param <type> $m_querystring
* @param <type> $props
* @return <type>
*/
private function ask($m_querystring, $props = array(), $limit = null, $offset = 0)
{
$rawparams = array();
if ($m_querystring != '') {
$rawparams[] = $m_querystring;
}
foreach ($props as $prop) {
$prop = trim($prop);
if ($prop != '' && $prop != '?') {
if ($prop[0] != '?') {
$prop = '?' . $prop;
}
$rawparams[] = $prop;
}
}
$m_params = array();
$m_printouts = array();
SMWQueryProcessor::processFunctionParams($rawparams, $m_querystring, $m_params, $m_printouts);
$m_params['offset'] = $offset;
if (!is_null($limit)) {
$m_params['limit'] = $limit;
}
$queryobj = SMWQueryProcessor::createQuery($m_querystring, $m_params, SMWQueryProcessor::SPECIAL_PAGE, null, $m_printouts);
return smwfGetStore()->getQueryResult($queryobj);
}