r95060 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95059‎ | r95060 | r95061 >
Date:23:30, 19 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
docs++
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php
@@ -1,18 +1,24 @@
22 <?php
 3+
34 /**
45 * Print query results in tables.
 6+ *
57 * @author Markus Krötzsch
 8+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 9+ *
610 * @file
711 * @ingroup SMWQuery
812 */
9 -
10 -/**
11 - * New implementation of SMW's printer for result tables.
12 - *
13 - * @ingroup SMWQuery
14 - */
1513 class SMWTableResultPrinter extends SMWResultPrinter {
1614
 15+ /**
 16+ * List of printrequests for which numeric sort keys are used.
 17+ * print request hash => true
 18+ *
 19+ * @since 1.6.1
 20+ *
 21+ * @var array
 22+ */
1723 protected $columnsWithSortKey = array();
1824
1925 public function getName() {
@@ -26,8 +32,8 @@
2733
2834 $tableRows = array();
2935
30 - while ( $record = $res->getNext() ) {
31 - $tableRows[] = $this->getRowForRecord( $record, $outputmode );
 36+ while ( $subject = $res->getNext() ) {
 37+ $tableRows[] = $this->getRowForSubject( $subject, $outputmode );
3238 }
3339
3440 // print header
@@ -72,16 +78,36 @@
7379 return $result;
7480 }
7581
76 - protected function getRowForRecord( array /* of SMWResultArray */ $record, $outputmode ) {
 82+ /**
 83+ * Gets a single table row for a subject, ie page.
 84+ *
 85+ * @since 1.6.1
 86+ *
 87+ * @param array $subject
 88+ * @param $outputmode
 89+ *
 90+ * @return string
 91+ */
 92+ protected function getRowForSubject( array /* of SMWResultArray */ $subject, $outputmode ) {
7793 $cells = array();
7894
79 - foreach ( $record as $field ) {
 95+ foreach ( $subject as $field ) {
8096 $cells[] = $this->getCellForPropVals( $field, $outputmode );
8197 }
8298
8399 return "<tr>\n\t" . implode( "\n\t", $cells ) . "\n</tr>";
84100 }
85101
 102+ /**
 103+ * Gets a table cell for all values of a property of a subject.
 104+ *
 105+ * @since 1.6.1
 106+ *
 107+ * @param SMWResultArray $resultArray
 108+ * @param $outputmode
 109+ *
 110+ * @return string
 111+ */
86112 protected function getCellForPropVals( SMWResultArray $resultArray, $outputmode ) {
87113 $attribs = array();
88114
@@ -98,6 +124,16 @@
99125 );
100126 }
101127
 128+ /**
 129+ * Gets the contents for a table cell for all values of a property of a subject.
 130+ *
 131+ * @since 1.6.1
 132+ *
 133+ * @param SMWResultArray $resultArray
 134+ * @param $outputmode
 135+ *
 136+ * @return string
 137+ */
102138 protected function getCellContent( SMWResultArray $resultArray, $outputmode ) {
103139 $values = array();
104140 $isFirst = true;