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


PHP SMWQueryResult::getStore方法代码示例

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


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

 private function getConceptDescription(DIWikiPage $concept)
 {
     $value = $this->queryResult->getStore()->getPropertyValues($concept, new DIProperty('_CONC'));
     if ($value === null || $value === array()) {
         return new ThingDescription();
     }
     $value = end($value);
     return ApplicationFactory::getInstance()->newQueryParser()->getQueryDescription($value->getConceptQuery());
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:9,代码来源:EmbeddedQueryDependencyListResolver.php

示例3: 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

示例4: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     global $wgContLang;
     // <H3> will generate TOC entries otherwise.  Probably need another way
     // to accomplish this -- user might still want TOC for other page content.
     $result = '__NOTOC__';
     $num = $res->getCount();
     $prev_first_char = "";
     $rows_per_column = ceil($num / $this->mNumColumns);
     // column width is a percentage
     $column_width = floor(100 / $this->mNumColumns);
     // Print all result rows:
     $rowindex = 0;
     $row = $res->getNext();
     while ($row !== false) {
         $nextrow = $res->getNext();
         // look ahead
         $content = $row[0]->getContent();
         $cur_first_char = $wgContLang->firstChar($content[0]->getDIType() == SMWDataItem::TYPE_WIKIPAGE ? $res->getStore()->getWikiPageSortKey($content[0]) : $content[0]->getSortKey());
         if ($rowindex % $rows_per_column == 0) {
             $result .= "\n\t\t\t<div style=\"float: left; width: {$column_width}%;\">\n";
             if ($cur_first_char == $prev_first_char) {
                 $result .= "\t\t\t\t<h3>{$cur_first_char} " . wfMessage('listingcontinuesabbrev')->text() . "</h3>\n\t\t\t\t<ul>\n";
             }
         }
         // if we're at a new first letter, end
         // the last list and start a new one
         if ($cur_first_char != $prev_first_char) {
             if ($rowindex % $rows_per_column > 0) {
                 $result .= "\t\t\t\t</ul>\n";
             }
             $result .= "\t\t\t\t<h3>{$cur_first_char}</h3>\n\t\t\t\t<ul>\n";
         }
         $prev_first_char = $cur_first_char;
         $result .= '<li>';
         $first_col = true;
         if ($this->mTemplate !== '') {
             // build template code
             $this->hasTemplates = true;
             $wikitext = $this->mUserParam ? "|userparam={$this->mUserParam}" : '';
             $i = 1;
             // explicitly number parameters for more robust parsing (values may contain "=")
             foreach ($row as $field) {
                 $wikitext .= '|' . $i++ . '=';
                 $first_value = true;
                 while (($text = $field->getNextText(SMW_OUTPUT_WIKI, $this->getLinker($first_col))) !== false) {
                     if ($first_value) {
                         $first_value = false;
                     } else {
                         $wikitext .= $this->mDelim . ' ';
                     }
                     $wikitext .= $text;
                 }
                 $first_col = false;
             }
             $wikitext .= "|#={$rowindex}";
             $result .= '{{' . $this->mTemplate . $wikitext . '}}';
             // str_replace('|', '&#x007C;', // encode '|' for use in templates (templates fail otherwise) -- this is not the place for doing this, since even DV-Wikitexts contain proper "|"!
         } else {
             // build simple list
             $first_col = true;
             $found_values = false;
             // has anything but the first column been printed?
             foreach ($row as $field) {
                 $first_value = true;
                 while (($text = $field->getNextText(SMW_OUTPUT_WIKI, $this->getLinker($first_col))) !== false) {
                     if (!$first_col && !$found_values) {
                         // first values after first column
                         $result .= ' (';
                         $found_values = true;
                     } elseif ($found_values || !$first_value) {
                         // any value after '(' or non-first values on first column
                         $result .= ', ';
                     }
                     if ($first_value) {
                         // first value in any column, print header
                         $first_value = false;
                         if ($this->mShowHeaders && $field->getPrintRequest()->getLabel() !== '') {
                             $result .= $field->getPrintRequest()->getText(SMW_OUTPUT_WIKI, $this->mLinker) . ' ';
                         }
                     }
                     $result .= $text;
                     // actual output value
                 }
                 $first_col = false;
             }
             if ($found_values) {
                 $result .= ')';
             }
         }
         $result .= '</li>';
         $row = $nextrow;
         // end list if we're at the end of the column
         // or the page
         if (($rowindex + 1) % $rows_per_column == 0 && $rowindex + 1 < $num) {
             $result .= "\t\t\t\t</ul>\n\t\t\t</div> <!-- end column -->";
         }
         $rowindex++;
     }
     // Make label for finding further results
//.........这里部分代码省略.........
开发者ID:yusufchang,项目名称:app,代码行数:101,代码来源:SMW_QP_Category.php

示例5: 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

示例6: getResultText

 /**
  * Return serialised results in specified format.
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($this->mTreeProp === null || $this->mTreeProp === '') {
         $res->addErrors(array(wfMessage('srf-noparentprop')->inContentLanguage()->text()));
         return '';
     }
     $store = $res->getStore();
     // first put everything in a list
     // elements appearing more than once will be inserted more than once,
     // but only one instance will be inserted with the hash
     // only this instance will be considered as a parent element in the tree
     $list = array();
     while ($row = $res->getNext()) {
         $hash = $row[0]->getResultSubject()->getSerialization();
         if (array_key_exists($hash, $list)) {
             $list[] = new SRFTreeElement($row);
         } else {
             $list[$hash] = new SRFTreeElement($row);
         }
     }
     // transfer the listelements into the tree
     // elements with more than one parent will be cloned for each parent
     $tree = array();
     foreach ($list as $hash => $listElem) {
         $parents = $store->getPropertyValues($listElem->mRow[0]->getResultSubject(), SMWDIProperty::newFromUserLabel($this->mTreeProp));
         // transfer element from list to tree
         foreach ($parents as $parent) {
             $parentPageHash = $parent->getSerialization();
             if ($hash !== null) {
                 if (array_key_exists($parentPageHash, $list)) {
                     $listElem->mParent = $parentPageHash;
                 }
                 $tree[$hash] = $listElem;
                 $hash = null;
             } else {
                 $treeElem = clone $listElem;
                 if (array_key_exists($parentPageHash, $list)) {
                     $treeElem->mParent = $parentPageHash;
                 } else {
                     $treeElem->mParent = null;
                 }
                 $tree[] = $treeElem;
             }
         }
     }
     foreach ($tree as $hash => $value) {
     }
     // build pointers from parants to children
     foreach ($tree as $hash => $treeElem) {
         if ($treeElem->mParent != null) {
             $tree[$treeElem->mParent]->mChildren[] = $treeElem;
         }
     }
     // remove children from toplevel
     foreach ($tree as $hash => $treeElem) {
         if ($treeElem->mParent != null) {
             unset($tree[$hash]);
         }
     }
     $result = '';
     $rownum = 0;
     foreach ($tree as $hash => $treeElem) {
         $this->printElement($result, $treeElem, $row);
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:69,代码来源:SRF_Tree.php

示例7: getResultText

 /**
  * Return serialised results in specified format.
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($this->mTreeProp === '') {
         $res->addErrors(array(wfMessage('srf-noparentprop')->inContentLanguage()->text()));
         return '';
     }
     $store = $res->getStore();
     // put everything in a list and set parent hashes
     // elements appearing more than once will be inserted more than once and
     // elements with more than one parent will be cloned for each parent,
     // but only one instance will ever be inserted with the hash and
     // only this instance will later be considered as a parent element in the tree
     $tree = array();
     while ($row = $res->getNext()) {
         $element = new SRFTreeElement($row);
         $hash = $row[0]->getResultSubject()->getSerialization();
         if (array_key_exists($hash, $tree)) {
             $hash = null;
         }
         $parents = $store->getPropertyValues($element->mRow[0]->getResultSubject(), SMWDIProperty::newFromUserLabel($this->mTreeProp));
         if (empty($parents)) {
             // no parents: copy into tree as root level item
             if ($hash !== null) {
                 $tree[$hash] = $element;
             } else {
                 $tree[] = $element;
             }
         } else {
             // one or more parents: copy one copy per parent into tree
             foreach ($parents as $parent) {
                 if ($hash !== null) {
                     $tree[$hash] = $element;
                     $hash = null;
                 } else {
                     $element = clone $element;
                     $tree[] = $element;
                 }
                 $element->mParent = $parent->getSerialization();
             }
         }
     }
     $rootElements = array();
     // build pointers from parents to children and remove pointers to parents that don't exist in the tree
     foreach ($tree as $hash => $element) {
         if ($element->mParent !== null) {
             if (array_key_exists($element->mParent, $tree)) {
                 $tree[$element->mParent]->mChildren[] = $element;
             } else {
                 $element->mParent = null;
                 $rootElements[$hash] = $element;
             }
         } else {
             $rootElements[$hash] = $element;
         }
     }
     $result = '';
     $rownum = 0;
     // if a specific page was specified as root element of the tree
     if ($this->mRoot !== '') {
         // get the title object of the root page
         $rootTitle = Title::newFromText($this->mRoot);
         if ($rootTitle === null) {
             $res->addErrors(array(wfMessage('srf-rootinvalid')->params($this->mRoot)->inContentLanguage()->text()));
             return '';
         }
         $rootSerialization = SMWDIWikiPage::newFromTitle($rootTitle)->getSerialization();
         // find the root page in the tree and print it and its subtree
         if (array_key_exists($rootSerialization, $tree)) {
             $this->printElement($result, $tree[$rootSerialization], $rownum, $this->mStartLevel);
         }
     } else {
         // iterate through all tree elements
         foreach ($rootElements as $hash => $element) {
             // print current root element and its subtree
             $this->printElement($result, $element, $rownum, $this->mStartLevel);
         }
     }
     return $result;
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:82,代码来源:SRF_Tree.php


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