Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php |
— | — | @@ -1,18 +1,24 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * Print query results in tables. |
| 6 | + * |
5 | 7 | * @author Markus Krötzsch |
| 8 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 9 | + * |
6 | 10 | * @file |
7 | 11 | * @ingroup SMWQuery |
8 | 12 | */ |
9 | | - |
10 | | -/** |
11 | | - * New implementation of SMW's printer for result tables. |
12 | | - * |
13 | | - * @ingroup SMWQuery |
14 | | - */ |
15 | 13 | class SMWTableResultPrinter extends SMWResultPrinter { |
16 | 14 | |
| 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 | + */ |
17 | 23 | protected $columnsWithSortKey = array(); |
18 | 24 | |
19 | 25 | public function getName() { |
— | — | @@ -26,8 +32,8 @@ |
27 | 33 | |
28 | 34 | $tableRows = array(); |
29 | 35 | |
30 | | - while ( $record = $res->getNext() ) { |
31 | | - $tableRows[] = $this->getRowForRecord( $record, $outputmode ); |
| 36 | + while ( $subject = $res->getNext() ) { |
| 37 | + $tableRows[] = $this->getRowForSubject( $subject, $outputmode ); |
32 | 38 | } |
33 | 39 | |
34 | 40 | // print header |
— | — | @@ -72,16 +78,36 @@ |
73 | 79 | return $result; |
74 | 80 | } |
75 | 81 | |
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 ) { |
77 | 93 | $cells = array(); |
78 | 94 | |
79 | | - foreach ( $record as $field ) { |
| 95 | + foreach ( $subject as $field ) { |
80 | 96 | $cells[] = $this->getCellForPropVals( $field, $outputmode ); |
81 | 97 | } |
82 | 98 | |
83 | 99 | return "<tr>\n\t" . implode( "\n\t", $cells ) . "\n</tr>"; |
84 | 100 | } |
85 | 101 | |
| 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 | + */ |
86 | 112 | protected function getCellForPropVals( SMWResultArray $resultArray, $outputmode ) { |
87 | 113 | $attribs = array(); |
88 | 114 | |
— | — | @@ -98,6 +124,16 @@ |
99 | 125 | ); |
100 | 126 | } |
101 | 127 | |
| 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 | + */ |
102 | 138 | protected function getCellContent( SMWResultArray $resultArray, $outputmode ) { |
103 | 139 | $values = array(); |
104 | 140 | $isFirst = true; |