Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php |
— | — | @@ -35,13 +35,8 @@ |
36 | 36 | |
37 | 37 | $result = ''; |
38 | 38 | |
39 | | - $tableRows = array(); |
| 39 | + $columnClasses = array(); |
40 | 40 | |
41 | | - $rowNum = 1; |
42 | | - while ( $subject = $res->getNext() ) { |
43 | | - $tableRows[] = $this->getRowForSubject( $subject, $outputmode, $rowNum++ ); |
44 | | - } |
45 | | - |
46 | 41 | if ( $this->mShowHeaders != SMW_HEADERS_HIDE ) { // building headers |
47 | 42 | $headers = array(); |
48 | 43 | |
— | — | @@ -49,6 +44,9 @@ |
50 | 45 | $attribs = array(); |
51 | 46 | $columnClass = str_replace( array( ' ', '_' ), '-', $pr->getText( SMW_OUTPUT_WIKI ) ); |
52 | 47 | $attribs['class'] = $columnClass; |
| 48 | + // Also add this to the array of classes, for |
| 49 | + // use in displaying each row. |
| 50 | + $columnClasses[] = $columnClass; |
53 | 51 | $text = $pr->getText( $outputmode, ( $this->mShowHeaders == SMW_HEADERS_PLAIN ? null : $this->mLinker ) ); |
54 | 52 | |
55 | 53 | $headers[] = Html::rawElement( |
— | — | @@ -63,9 +61,16 @@ |
64 | 62 | if ( $outputmode == SMW_OUTPUT_HTML ) { |
65 | 63 | $headers = '<thead>' . $headers . '</thead>'; |
66 | 64 | } |
67 | | - |
| 65 | + $headers = "\n$headers\n"; |
| 66 | + |
68 | 67 | $result .= $headers; |
69 | 68 | } |
| 69 | + |
| 70 | + $tableRows = array(); |
| 71 | + $rowNum = 1; |
| 72 | + while ( $subject = $res->getNext() ) { |
| 73 | + $tableRows[] = $this->getRowForSubject( $subject, $outputmode, $columnClasses, $rowNum++ ); |
| 74 | + } |
70 | 75 | |
71 | 76 | $tableRows = implode( "\n", $tableRows ); |
72 | 77 | |
— | — | @@ -108,11 +113,12 @@ |
109 | 114 | * |
110 | 115 | * @return string |
111 | 116 | */ |
112 | | - protected function getRowForSubject( array /* of SMWResultArray */ $subject, $outputmode, $rowNum ) { |
| 117 | + protected function getRowForSubject( array /* of SMWResultArray */ $subject, $outputmode, $columnClasses, $rowNum ) { |
113 | 118 | $cells = array(); |
114 | 119 | |
115 | | - foreach ( $subject as $field ) { |
116 | | - $cells[] = $this->getCellForPropVals( $field, $outputmode ); |
| 120 | + foreach ( $subject as $i => $field ) { |
| 121 | + $columnClass = $columnClasses[$i]; |
| 122 | + $cells[] = $this->getCellForPropVals( $field, $outputmode, $columnClass ); |
117 | 123 | } |
118 | 124 | |
119 | 125 | $rowClass = ( $rowNum % 2 == 1 ) ? 'row-odd' : 'row-even'; |
— | — | @@ -129,7 +135,7 @@ |
130 | 136 | * |
131 | 137 | * @return string |
132 | 138 | */ |
133 | | - protected function getCellForPropVals( SMWResultArray $resultArray, $outputmode ) { |
| 139 | + protected function getCellForPropVals( SMWResultArray $resultArray, $outputmode, $columnClass ) { |
134 | 140 | $dataValues = array(); |
135 | 141 | |
136 | 142 | while ( ( $dv = $resultArray->getNextDataValue() ) !== false ) { |
— | — | @@ -151,7 +157,8 @@ |
152 | 158 | if ( in_array( $alignment, array( 'right', 'left', 'center' ) ) ) { |
153 | 159 | $attribs['style'] = "text-align:' . $alignment . ';"; |
154 | 160 | } |
155 | | - |
| 161 | + $attribs['class'] = $columnClass; |
| 162 | + |
156 | 163 | $content = $this->getCellContent( |
157 | 164 | $dataValues, |
158 | 165 | $outputmode, |