Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUI.php |
— | — | @@ -55,55 +55,69 @@ |
56 | 56 | |
57 | 57 | if ( !$smwgQEnabled ) { |
58 | 58 | $wgOut->addHTML( '<br />' . wfMsg( 'smw_iq_disabled' ) ); |
59 | | - } else { |
60 | | - $format_options_requested = $this->processFormatOptions( $wgRequest ); // handling ajax for format options |
61 | | - if ( !$format_options_requested ) { |
62 | | - // Checking if a query string has been sent by using the form |
63 | | - if ( !( $this->processQueryFormBox( $wgRequest ) === false ) ) { |
64 | | - $params = $this->processParams(); |
65 | | - $this->uiCore = SMWQueryUIHelper::makeForUI( |
66 | | - $this->processQueryFormBox( $wgRequest ), |
67 | | - $params, |
68 | | - array(), |
69 | | - false ); |
70 | | - if ( $this->uiCore->getQueryString() != "" ) { |
71 | | - $this->uiCore->execute(); |
72 | | - } |
73 | | - } else { |
74 | | - // the user has entered this page from a wiki-page using an infolink, |
75 | | - // or no query has been set |
76 | | - $this->uiCore = SMWQueryUIHelper::makeForInfoLink( $p ); |
| 59 | + return; |
| 60 | + } |
| 61 | + |
| 62 | + // Check if this request is actually an AJAX request, and handle it accodingly: |
| 63 | + $ajaxMode = $this->processFormatOptions( $wgRequest ); |
| 64 | + |
| 65 | + // If not replying to AJAX, build the UI HTML as usual: |
| 66 | + if ( !$ajaxMode ) { |
| 67 | + // Checking if a query string has been sent by using the form: |
| 68 | + if ( $this->processQueryFormBox( $wgRequest ) !== false ) { |
| 69 | + $params = $this->processParams(); |
| 70 | + $this->uiCore = SMWQueryUIHelper::makeForUI( |
| 71 | + $this->processQueryFormBox( $wgRequest ), |
| 72 | + $params, array(), false ); |
| 73 | + if ( $this->uiCore->getQueryString() != '' ) { |
| 74 | + $this->uiCore->execute(); |
77 | 75 | } |
78 | | - // adding rss feed of results to the page head |
79 | | - if ( ( $this->isSyndicated() ) |
80 | | - && ( $this->uiCore->getQueryString() !== '' ) |
81 | | - && ( method_exists( $wgOut, 'addFeedlink' ) ) // remove this line after MW 1.5 is no longer supported by SMW |
82 | | - && ( array_key_exists( 'rss', $wgFeedClasses ) ) ) { |
83 | | - $res = $this->uiCore->getResultObject(); |
84 | | - $link = $res->getQueryLink(); |
85 | | - $link->setParameter( 'rss', 'format' ); |
86 | | - $link->setParameter( $this->uiCore->getLimit(), 'limit' ); |
87 | | - $wgOut->addFeedLink( 'rss', $link->getURl() ); |
88 | | - } |
| 76 | + } else { // Query not sent via form (though maybe from "further results" link: |
| 77 | + $this->uiCore = SMWQueryUIHelper::makeForInfoLink( $p ); |
| 78 | + } |
89 | 79 | |
90 | | - $this->makePage( $p ); |
| 80 | + // Add RSS feed of results to the page head: |
| 81 | + if ( $this->isSyndicated() && |
| 82 | + $this->uiCore->getQueryString() !== '' && |
| 83 | + // Remove next line when MW 1.15 is no longer supported by SMW: |
| 84 | + method_exists( $wgOut, 'addFeedlink' ) && |
| 85 | + array_key_exists( 'rss', $wgFeedClasses ) ) { |
| 86 | + $res = $this->uiCore->getResultObject(); |
| 87 | + $link = $res->getQueryLink(); |
| 88 | + $link->setParameter( 'rss', 'format' ); |
| 89 | + $link->setParameter( $this->uiCore->getLimit(), 'limit' ); |
| 90 | + $wgOut->addFeedLink( 'rss', $link->getURl() ); |
91 | 91 | } |
| 92 | + |
| 93 | + $wgOut->addHTML( $this->makePage( $p ) ); |
92 | 94 | } |
93 | 95 | |
94 | | - SMWOutputs::commitToOutputPage( $wgOut ); // make sure locally collected output data is pushed to the output! |
| 96 | + // Make sure locally collected output data is pushed to the output: |
| 97 | + SMWOutputs::commitToOutputPage( $wgOut ); |
95 | 98 | } |
96 | 99 | |
97 | 100 | /** |
98 | | - * This method should call the various processXXXBox() methods for each |
99 | | - * of the corresponding getXXXBox() methods which the UI uses. Merge the |
100 | | - * results of these methods and return them. |
| 101 | + * This method should return an associative array of parameters |
| 102 | + * extracted from the current (global) web request. |
101 | 103 | * |
102 | | - * @global WebRequest $wgRequest |
103 | | - * @return array |
| 104 | + * Implementations can call the various processXXXBox() methods for |
| 105 | + * reading parameters that belong to standard UI elements provided by |
| 106 | + * this base class (by according getXXXBox() methods). |
| 107 | + * |
| 108 | + * @return array of parameters |
104 | 109 | */ |
105 | 110 | protected abstract function processParams(); |
106 | 111 | |
107 | 112 | /** |
| 113 | + * Create an HTML form that is to be displayed on the page and return |
| 114 | + * the according HTML code. |
| 115 | + * |
| 116 | + * @param string $p the sub-page string |
| 117 | + * @return string HTML code for the page |
| 118 | + */ |
| 119 | + protected abstract function makePage( $p ); |
| 120 | + |
| 121 | + /** |
108 | 122 | * To enable/disable syndicated feeds of results to appear in the UI |
109 | 123 | * header. |
110 | 124 | * |
— | — | @@ -114,15 +128,6 @@ |
115 | 129 | } |
116 | 130 | |
117 | 131 | /** |
118 | | - * The main entry point for your UI. Call the various methods of |
119 | | - * SMWQueryUI and SMWQueryUIHelper to build UI elements and to process |
120 | | - * them. |
121 | | - * |
122 | | - * @param string $p the sub-page string |
123 | | - */ |
124 | | - protected abstract function makePage( $p ); |
125 | | - |
126 | | - /** |
127 | 132 | * Builds a read-only #ask embed code of the given query. The code is |
128 | 133 | * presented in html code. |
129 | 134 | * |
— | — | @@ -1876,8 +1881,8 @@ |
1877 | 1882 | /** |
1878 | 1883 | * Generates form elements for a (web)requested format. |
1879 | 1884 | * |
1880 | | - * Required by getFormatSelectBox() to recieve form elements from the Web. |
1881 | | - * UIs may need to overload processFormatOptions(), |
| 1885 | + * Required by getFormatSelectBox() to recieve form elements from the |
| 1886 | + * Web. UIs may need to overload processFormatOptions(), |
1882 | 1887 | * processFormatSelectBox() and getFormatSelectBox() to change behavior. |
1883 | 1888 | * |
1884 | 1889 | * @param WebRequest $wgRequest |
Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | |
58 | 58 | } |
59 | 59 | |
60 | | - $wgOut->addHTML( $htmlOutput ); |
| 60 | + return $htmlOutput; |
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |