本文整理汇总了PHP中SMWQuery类的典型用法代码示例。如果您正苦于以下问题:PHP SMWQuery类的具体用法?PHP SMWQuery怎么用?PHP SMWQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMWQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getStringFrom
/**
* Generate textual debug output that shows an arbitrary list of informative
* fields. Used for formatting query debug output.
*
* @note All strings given must be usable and safe in wiki and HTML
* contexts.
*
* @param $storeName string name of the storage backend for which this is generated
* @param $entries array of name => value of informative entries to display
* @param $query SMWQuery or null, if given add basic data about this query as well
*
* @return string
*/
public static function getStringFrom($storeName, array $entries, Query $query = null)
{
if ($query instanceof Query) {
$preEntries = array();
$preEntries['ASK Query'] = '<div class="smwpre">' . str_replace('[', '[', $query->getDescription()->getQueryString()) . '</div>';
$entries = array_merge($preEntries, $entries);
$entries['Query Metrics'] = 'Query-Size:' . $query->getDescription()->getSize() . '<br />' . 'Query-Depth:' . $query->getDescription()->getDepth();
$errors = '';
$queryErrors = ProcessingErrorMsgHandler::normalizeMessages($query->getErrors());
foreach ($queryErrors as $error) {
$errors .= $error . '<br />';
}
if ($errors === '') {
$errors = 'None';
}
$entries['Errors and Warnings'] = $errors;
}
$result = '<div style="border: 5px dotted #ffcc00; background: #FFF0BD; padding: 20px; ">' . "<div class='smw-column-header'><big>{$storeName} debug output</big></div>";
foreach ($entries as $header => $information) {
$result .= "<div class='smw-column-header'>{$header}</div>";
if ($information !== '') {
$result .= "{$information}";
}
}
$result .= '</div>';
return $result;
}
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:40,代码来源:DebugOutputFormatter.php
示例2: formatOutputFor
/**
* Generate textual debug output that shows an arbitrary list of informative
* fields. Used for formatting query debug output.
*
* @note All strings given must be usable and safe in wiki and HTML
* contexts.
*
* @param $storeName string name of the storage backend for which this is generated
* @param $entries array of name => value of informative entries to display
* @param $query SMWQuery or null, if given add basic data about this query as well
*
* @return string
*/
public static function formatOutputFor($storeName, array $entries, Query $query = null)
{
if ($query instanceof Query) {
$preEntries = array();
$preEntries['Ask query'] = '<div class="smwpre">' . str_replace('[', '[', $query->getDescription()->getQueryString()) . '</div>';
$entries = array_merge($preEntries, $entries);
$entries['Query Metrics'] = 'Query-Size:' . $query->getDescription()->getSize() . '<br />' . 'Query-Depth:' . $query->getDescription()->getDepth();
$errors = '';
foreach ($query->getErrors() as $error) {
$errors .= $error . '<br />';
}
if ($errors === '') {
$errors = 'None';
}
$entries['Errors and Warnings'] = $errors;
}
$result = '<div style="border: 5px dotted #A1FB00; background: #FFF0BD; padding: 20px; ">' . "<h3>Debug Output by {$storeName}</h3>";
foreach ($entries as $header => $information) {
$result .= "<h4>{$header}</h4>";
if ($information !== '') {
$result .= "{$information}";
}
}
$result .= '</div>';
return $result;
}
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:39,代码来源:DebugOutputFormatter.php
示例3: addQueryData
/**
* Add data about the query and its parameters to the semantic data of
* the given parser. The $queryKey is a string key that uniquely
* identifies the query; this is difficult to create in a stable way
* from the processed query object and parameters, but easy to get from
* the raw user input.
*
* @param string $queryKey
* @param SMWQuery $query
* @param array $params
* @param Parser $parser
*
* @since 1.8
*/
public static function addQueryData($queryKey, SMWQuery $query, array $params, Parser $parser)
{
$mainSemanticData = SMWParseData::getSMWData($parser);
$subject = $mainSemanticData->getSubject();
$diSubWikiPage = new SMWDIWikiPage($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), "_QUERY" . $queryKey);
$semanticData = new SMWContainerSemanticData($diSubWikiPage);
$description = $query->getDescription();
// Add query string
$propertyDi = new SMWDIProperty('_ASKST');
$valueDi = new SMWDIBlob($description->getQueryString());
$semanticData->addPropertyObjectValue($propertyDi, $valueDi);
// Add query size
$propertyDi = new SMWDIProperty('_ASKSI');
$valueDi = new SMWDINumber($description->getSize());
$semanticData->addPropertyObjectValue($propertyDi, $valueDi);
// Add query depth
$propertyDi = new SMWDIProperty('_ASKDE');
$valueDi = new SMWDINumber($description->getDepth());
$semanticData->addPropertyObjectValue($propertyDi, $valueDi);
// Add query format
$propertyDi = new SMWDIProperty('_ASKFO');
$valueDi = new SMWDIString($params['format']->getValue());
$semanticData->addPropertyObjectValue($propertyDi, $valueDi);
$propertyDi = new SMWDIProperty('_ASK');
$subObjectDi = new SMWDIContainer($semanticData);
SMWParseData::getSMWData($parser)->addPropertyObjectValue($propertyDi, $subObjectDi);
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:41,代码来源:SMW_Ask.php
示例4: testGetImmediateEmptyQueryResultForLimitLessThanOne
public function testGetImmediateEmptyQueryResultForLimitLessThanOne()
{
$connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
$this->store->expects($this->never())->method('getConnection')->will($this->returnValue($connection));
$this->querySegmentListBuilder->expects($this->any())->method('getErrors')->will($this->returnValue(array()));
$description = $this->getMockForAbstractClass('\\SMW\\Query\\Language\\Description');
$instance = new QueryEngine($this->store, $this->querySegmentListBuilder, $this->querySegmentListProcessor, $this->engineOptions);
$query = new Query($description);
$query->setUnboundLimit(-1);
$this->assertInstanceOf('\\SMWQueryResult', $instance->getQueryResult($query));
}
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:11,代码来源:QueryEngineTest.php
示例5: 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
示例6: testEmptyGetQueryResultWhereQueryContainsErrors
public function testEmptyGetQueryResultWhereQueryContainsErrors()
{
$connection = $this->getMockBuilder('\\SMW\\SPARQLStore\\RepositoryConnection')->disableOriginalConstructor()->getMockForAbstractClass();
$store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$compoundConditionBuilder = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\CompoundConditionBuilder')->disableOriginalConstructor()->getMock();
$description = $this->getMockForAbstractClass('\\SMW\\Query\\Language\\Description');
$engineOptions = new EngineOptions();
$engineOptions->set('smwgIgnoreQueryErrors', false);
$instance = new QueryEngine($connection, $compoundConditionBuilder, new QueryResultFactory($store), $engineOptions);
$query = new Query($description);
$query->addErrors(array('Foo'));
$this->assertInstanceOf('\\SMWQueryResult', $instance->getQueryResult($query));
$this->assertEmpty($instance->getQueryResult($query)->getResults());
}
开发者ID:Rikuforever,项目名称:wiki,代码行数:14,代码来源:QueryEngineTest.php
示例7: testNullQueryResult
public function testNullQueryResult()
{
$term = '[[Some_string_to_query]]';
$description = new ValueDescription(new DIWikiPage($term, NS_MAIN), null);
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
$description = $query->getDescription();
$namespacesDisjunction = new Disjunction(array_map(function ($ns) {
return new NamespaceDescription($ns);
}, array(NS_MAIN)));
$description = new Conjunction(array($description, $namespacesDisjunction));
$query->setDescription($description);
$this->assertInstanceOf('\\SMWQueryResult', ApplicationFactory::getInstance()->getStore()->getQueryResult($query));
}
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:14,代码来源:NullQueryResultTest.php
示例8: toArray
/**
* Returns a serialized SMWQueryResult object with additional meta data
*
* This methods extends the serializeToArray() for additional meta
* that are useful when handling data via the api
*
* @note should be used instead of SMWQueryResult::serializeToArray()
* as this method contains additional informaion
*
* @since 1.9
*
* @return array
*/
public function toArray()
{
// @note micro optimization: We call getSerializedQueryResult()
// only once and create the hash here instead of calling getHash()
// to avoid getSerializedQueryResult() being called again
// @note count + offset equals total therefore we deploy both values
$serializeArray = $this->serializeToArray();
return array_merge($serializeArray, array('meta' => array('hash' => md5(FormatJson::encode($serializeArray)), 'count' => $this->getCount(), 'offset' => $this->mQuery->getOffset())));
}
开发者ID:Rikuforever,项目名称:wiki,代码行数:22,代码来源:SMW_QueryResult.php
示例9: toArray
/**
* Returns a serialized SMWQueryResult object with additional meta data
*
* This methods extends the serializeToArray() for additional meta
* that are useful when handling data via the api
*
* @note should be used instead of SMWQueryResult::serializeToArray()
* as this method contains additional informaion
*
* @since 1.9
*
* @return array
*/
public function toArray()
{
$time = microtime(true);
// @note micro optimization: We call getSerializedQueryResult()
// only once and create the hash here instead of calling getHash()
// to avoid getSerializedQueryResult() being called again
// @note count + offset equals total therefore we deploy both values
$serializeArray = $this->serializeToArray();
return array_merge($serializeArray, array('meta' => array('hash' => HashBuilder::createHashIdForContent($serializeArray), 'count' => $this->getCount(), 'offset' => $this->mQuery->getOffset(), 'source' => $this->mQuery->getQuerySource(), 'time' => number_format(microtime(true) - $time, 6, '.', ''))));
}
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:23,代码来源:SMW_QueryResult.php
示例10: getLink
/**
* Returns an SMWInfolink object with the QueryResults print requests as parameters.
*
* @since 1.8
*
* @return SMWInfolink
*/
public function getLink()
{
$params = array(trim($this->mQuery->getQueryString()));
foreach ($this->mQuery->getExtraPrintouts() as $printout) {
$serialization = $printout->getSerialisation();
// TODO: this is a hack to get rid of the mainlabel param in case it was automatically added
// by SMWQueryProcessor::addThisPrintout. Should be done nicer when this link creation gets redone.
if ($serialization !== '?#') {
$params[] = $serialization;
}
}
// Note: the initial : prevents SMW from reparsing :: in the query string.
return SMWInfolink::newInternalLink('', ':Special:Ask', false, $params);
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:21,代码来源:SMW_QueryResult.php
示例11: getQueryLink
/**
* Create an SMWInfolink object representing a link to further query results.
* This link can then be serialised or extended by further params first.
* The optional $caption can be used to set the caption of the link (though this
* can also be changed afterwards with SMWInfolink::setCaption()). If empty, the
* message 'smw_iq_moreresults' is used as a caption.
*
* TODO: have this work for all params without manually overriding and adding everything
* (this is possible since the param handling changes in 1.7)
*
* @param string|false $caption
*
* @return SMWInfolink
*/
public function getQueryLink($caption = false)
{
$params = array(trim($this->mQuery->getQueryString()));
foreach ($this->mQuery->getExtraPrintouts() as $printout) {
$serialization = $printout->getSerialisation();
// TODO: this is a hack to get rid of the mainlabel param in case it was automatically added
// by SMWQueryProcessor::addThisPrintout. Should be done nicer when this link creation gets redone.
if ($serialization !== '?#') {
$params[] = $serialization;
}
}
if ($this->mQuery->getMainLabel() !== false) {
$params['mainlabel'] = $this->mQuery->getMainLabel();
}
$params['offset'] = $this->mQuery->getOffset() + count($this->mResults);
if ($params['offset'] === 0) {
unset($params['offset']);
}
if ($this->mQuery->getLimit() > 0) {
$params['limit'] = $this->mQuery->getLimit();
}
if (count($this->mQuery->sortkeys) > 0) {
$order = implode(',', $this->mQuery->sortkeys);
$sort = implode(',', array_keys($this->mQuery->sortkeys));
if ($sort !== '' || $order != 'ASC') {
$params['order'] = $order;
$params['sort'] = $sort;
}
}
if ($caption == false) {
$caption = ' ' . wfMsgForContent('smw_iq_moreresults');
// The space is right here, not in the QPs!
}
// Note: the initial : prevents SMW from reparsing :: in the query string.
$result = SMWInfolink::newInternalLink($caption, ':Special:Ask', false, $params);
return $result;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:51,代码来源:SMW_QueryResult.php
示例12: 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
示例13: serializePage
//.........这里部分代码省略.........
foreach ($additionalDataArray as $additionalData) {
$this->serializer->serializeExpData($additionalData);
// serialise
}
if ($recursiondepth != 0) {
$subrecdepth = $recursiondepth > 0 ? $recursiondepth - 1 : ($recursiondepth == 0 ? 0 : -1);
foreach ($expData->getProperties() as $property) {
if ($property->getDataItem() instanceof SMWWikiPageValue) {
$this->queuePage($property->getDataItem(), 0);
// no real recursion along properties
}
$wikipagevalues = false;
foreach ($expData->getValues($property) as $valueExpElement) {
$valueResource = $valueExpElement instanceof SMWExpData ? $valueExpElement->getSubject() : $valueExpElement;
if (!$wikipagevalues && $valueResource->getDataItem() instanceof SMWWikiPageValue) {
$wikipagevalues = true;
} elseif (!$wikipagevalues) {
break;
}
$this->queuePage($valueResource->getDataItem(), $subrecdepth);
}
}
// Add backlinks:
// Note: Backlinks are different from recursive serialisations, since
// stub declarations (recdepth==0) still need to have the property that
// links back to the object. So objects that would be exported with
// recdepth 0 cannot be put into the main queue but must be done right
// away. They also might be required many times, if they link back to
// many different objects in many ways (we cannot consider them "Done"
// if they were serialised at recdepth 0 only).
if ($this->add_backlinks) {
$inprops = \SMW\StoreFactory::getStore()->getInProperties($diWikiPage);
foreach ($inprops as $inprop) {
$propWikiPage = $inprop->getCanonicalDiWikiPage();
if (!is_null($propWikiPage)) {
$this->queuePage($propWikiPage, 0);
// no real recursion along properties
}
$inSubs = \SMW\StoreFactory::getStore()->getPropertySubjects($inprop, $diWikiPage);
foreach ($inSubs as $inSub) {
if (!$this->isPageDone($inSub, $subrecdepth)) {
$semdata = $this->getSemanticData($inSub, true);
if (!$semdata instanceof SMWSemanticData) {
continue;
}
$semdata->addPropertyObjectValue($inprop, $diWikiPage);
$expData = SMWExporter::getInstance()->makeExportData($semdata);
$this->serializer->serializeExpData($expData, $subrecdepth);
}
}
}
if (NS_CATEGORY === $diWikiPage->getNamespace()) {
// also print elements of categories
$options = new SMWRequestOptions();
$options->limit = 100;
// Categories can be large, always use limit
$instances = \SMW\StoreFactory::getStore()->getPropertySubjects(new SMW\DIProperty('_INST'), $diWikiPage, $options);
$pinst = new SMW\DIProperty('_INST');
foreach ($instances as $instance) {
if (!array_key_exists($instance->getHash(), $this->element_done)) {
$semdata = $this->getSemanticData($instance, true);
if (!$semdata instanceof SMWSemanticData) {
continue;
}
$semdata->addPropertyObjectValue($pinst, $diWikiPage);
$expData = SMWExporter::getInstance()->makeExportData($semdata);
$this->serializer->serializeExpData($expData, $subrecdepth);
}
}
} elseif (SMW_NS_CONCEPT === $diWikiPage->getNamespace()) {
// print concept members (slightly different code)
$desc = new SMWConceptDescription($diWikiPage);
$desc->addPrintRequest(new PrintRequest(PrintRequest::PRINT_THIS, ''));
$query = new SMWQuery($desc);
$query->setLimit(100);
$res = \SMW\StoreFactory::getStore()->getQueryResult($query);
$resarray = $res->getNext();
$pinst = new SMW\DIProperty('_INST');
while ($resarray !== false) {
$instance = end($resarray)->getNextDataItem();
if (!$instance instanceof \SMWDataItem) {
$resarray = $res->getNext();
continue;
}
if (!array_key_exists($instance->getHash(), $this->element_done)) {
$semdata = $this->getSemanticData($instance, true);
if (!$semdata instanceof \SMW\SemanticData) {
$resarray = $res->getNext();
continue;
}
$semdata->addPropertyObjectValue($pinst, $diWikiPage);
$expData = SMWExporter::getInstance()->makeExportData($semdata);
$this->serializer->serializeExpData($expData);
}
$resarray = $res->getNext();
}
}
}
}
}
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:101,代码来源:SMW_ExportController.php
示例14: getSparqlOptions
/**
* Get a SPARQL option array for the given query.
*
* @param SMWQuery $query
* @param SMWSparqlCondition $sparqlCondition (storing order by variable names)
* @return array
*/
protected function getSparqlOptions(SMWQuery $query, SMWSparqlCondition $sparqlCondition)
{
global $smwgQSortingSupport, $smwgQRandSortingSupport;
$result = array('LIMIT' => $query->getLimit() + 1, 'OFFSET' => $query->getOffset());
// Build ORDER BY options using discovered sorting fields.
if ($smwgQSortingSupport) {
$orderByString = '';
foreach ($this->m_sortkeys as $propkey => $order) {
if ($order != 'RANDOM' && array_key_exists($propkey, $sparqlCondition->orderVariables)) {
$orderByString .= "{$order}(?" . $sparqlCondition->orderVariables[$propkey] . ") ";
} elseif ($order == 'RANDOM' && $smwgQRandSortingSupport) {
// not supported in SPARQL; might be possible via function calls in some stores
}
}
if ($orderByString !== '') {
$result['ORDER BY'] = $orderByString;
}
}
return $result;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:SMW_SparqlStoreQueryEngine.php
示例15: getSQLOptions
/**
* Get a SQL option array for the given query and preprocessed query object at given id.
*
* @param SMWQuery $query
* @param integer $rootid
*/
protected function getSQLOptions(SMWQuery $query, $rootid)
{
global $smwgQSortingSupport, $smwgQRandSortingSupport;
$result = array('LIMIT' => $query->getLimit() + 1, 'OFFSET' => $query->getOffset());
// Build ORDER BY options using discovered sorting fields.
if ($smwgQSortingSupport) {
$qobj = $this->m_queries[$rootid];
foreach ($this->m_sortkeys as $propkey => $order) {
if ($order != 'RANDOM' && array_key_exists($propkey, $qobj->sortfields)) {
// Field was successfully added.
$result['ORDER BY'] = (array_key_exists('ORDER BY', $result) ? $result['ORDER BY'] . ', ' : '') . $qobj->sortfields[$propkey] . " {$order} ";
} elseif ($order == 'RANDOM' && $smwgQRandSortingSupport) {
$result['ORDER BY'] = (array_key_exists('ORDER BY', $result) ? $result['ORDER BY'] . ', ' : '') . ' RAND() ';
}
}
}
return $result;
}
开发者ID:seedbank,项目名称:old-repo,代码行数:24,代码来源:SMW_SQLStore3_Queries.php
示例16: getQuery
/**
* Make SMWQuery suitable for obtaining a list of results based on the
* given description, limit, and from or until string. One more result
* than the limit will be created, and the results may have to be
* reversed in order if $until is nonempty.
*
* @param $description SMWDescription main query description
* @param $limit integer
* @param $from string can be empty if no from condition is desired
* @param $until string can be empty if no until condition is desired
* @return SMWQuery
*/
public static function getQuery(SMWDescription $description, $limit, $from, $until)
{
if ($from !== '') {
$diWikiPage = new SMWDIWikiPage($from, NS_MAIN, '');
// make a dummy wiki page as boundary
$fromDescription = new SMWValueDescription($diWikiPage, null, SMW_CMP_GEQ);
$queryDescription = new SMWConjunction(array($description, $fromDescription));
$order = 'ASC';
} elseif ($until !== '') {
$diWikiPage = new SMWDIWikiPage($until, NS_MAIN, '');
// make a dummy wiki page as boundary
$untilDescription = new SMWValueDescription($diWikiPage, null, SMW_CMP_LESS);
// do not include boundary in this case
$queryDescription = new SMWConjunction(array($description, $untilDescription));
$order = 'DESC';
} else {
$queryDescription = $description;
$order = 'ASC';
}
$queryDescription->addPrintRequest(new SMWPrintRequest(SMWPrintRequest::PRINT_THIS, ''));
$query = new SMWQuery($queryDescription);
$query->sortkeys[''] = $order;
$query->setLimit($limit + 1);
return $query;
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:37,代码来源:SMW_PageLister.php
示例17: getQueryId
/**
* @since 2.4
*
* @return string
*/
public function getQueryId()
{
if ($this->queryId === null) {
$this->queryId = $this->query->getQueryId();
}
return $this->queryId;
}
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:12,代码来源:EntityListAccumulator.php
示例18: makeQueryResultForInstance
private function makeQueryResultForInstance(FederateResultSet $federateResultSet, Query $query)
{
$resultDataItems = array();
foreach ($federateResultSet as $resultRow) {
if (count($resultRow) > 0) {
$dataItem = Exporter::findDataItemForExpElement($resultRow[0]);
if (!is_null($dataItem)) {
$resultDataItems[] = $dataItem;
}
}
}
if ($federateResultSet->numRows() > $query->getLimit()) {
array_pop($resultDataItems);
$hasFurtherResults = true;
} else {
$hasFurtherResults = false;
}
$result = new QueryResult($query->getDescription()->getPrintrequests(), $query, $resultDataItems, $this->store, $hasFurtherResults);
switch ($federateResultSet->getErrorCode()) {
case FederateResultSet::ERROR_NOERROR:
break;
case FederateResultSet::ERROR_INCOMPLETE:
$result->addErrors(array(wfMessage('smw_db_sparqlqueryincomplete')->inContentLanguage()->text()));
break;
default:
$result->addErrors(array(wfMessage('smw_db_sparqlqueryproblem')->inContentLanguage()->text()));
break;
}
return $result;
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:30,代码来源:QueryResultFactory.php
示例19: newJointProfileAnnotator
/**
* @since 2.1
*
* @param Title $title
* @param Query $query
* @param string $format
* @param integer|null $duration
*
* @return ProfileAnnotator
*/
public function newJointProfileAnnotator(Title $title, Query $query, $format, $duration = null)
{
$profiler = new NullProfile(new Subobject($title), $query->getHash());
$profiler = new DescriptionProfile($profiler, $query->getDescription());
$profiler = new FormatProfile($profiler, $format);
$profiler = new DurationProfile($profiler, $duration);
return $profiler;
}
开发者ID:ReachingOut,项目名称:SemanticMediaWiki,代码行数:18,代码来源:QueryProfilerFactory.php
示例20: newJointProfileAnnotator
/**
* @since 2.1
*
* @param Query $query
* @param string $format
* @param integer|null $duration
*
* @return ProfileAnnotator
*/
public function newJointProfileAnnotator(Query $query, $format, $duration = null)
{
$nullProfileAnnotator = new NullProfileAnnotator(new Subobject($query->getSubject()->getTitle()), $query->getQueryId());
$descriptionProfileAnnotator = new DescriptionProfileAnnotator($nullProfileAnnotator, $query->getDescription());
$formatProfileAnnotator = new FormatProfileAnnotator($descriptionProfileAnnotator, $format);
$durationProfileAnnotator = new DurationProfileAnnotator($formatProfileAnnotator, $duration);
return $durationProfileAnnotator;
}
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:17,代码来源:QueryProfileAnnotatorFactory.php
注:本文中的SMWQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论