r93177 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93176‎ | r93177 | r93178 >
Date:13:51, 26 July 2011
Author:devayon
Status:deferred
Tags:
Comment:
cleanup, 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
@@ -84,13 +84,13 @@
8585 $this->uiCore = SMWQueryUIHelper::makeForInfoLink( $p );
8686 }
8787 // adding rss feed of results to the page head
88 - if(($this->uiCore->getQueryString()!=='')
89 - and ($this->isSyndicated())
90 - and (method_exists($wgOut, 'addFeedlink')) //remove this line after MW 1.5 is no longer supported by SMW
91 - and (array_key_exists('rss', $wgFeedClasses))){
92 - $res=$this->uiCore->getResultObject();
93 - $href=$res->getQueryLink()->getURl().'/format%3Drss/limit%3D'. $this->uiCore->getLimit();
94 - $wgOut->addFeedLink('rss', $href);
 88+ if ( ( $this->uiCore->getQueryString() !== '' )
 89+ and ( $this->isSyndicated() )
 90+ and ( method_exists( $wgOut, 'addFeedlink' ) ) // remove this line after MW 1.5 is no longer supported by SMW
 91+ and ( array_key_exists( 'rss', $wgFeedClasses ) ) ) {
 92+ $res = $this->uiCore->getResultObject();
 93+ $href = $res->getQueryLink()->getURl() . '/format%3Drss/limit%3D' . $this->uiCore->getLimit();
 94+ $wgOut->addFeedLink( 'rss', $href );
9595 }
9696
9797 $this->makePage( $p );
@@ -102,10 +102,10 @@
103103
104104 /**
105105 * To enable/disable syndicated feeds of results to appear in the UI header
106 - *
 106+ *
107107 * @return boolean
108108 */
109 - public function isSyndicated(){
 109+ public function isSyndicated() {
110110 return true;
111111 }
112112
@@ -365,7 +365,7 @@
366366
367367 $result = '';
368368
369 - //START: fetch sorting order, if defined earlier
 369+ // START: fetch sorting order, if defined earlier
370370 $params = $this->uiCore->getParameters();
371371 if ( array_key_exists( 'sort', $params ) && array_key_exists( 'order', $params ) ) {
372372 $sorts = explode( ',', $params['sort'] );
@@ -385,25 +385,26 @@
386386 }
387387
388388 foreach ( $orders as $i => $order ) {
389 - $result .= "<div id=\"sort_div_$i\">" . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" name="sort[' . $i . ']" value="' .
 389+ $result .= "<div id=\"sort_div_$i\">" . 'Property' . // TODO: add i18n
 390+ ' <input type="text" name="property[' . $i . ']" value="' .
390391 htmlspecialchars( $sorts[$i] ) . "\" size=\"35\"/>\n" . '<select name="order[' . $i . ']"><option ';
391392 if ( $order == 'ASC' ) $result .= 'selected="selected" ';
392393 $result .= 'value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . '</option><option ';
393394 if ( $order == 'DESC' ) $result .= 'selected="selected" ';
394 -
395395 $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'
396397 $result .= '[<a href="javascript:removePOInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n";
397398 $result .= "</div>\n";
398399 }
399 - //END: fetch sorting order, if defined earlier
 400+ // END: fetch sorting order, if defined earlier
400401
401 - $result .= '<div id="sorting_starter" style="display: none">' . 'Property' . //TODO: add i18n
 402+ $result .= '<div id="sorting_starter" style="display: none">' . 'Property' . // TODO: add i18n
402403 ' <input type="text" size="35" name="property_num" />' . "\n";
403404 $result .= ' <select name="order_num">' . "\n";
404 - $result .= ' <option value="NONE"> No Sorting </option>'."\n"; //TODO add i18n
 405+ $result .= ' <option value="NONE"> No Sorting </option>' . "\n"; // TODO add i18n
405406 $result .= ' <option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n";
406407 $result .= ' <option value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option>\n</select>\n";
407 - $result .= 'show in results: <input type="checkbox" checked name="display_num" value="yes">'."\n"; //TODO: add i18n
 408+ $result .= 'show in results: <input type="checkbox" checked name="display_num" value="yes">' . "\n"; // TODO: add i18n
408409 $result .= "</div>\n";
409410 $result .= '<div id="sorting_main"></div>' . "\n";
410411 $result .= '<a href="javascript:addPOInstance(\'sorting_starter\', \'sorting_main\')">' . '[Add additional properties]' . '</a>' . "\n";
@@ -412,7 +413,9 @@
413414 $delete_msg = wfMsg( 'delete' );
414415
415416 $this->enableJQuery();
416 - $this->addAutocompletionJavascriptAndCSS();
 417+ if ( $enableAutocomplete == SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
 418+ $this->addAutocompletionJavascriptAndCSS();
 419+ }
417420 $javascript_text = <<<EOT
418421 <script type="text/javascript">
419422 // code for handling adding and removing the "sort" inputs
@@ -443,7 +446,9 @@
444447
445448 //Add the new instance
446449 main_div.appendChild(new_div);
447 -
 450+EOT;
 451+ if ( $enableAutocomplete == SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
 452+ $javascript_text .= <<<EOT
448453 //add autocomplete
449454 jQuery('[name*="property"]').autocomplete({
450455 minLength: 2,
@@ -457,7 +462,9 @@
458463 });
459464 }
460465 });
461 -
 466+EOT;
 467+ }
 468+ $javascript_text .= <<<EOT
462469 num_elements++;
463470
464471 }
@@ -495,25 +502,25 @@
496503 $params['sort'] = '';
497504 $params['order'] = '';
498505 foreach ( $order_values as $key => $order_value ) {
499 - if($order_value!='NONE'){
500 - $params['sort'] .= ($params['sort']!=''?',':'') . $property_values[$key];
501 - $params['order'] .= ($params['order']!=''?',':''). $order_values[$key];
 506+ if ( $order_value != 'NONE' ) {
 507+ $params['sort'] .= ( $params['sort'] != '' ? ',':'' ) . $property_values[$key];
 508+ $params['order'] .= ( $params['order'] != '' ? ',':'' ) . $order_values[$key];
502509 }
503510 }
504511 }
505512
506513 $display_values = $wgRequest->getArray( 'display' );
507514 $po = array();
508 - if( is_array($display_values) ) {
509 - foreach ($display_values as $key => $value) {
510 - if($value == 'yes'){
511 - $po[] = '?'.$property_values[$key];
 515+ if ( is_array( $display_values ) ) {
 516+ foreach ( $display_values as $key => $value ) {
 517+ if ( $value == 'yes' ) {
 518+ $po[] = '?' . $property_values[$key];
512519 }
513520
514521 }
515522 }
516523
517 - $params=array_merge($params,$po);
 524+ $params = array_merge( $params, $po );
518525
519526 return $params;
520527
@@ -798,7 +805,7 @@
799806
800807 foreach ( $params as $param ) {
801808 // Ignore the format parameter, as we got a special control in the GUI for it already.
802 - if( $param->getName() == 'format') {
 809+ if ( $param->getName() == 'format' ) {
803810 continue;
804811 }
805812 $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