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


PHP SMWQueryResult::getNext方法代码示例

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


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

示例1: testVerifyThatAfterSerializeToArrayResultNextCanBeUsed

 public function testVerifyThatAfterSerializeToArrayResultNextCanBeUsed()
 {
     $query = $this->getMockBuilder('\\SMWQuery')->disableOriginalConstructor()->getMock();
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $printRequests = array();
     $results = array(new DIWikiPage('Foo', 0), new DIWikiPage('Bar', 0));
     $instance = new QueryResult($printRequests, $query, $results, $store);
     $instance->serializeToArray();
     $this->assertInternalType('array', $instance->getNext());
     $instance->getHash();
     $this->assertInternalType('array', $instance->getNext());
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:12,代码来源:QueryResultTest.php

示例2: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $this->isHTML = true;
     $t = "";
     $n = "";
     // if there is only one column in the results then stop right away
     if ($res->getColumnCount() == 1) {
         return "";
     }
     // print all result rows
     $first = true;
     $max = 0;
     // the biggest value. needed for scaling
     while ($row = $res->getNext()) {
         $name = $row[0]->getNextDataValue()->getShortWikiText();
         foreach ($row as $field) {
             while (($object = $field->getNextDataValue()) !== false) {
                 // use numeric sortkey
                 if ($object->isNumeric()) {
                     $nr = $object->getDataItem()->getSortKey();
                     $max = max($max, $nr);
                     if ($first) {
                         $first = false;
                         $t .= $nr;
                         $n = $name;
                     } else {
                         $t = $nr . ',' . $t;
                         $n = $name . '|' . $n;
                     }
                 }
             }
         }
     }
     return '<img src="http://chart.apis.google.com/chart?cht=p3&chs=' . $this->m_width . 'x' . $this->m_height . '&chds=0,' . $max . '&chd=t:' . $t . '&chl=' . $n . '" width="' . $this->m_width . '" height="' . $this->m_height . '"  />';
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:SRF_GooglePie.php

示例3: getIcal

	/**
	 * Returns the query result in iCal.
	 * 
	 * @since 1.5.2
	 *  
	 * @param SMWQueryResult $res
	 * 
	 * @return string
	 */
	protected function getIcal( SMWQueryResult $res ) {
		$result = '';
		
		if ( $this->m_title == '' ) {
			global $wgSitename;
			$this->m_title = $wgSitename;
		}
		
		$result .= "BEGIN:VCALENDAR\r\n";
		$result .= "PRODID:-//SMW Project//Semantic Result Formats\r\n";
		$result .= "VERSION:2.0\r\n";
		$result .= "METHOD:PUBLISH\r\n";
		$result .= "X-WR-CALNAME:" . $this->m_title . "\r\n";
		
		if ( $this->m_description !== '' ) {
			$result .= "X-WR-CALDESC:" . $this->m_description . "\r\n";
		}
		
		// TODO: http://www.kanzaki.com/docs/ical/vtimezone.html
		// $result .= "BEGIN:VTIMEZONE\r\n";
		// $result .= "TZID:\r\n";

		$row = $res->getNext();
		while ( $row !== false ) {
			$result .= $this->getIcalForItem( $row );
			$row = $res->getNext();
		}
		
		// $result .= "END:VTIMEZONE\r\n";
		
		$result .= "END:VCALENDAR\r\n";

		return $result;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:43,代码来源:SRF_iCalendar.php

示例4: getResultFileContents

 /**
  * Returns the query result in DSV.
  * 
  * @since 1.6
  *  
  * @param SMWQueryResult $res
  * 
  * @return string
  */
 protected function getResultFileContents(SMWQueryResult $res)
 {
     $lines = array();
     if ($this->mShowHeaders) {
         $headerItems = array();
         foreach ($res->getPrintRequests() as $pr) {
             $headerItems[] = $pr->getLabel();
         }
         $lines[] = $this->getDSVLine($headerItems);
     }
     // Loop over the result objects (pages).
     while ($row = $res->getNext()) {
         $rowItems = array();
         // Loop over their fields (properties).
         foreach ($row as $field) {
             $itemSegments = array();
             // Loop over all values for the property.
             while (($object = $field->getNextDataValue()) !== false) {
                 $itemSegments[] = Sanitizer::decodeCharReferences($object->getWikiValue());
             }
             // Join all values into a single string, separating them with comma's.
             $rowItems[] = implode(',', $itemSegments);
         }
         $lines[] = $this->getDSVLine($rowItems);
     }
     return implode("\n", $lines);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:36,代码来源:SMW_QP_DSV.php

示例5: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     global $wgSitename;
     $result = '';
     if ($outputmode == SMW_OUTPUT_FILE) {
         // make file
         if ($this->m_title == '') {
             $this->m_title = $wgSitename;
         }
         $items = array();
         while ($row = $res->getNext()) {
             $items[] = $this->getItemForResultRow($row)->text();
         }
         $result = implode('', $items);
     } else {
         // just make link to export
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             $label = wfMessage('srf_bibtex_link')->inContentLanguage()->text();
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('bibtex', 'format');
         if ($this->getSearchLabel(SMW_OUTPUT_WIKI) != '') {
             $link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
         }
         $result .= $link->getText($outputmode, $this->mLinker);
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
     }
     return $result;
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:32,代码来源:SRF_BibTeX.php

示例6: getResultData

 /**
  * Returns an array with the numerical data
  *
  * @since 1.8
  *
  * @param SMWQueryResult $result
  * @param $outputMode
  *
  * @return array
  */
 protected function getResultData(SMWQueryResult $res, $outputMode)
 {
     $data = array();
     $data['series'] = array();
     while ($row = $res->getNext()) {
         // Loop over their fields (properties)
         $label = '';
         $i = 0;
         foreach ($row as $field) {
             $i++;
             $rowNumbers = array();
             // Grouping by subject (page object) or property
             if ($this->params['group'] === 'subject') {
                 $groupedBy = $field->getResultSubject()->getTitle()->getText();
             } else {
                 $groupedBy = $field->getPrintRequest()->getLabel();
             }
             // Property label
             $property = $field->getPrintRequest()->getLabel();
             // First column property typeid
             $i == 1 ? $data['fcolumntypeid'] = $field->getPrintRequest()->getTypeID() : '';
             // Loop over all values for the property.
             while (($object = $field->getNextDataValue()) !== false) {
                 if ($object->getDataItem()->getDIType() == SMWDataItem::TYPE_NUMBER) {
                     $number = $object->getNumber();
                     // Checking against the row and in case the first column is a numeric
                     // value it is handled as label with the remaining steps continue to work
                     // as it were a text label
                     // The first column container will not be part of the series container
                     if ($i == 1) {
                         $label = $number;
                         continue;
                     }
                     if ($label !== '' && $number >= $this->params['min']) {
                         // Reference array summarize all items per row
                         $rowNumbers += array('subject' => $label, 'value' => $number, 'property' => $property);
                         // Store plain numbers for simpler handling
                         $data['series'][$groupedBy][] = $number;
                     }
                 } elseif ($object->getDataItem()->getDIType() == SMWDataItem::TYPE_TIME) {
                     $label = $object->getShortWikiText();
                 } else {
                     $label = $object->getWikiValue();
                 }
             }
             // Only for array's with numbers
             if (count($rowNumbers) > 0) {
                 // For cases where mainlabel=- we assume that the subject should not be
                 // used as identifier and therefore we try to match the groupby
                 // with the first available text label
                 if ($this->params['mainlabel'] == '-' && $this->params['group'] === 'subject') {
                     $data[$this->params['group']][$label][] = $rowNumbers;
                 } else {
                     $data[$this->params['group']][$groupedBy][] = $rowNumbers;
                 }
             }
         }
     }
     return $data;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:70,代码来源:SRF_jqPlotSeries.php

示例7: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($outputmode == SMW_OUTPUT_FILE) {
         // make RDF file
         $serializer = $this->syntax == 'turtle' ? new SMWTurtleSerializer() : new SMWRDFXMLSerializer();
         $serializer->startSerialization();
         $serializer->serializeExpData(SMWExporter::getOntologyExpData(''));
         while ($row = $res->getNext()) {
             $subjectDi = reset($row)->getResultSubject();
             $data = SMWExporter::makeExportDataForSubject($subjectDi);
             foreach ($row as $resultarray) {
                 $printreq = $resultarray->getPrintRequest();
                 $property = null;
                 switch ($printreq->getMode()) {
                     case SMWPrintRequest::PRINT_PROP:
                         $property = $printreq->getData()->getDataItem();
                         break;
                     case SMWPrintRequest::PRINT_CATS:
                         $property = new SMWDIProperty('_TYPE');
                         break;
                     case SMWPrintRequest::PRINT_CCAT:
                         // not serialised right now
                         break;
                     case SMWPrintRequest::PRINT_THIS:
                         // ignored here (object is always included in export)
                         break;
                 }
                 if (!is_null($property)) {
                     SMWExporter::addPropertyValues($property, $resultarray->getContent(), $data, $subjectDi);
                 }
             }
             $serializer->serializeExpData($data);
         }
         $serializer->finishSerialization();
         return $serializer->flushContent();
     } else {
         // just make link to feed
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             $label = wfMsgForContent('smw_rdf_link');
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('rdf', 'format');
         $link->setParameter($this->syntax, 'syntax');
         if (array_key_exists('limit', $this->params)) {
             $link->setParameter($this->params['limit'], 'limit');
         } else {
             // use a reasonable default limit
             $link->setParameter(100, 'limit');
         }
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
         return $link->getText($outputmode, $this->mLinker);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:56,代码来源:SMW_QP_RDF.php

示例8: getNumbers

 /**
  * Gets a list of all numbers.
  * 
  * @since 1.6
  * 
  * @param SMWQueryResult $res
  * 
  * @return array
  */
 protected function getNumbers(SMWQueryResult $res)
 {
     $numbers = array();
     while ($row = $res->getNext()) {
         foreach ($row as $resultArray) {
             foreach ($resultArray->getContent() as $dataItem) {
                 self::addNumbersForDataItem($dataItem, $numbers);
             }
         }
     }
     return $numbers;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:21,代码来源:SRF_Math.php

示例9: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $result = '';
     if ($outputmode == SMW_OUTPUT_FILE) {
         // make CSV file
         $csv = fopen('php://temp', 'r+');
         if ($this->mShowHeaders) {
             $header_items = array();
             foreach ($res->getPrintRequests() as $pr) {
                 $header_items[] = $pr->getLabel();
             }
             fputcsv($csv, $header_items, $this->m_sep);
         }
         while ($row = $res->getNext()) {
             $row_items = array();
             foreach ($row as $field) {
                 $growing = array();
                 while (($object = $field->getNextDataValue()) !== false) {
                     $growing[] = Sanitizer::decodeCharReferences($object->getWikiValue());
                 }
                 $row_items[] = implode(',', $growing);
             }
             fputcsv($csv, $row_items, $this->m_sep);
         }
         rewind($csv);
         $result .= stream_get_contents($csv);
     } else {
         // just make link to feed
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             $label = wfMsgForContent('smw_csv_link');
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('csv', 'format');
         $link->setParameter($this->m_sep, 'sep');
         if (array_key_exists('mainlabel', $this->params) && $this->params['mainlabel'] !== false) {
             $link->setParameter($this->params['mainlabel'], 'mainlabel');
         }
         $link->setParameter($this->mShowHeaders ? 'show' : 'hide', 'headers');
         if (array_key_exists('limit', $this->params)) {
             $link->setParameter($this->params['limit'], 'limit');
         } else {
             // use a reasonable default limit
             $link->setParameter(100, 'limit');
         }
         $result .= $link->getText($outputmode, $this->mLinker);
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:52,代码来源:SMW_QP_CSV.php

示例10: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $result = '';
     $columnClasses = array();
     if ($this->mShowHeaders != SMW_HEADERS_HIDE) {
         // building headers
         $headers = array();
         foreach ($res->getPrintRequests() as $pr) {
             $attribs = array();
             $columnClass = str_replace(array(' ', '_'), '-', $pr->getText(SMW_OUTPUT_WIKI));
             $attribs['class'] = $columnClass;
             // Also add this to the array of classes, for
             // use in displaying each row.
             $columnClasses[] = $columnClass;
             $text = $pr->getText($outputmode, $this->mShowHeaders == SMW_HEADERS_PLAIN ? null : $this->mLinker);
             $headers[] = Html::rawElement('th', $attribs, $text === '' ? '&nbsp;' : $text);
         }
         $headers = '<tr>' . implode("\n", $headers) . '</tr>';
         if ($outputmode == SMW_OUTPUT_HTML) {
             $headers = '<thead>' . $headers . '</thead>';
         }
         $headers = "\n{$headers}\n";
         $result .= $headers;
     }
     $tableRows = array();
     $rowNum = 1;
     while ($subject = $res->getNext()) {
         $tableRows[] = $this->getRowForSubject($subject, $outputmode, $columnClasses, $rowNum++);
     }
     $tableRows = implode("\n", $tableRows);
     if ($outputmode == SMW_OUTPUT_HTML) {
         $tableRows = '<tbody>' . $tableRows . '</tbody>';
     }
     $result .= $tableRows;
     // print further results footer
     if ($this->linkFurtherResults($res)) {
         $link = $res->getQueryLink();
         if ($this->getSearchLabel($outputmode)) {
             $link->setCaption($this->getSearchLabel($outputmode));
         }
         $result .= "\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . $res->getColumnCount() . '"> ' . $link->getText($outputmode, $this->mLinker) . "</td></tr>\n";
     }
     // Put the <table> tag around the whole thing
     $tableAttrs = array('class' => $this->mHTMLClass);
     if ($this->mFormat == 'broadtable') {
         $tableAttrs['width'] = '100%';
     }
     $result = Xml::tags('table', $tableAttrs, $result);
     $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
     // yes, our code can be viewed as HTML if requested, no more parsing needed
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:52,代码来源:SMW_QP_Table.php

示例11: getSortKeys

 /**
  * Returns an array with sortkeys for dates pointing to their source DataItems.
  *
  * @param SMWQueryResult $res
  *
  * @return array
  */
 protected function getSortKeys(SMWQueryResult $res)
 {
     $seconds = array();
     while ($row = $res->getNext()) {
         foreach ($row as $resultArray) {
             foreach ($resultArray->getContent() as $dataItem) {
                 if ($dataItem->getDIType() === SMWDataItem::TYPE_TIME) {
                     $seconds[$dataItem->getSortKey()] = $dataItem;
                 }
             }
         }
     }
     return $seconds;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:21,代码来源:SRF_Time.php

示例12: assertThatDataItemIsSet

 /**
  * @since 2.0
  *
  * @param  DataItem $expectedDataItem
  * @param  QueryResult $queryResult
  */
 public function assertThatDataItemIsSet(DataItem $expectedDataItem, QueryResult $queryResult)
 {
     $assertThatDataItemIsSet = false;
     $this->assertEmpty($queryResult->getErrors());
     while ($resultArray = $queryResult->getNext()) {
         foreach ($resultArray as $result) {
             while (($dataItem = $result->getNextDataItem()) !== false) {
                 $this->assertEquals($expectedDataItem, $dataItem);
                 $assertThatDataItemIsSet = true;
             }
         }
     }
     $this->assertTrue($assertThatDataItemIsSet, 'Asserts that the expected DataItem is set');
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:20,代码来源:QueryResultValidator.php

示例13: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $result = '';
     if ($outputmode == SMW_OUTPUT_FILE) {
         $people = array();
         $row = $res->getNext();
         while ($row !== false) {
             $people[] = new PersonPageValues($row[0]->getResultSubject());
             $row = $res->getNext();
         }
         $printer = new Gedcom5FilePrinter();
         $printer->addPeople($people);
         $result = $printer->getFile();
     } else {
         // just make link
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             $label = wfMsgForContent('semanticgenealogy-gedcomexport-link');
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('gedcom5', 'format');
         if ($this->getSearchLabel(SMW_OUTPUT_WIKI) != '') {
             $link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
         }
         if (array_key_exists('limit', $this->m_params)) {
             $link->setParameter($this->m_params['limit'], 'limit');
         } else {
             // use a reasonable default limit
             $link->setParameter(20, 'limit');
         }
         $result .= $link->getText($outputmode, $this->mLinker);
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
     }
     return $result;
 }
开发者ID:Wilkins,项目名称:mediawiki-extensions-SemanticGenealogy,代码行数:37,代码来源:Gedcom5ResultPrinter.php

示例14: getAggregatedTimeSeries

 /**
  * Returns an array with numerical data
  *
  * @since 1.8
  *
  * @param SMWQueryResult $result
  * @param $outputMode
  *
  * @return array
  */
 protected function getAggregatedTimeSeries(SMWQueryResult $result, $outputMode)
 {
     $values = array();
     $aggregatedValues = array();
     while ($row = $result->getNext()) {
         // Objects (pages)
         $timeStamp = '';
         $value = '';
         $series = array();
         foreach ($row as $field) {
             $value = array();
             $sum = array();
             $rowSum = array();
             // Group by subject (page object)  or property
             if ($this->params['group'] == 'subject') {
                 $group = $field->getResultSubject()->getTitle()->getText();
             } else {
                 $group = $field->getPrintRequest()->getLabel();
             }
             while (($dataValue = $field->getNextDataValue()) !== false) {
                 // Data values
                 // Find the timestamp
                 if ($dataValue->getDataItem()->getDIType() == SMWDataItem::TYPE_TIME) {
                     // We work with a timestamp, we have to use intval because DataItem
                     // returns a string but we want a numeric representation of the timestamp
                     $timeStamp = intval($dataValue->getDataItem()->getMwTimestamp());
                 }
                 // Find the values (numbers only)
                 if ($dataValue->getDataItem()->getDIType() == SMWDataItem::TYPE_NUMBER) {
                     $sum[] = $dataValue->getNumber();
                 }
             }
             // Aggegate individual values into a sum
             $rowSum = array_sum($sum);
             // Check the sum and threshold/min
             if ($timeStamp !== '' && $rowSum == true && $rowSum >= $this->params['min']) {
                 $series[$group] = array($timeStamp, $rowSum);
             }
         }
         $values[] = $series;
     }
     // Re-assign values according to their group
     foreach ($values as $key => $value) {
         foreach ($values[$key] as $row => $rowvalue) {
             $aggregatedValues[$row][] = $rowvalue;
         }
     }
     return $aggregatedValues;
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:59,代码来源:SRF_Timeseries.php

示例15: getTags

 /**
  * Returns an array with the tags (keys) and the number of times they occur (values).
  *
  * @since 1.5.3
  *
  * @param SMWQueryResult $results
  * @param $outputmode
  *
  * @return array
  */
 protected function getTags(SMWQueryResult $results, $outputmode)
 {
     $tags = array();
     $excludetags = explode(';', $this->params['excludetags']);
     while ($row = $results->getNext()) {
         // Objects (pages)
         for ($i = 0, $n = count($row); $i < $n; $i++) {
             // SMWResultArray for a sinlge property
             /**
              * @var SMWDataValue $dataValue
              */
             while (($dataValue = $row[$i]->getNextDataValue()) !== false) {
                 // Data values
                 $isSubject = $row[$i]->getPrintRequest()->getMode() == SMWPrintRequest::PRINT_THIS;
                 // If the main object should not be included, skip it.
                 if ($i == 0 && !$this->params['includesubject'] && $isSubject) {
                     continue;
                 }
                 // Get the HTML for the tag content. Pages are linked, other stuff is just plaintext.
                 if ($dataValue->getTypeID() == '_wpg') {
                     $value = $dataValue->getTitle()->getText();
                     $html = $dataValue->getLongText($outputmode, $this->getLinker($isSubject));
                 } else {
                     $html = $dataValue->getShortText($outputmode, $this->getLinker(false));
                     $value = $html;
                 }
                 // Exclude tags from result set
                 if (in_array($value, $excludetags)) {
                     continue;
                 }
                 // Replace content with template inclusion
                 $html = $this->params['template'] !== '' ? $this->addTemplateOutput($value, $rownum) : $html;
                 if (!array_key_exists($value, $tags)) {
                     $tags[$value] = 0;
                     $this->tagsHtml[$value] = $html;
                     // Store the HTML separetely, so sorting can be done easily.
                 }
                 $tags[$value]++;
             }
         }
     }
     foreach ($tags as $name => $count) {
         if ($count < $this->params['mincount']) {
             unset($tags[$name]);
         }
     }
     return $tags;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:58,代码来源:SRF_TagCloud.php


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