Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -84,13 +84,13 @@ |
85 | 85 | $this->uiCore = SMWQueryUIHelper::makeForInfoLink( $p ); |
86 | 86 | } |
87 | 87 | // 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 ); |
95 | 95 | } |
96 | 96 | |
97 | 97 | $this->makePage( $p ); |
— | — | @@ -102,10 +102,10 @@ |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * To enable/disable syndicated feeds of results to appear in the UI header |
106 | | - * |
| 106 | + * |
107 | 107 | * @return boolean |
108 | 108 | */ |
109 | | - public function isSyndicated(){ |
| 109 | + public function isSyndicated() { |
110 | 110 | return true; |
111 | 111 | } |
112 | 112 | |
— | — | @@ -365,7 +365,7 @@ |
366 | 366 | |
367 | 367 | $result = ''; |
368 | 368 | |
369 | | - //START: fetch sorting order, if defined earlier |
| 369 | + // START: fetch sorting order, if defined earlier |
370 | 370 | $params = $this->uiCore->getParameters(); |
371 | 371 | if ( array_key_exists( 'sort', $params ) && array_key_exists( 'order', $params ) ) { |
372 | 372 | $sorts = explode( ',', $params['sort'] ); |
— | — | @@ -385,25 +385,26 @@ |
386 | 386 | } |
387 | 387 | |
388 | 388 | 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="' . |
390 | 391 | htmlspecialchars( $sorts[$i] ) . "\" size=\"35\"/>\n" . '<select name="order[' . $i . ']"><option '; |
391 | 392 | if ( $order == 'ASC' ) $result .= 'selected="selected" '; |
392 | 393 | $result .= 'value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . '</option><option '; |
393 | 394 | if ( $order == 'DESC' ) $result .= 'selected="selected" '; |
394 | | - |
395 | 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' |
396 | 397 | $result .= '[<a href="javascript:removePOInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n"; |
397 | 398 | $result .= "</div>\n"; |
398 | 399 | } |
399 | | - //END: fetch sorting order, if defined earlier |
| 400 | + // END: fetch sorting order, if defined earlier |
400 | 401 | |
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 |
402 | 403 | ' <input type="text" size="35" name="property_num" />' . "\n"; |
403 | 404 | $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 |
405 | 406 | $result .= ' <option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n"; |
406 | 407 | $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 |
408 | 409 | $result .= "</div>\n"; |
409 | 410 | $result .= '<div id="sorting_main"></div>' . "\n"; |
410 | 411 | $result .= '<a href="javascript:addPOInstance(\'sorting_starter\', \'sorting_main\')">' . '[Add additional properties]' . '</a>' . "\n"; |
— | — | @@ -412,7 +413,9 @@ |
413 | 414 | $delete_msg = wfMsg( 'delete' ); |
414 | 415 | |
415 | 416 | $this->enableJQuery(); |
416 | | - $this->addAutocompletionJavascriptAndCSS(); |
| 417 | + if ( $enableAutocomplete == SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
| 418 | + $this->addAutocompletionJavascriptAndCSS(); |
| 419 | + } |
417 | 420 | $javascript_text = <<<EOT |
418 | 421 | <script type="text/javascript"> |
419 | 422 | // code for handling adding and removing the "sort" inputs |
— | — | @@ -443,7 +446,9 @@ |
444 | 447 | |
445 | 448 | //Add the new instance |
446 | 449 | main_div.appendChild(new_div); |
447 | | - |
| 450 | +EOT; |
| 451 | + if ( $enableAutocomplete == SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
| 452 | + $javascript_text .= <<<EOT |
448 | 453 | //add autocomplete |
449 | 454 | jQuery('[name*="property"]').autocomplete({ |
450 | 455 | minLength: 2, |
— | — | @@ -457,7 +462,9 @@ |
458 | 463 | }); |
459 | 464 | } |
460 | 465 | }); |
461 | | - |
| 466 | +EOT; |
| 467 | + } |
| 468 | + $javascript_text .= <<<EOT |
462 | 469 | num_elements++; |
463 | 470 | |
464 | 471 | } |
— | — | @@ -495,25 +502,25 @@ |
496 | 503 | $params['sort'] = ''; |
497 | 504 | $params['order'] = ''; |
498 | 505 | 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]; |
502 | 509 | } |
503 | 510 | } |
504 | 511 | } |
505 | 512 | |
506 | 513 | $display_values = $wgRequest->getArray( 'display' ); |
507 | 514 | $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]; |
512 | 519 | } |
513 | 520 | |
514 | 521 | } |
515 | 522 | } |
516 | 523 | |
517 | | - $params=array_merge($params,$po); |
| 524 | + $params = array_merge( $params, $po ); |
518 | 525 | |
519 | 526 | return $params; |
520 | 527 | |
— | — | @@ -798,7 +805,7 @@ |
799 | 806 | |
800 | 807 | foreach ( $params as $param ) { |
801 | 808 | // 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' ) { |
803 | 810 | continue; |
804 | 811 | } |
805 | 812 | $currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false; |