r77395 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77394‎ | r77395 | r77396 >
Date:16:57, 28 November 2010
Author:yaron
Status:ok
Tags:
Comment:
Restructured so that the 'ol' and 'ul' formats, when displayed with more than one column, produce correct HTML (well, mostly correct - the 'ol' format uses the deprecated 'start=' attribute); generally improved HTML formatting
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
@@ -97,9 +97,8 @@
9898 }
9999 }
100100
101 - // Print header
102 - $result = $header;
103 -
 101+ // Initialise more values
 102+ $result = '';
104103 $column_width = 0;
105104
106105 // Set up floating divs, if there's more than one column
@@ -109,6 +108,9 @@
110109 $rows_per_column = ceil( $res->getCount() / $this->mColumns );
111110 $rows_in_cur_column = 0;
112111 }
 112+
 113+ $result .= "\t\t\t\t$header\n";
 114+
113115
114116 if ( $this->mIntroTemplate != '' ) {
115117 $result .= "{{" . $this->mIntroTemplate . "}}";
@@ -117,8 +119,10 @@
118120 // Now print each row
119121 $rownum = -1;
120122 while ( $row = $res->getNext() ) {
121 - $this->printRow( $row, $rownum, $rows_in_cur_column, $rows_in_cur_column, $plainlist,
122 - $header, $footer, $rowstart, $rowend, $result, $column_width, $res, $listsep, $finallistsep );
 123+ $this->printRow( $row, $rownum, $rows_in_cur_column,
 124+ $rows_per_column, $this->mFormat, $plainlist,
 125+ $header, $footer, $rowstart, $rowend, $result,
 126+ $column_width, $res, $listsep, $finallistsep );
123127 }
124128
125129 if ( $this->mOutroTemplate != '' ) {
@@ -129,13 +133,13 @@
130134 if ( $this->linkFurtherResults( $res ) && ( ( $this->mFormat != 'ol' ) || ( $this->getSearchLabel( SMW_OUTPUT_WIKI ) ) ) ) {
131135 $this->showFurtherResults( $result, $res, $rowstart, $rowend );
132136 }
 137+
 138+ // Print footer
 139+ $result .= "\t\t\t\t$footer\n";
133140
134141 if ( $this->mColumns > 1 ) {
135 - $result .= '</div>' . "\n";
 142+ $result .= "\t\t\t\t</div>\n";
136143 }
137 -
138 - // Print footer
139 - $result .= $footer;
140144
141145 if ( $this->mColumns > 1 ) {
142146 $result .= '<br style="clear: both">' . "\n";
@@ -144,20 +148,39 @@
145149 return $result;
146150 }
147151
148 - protected function printRow( $row, &$rownum, &$rows_in_cur_column, $rows_per_column,
149 - $plainlist, $header, $footer, $rowstart, $rowend, &$result, $column_width, $res, $listsep, $finallistsep ) {
 152+ protected function printRow( $row, &$rownum, &$rows_in_cur_column,
 153+ $rows_per_column, $format, $plainlist, $header, $footer,
 154+ $rowstart, $rowend, &$result, $column_width, $res, $listsep,
 155+ $finallistsep ) {
 156+
150157 $rownum++;
151158
152159 if ( $this->mColumns > 1 ) {
153160 if ( $rows_in_cur_column == $rows_per_column ) {
154 - $result .= "\n</div>";
155 - $result .= '<div style="float: left; width: ' . $column_width . '%">' . "\n";
 161+ // If it's a numbered list, and it's split
 162+ // into columns, add in the 'start='
 163+ // attribute so that each additional column
 164+ // starts at the right place. This attribute
 165+ // is actually deprecated, but it appears to
 166+ // still be supported by the major browsers...
 167+ if ( $format == 'ol' ) {
 168+ $header = "<ol start=\"" . ( $rownum + 1 ) . "\">";
 169+ }
 170+ $result .= <<<END
 171+
 172+ $footer
 173+ </div>
 174+ <div style="float: left; width: $column_width%">
 175+ $header
 176+
 177+END;
156178 $rows_in_cur_column = 0;
157179 }
158180
159181 $rows_in_cur_column++;
160182 }
161183
 184+ $result .= "\t\t\t\t\t";
162185 if ( $rownum > 0 && $plainlist ) {
163186 $result .= ( $rownum <= $res->getCount() ) ? $listsep : $finallistsep; // the comma between "rows" other than the last one
164187 } else {
@@ -265,7 +288,7 @@
266289 $link->setParameter( $this->mOutroTemplate, 'outrotemplate' );
267290 }
268291
269 - $result .= $rowstart . $link->getText( SMW_OUTPUT_WIKI, $this->mLinker ) . $rowend . "\n";
 292+ $result .= "\t\t\t\t" . $rowstart . $link->getText( SMW_OUTPUT_WIKI, $this->mLinker ) . $rowend . "\n";
270293 }
271294
272295 public function getParameters() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r79916Follow-up to r77395 - removed printing of tabs before query results; it was a...yaron20:33, 9 January 2011

Status & tagging log