r67057 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67056‎ | r67057 | r67058 >
Date:21:07, 29 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed more yoda-conditions and style improvements
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Category.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_List.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/Export/SMW_SpecialOWLExport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -258,7 +258,7 @@
259259 foreach ( $this->m_printouts as $printout ) {
260260 $printoutstring .= $printout->getSerialisation() . "\n";
261261 }
262 - if ( '' != $printoutstring ) $urltail .= '&po=' . urlencode( $printoutstring );
 262+ if ( $printoutstring != '' ) $urltail .= '&po=' . urlencode( $printoutstring );
263263 if ( array_key_exists( 'sort', $this->m_params ) ) $urltail .= '&sort=' . $this->m_params['sort'];
264264 if ( array_key_exists( 'order', $this->m_params ) ) $urltail .= '&order=' . $this->m_params['order'];
265265
Index: trunk/extensions/SemanticMediaWiki/specials/Export/SMW_SpecialOWLExport.php
@@ -50,7 +50,7 @@
5151
5252 if ( $page == '' ) { // try to get POST list; some settings are only available via POST
5353 $pageblob = $wgRequest->getText( 'pages' );
54 - if ( '' != $pageblob ) {
 54+ if ( $pageblob != '' ) {
5555 $pages = explode( "\n", $pageblob );
5656 }
5757 } else {
@@ -309,17 +309,20 @@
310310 // for pages not processed recursively, print at least basic declarations
311311 wfProfileIn( "RDF::PrintPages::Auxiliary" );
312312 $this->date = ''; // no date restriction for the rest!
 313+
313314 if ( !empty( $this->element_queue ) ) {
314 - if ( '' != $this->pre_ns_buffer ) {
 315+ if ( $this->pre_ns_buffer != '' ) {
315316 $this->post_ns_buffer .= "\t<!-- auxiliary definitions -->\n";
316317 } else {
317318 print "\t<!-- auxiliary definitions -->\n"; // just print this comment, so that later outputs still find the empty pre_ns_buffer!
318319 }
 320+
319321 while ( !empty( $this->element_queue ) ) {
320322 $st = array_pop( $this->element_queue );
321323 $this->printObject( $st, false, false );
322324 }
323325 }
 326+
324327 wfProfileOut( "RDF::PrintPages::Auxiliary" );
325328 $this->printFooter();
326329 $this->flushBuffers( true );
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_List.php
@@ -140,21 +140,26 @@
141141 }
142142 if ( $first_value ) { // first value in any column, print header
143143 $first_value = false;
144 - if ( ( $this->mShowHeaders != SMW_HEADERS_HIDE ) && ( '' != $field->getPrintRequest()->getLabel() ) ) {
 144+
 145+ if ( ( $this->mShowHeaders != SMW_HEADERS_HIDE ) && ( $field->getPrintRequest()->getLabel() != '' ) ) {
145146 $result .= $field->getPrintRequest()->getText( SMW_OUTPUT_WIKI, ( $this->mShowHeaders == SMW_HEADERS_PLAIN ? null:$this->mLinker ) ) . ' ';
146147 }
147148 }
 149+
148150 $result .= $text; // actual output value
149151 }
 152+
150153 $first_col = false;
151154 }
 155+
152156 if ( $found_values ) $result .= ')';
153157 }
 158+
154159 $result .= $rowend;
155160 }
156161
157162 // Make label for finding further results
158 - if ( $this->linkFurtherResults( $res ) && ( ( 'ol' != $this->mFormat ) || ( $this->getSearchLabel( SMW_OUTPUT_WIKI ) ) ) ) {
 163+ if ( $this->linkFurtherResults( $res ) && ( ( $this->mFormat != 'ol' ) || ( $this->getSearchLabel( SMW_OUTPUT_WIKI ) ) ) ) {
159164 $link = $res->getQueryLink();
160165 if ( $this->getSearchLabel( SMW_OUTPUT_WIKI ) ) {
161166 $link->setCaption( $this->getSearchLabel( SMW_OUTPUT_WIKI ) );
@@ -184,15 +189,20 @@
185190 public function getParameters() {
186191 $params = parent::getParameters();
187192 $params = array_merge( $params, parent::textDisplayParameters() );
188 - $plainlist = ( 'ul' != $this->mFormat && 'ol' != $this->mFormat );
 193+
 194+ $plainlist = ( $this->mFormat != 'ul' && $this->mFormat != 'ol' );
 195+
189196 if ( $plainlist ) {
190197 $params[] = array( 'name' => 'sep', 'type' => 'string', 'description' => wfMsg( 'smw_paramdesc_sep' ) );
191198 }
 199+
192200 $params[] = array( 'name' => 'template', 'type' => 'string', 'description' => wfMsg( 'smw_paramdesc_template' ) );
 201+
193202 if ( ! $plainlist ) {
194203 $params[] = array( 'name' => 'columns', 'type' => 'int', 'description' => wfMsg( 'smw_paramdesc_columns', 1 ) );
195204 }
 205+
196206 return $params;
197207 }
198208
199 -}
 209+}
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Category.php
@@ -106,6 +106,7 @@
107107 $found_values = false; // has anything but the first column been printed?
108108 foreach ( $row as $field ) {
109109 $first_value = true;
 110+
110111 while ( ( $text = $field->getNextText( SMW_OUTPUT_WIKI, $this->getLinker( $first_col ) ) ) !== false ) {
111112 if ( !$first_col && !$found_values ) { // first values after first column
112113 $result .= ' (';
@@ -114,25 +115,32 @@
115116 // any value after '(' or non-first values on first column
116117 $result .= ', ';
117118 }
 119+
118120 if ( $first_value ) { // first value in any column, print header
119121 $first_value = false;
120 - if ( $this->mShowHeaders && ( '' != $field->getPrintRequest()->getLabel() ) ) {
 122+
 123+ if ( $this->mShowHeaders && ( $field->getPrintRequest()->getLabel() != '' ) ) {
121124 $result .= $field->getPrintRequest()->getText( SMW_OUTPUT_WIKI, $this->mLinker ) . ' ';
122125 }
123126 }
 127+
124128 $result .= $text; // actual output value
125129 }
 130+
126131 $first_col = false;
127132 }
 133+
128134 if ( $found_values ) $result .= ')';
129135 }
 136+
130137 $result .= '</li>';
131138 $row = $nextrow;
132139
133140 // end list if we're at the end of the column
134141 // or the page
135 - if ( ( $rowindex + 1 ) % $rows_per_column == 0 && ( $rowindex + 1 ) < $num )
 142+ if ( ( $rowindex + 1 ) % $rows_per_column == 0 && ( $rowindex + 1 ) < $num ) {
136143 $result .= " </ul>\n </div> <!-- end column -->";
 144+ }
137145
138146 $rowindex++;
139147 }
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php
@@ -1091,7 +1091,7 @@
10921092 $qobj = $this->m_queries[$rootid];
10931093
10941094 foreach ( $this->m_sortkeys as $propkey => $order ) {
1095 - if ( ( 'RANDOM' != $order ) && array_key_exists( $propkey, $qobj->sortfields ) ) { // Field was successfully added.
 1095+ if ( ( $order != 'RANDOM' ) && array_key_exists( $propkey, $qobj->sortfields ) ) { // Field was successfully added.
10961096 $result['ORDER BY'] = ( array_key_exists( 'ORDER BY', $result ) ? $result['ORDER BY'] . ', ' : '' ) . $qobj->sortfields[$propkey] . " $order ";
10971097 } elseif ( ( $order == 'RANDOM' ) && $smwgQRandSortingSupport ) {
10981098 $result['ORDER BY'] = ( array_key_exists( 'ORDER BY', $result ) ? $result['ORDER BY'] . ', ' : '' ) . ' RAND() ';

Status & tagging log