Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -85,6 +85,7 @@ |
86 | 86 | }); |
87 | 87 | } |
88 | 88 | }); |
| 89 | +</script> |
89 | 90 | END; |
90 | 91 | |
91 | 92 | $wgOut->addScript( $javascript_autocomplete_text ); |
— | — | @@ -273,9 +274,9 @@ |
274 | 275 | * @param WebRequest $wgRequest |
275 | 276 | * @return string |
276 | 277 | */ |
277 | | - protected function processQueryFormBox(WebRequest $wgRequest){ |
278 | | - $query=""; |
279 | | - if($wgRequest->getCheck('q')) $query = $wgRequest->getVal('q'); |
| 278 | + protected function processQueryFormBox( WebRequest $wgRequest ) { |
| 279 | + $query = ""; |
| 280 | + if ( $wgRequest->getCheck( 'q' ) ) $query = $wgRequest->getVal( 'q' ); |
280 | 281 | return $query; |
281 | 282 | } |
282 | 283 | |
— | — | @@ -284,7 +285,6 @@ |
285 | 286 | * Use its complement processPOFormBox() to decode data sent through these |
286 | 287 | * form elements. UIs may overload both to change the form parameter or the html elements. |
287 | 288 | * |
288 | | - * @global OutputPage $wgOut |
289 | 289 | * @param string $content The content expected to appear in the box |
290 | 290 | * @param boolean $enableAutocomplete If set to true, adds the relevant JS and CSS to the page |
291 | 291 | * @return string The HTML code |
— | — | @@ -293,8 +293,8 @@ |
294 | 294 | if ( $enableAutocomplete ) { |
295 | 295 | global $wgOut; |
296 | 296 | |
297 | | - if ( !$this->autocompleteenabled ) addAutocompletionJavascriptAndCSS(); |
298 | | - $javascript_autocomplete_text = <<<END |
| 297 | + $this->addAutocompletionJavascriptAndCSS(); |
| 298 | + $javascript_autocomplete_text = <<<EOT |
299 | 299 | <script type="text/javascript"> |
300 | 300 | jQuery(document).ready(function(){ |
301 | 301 | jQuery("#add_property").autocomplete({ |
— | — | @@ -327,7 +327,7 @@ |
328 | 328 | }); |
329 | 329 | }); |
330 | 330 | </script> |
331 | | -END; |
| 331 | +EOT; |
332 | 332 | |
333 | 333 | $wgOut->addScript( $javascript_autocomplete_text ); |
334 | 334 | |
— | — | @@ -339,14 +339,14 @@ |
340 | 340 | |
341 | 341 | /** |
342 | 342 | * A method which decodes form data sent through form-elements generated by |
343 | | - * its complement, getPOFormBox. UIs may overload both to change form parameters. |
| 343 | + * its complement, getPOFormBox(). UIs may overload both to change form parameters. |
344 | 344 | * |
345 | 345 | * @param WebRequest $wgRequest |
346 | 346 | * @return array |
347 | 347 | */ |
348 | | - protected function processPOFormBox(WebRequest $wgRequest){ |
| 348 | + protected function processPOFormBox( WebRequest $wgRequest ) { |
349 | 349 | $postring = $wgRequest->getText( 'po' ); |
350 | | - $poarray=array(); |
| 350 | + $poarray = array(); |
351 | 351 | |
352 | 352 | if ( $postring != '' ) { // parameters from HTML input fields |
353 | 353 | $ps = explode( "\n", $postring ); // params separated by newlines here (compatible with text-input for printouts) |
— | — | @@ -522,7 +522,7 @@ |
523 | 523 | * options using ajax. Also, use its complement processFormatSelectBox() to |
524 | 524 | * decode form data sent by these elements. UI's may overload these methods |
525 | 525 | * to change behaviour or form parameters. |
526 | | - * |
| 526 | + * |
527 | 527 | * @param string $defaultformat The default format which remains selected in the form |
528 | 528 | * @return string |
529 | 529 | */ |
— | — | @@ -602,11 +602,11 @@ |
603 | 603 | /** |
604 | 604 | * A method which decodes form data sent through form-elements generated by |
605 | 605 | * its complement, getFormatSelectBox(). UIs may overload both to change form parameters. |
606 | | - * |
| 606 | + * |
607 | 607 | * @param WebRequest $wgRequest |
608 | 608 | * @return array |
609 | 609 | */ |
610 | | - protected function processFormatSelectBox(WebRequest $wgRequest){ |
| 610 | + protected function processFormatSelectBox( WebRequest $wgRequest ) { |
611 | 611 | $query_val = $wgRequest->getVal( 'p' ); |
612 | 612 | if ( !empty( $query_val ) ) |
613 | 613 | $params = SMWInfolink::decodeParameters( $query_val, false ); |
— | — | @@ -648,10 +648,28 @@ |
649 | 649 | return false; |
650 | 650 | } |
651 | 651 | } |
652 | | - |
| 652 | + |
653 | 653 | /** |
| 654 | + * Returns the additional printouts as a string. |
| 655 | + * |
| 656 | + * UIs may overload this to change how this string should be displayed. |
| 657 | + * |
| 658 | + * @return string |
| 659 | + */ |
| 660 | + public function getPOStrings() { |
| 661 | + $string = ""; |
| 662 | + $printouts = $this->m_ui_helper->getPrintOuts(); |
| 663 | + if ( !empty( $printouts ) ) { |
| 664 | + foreach ( $printouts as $value ) { |
| 665 | + $string .= $value->getSerialisation() . "\n"; |
| 666 | + } |
| 667 | + } |
| 668 | + return $string; |
| 669 | + } |
| 670 | + |
| 671 | + /** |
654 | 672 | * Returns true if this page shows the navigationBar. Overload to change behavior. |
655 | | - * |
| 673 | + * |
656 | 674 | * @return boolean |
657 | 675 | */ |
658 | 676 | protected function usesNavigationBar() { |
— | — | @@ -661,13 +679,10 @@ |
662 | 680 | } |
663 | 681 | |
664 | 682 | /** |
665 | | - * This class helps to implement a Special Page for creating and executing queries. |
666 | | - * |
667 | | - * It captures the primary activities of what a semantic search pages does: |
| 683 | + * This class captures the core activities of what a semantic search page should do: |
668 | 684 | * (take parameters, validate them and generate results, or errors, if any). |
669 | 685 | * |
670 | | - * Query UIs may use this class and override methods to create a customised UI |
671 | | - * interface. |
| 686 | + * Query UIs may use this class to create a customised UI interface. |
672 | 687 | * |
673 | 688 | * @author Devayon Das |
674 | 689 | * |
— | — | @@ -676,10 +691,11 @@ |
677 | 692 | /* |
678 | 693 | * Design note: |
679 | 694 | * This class does not define any format for how parameters should be |
680 | | - * passed from the user to this class, expect those already defined by (Infolink) |
681 | | - * |
| 695 | + * passed from the user to this class, except those already defined by Infolink. |
| 696 | + * |
| 697 | + * |
682 | 698 | */ |
683 | | - |
| 699 | + |
684 | 700 | // members |
685 | 701 | protected $m_querystring = ''; // The query |
686 | 702 | protected $m_params = array(); // Parameters controlling how the results should be displayed |
— | — | @@ -972,21 +988,25 @@ |
973 | 989 | else return 0; |
974 | 990 | |
975 | 991 | } |
| 992 | + |
976 | 993 | public function getParams() { |
977 | 994 | return $this->m_params; |
978 | 995 | } |
| 996 | + |
979 | 997 | /** |
| 998 | + * Returns additional prinouts as an array of SMWPrintRequests |
980 | 999 | * |
981 | | - * @return array of SMWPrintRequest |
| 1000 | + * @return array SMWPrintRequest or an empty array |
982 | 1001 | */ |
983 | 1002 | public function getPrintOuts() { |
984 | | - if ( !empty( $this->printouts ) ) { |
985 | | - if ( is_a( $this->printouts[0], 'SMWPrintRequest' ) ) { |
| 1003 | + if ( !empty( $this->m_printouts ) ) { |
| 1004 | + if ( is_a( $this->m_printouts[0], 'SMWPrintRequest' ) ) { |
986 | 1005 | return $this->m_printouts; |
987 | 1006 | } |
988 | 1007 | } |
989 | 1008 | return array(); |
990 | 1009 | } |
| 1010 | + |
991 | 1011 | /** |
992 | 1012 | * Constructs a new SMWQueryUIHelper when parameters are passed in the InfoLink style |
993 | 1013 | * |
— | — | @@ -1020,7 +1040,7 @@ |
1021 | 1041 | $result->setPrintOuts( $printouts, $enable_validation ); |
1022 | 1042 | $result->setQueryString( $query, $enable_validation ); |
1023 | 1043 | $result->extractParameters( "" ); |
1024 | | - //$result->execute(); |
| 1044 | + // $result->execute(); |
1025 | 1045 | return $result; |
1026 | 1046 | } |
1027 | 1047 | /** |