r93455 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93454‎ | r93455 | r93456 >
Date:08:05, 29 July 2011
Author:devayon
Status:deferred
Tags:
Comment:
refactored methods created in r93168. Removed some dead code.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -68,7 +68,7 @@
6969 'format' => $wgRequest->getVal( 'format' ),
7070 'offset' => $wgRequest->getVal( 'offset', '0' ),
7171 'limit' => $wgRequest->getVal( 'limit', '20' ) ),
72 - $this->processSortedPOFormBox( $wgRequest ),
 72+ $this->processPoSortFormBox( $wgRequest ),
7373 $this->processFormatSelectBox( $wgRequest ) );
7474 $this->uiCore = SMWQueryUIHelper::makeForUI(
7575 $this->processQueryFormBox( $wgRequest ),
@@ -326,13 +326,12 @@
327327 * complement processQueryFormBox() to decode data sent through these elements.
328328 * UI's may overload both to change form parameters.
329329 *
330 - * @param string $contents
331330 * @param string $errors
332331 * @return string
333332 */
334 - protected function getQueryFormBox( $content, $errors = '' ) {
 333+ protected function getQueryFormBox( $errors = '' ) {
335334 $result = '';
336 - $result = Html::element( 'textarea', array( 'name' => 'q', 'id' => 'querybox', 'rows' => '6' ), $content );
 335+ $result = Html::element( 'textarea', array( 'name' => 'q', 'id' => 'querybox', 'rows' => '6' ), $this->uiCore->getQueryString() );
337336 // TODO:enable/disable on checking for errors; perhaps show error messages right below the box
338337 return $result;
339338 }
@@ -353,12 +352,12 @@
354353
355354 /**
356355 * Generates the forms elements(s) for choosing printouts and sorting
357 - * options. Use its complement processSortedPOFormBox() to decode data
 356+ * options. Use its complement processPoSortFormBox() to decode data
358357 * sent by these elements.
359358 *
360359 * @return string
361360 */
362 - protected function getSortedPOFormBox( $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
 361+ protected function getPoSortFormBox( $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
363362 global $smwgQSortingSupport, $wgRequest, $wgOut;
364363
365364 if ( !$smwgQSortingSupport ) return '';
@@ -386,7 +385,7 @@
387386 * be removed. This is a bit of a hack, converting all strings to
388387 * lowercase to simplify searching procedure and using in_array.
389388 */
390 -
 389+
391390 $po = explode( '?', $this->getPOStrings() );
392391 reset( $po );
393392 foreach ( $po as $key => $value ) {
@@ -425,12 +424,12 @@
426425 $result .= Html::openElement( 'div', array( 'id' => "sort_div_$i" ) ) . 'Property '; // TODO: add i18n
427426 $result .= Html::input( 'property[' . $i . ']', $property_value, 'text', array( 'size' => '35' ) ) . "\n";
428427 $result .= html::openElement( 'select', array( 'name' => "order[$i]" ) );
429 - if ( !is_array( $order_values ) or !array_key_exists( $i, $order_values ) or $order_values[$i] == 'NONE'){
 428+ if ( !is_array( $order_values ) or !array_key_exists( $i, $order_values ) or $order_values[$i] == 'NONE' ) {
430429 $result .= '<option selected value="NONE">' . 'No sorting' . "</option>\n"; // TODO: add i18n
431430 } else {
432431 $result .= '<option value="NONE">' . 'No sorting' . "</option>\n"; // TODO: add i18n
433432 }
434 - if(is_array( $order_values ) and array_key_exists( $i, $order_values ) and $order_values[$i] == 'ASC' ) {
 433+ if ( is_array( $order_values ) and array_key_exists( $i, $order_values ) and $order_values[$i] == 'ASC' ) {
435434 $result .= '<option selected value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n";
436435 } else {
437436 $result .= '<option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n";
@@ -442,9 +441,9 @@
443442 }
444443 $result .= "</select> \n";
445444 if ( is_array( $display_values ) and array_key_exists( $i, $display_values ) ) {
446 - $result .= 'show in results: <input type="checkbox" checked name="display[' . $i . ']" value="yes">' . "\n"; // TODO: add i18n
 445+ $result .= '<input type="checkbox" checked name="display[' . $i . ']" value="yes">show in results' . "\n"; // TODO: add i18n
447446 } else {
448 - $result .= 'show in results: <input type="checkbox" name="display[' . $i . ']" value="yes">' . "\n"; // TODO: add i18n
 447+ $result .= '<input type="checkbox" name="display[' . $i . ']" value="yes">show in results' . "\n"; // TODO: add i18n
449448 }
450449 $result .= '[<a href="javascript:removePOInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n";
451450 $result .= "</div> \n";
@@ -457,7 +456,7 @@
458457 $result .= ' <option value="NONE"> No Sorting </option>' . "\n"; // TODO add i18n
459458 $result .= ' <option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n";
460459 $result .= ' <option value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option>\n</select>\n";
461 - $result .= 'show in results: <input type="checkbox" checked name="display_num" value="yes">' . "\n"; // TODO: add i18n
 460+ $result .= '<input type="checkbox" checked name="display_num" value="yes">show in results' . "\n"; // TODO: add i18n
462461 $result .= "</div>\n";
463462 $result .= '<div id="sorting_main"></div>' . "\n";
464463 $result .= '<a href="javascript:addPOInstance(\'sorting_starter\', \'sorting_main\')">' . '[Add additional properties]' . '</a>' . "\n";
@@ -537,14 +536,14 @@
538537
539538 /**
540539 * Decodes printouts and sorting - related form options generated by its
541 - * complement, getSortedPOFormBox(). UIs may overload both to change form
 540+ * complement, getPoSortFormBox(). UIs may overload both to change form
542541 * parameters.
543542 *
544543 * @global boolean $smwgQSortingSupport
545544 * @param WebRequest $wgRequest
546545 * @return string
547546 */
548 - protected function processSortedPOFormBox( WebRequest $wgRequest ) {
 547+ protected function processPoSortFormBox( WebRequest $wgRequest ) {
549548 global $smwgQSortingSupport;
550549 if ( !$smwgQSortingSupport ) return array();
551550
@@ -568,7 +567,7 @@
569568 $display_values = $wgRequest->getArray( 'display' );
570569 if ( is_array( $display_values ) ) {
571570 foreach ( $display_values as $key => $value ) {
572 - if ( $value == 'yes' and array_key_exists($key, $property_values )) {
 571+ if ( $value == 'yes' and array_key_exists( $key, $property_values ) ) {
573572 $po[] = '?' . trim( $property_values[$key] );
574573 }
575574
@@ -726,11 +725,10 @@
727726 * form elements. UIs may overload both to change the form parameter or the
728727 * html elements.
729728 *
730 - * @param string $content The content expected to appear in the box
731729 * @param boolean $enableAutocomplete If set to true, adds the relevant JS and CSS to the page
732730 * @return string The HTML code
733731 */
734 - protected function getPOFormBox( $content, $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
 732+ protected function getPOFormBox( $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
735733 global $wgOut;
736734
737735 if ( $enableAutocomplete ) {
@@ -774,7 +772,7 @@
775773
776774 }
777775
778 - return Html::element( 'textarea', array( 'id' => 'add_property', 'name' => 'po', 'cols' => '20', 'rows' => '6' ), $content );
 776+ return Html::element( 'textarea', array( 'id' => 'add_property', 'name' => 'po', 'cols' => '20', 'rows' => '6' ), $this->getPOStrings() );
779777 }
780778
781779 /**
@@ -861,7 +859,7 @@
862860
863861 foreach ( $params as $param ) {
864862 // Ignore the format parameter, as we got a special control in the GUI for it already.
865 - if ( $param->getName() == 'format' ) {
 863+ if ( $param->getName() == 'format' or $param->getName() == 'limit' or $param->getName() == 'offset' ) {
866864 continue;
867865 }
868866 $currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false;

Past revisions this follows-up on

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