Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -322,54 +322,51 @@ |
323 | 323 | */ |
324 | 324 | protected function addSortingFormBox() { |
325 | 325 | global $smwgQSortingSupport, $wgRequest, $wgOut, $smwgJQueryIncluded; |
| 326 | + if ( !$smwgQSortingSupport ) return ''; |
| 327 | + |
326 | 328 | $result = ''; |
327 | | - if ( $smwgQSortingSupport ) { |
| 329 | + if ( ! array_key_exists( 'sort', $this->m_params ) || ! array_key_exists( 'order', $this->m_params ) ) { |
| 330 | + $orders = array(); // do not even show one sort input here |
| 331 | + } else { |
| 332 | + $sorts = explode( ',', $this->m_params['sort'] ); |
| 333 | + $orders = explode( ',', $this->m_params['order'] ); |
| 334 | + reset( $sorts ); |
| 335 | + } |
328 | 336 | |
329 | | - if ( ! array_key_exists( 'sort', $this->m_params ) || ! array_key_exists( 'order', $this->m_params ) ) { |
330 | | - $orders = array(); // do not even show one sort input here |
331 | | - } else { |
332 | | - $sorts = explode( ',', $this->m_params['sort'] ); |
333 | | - $orders = explode( ',', $this->m_params['order'] ); |
334 | | - reset( $sorts ); |
335 | | - } |
| 337 | + foreach ( $orders as $i => $order ) { |
| 338 | + $result .= "<div id=\"sort_div_$i\">" . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" name="sort[' . $i . ']" value="' . |
| 339 | + htmlspecialchars( $sorts[$i] ) . "\" size=\"35\"/>\n" . '<select name="order[' . $i . ']"><option '; |
| 340 | + if ( $order == 'ASC' ) $result .= 'selected="selected" '; |
| 341 | + $result .= 'value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . '</option><option '; |
| 342 | + if ( $order == 'DESC' ) $result .= 'selected="selected" '; |
336 | 343 | |
337 | | - foreach ( $orders as $i => $order ) { |
338 | | - $result .= "<div id=\"sort_div_$i\">" . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" name="sort[' . $i . ']" value="' . |
339 | | - htmlspecialchars( $sorts[$i] ) . "\" size=\"35\"/>\n" . '<select name="order[' . $i . ']"><option '; |
340 | | - if ( $order == 'ASC' ) $result .= 'selected="selected" '; |
341 | | - $result .= 'value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . '</option><option '; |
342 | | - if ( $order == 'DESC' ) $result .= 'selected="selected" '; |
343 | | - |
344 | | - $result .= 'value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option></select>\n"; |
345 | | - $result .= '[<a href="javascript:removeInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n"; |
346 | | - $result .= "</div>\n"; |
347 | | - } |
348 | | - |
349 | | - $result .= '<div id="sorting_starter" style="display: none">' . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" name="sort_num" size="35" />' . "\n"; |
350 | | - $result .= ' <select name="order_num">' . "\n"; |
351 | | - $result .= ' <option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n"; |
352 | | - $result .= ' <option value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option>\n</select>\n"; |
| 344 | + $result .= 'value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option></select>\n"; |
| 345 | + $result .= '[<a href="javascript:removeInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n"; |
353 | 346 | $result .= "</div>\n"; |
354 | | - $result .= '<div id="sorting_main"></div>' . "\n"; |
355 | | - $result .= '<a href="javascript:addInstance(\'sorting_starter\', \'sorting_main\')">' . wfMsg( 'smw_add_sortcondition' ) . '</a>' . "\n"; |
| 347 | + } |
356 | 348 | |
| 349 | + $result .= '<div id="sorting_starter" style="display: none">' . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" name="sort_num" size="35" />' . "\n"; |
| 350 | + $result .= ' <select name="order_num">' . "\n"; |
| 351 | + $result .= ' <option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n"; |
| 352 | + $result .= ' <option value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option>\n</select>\n"; |
| 353 | + $result .= "</div>\n"; |
| 354 | + $result .= '<div id="sorting_main"></div>' . "\n"; |
| 355 | + $result .= '<a href="javascript:addInstance(\'sorting_starter\', \'sorting_main\')">' . wfMsg( 'smw_add_sortcondition' ) . '</a>' . "\n"; |
357 | 356 | |
| 357 | + $this->m_num_sort_values = 0; |
358 | 358 | |
359 | | - |
360 | | - $this->m_num_sort_values = 0; |
361 | | - |
362 | | - if ( !array_key_exists( 'sort', $this->m_params ) ) { |
363 | | - $sort_values = $wgRequest->getArray( 'sort' ); |
364 | | - if ( is_array( $sort_values ) ) { |
365 | | - $this->m_params['sort'] = implode( ',', $sort_values ); |
366 | | - $this->m_num_sort_values = count( $sort_values ); |
367 | | - } |
| 359 | + if ( !array_key_exists( 'sort', $this->m_params ) ) { |
| 360 | + $sort_values = $wgRequest->getArray( 'sort' ); |
| 361 | + if ( is_array( $sort_values ) ) { |
| 362 | + $this->m_params['sort'] = implode( ',', $sort_values ); |
| 363 | + $this->m_num_sort_values = count( $sort_values ); |
368 | 364 | } |
| 365 | + } |
369 | 366 | // Javascript code for handling adding and removing the "sort" inputs |
370 | | - $delete_msg = wfMsg( 'delete' ); |
| 367 | + $delete_msg = wfMsg( 'delete' ); |
371 | 368 | |
372 | 369 | |
373 | | - $javascript_text = <<<EOT |
| 370 | + $javascript_text = <<<EOT |
374 | 371 | <script type="text/javascript"> |
375 | 372 | // code for handling adding and removing the "sort" inputs |
376 | 373 | var num_elements = {$this->m_num_sort_values}; |
— | — | @@ -411,20 +408,20 @@ |
412 | 409 | |
413 | 410 | EOT; |
414 | 411 | |
415 | | - $wgOut->addScript( $javascript_text ); |
| 412 | + $wgOut->addScript( $javascript_text ); |
416 | 413 | |
417 | | - if ( !$smwgJQueryIncluded ) { |
418 | | - $realFunction = array( 'OutputPage', 'includeJQuery' ); |
419 | | - if ( is_callable( $realFunction ) ) { |
420 | | - $wgOut->includeJQuery(); |
421 | | - } else { |
422 | | - $scripts[] = "$smwgScriptPath/libs/jquery-1.4.2.min.js"; |
423 | | - } |
| 414 | + if ( !$smwgJQueryIncluded ) { |
| 415 | + $realFunction = array( 'OutputPage', 'includeJQuery' ); |
| 416 | + if ( is_callable( $realFunction ) ) { |
| 417 | + $wgOut->includeJQuery(); |
| 418 | + } else { |
| 419 | + $scripts[] = "$smwgScriptPath/libs/jquery-1.4.2.min.js"; |
| 420 | + } |
424 | 421 | |
425 | | - $smwgJQueryIncluded = true; |
426 | | - } |
427 | | - } |
428 | | - return $result; |
| 422 | + $smwgJQueryIncluded = true; |
| 423 | + } |
| 424 | + |
| 425 | + return $result; |
429 | 426 | } |
430 | 427 | |
431 | 428 | protected function processSortingFormBox( WebRequest $wgRequest ) { |
— | — | @@ -434,12 +431,15 @@ |
435 | 432 | $params['order'] = ''; |
436 | 433 | |
437 | 434 | foreach ( $order_values as $order_value ) { |
438 | | - if ( $order_value == '' ) $order_value = 'ASC'; |
| 435 | + if ( $order_value == '' ) { |
| 436 | + $order_value = 'ASC'; |
| 437 | + } |
439 | 438 | $params['order'] .= ( $params['order'] != '' ? ',' : '' ) . $order_value; |
440 | 439 | } |
441 | 440 | return $params; |
| 441 | + } else { |
| 442 | + return array(); |
442 | 443 | } |
443 | | - return array(); |
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
— | — | @@ -452,9 +452,9 @@ |
453 | 453 | * @return string The HTML code |
454 | 454 | */ |
455 | 455 | protected function getPOFormBox( $content, $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
| 456 | + global $wgOut; |
| 457 | + |
456 | 458 | if ( $enableAutocomplete ) { |
457 | | - global $wgOut; |
458 | | - |
459 | 459 | $this->addAutocompletionJavascriptAndCSS(); |
460 | 460 | $javascript_autocomplete_text = <<<EOT |
461 | 461 | <script type="text/javascript"> |
— | — | @@ -494,14 +494,14 @@ |
495 | 495 | $wgOut->addScript( $javascript_autocomplete_text ); |
496 | 496 | |
497 | 497 | } |
498 | | - $result = ""; |
499 | | - $result = Html::element( 'textarea', array( 'id' => 'add_property', 'name' => 'po', 'cols' => '20', 'rows' => '6' ), $content ); |
500 | | - return $result; |
| 498 | + |
| 499 | + return Html::element( 'textarea', array( 'id' => 'add_property', 'name' => 'po', 'cols' => '20', 'rows' => '6' ), $content ); |
501 | 500 | } |
502 | 501 | |
503 | 502 | /** |
504 | 503 | * Decodes form data sent through form-elements generated by |
505 | | - * its complement, getPOFormBox(). UIs may overload both to change form parameters. |
| 504 | + * its complement, getPOFormBox(). UIs may overload both to change form |
| 505 | + * parameters. |
506 | 506 | * |
507 | 507 | * @param WebRequest $wgRequest |
508 | 508 | * @return array |
— | — | @@ -523,17 +523,20 @@ |
524 | 524 | $poarray[] = $param; |
525 | 525 | } |
526 | 526 | } |
| 527 | + |
527 | 528 | return $poarray; |
528 | 529 | } |
529 | 530 | |
530 | 531 | /** |
531 | 532 | * Generates the url parameters based on passed parameters. |
532 | | - * UI implementations need to overload this if they use different form parameters. |
| 533 | + * UI implementations need to overload this if they use different form |
| 534 | + * parameters. |
533 | 535 | * |
534 | 536 | * @return string An url-encoded string. |
535 | 537 | */ |
536 | 538 | protected function getUrlTail() { |
537 | 539 | $urltail = '&q=' . urlencode( $this->uiCore->getQuerystring() ); |
| 540 | + |
538 | 541 | $tmp_parray = array(); |
539 | 542 | $params = $this->uiCore->getParams(); |
540 | 543 | foreach ( $params as $key => $value ) { |
— | — | @@ -541,16 +544,23 @@ |
542 | 545 | $tmp_parray[$key] = $value; |
543 | 546 | } |
544 | 547 | } |
| 548 | + $urltail .= '&p=' . urlencode( SMWInfolink::encodeParameters( $tmp_parray ) ); |
545 | 549 | |
546 | | - $urltail .= '&p=' . urlencode( SMWInfolink::encodeParameters( $tmp_parray ) ); |
547 | 550 | $printoutstring = ''; |
548 | 551 | foreach ( $this->uiCore->getPrintOuts() as $printout ) { |
549 | 552 | $printoutstring .= $printout->getSerialisation() . "\n"; |
550 | 553 | } |
551 | 554 | |
552 | | - if ( $printoutstring != '' ) $urltail .= '&po=' . urlencode( $printoutstring ); |
553 | | - if ( array_key_exists( 'sort', $params ) ) $urltail .= '&sort=' . $params['sort']; |
554 | | - if ( array_key_exists( 'order', $params ) ) $urltail .= '&order=' . $params['order']; |
| 555 | + if ( $printoutstring != '' ) { |
| 556 | + $urltail .= '&po=' . urlencode( $printoutstring ); |
| 557 | + } |
| 558 | + if ( array_key_exists( 'sort', $params ) ) { |
| 559 | + $urltail .= '&sort=' . $params['sort']; |
| 560 | + } |
| 561 | + if ( array_key_exists( 'order', $params ) ) { |
| 562 | + $urltail .= '&order=' . $params['order']; |
| 563 | + } |
| 564 | + |
555 | 565 | return $urltail; |
556 | 566 | } |
557 | 567 | |
— | — | @@ -564,8 +574,6 @@ |
565 | 575 | * @return string |
566 | 576 | */ |
567 | 577 | protected function showFormatOptions( $format, array $paramValues ) { |
568 | | - $text = ''; |
569 | | - |
570 | 578 | $printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE ); |
571 | 579 | |
572 | 580 | $params = method_exists( $printer, 'getParameters' ) ? $printer->getParameters() : array(); |
— | — | @@ -592,7 +600,7 @@ |
593 | 601 | ); |
594 | 602 | } |
595 | 603 | |
596 | | - for ( $i = 0, $n = count( $optionsHtml ); $i < $n; $i++ ) { |
| 604 | + for ( $i = 0, $n = count( $optionsHtml ); $i < $n; $i += 1 ) { |
597 | 605 | if ( $i % 3 == 2 || $i == $n - 1 ) { |
598 | 606 | $optionsHtml[$i] .= Html::element( 'div', array( 'style' => 'clear: both;' ) ) . "\n"; |
599 | 607 | } |
— | — | @@ -602,9 +610,10 @@ |
603 | 611 | $rowHtml = ''; |
604 | 612 | $resultHtml = ''; |
605 | 613 | |
| 614 | + /// @todo Check if this code works if the number of options is not a multiple of 3! |
606 | 615 | while ( $option = array_shift( $optionsHtml ) ) { |
607 | 616 | $rowHtml .= $option; |
608 | | - $i++; |
| 617 | + $i += 1; |
609 | 618 | |
610 | 619 | if ( $i % 3 == 0 ) { |
611 | 620 | $resultHtml .= Html::rawElement( |
— | — | @@ -625,7 +634,7 @@ |
626 | 635 | * Returns a Validator style Parameter definition. |
627 | 636 | * SMW 1.5.x style definitions are converted. |
628 | 637 | * |
629 | | - * @param mixed $param |
| 638 | + * @param mixed $param Parameter or array |
630 | 639 | * |
631 | 640 | * @return Parameter |
632 | 641 | */ |
— | — | @@ -639,8 +648,10 @@ |
640 | 649 | $param['type'] = 'string'; |
641 | 650 | } |
642 | 651 | |
643 | | - $paramClass = $param['type'] == 'enum-list' ? 'ListParameter' : 'Parameter'; |
644 | | - $paramType = array_key_exists( $param['type'], $typeMap ) ? $typeMap[$param['type']] : Parameter::TYPE_STRING; |
| 652 | + $paramClass = $param['type'] == 'enum-list' ? |
| 653 | + 'ListParameter' : 'Parameter'; |
| 654 | + $paramType = array_key_exists( $param['type'], $typeMap ) ? |
| 655 | + $typeMap[$param['type']] : Parameter::TYPE_STRING; |
645 | 656 | |
646 | 657 | $parameter = new $paramClass( $param['name'], $paramType ); |
647 | 658 | |
— | — | @@ -653,8 +664,7 @@ |
654 | 665 | } |
655 | 666 | |
656 | 667 | return $parameter; |
657 | | - } |
658 | | - else { |
| 668 | + } else { |
659 | 669 | return $param; |
660 | 670 | } |
661 | 671 | } |
— | — | @@ -666,6 +676,8 @@ |
667 | 677 | * @param mixed $currentValue |
668 | 678 | * |
669 | 679 | * @return string |
| 680 | + * @todo Change method name to reflect behaviour (it does not "show" anything). |
| 681 | + * @todo Document what kind of types are expected for $currentValue, or at least say what its meaning is. |
670 | 682 | */ |
671 | 683 | private function showFormatOption( Parameter $parameter, $currentValue ) { |
672 | 684 | $input = new ParameterInput( $parameter ); |
— | — | @@ -679,24 +691,25 @@ |
680 | 692 | } |
681 | 693 | |
682 | 694 | /** |
683 | | - * Creates form elements for choosing the result-format and their associated |
684 | | - * format. Use in conjunction with processFormatOptions() to supply formats |
685 | | - * options using ajax. Also, use its complement processFormatSelectBox() to |
686 | | - * decode form data sent by these elements. UI's may overload these methods |
687 | | - * to change behaviour or form parameters. |
| 695 | + * Creates form elements for choosing the result-format and their |
| 696 | + * associated format. Use in conjunction with processFormatOptions() to |
| 697 | + * supply formats options using ajax. Also, use its complement |
| 698 | + * processFormatSelectBox() to decode form data sent by these elements. |
| 699 | + * UI's may overload these methods to change behaviour or form |
| 700 | + * parameters. |
688 | 701 | * |
689 | 702 | * @param string $defaultformat The default format which remains selected in the form |
690 | 703 | * @return string |
691 | 704 | */ |
692 | 705 | protected function getFormatSelectBox( $defaultformat = 'broadtable' ) { |
693 | | - |
694 | 706 | global $smwgResultFormats, $smwgJQueryIncluded, $wgOut; |
695 | 707 | |
| 708 | + /// @todo The very same code for JQuery inclusion occurs multiple times. Should be a helper function. |
696 | 709 | if ( !$smwgJQueryIncluded ) { |
697 | 710 | $realFunction = array( 'OutputPage', 'includeJQuery' ); |
698 | 711 | if ( is_callable( $realFunction ) ) { |
699 | 712 | $wgOut->includeJQuery(); |
700 | | - } else { |
| 713 | + } else { ///@bug $scripts is undefined and not used later on |
701 | 714 | $scripts[] = "$smwgScriptPath/libs/jquery-1.4.2.min.js"; |
702 | 715 | } |
703 | 716 | $smwgJQueryIncluded = true; |
— | — | @@ -708,7 +721,7 @@ |
709 | 722 | $default_format = $defaultformat; |
710 | 723 | } |
711 | 724 | |
712 | | - $result = ""; |
| 725 | + $result = ''; |
713 | 726 | $printer = SMWQueryProcessor::getResultPrinter( $default_format, SMWQueryProcessor::SPECIAL_PAGE ); |
714 | 727 | $url = $this->getTitle()->getLocalURL( "showformatoptions=' + this.value + '" ); |
715 | 728 | |
— | — | @@ -719,11 +732,11 @@ |
720 | 733 | } |
721 | 734 | |
722 | 735 | $result .= "\n<p>" . wfMsg( 'smw_ask_format_as' ) . "\n" . |
723 | | - '<select id="formatSelector" name="p[format]" onChange="JavaScript:updateOtherOptions(\'' . $url . '\')">' . "\n" . |
724 | | - ' <option value="' . $default_format . '">' . $printer->getName() . ' (' . wfMsg( 'smw_ask_defaultformat' ) . ')</option>' . "\n"; |
| 736 | + '<select id="formatSelector" name="p[format]" onChange="JavaScript:updateOtherOptions(\'' . $url . '\')">' . "\n" . |
| 737 | + '<option value="' . $default_format . '">' . $printer->getName() . |
| 738 | + ' (' . wfMsg( 'smw_ask_defaultformat' ) . ')</option>' . "\n"; |
725 | 739 | |
726 | 740 | $formats = array(); |
727 | | - |
728 | 741 | foreach ( array_keys( $smwgResultFormats ) as $format ) { |
729 | 742 | // Special formats "count" and "debug" currently not supported. |
730 | 743 | if ( $format != $default_format && $format != 'count' && $format != 'debug' ) { |
— | — | @@ -731,12 +744,13 @@ |
732 | 745 | $formats[$format] = $printer->getName(); |
733 | 746 | } |
734 | 747 | } |
| 748 | + natcasesort( $formats ); |
735 | 749 | |
736 | | - natcasesort( $formats ); |
737 | 750 | $params = $this->uiCore->getParams(); |
738 | 751 | foreach ( $formats as $format => $name ) { |
739 | | - $result .= ' <option value="' . $format . '"' . ( $params['format'] == $format ? ' selected' : '' ) . '>' . $name . "</option>\n"; |
| 752 | + $result .= '<option value="' . $format . '"' . ( $params['format'] == $format ? ' selected' : '' ) . '>' . $name . "</option>\n"; |
740 | 753 | } |
| 754 | + |
741 | 755 | $result .= "</select>"; |
742 | 756 | $result .= "</p>\n"; |
743 | 757 | $result .= '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n"; |
— | — | @@ -744,7 +758,6 @@ |
745 | 759 | $result .= "</fieldset>\n"; |
746 | 760 | |
747 | 761 | // BEGIN: add javascript for updating formating options by ajax |
748 | | - global $wgOut; |
749 | 762 | $javascript = <<<END |
750 | 763 | <script type="text/javascript"> |
751 | 764 | function updateOtherOptions(strURL) { |
— | — | @@ -762,17 +775,19 @@ |
763 | 776 | } |
764 | 777 | |
765 | 778 | /** |
766 | | - * A method which decodes form data sent through form-elements generated by |
767 | | - * its complement, getFormatSelectBox(). UIs may overload both to change form parameters. |
| 779 | + * A method which decodes form data sent through form-elements generated |
| 780 | + * by its complement, getFormatSelectBox(). UIs may overload both to |
| 781 | + * change form parameters. |
768 | 782 | * |
769 | 783 | * @param WebRequest $wgRequest |
770 | 784 | * @return array |
771 | 785 | */ |
772 | 786 | protected function processFormatSelectBox( WebRequest $wgRequest ) { |
773 | 787 | $query_val = $wgRequest->getVal( 'p' ); |
774 | | - if ( !empty( $query_val ) ) |
| 788 | + |
| 789 | + if ( !empty( $query_val ) ) { |
775 | 790 | $params = SMWInfolink::decodeParameters( $query_val, false ); |
776 | | - else { |
| 791 | + } else { |
777 | 792 | $query_values = $wgRequest->getArray( 'p' ); |
778 | 793 | |
779 | 794 | if ( is_array( $query_values ) ) { |
— | — | @@ -781,34 +796,35 @@ |
782 | 797 | } |
783 | 798 | } |
784 | 799 | |
785 | | - // p is used for any additional parameters in certain links. |
786 | | - $params = SMWInfolink::decodeParameters( $query_values, false ); |
| 800 | + // p is used for any additional parameters in certain links. |
| 801 | + $params = SMWInfolink::decodeParameters( $query_values, false ); |
787 | 802 | } |
| 803 | + |
788 | 804 | return $params; |
789 | 805 | } |
790 | 806 | |
791 | 807 | /** |
792 | 808 | * Generates form elements for a (web)requested format. |
793 | 809 | * |
794 | | - * Required by getFormatSelectBox() to recieve form elements from the web. |
795 | | - * UIs may need to overload processFormatOptions(), getgetFormatSelectBox() |
796 | | - * and getFormatSelectBox() to change behavior. |
| 810 | + * Required by getFormatSelectBox() to recieve form elements from the Web. |
| 811 | + * UIs may need to overload processFormatOptions(), |
| 812 | + * getgetFormatSelectBox() and getFormatSelectBox() to change behavior. |
797 | 813 | * |
798 | 814 | * @param WebRequest $wgRequest |
799 | | - * @return boolean Returns true if format options were requested and returned, else false |
| 815 | + * @return boolean true if format options were requested and returned, else false |
800 | 816 | */ |
801 | 817 | protected function processFormatOptions( $wgRequest ) { |
802 | 818 | global $wgOut; |
803 | 819 | if ( $wgRequest->getCheck( 'showformatoptions' ) ) { |
804 | | - // handle Ajax action |
805 | | - $format = $wgRequest->getVal( 'showformatoptions' ); |
806 | | - $params = $wgRequest->getArray( 'params' ); |
807 | | - $wgOut->disable(); |
808 | | - echo $this->showFormatOptions( $format, $params ); |
809 | | - return true; |
810 | | - } else { |
811 | | - return false; |
812 | | - } |
| 820 | + // handle Ajax action |
| 821 | + $format = $wgRequest->getVal( 'showformatoptions' ); |
| 822 | + $params = $wgRequest->getArray( 'params' ); |
| 823 | + $wgOut->disable(); |
| 824 | + echo $this->showFormatOptions( $format, $params ); |
| 825 | + return true; |
| 826 | + } else { |
| 827 | + return false; |
| 828 | + } |
813 | 829 | } |
814 | 830 | |
815 | 831 | /** |
— | — | @@ -819,9 +835,9 @@ |
820 | 836 | * @return string |
821 | 837 | */ |
822 | 838 | public function getPOStrings() { |
823 | | - $string = ""; |
| 839 | + $string = ''; |
824 | 840 | $printouts = $this->uiCore->getPrintOuts(); |
825 | | - if ( !empty( $printouts ) ) { |
| 841 | + if ( !empty( $printouts ) ) { |
826 | 842 | foreach ( $printouts as $value ) { |
827 | 843 | $string .= $value->getSerialisation() . "\n"; |
828 | 844 | } |
— | — | @@ -830,32 +846,33 @@ |
831 | 847 | } |
832 | 848 | |
833 | 849 | /** |
834 | | - * Returns true if this page shows the navigationBar. Overload to change behavior. |
| 850 | + * Returns true if this page shows the navigationBar. Overload to change |
| 851 | + * behavior. |
835 | 852 | * |
836 | 853 | * @return boolean |
837 | 854 | */ |
838 | 855 | protected function usesNavigationBar() { |
839 | 856 | // hide if no results are found |
840 | | - if ( $this->uiCore->getResultCount() == 0 ) return false; |
841 | | - else return true; |
| 857 | + return ( $this->uiCore->getResultCount() != 0 ); |
842 | 858 | } |
843 | 859 | |
844 | 860 | } |
845 | 861 | |
846 | 862 | /** |
847 | | - * This class captures the core activities of what a semantic search page should do: |
848 | | - * (take parameters, validate them and generate results, or errors, if any). |
| 863 | + * This class captures the core activities of what a semantic search page should |
| 864 | + * do: take parameters, validate them and generate results, or errors, if any. |
849 | 865 | * |
850 | | - * Query UIs may use this class to create a customised UI interface. In most cases, |
851 | | - * one is likely to extend the SMWQueryUI class to build a Search Special page. |
852 | | - * However in order to acces some core featues, one may directly access the methods |
853 | | - * of this class. |
| 866 | + * Query UIs may use this class to create a customised UI interface. In most |
| 867 | + * cases, one is likely to extend the SMWQueryUI class to build a Search Special |
| 868 | + * page. However in order to acces some core featues, one may directly access |
| 869 | + * the methods of this class. |
854 | 870 | * |
855 | 871 | * This class does not define the format in which data should be passed through |
856 | 872 | * the web, except those already defined by SMWInfolink. |
857 | 873 | * |
858 | 874 | * @author Devayon Das |
859 | 875 | * |
| 876 | + * @todo The is_a function is deprecated in PHP and instanceof should be used instead. In many cases as simple check for "is_null" would be even better. |
860 | 877 | */ |
861 | 878 | class SMWQueryUIHelper { |
862 | 879 | |
— | — | @@ -866,19 +883,21 @@ |
867 | 884 | protected $queryString = ''; |
868 | 885 | |
869 | 886 | /** |
870 | | - * Various parameters passed by the user which control the format, limit, offset. |
| 887 | + * Various parameters passed by the user which control the format, |
| 888 | + * limit, offset. |
871 | 889 | * @var array of strings |
872 | 890 | */ |
873 | 891 | protected $parameters = array(); |
874 | 892 | |
875 | 893 | /** |
876 | | - * The additional columns to be displayed with results |
| 894 | + * The additional columns to be displayed with results. |
877 | 895 | * @var array of SMWPrintRequest |
878 | 896 | */ |
879 | 897 | protected $printOuts = array(); // Properties to be printed along with results |
880 | 898 | |
881 | 899 | /** |
882 | | - * The The additional columns to be displayed with results in '?property' form |
| 900 | + * The The additional columns to be displayed with results in |
| 901 | + * '?property' form. |
883 | 902 | * |
884 | 903 | * @var array of strings |
885 | 904 | */ |
— | — | @@ -928,7 +947,7 @@ |
929 | 948 | * |
930 | 949 | * @var array of SpecialPage |
931 | 950 | */ |
932 | | - protected static $uiPages = array(); // A list of Query UIs |
| 951 | + protected static $uiPages = array(); |
933 | 952 | |
934 | 953 | /** |
935 | 954 | * Although this constructor is publicly accessible, its use is discouraged. |
— | — | @@ -953,27 +972,26 @@ |
954 | 973 | /** |
955 | 974 | * Returns the limit of results defined. If not set, it returns 0. |
956 | 975 | * |
957 | | - * @return int |
| 976 | + * @return integer |
958 | 977 | */ |
959 | 978 | public function getLimit() { |
960 | 979 | if ( array_key_exists( 'limit', $this->parameters ) ) { |
961 | 980 | return $this->parameters['limit']; |
962 | | - } |
963 | | - else { |
| 981 | + } else { |
964 | 982 | return 0; |
965 | 983 | } |
966 | 984 | } |
967 | 985 | |
968 | 986 | /** |
969 | | - * Returns the offset of results. If it isnt defined, returns a default value of 20. |
| 987 | + * Returns the offset of results. If it isnt defined, returns a default |
| 988 | + * value of 20. |
970 | 989 | * |
971 | | - * @return int |
| 990 | + * @return integer |
972 | 991 | */ |
973 | 992 | public function getOffset() { |
974 | 993 | if ( array_key_exists( 'offset', $this->parameters ) ) { |
975 | 994 | return $this->parameters['offset']; |
976 | | - } |
977 | | - else { |
| 995 | + } else { |
978 | 996 | return 20; |
979 | 997 | } |
980 | 998 | } |
— | — | @@ -986,8 +1004,7 @@ |
987 | 1005 | public function hasFurtherResults() { |
988 | 1006 | if ( is_a( $this->queryResult, 'SMWQueryResult' ) ) { // The queryResult may not be set |
989 | 1007 | return $this->queryResult->hasFurtherResults(); |
990 | | - } |
991 | | - else { |
| 1008 | + } else { |
992 | 1009 | return false; |
993 | 1010 | } |
994 | 1011 | } |
— | — | @@ -996,10 +1013,10 @@ |
997 | 1014 | * Returns a handle to the underlying Result object. |
998 | 1015 | * |
999 | 1016 | * @return SMWQueryResult |
| 1017 | + * @todo Check if this method can be removed. |
1000 | 1018 | */ |
1001 | 1019 | public function getResultObject() { |
1002 | 1020 | return $this->queryResult; |
1003 | | - // TODO: see if this method can be removed. |
1004 | 1021 | } |
1005 | 1022 | |
1006 | 1023 | /** |
— | — | @@ -1015,17 +1032,17 @@ |
1016 | 1033 | * Register a Semantic Search Special Page. |
1017 | 1034 | * |
1018 | 1035 | * This method can be used by any new Query UI to register itself. |
1019 | | - * The corresponding method getUiList() would return the names of all lists |
1020 | | - * Query UIs. |
| 1036 | + * The corresponding method getUiList() would return the names of all |
| 1037 | + * lists Query UIs. |
1021 | 1038 | * |
1022 | 1039 | * @see getUiList() |
1023 | 1040 | * @param SpecialPage $page |
1024 | 1041 | */ |
1025 | 1042 | public static function addUI( SpecialPage &$page ) { |
1026 | | - /* |
1027 | | - * This way of registering, instead of using a global variable will cause |
1028 | | - * SMWQueryUIHelper to AutoLoad, but the alternate would break encapsulation. |
1029 | | - */ |
| 1043 | + /* |
| 1044 | + * This way of registering, instead of using a global variable will cause |
| 1045 | + * SMWQueryUIHelper to AutoLoad, but the alternate would break encapsulation. |
| 1046 | + */ |
1030 | 1047 | self::$uiPages[] = $page; |
1031 | 1048 | } |
1032 | 1049 | |
— | — | @@ -1040,8 +1057,8 @@ |
1041 | 1058 | } |
1042 | 1059 | |
1043 | 1060 | /** |
1044 | | - * Sets up a query. If validation is enabled, then the query string is checked |
1045 | | - * for errors. |
| 1061 | + * Sets up a query. If validation is enabled, then the query string is |
| 1062 | + * checked for errors. |
1046 | 1063 | * |
1047 | 1064 | * @param string $query_string The query |
1048 | 1065 | * @return array array of errors, if any. |
— | — | @@ -1053,9 +1070,7 @@ |
1054 | 1071 | if ( $enable_validation ) { |
1055 | 1072 | if ( $query_string == '' ) { |
1056 | 1073 | $errors[] = "No query has been specified"; // TODO i18n |
1057 | | - } |
1058 | | - else |
1059 | | - { |
| 1074 | + } else { |
1060 | 1075 | $query = SMWQueryProcessor::createQuery( $query_string, array() ); |
1061 | 1076 | $errors = $query ->getErrors(); |
1062 | 1077 | } |
— | — | @@ -1070,12 +1085,13 @@ |
1071 | 1086 | |
1072 | 1087 | /** |
1073 | 1088 | * |
1074 | | - * Sets up any extra properties which need to be displayed with results. Each |
1075 | | - * string in printouts should be of the form "?property" or "property" |
| 1089 | + * Sets up any extra properties which need to be displayed with results. |
| 1090 | + * Each string in printouts should be of the form "?property" or |
| 1091 | + * "property". |
1076 | 1092 | * |
1077 | | - * When validation is enabled, the values in $print_outs are checked against |
1078 | | - * properties which exist in the wiki, and a warning string (for each |
1079 | | - * property) is returned. Returns an empty array otherwise. |
| 1093 | + * When validation is enabled, the values in $print_outs are checked |
| 1094 | + * against properties which exist in the wiki, and a warning string (for |
| 1095 | + * each property) is returned. Returns an empty array otherwise. |
1080 | 1096 | * |
1081 | 1097 | * @param array $print_outs Array of strings |
1082 | 1098 | * @param boolean $enable_validation |
— | — | @@ -1106,12 +1122,13 @@ |
1107 | 1123 | /** |
1108 | 1124 | * Sets the parameters for the query. |
1109 | 1125 | * |
1110 | | - * The structure of $params is defined partly by #ask |
1111 | | - * and also by the Result Printer used. When validation is enabled, $params are checked |
| 1126 | + * The structure of $params is defined partly by #ask and also by the |
| 1127 | + * Result Printer used. When validation is enabled, $params are checked |
1112 | 1128 | * for conformance, and error messages, if any, are returned. |
1113 | 1129 | * |
1114 | | - * Although it is not mandatory for any params to be set while calling this method, |
1115 | | - * this method must be called so that default parameters are used. |
| 1130 | + * Although it is not mandatory for any params to be set while calling |
| 1131 | + * this method, this method must be called so that default parameters |
| 1132 | + * are used. |
1116 | 1133 | * |
1117 | 1134 | * @global int $smwgQMaxInlineLimit |
1118 | 1135 | * @global array $smwgResultFormats |
— | — | @@ -1123,40 +1140,39 @@ |
1124 | 1141 | global $smwgQMaxInlineLimit, $smwgResultFormats; |
1125 | 1142 | $errors = array(); |
1126 | 1143 | |
1127 | | - // checking for missing parameters and adding them |
1128 | | - if ( !array_key_exists( 'format', $params ) or ! array_key_exists ( $params['format'], $smwgResultFormats ) ) |
1129 | | - $params[ 'format' ] = $this->defaultResultPrinter; |
1130 | | - if ( !array_key_exists( 'limit', $params ) ) |
1131 | | - $params[ 'limit' ] = 20; |
| 1144 | + // checking for missing parameters and adding them |
| 1145 | + if ( !array_key_exists( 'format', $params ) or ! array_key_exists ( $params['format'], $smwgResultFormats ) ) { |
| 1146 | + $params[ 'format' ] = $this->defaultResultPrinter; |
| 1147 | + } |
| 1148 | + if ( !array_key_exists( 'limit', $params ) ) { |
| 1149 | + $params[ 'limit' ] = 20; |
| 1150 | + } |
1132 | 1151 | $params[ 'limit' ] = min( $params[ 'limit' ], $smwgQMaxInlineLimit ); |
1133 | | - if ( !array_key_exists( 'offset', $params ) ) |
1134 | | - $params['offset'] = 0; |
| 1152 | + if ( !array_key_exists( 'offset', $params ) ) { |
| 1153 | + $params['offset'] = 0; |
| 1154 | + } |
1135 | 1155 | |
1136 | | - if ( $enable_validation ) { |
1137 | | - // validating the format |
| 1156 | + if ( $enable_validation ) { // validating the format |
1138 | 1157 | if ( !array_key_exists( $params['format'], $smwgResultFormats ) ) { |
1139 | 1158 | $errors[] = "The chosen format " + $params['format'] + " does not exist for this wiki"; // TODO i18n |
1140 | 1159 | $this->errorsOccured = true; |
1141 | | - } |
1142 | | - else |
1143 | | - { // validating parameters for result printer |
| 1160 | + } else { // validating parameters for result printer |
1144 | 1161 | $printer = SMWQueryProcessor::getResultPrinter( $params[ 'format' ] ); |
1145 | 1162 | $para_meters = $printer->getParameters(); |
1146 | 1163 | if ( is_array( $para_meters ) ) { |
1147 | | - $validator = new Validator(); |
1148 | | - $validator -> setParameters( $params, $para_meters ); |
1149 | | - $validator->validateParameters(); |
1150 | | - $validator_has_error = $validator->hasFatalError(); |
1151 | | - if ( $validator_has_error ) { |
1152 | | - array_merge ( $errors, $validator->getErrorMessages () ); |
1153 | | - $this->errorsOccured = true; |
1154 | | - } |
| 1164 | + $validator = new Validator(); |
| 1165 | + $validator->setParameters( $params, $para_meters ); |
| 1166 | + $validator->validateParameters(); |
| 1167 | + if ( $validator->hasFatalError() ) { |
| 1168 | + array_merge ( $errors, $validator->getErrorMessages () ); |
| 1169 | + $this->errorsOccured = true; |
| 1170 | + } |
1155 | 1171 | } |
1156 | 1172 | } |
1157 | 1173 | } |
1158 | 1174 | |
1159 | | - $this -> parameters = $params; |
1160 | | - $this -> errors = array_merge( $errors, $this->errors ); |
| 1175 | + $this->parameters = $params; |
| 1176 | + $this->errors = array_merge( $errors, $this->errors ); |
1161 | 1177 | return $errors; |
1162 | 1178 | } |
1163 | 1179 | |
— | — | @@ -1164,15 +1180,12 @@ |
1165 | 1181 | * Processes the QueryString, Params, and PrintOuts. |
1166 | 1182 | * |
1167 | 1183 | * @todo Combine this method with execute() or remove it altogether. |
1168 | | - * |
1169 | 1184 | */ |
1170 | 1185 | public function extractParameters( $p ) { |
1171 | 1186 | if ( $this->context == self::SPECIAL_PAGE ) { |
1172 | 1187 | // assume setParams(), setPintouts and setQueryString have been called |
1173 | 1188 | $rawparams = array_merge( $this->parameters, array( $this->queryString ), $this->printOutStrings ); |
1174 | | - } |
1175 | | - else // context is WIKI_LINK |
1176 | | - { |
| 1189 | + } else {// context is WIKI_LINK |
1177 | 1190 | $rawparams = SMWInfolink::decodeParameters( $p, true ); |
1178 | 1191 | // calling setParams to fill in missing parameters |
1179 | 1192 | $this->setParams( $rawparams ); |
— | — | @@ -1185,17 +1198,20 @@ |
1186 | 1199 | /** |
1187 | 1200 | * Executes the query. |
1188 | 1201 | * |
1189 | | - * This method can be called once $queryString, $parameters, $printOuts are set |
1190 | | - * either by using the setQueryString(), setParams() and setPrintOuts() followed by extractParameters(), |
1191 | | - * or one of the static factory methods such as makeForInfoLink() or makeForUI(). |
| 1202 | + * This method can be called once $queryString, $parameters, $printOuts |
| 1203 | + * are set either by using the setQueryString(), setParams() and |
| 1204 | + * setPrintOuts() followed by extractParameters(), or one of the static |
| 1205 | + * factory methods such as makeForInfoLink() or makeForUI(). |
1192 | 1206 | * |
1193 | 1207 | * Errors, if any can be accessed from hasError() and getErrors(). |
1194 | 1208 | */ |
1195 | 1209 | public function execute() { |
1196 | 1210 | $errors = array(); |
1197 | | - $query = SMWQueryProcessor::createQuery( $this->queryString, $this->parameters, SMWQueryProcessor::SPECIAL_PAGE , $this->parameters['format'], $this->printOuts ); |
| 1211 | + $query = SMWQueryProcessor::createQuery( $this->queryString, $this->parameters, |
| 1212 | + SMWQueryProcessor::SPECIAL_PAGE , $this->parameters['format'], $this->printOuts ); |
1198 | 1213 | $res = smwfGetStore()->getQueryResult( $query ); |
1199 | 1214 | $this->queryResult = $res; |
| 1215 | + |
1200 | 1216 | $errors = array_merge( $errors, $res->getErrors() ); |
1201 | 1217 | if ( !empty( $errors ) ) { |
1202 | 1218 | $this->errorsOccured = true; |
— | — | @@ -1213,7 +1229,7 @@ |
1214 | 1230 | $desckey = false; |
1215 | 1231 | } |
1216 | 1232 | |
1217 | | - if ( ( $desckey ) && ( $query->getDescription() instanceof SMWConceptDescription ) && |
| 1233 | + if ( $desckey && ( $query->getDescription() instanceof SMWConceptDescription ) && |
1218 | 1234 | ( !isset( $this->parameters[$desckey] ) || !isset( $this->parameters[$titlekey] ) ) ) { |
1219 | 1235 | $concept = $query->getDescription()->getConcept(); |
1220 | 1236 | |
— | — | @@ -1222,6 +1238,7 @@ |
1223 | 1239 | } |
1224 | 1240 | |
1225 | 1241 | if ( !isset( $this->parameters[$desckey] ) ) { |
| 1242 | + /// @bug The current SMWStore will never return SMWConceptValue (an SMWDataValue) here; it might return SMWDIConcept (an SMWDataItem) |
1226 | 1243 | $dv = end( smwfGetStore()->getPropertyValues( SMWWikiPageValue::makePageFromTitle( $concept ), new SMWDIProperty( '_CONC' ) ) ); |
1227 | 1244 | if ( $dv instanceof SMWConceptValue ) { |
1228 | 1245 | $this->parameters[$desckey] = $dv->getDocu(); |
— | — | @@ -1232,32 +1249,34 @@ |
1233 | 1250 | } |
1234 | 1251 | |
1235 | 1252 | /** |
1236 | | - * Returns the results in HTML, or in case of exports, a link to the result. |
| 1253 | + * Returns the results in HTML, or in case of exports, a link to the |
| 1254 | + * result. |
1237 | 1255 | * |
1238 | 1256 | * This method can only be called after execute() has been called. |
1239 | 1257 | * |
1240 | | - * @return string of all the html generated |
| 1258 | + * @return string of all the HTML generated |
1241 | 1259 | */ |
1242 | 1260 | public function getHTMLResult() { |
1243 | 1261 | $result = ''; |
| 1262 | + |
1244 | 1263 | $res = $this->queryResult; |
1245 | | - $printer = SMWQueryProcessor::getResultPrinter( $this->parameters['format'], SMWQueryProcessor::SPECIAL_PAGE ); |
| 1264 | + $printer = SMWQueryProcessor::getResultPrinter( $this->parameters['format'], |
| 1265 | + SMWQueryProcessor::SPECIAL_PAGE ); |
1246 | 1266 | $result_mime = $printer->getMimeType( $res ); |
1247 | 1267 | |
1248 | | - if ( $res->getCount() > 0 ) { |
| 1268 | + if ( $res->getCount() > 0 ) { |
| 1269 | + $query_result = $printer->getResult( $res, $this->parameters, SMW_OUTPUT_HTML ); |
1249 | 1270 | |
1250 | | - $query_result = $printer->getResult( $res, $this->parameters, SMW_OUTPUT_HTML ); |
1251 | | - |
1252 | | - if ( is_array( $query_result ) ) { |
1253 | | - $result .= $query_result[0]; |
1254 | | - } else { |
1255 | | - $result .= $query_result; |
1256 | | - } |
1257 | | - |
| 1271 | + if ( is_array( $query_result ) ) { |
| 1272 | + $result .= $query_result[0]; |
1258 | 1273 | } else { |
1259 | | - $result = wfMsg( 'smw_result_noresults' ); |
| 1274 | + $result .= $query_result; |
1260 | 1275 | } |
1261 | | - return $result; |
| 1276 | + } else { |
| 1277 | + $result = wfMsg( 'smw_result_noresults' ); |
| 1278 | + } |
| 1279 | + |
| 1280 | + return $result; |
1262 | 1281 | } |
1263 | 1282 | |
1264 | 1283 | /** |
— | — | @@ -1271,7 +1290,8 @@ |
1272 | 1291 | $result .= '|' . $printout->getSerialisation() . "\n"; |
1273 | 1292 | } |
1274 | 1293 | foreach ( $this->parameters as $param_name => $param_value ) { |
1275 | | - $result .= '|' . htmlspecialchars( $param_name ) . '=' . htmlspecialchars( $param_value ) . "\n"; |
| 1294 | + $result .= '|' . htmlspecialchars( $param_name ) . |
| 1295 | + '=' . htmlspecialchars( $param_value ) . "\n"; |
1276 | 1296 | } |
1277 | 1297 | $result .= '}}'; |
1278 | 1298 | return $result; |
— | — | @@ -1294,45 +1314,48 @@ |
1295 | 1315 | public function getResultCount() { |
1296 | 1316 | if ( is_a( $this->queryResult, 'SMWQueryResult' ) ) { |
1297 | 1317 | return $this->queryResult->getCount(); |
| 1318 | + } else { |
| 1319 | + return 0; |
1298 | 1320 | } |
1299 | | - else return 0; |
1300 | | - |
1301 | 1321 | } |
1302 | 1322 | |
1303 | 1323 | /** |
1304 | | - * Retuens the param array |
| 1324 | + * Returns the parameter array. |
1305 | 1325 | * |
1306 | 1326 | * @return array |
| 1327 | + * @todo Always avoid abbreviations (unless they are a special technical term used everywhere). Call this getParameters(). |
1307 | 1328 | */ |
1308 | 1329 | public function getParams() { |
1309 | 1330 | return $this->parameters; |
1310 | 1331 | } |
1311 | 1332 | |
1312 | 1333 | /** |
1313 | | - * Returns additional prinouts as an array of SMWPrintRequests |
| 1334 | + * Returns additional prinouts as an array of SMWPrintRequests. |
1314 | 1335 | * |
1315 | 1336 | * @return array SMWPrintRequest or an empty array |
1316 | 1337 | */ |
1317 | 1338 | public function getPrintOuts() { |
1318 | | - if ( !empty( $this->printOuts ) ) { |
1319 | | - if ( is_a( $this->printOuts[0], 'SMWPrintRequest' ) ) { |
1320 | | - return $this->printOuts; |
1321 | | - } |
| 1339 | + if ( !empty( $this->printOuts ) && |
| 1340 | + is_a( $this->printOuts[0], 'SMWPrintRequest' ) ) { |
| 1341 | + return $this->printOuts; |
1322 | 1342 | } |
1323 | 1343 | return array(); |
1324 | 1344 | } |
1325 | 1345 | |
1326 | 1346 | /** |
1327 | | - * Constructs a new SMWQueryUIHelper when parameters are passed in the InfoLink style |
| 1347 | + * Constructs a new SMWQueryUIHelper when parameters are passed in the |
| 1348 | + * InfoLink style. |
1328 | 1349 | * |
1329 | 1350 | * Errors, if any can be accessed from hasError() and getErrors() |
1330 | 1351 | * |
1331 | | - * @param string $p parametrs |
| 1352 | + * @param string $p parameters |
1332 | 1353 | * @param boolean $enable_validation |
1333 | 1354 | * @return SMWQueryUIHelper |
| 1355 | + * |
| 1356 | + * @todo The above documentation contains an unclear sequence of words that do not form a sentence. |
| 1357 | + * @todo Handle validation for infolink parameters |
1334 | 1358 | */ |
1335 | 1359 | public static function makeForInfoLink( $p, $enable_validation = true ) { |
1336 | | - // TODO handle validation for infolink parameters |
1337 | 1360 | $result = new SMWQueryUIHelper( self::WIKI_LINK ); |
1338 | 1361 | $result->extractParameters( $p ); |
1339 | 1362 | $result->execute(); |
— | — | @@ -1340,7 +1363,8 @@ |
1341 | 1364 | } |
1342 | 1365 | |
1343 | 1366 | /** |
1344 | | - * Constructs a new SMWQueryUIHelper when arguments are extracted from the UI |
| 1367 | + * Constructs a new SMWQueryUIHelper when arguments are extracted from |
| 1368 | + * the UI. |
1345 | 1369 | * |
1346 | 1370 | * Errors, if any can be accessed from hasError() and getErrors() |
1347 | 1371 | * |
— | — | @@ -1349,28 +1373,31 @@ |
1350 | 1374 | * @param array $printouts array of '?property' strings |
1351 | 1375 | * @param boolean $enable_validation |
1352 | 1376 | * @return SMWQueryUIHelper |
| 1377 | + * |
| 1378 | + * @todo The above documentation contains an unclear sequence of words that do not form a sentence. |
1353 | 1379 | */ |
1354 | 1380 | public static function makeForUI( $query, array $params, array $printouts, $enable_validation = true ) { |
1355 | 1381 | $result = new SMWQueryUIHelper( self::SPECIAL_PAGE ); |
1356 | 1382 | $result->setParams( $params, $enable_validation ); |
1357 | 1383 | $result->setPrintOuts( $printouts, $enable_validation ); |
1358 | 1384 | $result->setQueryString( $query, $enable_validation ); |
1359 | | - $result->extractParameters( "" ); |
| 1385 | + $result->extractParameters( '' ); |
1360 | 1386 | // $result->execute(); |
1361 | 1387 | return $result; |
1362 | 1388 | } |
1363 | 1389 | |
1364 | 1390 | /** |
1365 | | - * Checks if $property exists in the wiki or not |
| 1391 | + * Checks if $property exists in the wiki or not. |
1366 | 1392 | * |
1367 | 1393 | * @return bool |
| 1394 | + * @todo Document parameter type and format. |
1368 | 1395 | */ |
1369 | 1396 | protected static function validateProperty( $property ) { |
1370 | 1397 | /* |
1371 | 1398 | * Curently there isn't a simple, back-end agnost way of searching for properties from |
1372 | 1399 | * SMWStore. We hence we check if $property has a corresponding page describing it. |
1373 | 1400 | */ |
1374 | | - $prop = substr ( $property, 1 );// removing the leading '?' while checking. |
| 1401 | + $prop = substr( $property, 1 ); // removing the leading '?' while checking. |
1375 | 1402 | $propertypage = Title::newFromText( $prop, SMW_NS_PROPERTY ); |
1376 | 1403 | if ( is_a( $propertypage, 'Title' ) ) { |
1377 | 1404 | return( $propertypage->exists() ); |