r93259 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93258‎ | r93259 | r93260 >
Date:11:50, 27 July 2011
Author:devayon
Status:deferred
Tags:
Comment:
follow-up to r93168
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -364,39 +364,75 @@
365365 if ( !$smwgQSortingSupport ) return '';
366366
367367 $result = '';
368 -
369 - // START: fetch sorting order, if defined earlier
370 - $params = $this->uiCore->getParameters();
371 - if ( array_key_exists( 'sort', $params ) && array_key_exists( 'order', $params ) ) {
372 - $sorts = explode( ',', $params['sort'] );
373 - $orders = explode( ',', $params['order'] );
374 - reset( $sorts );
375 - } else {
376 - $orders = array(); // do not even show one sort input here
377 - }
378368 $num_sort_values = 0;
 369+ // START: create form elements already submitted earlier via form
379370
380 - if ( !array_key_exists( 'sort', $params ) ) {
381 - $sort_values = $wgRequest->getArray( 'sort' );
382 - if ( is_array( $sort_values ) ) {
383 - $params['sort'] = implode( ',', $sort_values );
384 - $num_sort_values = count( $sort_values );
 371+ // attempting to load parameters from $wgRequest
 372+ $property_values = $wgRequest->getArray( 'property' );
 373+ $order_values = $wgRequest->getArray( 'order' );
 374+ $display_values = $wgRequest->getArray( 'display' );
 375+ if ( is_array( $property_values ) and is_array( $order_values ) and is_array( $display_values ) ) {
 376+ $num_sort_values = count( $property_values );
 377+ foreach ( $property_values as $i => $property_value ) {
 378+ $result .= Html::rawElement( 'div', array( 'id' => "sort_div_$i" ) ) . 'Property'; // TODO: add i18n
 379+ $result .= Html::input( 'property[' . $i . ']', $property_value, 'text', array( 'size' => '35' ) );
 380+ $result .= html::rawElement( 'select', array( 'order' => "order[' . $i . ']" ) );
 381+ if ( $order_values[$i] == 'NONE' ) {
 382+ $result .= '<option selected="selected" value="NONE">' . 'No sorting' . "</option>\n"; // TODO: add i18n
 383+ } else {
 384+ $result .= '<option value="NONE">' . 'No sorting' . "</option>\n"; // TODO: add i18n
 385+ }
 386+ if ( $order_values[$i] == 'ASC' ) {
 387+ $result .= '<option selected="selected" value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n";
 388+ } else {
 389+ $result .= '<option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n";
 390+ }
 391+ if ( $order_values[$i] == 'DESC' ) {
 392+ $result .= '<option selected="selected" value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option>\n";
 393+ } else {
 394+ $result .= '<option value="DESC">' . wfMsg( 'smw_ask_deccorder' ) . "</option>\n";
 395+ }
 396+ $result .= Html::closeElement( 'select' ) . "\n";
 397+ if ( array_key_exists( $i, $display_values ) ) {
 398+ $result .= 'show in results: <input type="checkbox" checked name="display_[' . $i . ']" value="yes">' . "\n"; // TODO: add i18n
 399+ } else {
 400+ $result .= 'show in results: <input type="checkbox" name="display_[' . $i . ']" value="yes">' . "\n"; // TODO: add i18n
 401+ }
 402+ $result .= '[<a href="javascript:removePOInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n";
 403+ $result .= Html::closeElement( 'div' ) . "\n";
385404 }
386 - }
 405+ } else { // printouts and sorting were set via another widget, so create elements by fetching data from $uiCore
 406+ $params = $this->uiCore->getParameters();
 407+ if ( array_key_exists( 'sort', $params ) && array_key_exists( 'order', $params ) ) {
 408+ $sorts = explode( ',', $params['sort'] );
 409+ $orders = explode( ',', $params['order'] );
 410+ reset( $sorts );
 411+ } else {
 412+ $orders = array(); // do not even show one sort input here
 413+ }
387414
388 - foreach ( $orders as $i => $order ) {
389 - $result .= "<div id=\"sort_div_$i\">" . 'Property' . // TODO: add i18n
390 - ' <input type="text" name="property[' . $i . ']" value="' .
391 - htmlspecialchars( $sorts[$i] ) . "\" size=\"35\"/>\n" . '<select name="order[' . $i . ']"><option ';
392 - if ( $order == 'ASC' ) $result .= 'selected="selected" ';
393 - $result .= 'value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . '</option><option ';
394 - if ( $order == 'DESC' ) $result .= 'selected="selected" ';
395 - $result .= 'value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option></select>\n";
396 - $result .= 'show in results: <input type="checkbox" checked name="display_num" value="yes">' . "\n"; // TODO: add i18n'
397 - $result .= '[<a href="javascript:removePOInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n";
398 - $result .= "</div>\n";
 415+ if ( !array_key_exists( 'sort', $params ) ) {
 416+ $sort_values = $wgRequest->getArray( 'sort' );
 417+ if ( is_array( $sort_values ) ) {
 418+ $params['sort'] = implode( ',', $sort_values );
 419+ $num_sort_values = count( $sort_values );
 420+ }
 421+ }
 422+
 423+ foreach ( $orders as $i => $order ) {
 424+ $result .= "<div id=\"sort_div_$i\">" . 'Property' . // TODO: add i18n
 425+ ' <input type="text" name="property[' . $i . ']" value="' .
 426+ htmlspecialchars( $sorts[$i] ) . "\" size=\"35\"/>\n" . '<select name="order[' . $i . ']"><option ';
 427+ if ( $order == 'ASC' ) $result .= 'selected="selected" ';
 428+ $result .= 'value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . '</option><option ';
 429+ if ( $order == 'DESC' ) $result .= 'selected="selected" ';
 430+ $result .= 'value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option></select>\n";
 431+ $result .= 'show in results: <input type="checkbox" checked name="display_num" value="yes">' . "\n"; // TODO: add i18n'
 432+ $result .= '[<a href="javascript:removePOInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n";
 433+ $result .= "</div>\n";
 434+ }
399435 }
400 - // END: fetch sorting order, if defined earlier
 436+ // END: create form elements already submitted earlier via form
401437
402438 $result .= '<div id="sorting_starter" style="display: none">' . 'Property' . // TODO: add i18n
403439 ' <input type="text" size="35" name="property_num" />' . "\n";

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93168preliminary work combining PO and sortingdevayon12:21, 26 July 2011