当前位置: 首页>>代码示例>>PHP>>正文


PHP SMWQuery::setQueryString方法代码示例

本文整理汇总了PHP中SMWQuery::setQueryString方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQuery::setQueryString方法的具体用法?PHP SMWQuery::setQueryString怎么用?PHP SMWQuery::setQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMWQuery的用法示例。


在下文中一共展示了SMWQuery::setQueryString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: enableNotify

	/**
	 * Enable a NotifyMe with specified id and querystring
	 *
	 * used for inline query only
	 */
	static public function enableNotify( $notify_id, $querystring, &$msg = NULL ) {
		wfProfileIn( 'SMWNotifyProcessor::enableNotify (SMW)' );

		$sStore = NMStorage::getDatabase();
		global $smwgQDefaultNamespaces;

		SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $querystring ), $querystring, $params, $printouts );
		$relatedArticles = array();
		foreach ( $printouts as $po ) {
			$printoutArticles[] = array(
				'namespace' => SMW_NS_PROPERTY,
				'title' => Title::makeTitle( SMW_NS_PROPERTY, $po->getText( SMW_OUTPUT_WIKI ) )->getDBkey() );
		}

		$qp = new SMWNotifyParser( $notify_id, $printoutArticles );
		$qp->setDefaultNamespaces( $smwgQDefaultNamespaces );
		$desc = $qp->getQueryDescription( $querystring );

		if ( !$qp->m_result ) {
			$qp->m_errors[] = wfMsg( 'smw_nm_proc_pagenotexist' );
		}

		if ( isset( $msg ) && $qp->hasSubquery() ) {
			$msg .= "\n" . wfMsg( 'smw_nm_proc_subqueryhint' );
		}

		$query = new SMWQuery( $desc, true, false );
		$query->setQueryString( $querystring );
		$query->addErrors( $qp->getErrors() ); // keep parsing errors for later output

		$res = $sStore->getNMQueryResult( $query );

		if ( count( $query->getErrors() ) > 0 ) {
			if ( isset( $msg ) ) {
				$msg .= "\n\n" . implode( '\n', $query->getErrors() ) . "\n\n" . wfMsg( 'smw_nm_proc_enablehint' );
			}
			$sStore->disableNotifyState( $notify_id );
			wfProfileOut( 'SMWNotifyProcessor::enableNotify (SMW)' );
			return false;
		}

		$sStore->updateNMSql( $notify_id, $res['sql'], $res['tmp_hierarchy'] );
		if ( count( $res['page_ids'] ) > 0 ) {
			$add_monitor = array();
			foreach ( $res['page_ids'] as $page_id ) {
				$add_monitor[] = array( 'notify_id' => $notify_id, 'page_id' => $page_id );
			}
			$sStore->addNotifyMonitor( $add_monitor );
		}
		$sStore->updateNotifyState( $notify_id, 1 );
		wfProfileOut( 'SMWNotifyProcessor::enableNotify (SMW)' );

		return true;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:59,代码来源:SMW_NotifyProcessor.smw15.php

示例2: createQuery

 /**
  * Parse a query string given in SMW's query language to create
  * an SMWQuery. Parameters are given as key-value-pairs in the
  * given array. The parameter $context defines in what context the
  * query is used, which affects ceretain general settings.
  * An object of type SMWQuery is returned.
  *
  * The format string is used to specify the output format if already
  * known. Otherwise it will be determined from the parameters when
  * needed. This parameter is just for optimisation in a common case.
  *
  * @param string $queryString
  * @param array $params These need to be the result of a list fed to getProcessedParams
  * @param $context
  * @param string $format
  * @param array $extraPrintouts
  *
  * @return SMWQuery
  */
 public static function createQuery($queryString, array $params, $context = self::INLINE_QUERY, $format = '', array $extraPrintouts = array())
 {
     global $smwgQDefaultNamespaces, $smwgQFeatures, $smwgQConceptFeatures;
     // parse query:
     $queryfeatures = $context == self::CONCEPT_DESC ? $smwgQConceptFeatures : $smwgQFeatures;
     $qp = new SMWQueryParser($queryfeatures);
     $qp->setDefaultNamespaces($smwgQDefaultNamespaces);
     $desc = $qp->getQueryDescription($queryString);
     if ($format === '' || is_null($format)) {
         $format = $params['format']->getValue();
     }
     if ($format == 'count') {
         $querymode = SMWQuery::MODE_COUNT;
     } elseif ($format == 'debug') {
         $querymode = SMWQuery::MODE_DEBUG;
     } else {
         $printer = self::getResultPrinter($format, $context);
         $querymode = $printer->getQueryMode($context);
     }
     $query = new SMWQuery($desc, $context != self::SPECIAL_PAGE, $context == self::CONCEPT_DESC);
     $query->setQueryString($queryString);
     $query->setExtraPrintouts($extraPrintouts);
     $query->setMainLabel($params['mainlabel']->getValue());
     $query->addErrors($qp->getErrors());
     // keep parsing errors for later output
     // set mode, limit, and offset:
     $query->querymode = $querymode;
     if (array_key_exists('offset', $params) && is_int($params['offset']->getValue() + 0)) {
         $query->setOffset(max(0, trim($params['offset']->getValue()) + 0));
     }
     if ($query->querymode == SMWQuery::MODE_COUNT) {
         // largest possible limit for "count", even inline
         global $smwgQMaxLimit;
         $query->setOffset(0);
         $query->setLimit($smwgQMaxLimit, false);
     } else {
         if (array_key_exists('limit', $params) && is_int(trim($params['limit']->getValue()) + 0)) {
             $query->setLimit(max(0, trim($params['limit']->getValue()) + 0));
             if (trim($params['limit']->getValue()) + 0 < 0) {
                 // limit < 0: always show further results link only
                 $query->querymode = SMWQuery::MODE_NONE;
             }
         } else {
             global $smwgQDefaultLimit;
             $query->setLimit($smwgQDefaultLimit);
         }
     }
     $defaultSort = $format === 'rss' ? 'DESC' : 'ASC';
     $sort = self::getSortKeys($params['sort']->getValue(), $params['order']->getValue(), $defaultSort);
     $query->sortkeys = $sort['keys'];
     $query->addErrors($sort['errors']);
     $query->sort = count($query->sortkeys) > 0;
     // TODO: Why would we do this here?
     return $query;
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:74,代码来源:SMW_QueryProcessor.php


注:本文中的SMWQuery::setQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。