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


PHP SMWQueryResult::getResults方法代码示例

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


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

示例1: getResultData

 /**
  * Return relevant data set
  *
  * @param SMWQueryResult $res
  * @param $outputMode
  *
  * @return array
  */
 protected function getResultData(SMWQueryResult $res, $outputMode)
 {
     // Init
     $properties = array();
     $excludeProperties = explode($this->params['sep'], $this->params['exclude']);
     // Options used when retrieving data from the store
     $reqOptions = new SMWRequestOptions();
     $reqOptions->sort = true;
     $reqOptions->limit = $this->params['limit'];
     foreach ($res->getResults() as $key => $page) {
         // Find properties assigned to selected subject page
         foreach ($res->getStore()->getInProperties($page, $reqOptions) as $property) {
             $propertyLabel = $property->getLabel();
             // Exclude property from result set
             if (in_array($propertyLabel, $excludeProperties)) {
                 continue;
             }
             // NOTE There could be thousands of incoming links for one property,
             // counting the length of an array is inefficient but we don't want
             // to implement any native db select outside of smw core and rather
             // would like to see a counting method available but to counter
             // any potential inefficiencies we curb the selection by using
             // SMWRequestOptions -> limit as boundary
             $count = count($res->getStore()->getPropertySubjects($property, $page, $reqOptions));
             // Limit ouput by threshold
             if ($this->params['min'] <= $count) {
                 $properties[$propertyLabel] = $count;
             }
         }
     }
     return $properties;
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:40,代码来源:SRF_Incoming.php

示例2: getResultText

 /**
  * Return serialised results in specified format.
  * Implemented by subclasses.
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $html = '';
     $id = uniqid();
     // build an array of article IDs contained in the result set
     $objects = array();
     foreach ($res->getResults() as $key => $object) {
         $objects[] = array($object->getTitle()->getArticleId());
         $html .= $key . ': ' . $object->getSerialization() . "<br>\n";
     }
     // build an array of data about the printrequests
     $printrequests = array();
     foreach ($res->getPrintRequests() as $key => $printrequest) {
         $data = $printrequest->getData();
         if ($data instanceof SMWPropertyValue) {
             $name = $data->getDataItem()->getKey();
         } else {
             $name = null;
         }
         $printrequests[] = array($printrequest->getMode(), $printrequest->getLabel(), $name, $printrequest->getOutputFormat(), $printrequest->getParameters());
     }
     // write out results and query params into JS arrays
     // Define the srf_filtered_values array
     SMWOutputs::requireScript('srf_slideshow', Html::inlineScript('srf_slideshow = {};'));
     SMWOutputs::requireScript('srf_slideshow' . $id, Html::inlineScript('srf_slideshow["' . $id . '"] = ' . json_encode(array($objects, $this->params['template'], $this->params['delay'] * 1000, $this->params['height'], $this->params['width'], $this->params['nav controls'], $this->params['effect'], json_encode($printrequests))) . ';'));
     SMWOutputs::requireResource('ext.srf.slideshow');
     if ($this->params['nav controls']) {
         SMWOutputs::requireResource('jquery.ui.slider');
     }
     return Html::element('div', array('id' => $id, 'class' => 'srf-slideshow ' . $id . ' ' . $this->params['class']));
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:35,代码来源:SRF_SlideShow.php

示例3: getQueryDependencySubjectList

 /**
  * @since 2.3
  *
  * @return DIWikiPage[]|[]
  */
 public function getQueryDependencySubjectList()
 {
     // Resolving dependencies for non-embedded queries or limit=0 (which only
     // links to Special:Ask via further results) is not required
     if ($this->getSubject() === null || $this->getQuery()->getLimit() == 0) {
         return array();
     }
     $description = $this->getQuery()->getDescription();
     $dependencySubjectList = array($this->getSubject());
     // Find entities described by the query
     $this->doResolveDependenciesFromDescription($dependencySubjectList, $description);
     $this->doResolveDependenciesFromPrintRequest($dependencySubjectList, $description->getPrintRequests());
     $dependencySubjectList = array_merge($dependencySubjectList, $this->queryResult->getResults());
     $this->queryResult->reset();
     return $dependencySubjectList;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:21,代码来源:EmbeddedQueryDependencyListResolver.php

示例4: getSerializedQueryResult

 /**
  * Get the serialization for a SMWQueryResult object.
  *
  * @since 1.7
  *
  * @param SMWQueryResult $result
  *
  * @return array
  */
 public static function getSerializedQueryResult(SMWQueryResult $queryResult)
 {
     $results = array();
     $printRequests = array();
     foreach ($queryResult->getPrintRequests() as $printRequest) {
         $printRequests[] = array('label' => $printRequest->getLabel(), 'typeid' => $printRequest->getTypeID(), 'mode' => $printRequest->getMode());
     }
     foreach ($queryResult->getResults() as $diWikiPage) {
         $result = array('printouts' => array());
         foreach ($queryResult->getPrintRequests() as $printRequest) {
             $resultAarray = new SMWResultArray($diWikiPage, $printRequest, $queryResult->getStore());
             if ($printRequest->getMode() === SMWPrintRequest::PRINT_THIS) {
                 $dataItems = $resultAarray->getContent();
                 $result += self::getSerialization(array_shift($dataItems));
             } else {
                 $result['printouts'][$printRequest->getLabel()] = array_map(array(__CLASS__, 'getSerialization'), $resultAarray->getContent());
             }
         }
         $results[$diWikiPage->getTitle()->getFullText()] = $result;
     }
     return array('printrequests' => $printRequests, 'results' => $results);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:SMW_DISerializer.php

示例5: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if (!isset($this->paramWidth)) {
         $this->paramWidth = -1;
     }
     $this->isHTML = true;
     global $wgOut;
     $wgOut->addModules('ext.SemanticImageAnnotator.ResultFormat');
     $resultPages = $res->getResults();
     $store = smwfGetStore();
     $annotationArray = array();
     foreach ($resultPages as $page) {
         $namespace = $page->getNamespace();
         if ($namespace != 380) {
             continue;
         }
         $coords = "";
         $imgUrl = "";
         $pageName = $page->getDBkey();
         $propertyCoords = new SMWDIProperty("__SIA_RECTCOORDS");
         $propertyImgUrl = new SMWDIProperty("__SIA_IMG_URL");
         $coordValues = $store->getPropertyValues($page, $propertyCoords);
         $urlValues = $store->getPropertyValues($page, $propertyImgUrl);
         if (count($coordValues) == 1 && $coordValues[0] instanceof SMWDIString) {
             $coords = $coordValues[0]->getString();
         }
         if (count($urlValues) == 1 && $coordValues[0] instanceof SMWDIString) {
             $imgUrl = $urlValues[0]->getString();
         }
         if ($coords != "" && $imgUrl != "") {
             $annotationArray[$imgUrl][] = array($pageName, $coords);
         }
     }
     $returnString = "";
     foreach ($annotationArray as $image => $annotationData) {
         $returnString .= $this->createAnnotatedImg($image, $annotationData);
     }
     return $returnString;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:39,代码来源:SIA_AnnotationPrinter.php

示例6: getSerializedQueryResult

 /**
  * Get the serialization for a SMWQueryResult object.
  *
  * @since 1.7
  *
  * @param SMWQueryResult $result
  *
  * @return array
  */
 public static function getSerializedQueryResult(QueryResult $queryResult)
 {
     $results = array();
     $printRequests = array();
     foreach ($queryResult->getPrintRequests() as $printRequest) {
         $printRequests[] = self::getSerializedPrintRequestFormat($printRequest);
     }
     /**
      * @var DIWikiPage $diWikiPage
      * @var PrintRequest $printRequest
      */
     foreach ($queryResult->getResults() as $diWikiPage) {
         if (!$diWikiPage->getTitle() instanceof Title) {
             continue;
         }
         $result = array('printouts' => array());
         foreach ($queryResult->getPrintRequests() as $printRequest) {
             $resultArray = new SMWResultArray($diWikiPage, $printRequest, $queryResult->getStore());
             if ($printRequest->getMode() === PrintRequest::PRINT_THIS) {
                 $dataItems = $resultArray->getContent();
                 $result += self::getSerialization(array_shift($dataItems), $printRequest);
             } elseif ($resultArray->getContent() !== array()) {
                 $values = array();
                 foreach ($resultArray->getContent() as $dataItem) {
                     $values[] = self::getSerialization($dataItem, $printRequest);
                 }
                 $result['printouts'][$printRequest->getLabel()] = $values;
             } else {
                 // For those objects that are empty return an empty array
                 // to keep the output consistent
                 $result['printouts'][$printRequest->getLabel()] = array();
             }
         }
         $results[$diWikiPage->getTitle()->getFullText()] = $result;
     }
     return array('printrequests' => $printRequests, 'results' => $results);
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:46,代码来源:QueryResultSerializer.php

示例7: getQueryResult

 public function getQueryResult(SMWQuery $query, $force = false, $cacheThis = true)
 {
     //get title of article in which query was executed
     //or set title to false if query was executed somehow else
     global $wgParser;
     $title = false;
     if ($wgParser && $wgParser->getTitle()) {
         $title = $wgParser->getTitle();
     }
     $defaultStore = smwfGetStore();
     // update the semdata object for this title, respectively
     // the query management annotations
     if ($title !== false && $cacheThis) {
         SMWQRCQueryManagementHandler::getInstance()->storeQueryMetadata($title, $query);
     }
     //delegate query processing to the responsible store
     if ($query instanceof SMWSPARQLQuery) {
         $store = $defaultStore;
     } else {
         global $smwgBaseStore;
         $store = new $smwgBaseStore();
     }
     $queryData = $this->getQueryData($query);
     // execute the query if no valid cache entry is available, if force was
     // set to true (e.g. by the update process) or if the query is executed because
     // of an edit or a purge action
     if ($force || !$this->isReadAccess() || !$this->hasValidCacheEntry($queryData)) {
         $queryResult = $store->doGetQueryResult($query);
         if ($cacheThis) {
             //add the serialized query result to the database
             $qrcStore = SMWQRCStore::getInstance()->getDB();
             $queryId = SMWQRCQueryManagementHandler::getInstance()->getQueryId($query);
             $lastUpdate = time();
             $dirty = false;
             if ($queryData) {
                 //results for this query already have been stored in the cache
                 if ($force) {
                     //this query result update was not triggered by a Wiki user action
                     $accessFrequency = SMWQRCPriorityCalculator::getInstance()->computeNewAccessFrequency($queryData['accessFrequency']);
                     $invalidationFrequency = SMWQRCPriorityCalculator::getInstance()->computeNewInvalidationFrequency($queryData['invalidationFrequency']);
                 } else {
                     $accessFrequency = $queryData['accessFrequency'] + 1;
                     $invalidationFrequency = $queryData['invalidationFrequency'] + 1;
                 }
                 $priority = 0;
                 $qrcStore->updateQueryData($queryId, serialize($queryResult), $lastUpdate, $accessFrequency, $invalidationFrequency, $dirty, $priority);
             } else {
                 $priority = 0;
                 $qrcStore->addQueryData($queryId, serialize($queryResult), $lastUpdate, 1, 0, $dirty, $priority);
             }
         }
     } else {
         $qrcStore = SMWQRCStore::getInstance()->getDB();
         $queryResult = unserialize($queryData['queryResult']);
         //update access frequency and query priority
         $priority = 0;
         $qrcStore->updateQueryData($queryData['queryId'], $queryData['queryResult'], $queryData['lastUpdate'], $queryData['accessFrequency'] + 1, $queryData['invalidationFrequency'], $queryData['dirty'], $priority);
         if ($query instanceof SMWQueryResult) {
             $query->addErrors($queryResult->getErrors());
             $queryResult = new SMWQueryResult($query->getDescription()->getPrintRequests(), $query, $queryResult->getResults(), $store, $queryResult->hasFurtherResults());
         }
     }
     return $queryResult;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:64,代码来源:SMW_QRC_QueryResultsCache.php

示例8: assertThatQueryResultHasSubjects

 /**
  * @since 2.0
  *
  * @param  mixed $expected
  * @param  QueryResult $queryResult
  */
 public function assertThatQueryResultHasSubjects($expectedSubjects, QueryResult $queryResult)
 {
     $expectedSubjects = is_array($expectedSubjects) ? $expectedSubjects : array($expectedSubjects);
     $expectedToCount = count($expectedSubjects);
     $actualComparedToCount = 0;
     $this->assertEmpty($queryResult->getErrors());
     if ($expectedToCount == 0) {
         return;
     }
     $resultSubjects = $queryResult->getResults();
     foreach ($resultSubjects as $rKey => $resultSubject) {
         foreach ($expectedSubjects as $ekey => $expectedSubject) {
             if ($expectedSubject instanceof DIWikiPage && $expectedSubject->equals($resultSubject)) {
                 $actualComparedToCount++;
                 unset($expectedSubjects[$ekey]);
                 unset($resultSubjects[$rKey]);
             }
         }
     }
     $this->assertEquals($expectedToCount, $actualComparedToCount, 'Failed asserting that ' . implode(', ', $expectedSubjects) . ' is set.');
     $this->assertEmpty($resultSubjects, 'Failed to match results [ ' . implode(', ', $resultSubjects) . ' ] against the expected subjects.');
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:28,代码来源:QueryResultValidator.php

示例9: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     global $wgParser;
     // No page should embed itself, find out who we are:
     if ($wgParser->getTitle() instanceof Title) {
         $title = $wgParser->getTitle()->getPrefixedText();
     } else {
         // this is likely to be in vain -- this case is typical if we run on special pages
         global $wgTitle;
         $title = $wgTitle->getPrefixedText();
     }
     // print header
     $result = '';
     $footer = '';
     $embstart = '';
     $embend = '';
     $headstart = '';
     $headend = '';
     $this->hasTemplates = true;
     switch ($this->m_embedformat) {
         case 'h1':
         case 'h2':
         case 'h3':
         case 'h4':
         case 'h5':
         case 'h6':
             $headstart = '<' . $this->m_embedformat . '>';
             $headend = '</' . $this->m_embedformat . ">\n";
             break;
         case 'ul':
         case 'ol':
             $result .= '<' . $this->m_embedformat . '>';
             $footer = '</' . $this->m_embedformat . '>';
             $embstart = '<li>';
             $headend = "<br />\n";
             $embend = "</li>\n";
             break;
     }
     // Print all result rows:
     foreach ($res->getResults() as $diWikiPage) {
         if ($diWikiPage instanceof SMWDIWikiPage) {
             // ensure that we deal with title-likes
             $dvWikiPage = SMWDataValueFactory::newDataItemValue($diWikiPage, null);
             $result .= $embstart;
             if ($this->m_showhead) {
                 $result .= $headstart . $dvWikiPage->getLongWikiText($this->mLinker) . $headend;
             }
             if ($dvWikiPage->getLongWikiText() != $title) {
                 if ($diWikiPage->getNamespace() == NS_MAIN) {
                     $result .= '{{:' . $diWikiPage->getDBkey() . '}}';
                 } else {
                     $result .= '{{' . $dvWikiPage->getLongWikiText() . '}}';
                 }
             } else {
                 // block recursion
                 $result .= '<b>' . $dvWikiPage->getLongWikiText() . '</b>';
             }
             $result .= $embend;
         }
     }
     // show link to more results
     if ($this->linkFurtherResults($res)) {
         $result .= $embstart . $this->getFurtherResultsLink($res, $outputmode)->getText(SMW_OUTPUT_WIKI, $this->mLinker) . $embend;
     }
     $result .= $footer;
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:67,代码来源:SMW_QP_Embedded.php

示例10: __construct

 public function __construct(\SMWQueryResult $result, $count = null)
 {
     $this->pages = $result->getResults();
     $this->count = $count;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:5,代码来源:SearchResultSet.php


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