Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php |
— | — | @@ -24,47 +24,52 @@ |
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | | - * The main entrypoint. Call the various methods of SMWQueryUI and |
29 | | - * SMWQueryUIHelper to build ui elements and to process them. |
| 28 | + * The main method for creating the output page. |
| 29 | + * Calls the various methods of SMWQueryUI and SMWQueryUIHelper to build |
| 30 | + * UI elements and to process them. |
30 | 31 | * |
31 | 32 | * @global OutputPage $wgOut |
32 | 33 | * @param string $p |
33 | 34 | */ |
34 | 35 | protected function makePage( $p ) { |
35 | 36 | global $wgOut; |
| 37 | + |
36 | 38 | $htmlOutput = $this->makeForm( $p ); |
| 39 | + |
37 | 40 | if ( $this->uiCore->getQueryString() != "" ) { |
38 | 41 | if ( $this->usesNavigationBar() ) { |
39 | | - $htmlOutput .= Html::rawElement( 'div', array( 'class' => 'smwqcnavbar' ), |
40 | | - $this->getNavigationBar ( $this->uiCore->getLimit(), |
41 | | - $this->uiCore->getOffset(), |
42 | | - $this->uiCore->hasFurtherResults() ) |
43 | | - ); |
| 42 | + $navigationBar = $this->getNavigationBar ( |
| 43 | + $this->uiCore->getLimit(), |
| 44 | + $this->uiCore->getOffset(), |
| 45 | + $this->uiCore->hasFurtherResults() ); |
| 46 | + $navigation = Html::rawElement( 'div', |
| 47 | + array( 'class' => 'smwqcnavbar' ), |
| 48 | + $navigationBar ); |
| 49 | + } else { |
| 50 | + $navigation = ''; |
44 | 51 | } |
45 | 52 | |
46 | | - $htmlOutput .= Html::rawElement( 'div', array( 'class' => 'smwqcresult' ), $this->uiCore->getHTMLResult() ); |
| 53 | + $htmlOutput .= $navigation . |
| 54 | + Html::rawElement( 'div', array( 'class' => 'smwqcresult' ), |
| 55 | + $this->uiCore->getHTMLResult() ) . |
| 56 | + $navigation; |
47 | 57 | |
48 | | - if ( $this->usesNavigationBar() ) { |
49 | | - $htmlOutput .= Html::rawElement( 'div', array( 'class' => 'smwqcnavbar' ), |
50 | | - $this->getNavigationBar ( $this->uiCore->getLimit(), |
51 | | - $this->uiCore->getOffset(), |
52 | | - $this->uiCore->hasFurtherResults() ) |
53 | | - ); |
54 | | - } |
55 | 58 | } |
| 59 | + |
56 | 60 | $wgOut->addHTML( $htmlOutput ); |
57 | 61 | } |
58 | 62 | |
59 | 63 | /** |
60 | | - * This method should call the various processXXXBox() methods for each of |
61 | | - * the corresponding getXXXBox() methods which the UI uses. |
62 | | - * Merge the results of these methods and return them. |
| 64 | + * This method calls the various processXXXBox() methods for each |
| 65 | + * of the corresponding getXXXBox() methods which the UI uses. Then it |
| 66 | + * merges the results of these methods and return them. |
63 | 67 | * |
64 | 68 | * @global WebRequest $wgRequest |
65 | 69 | * @return array |
66 | 70 | */ |
67 | 71 | protected function processParams() { |
68 | 72 | global $wgRequest; |
| 73 | + |
69 | 74 | $params = array_merge( |
70 | 75 | array( |
71 | 76 | 'format' => $wgRequest->getVal( 'format' ), |
— | — | @@ -95,58 +100,69 @@ |
96 | 101 | } |
97 | 102 | |
98 | 103 | /** |
99 | | - * Creates the search form |
| 104 | + * Create the search form. |
100 | 105 | * |
101 | 106 | * @global OutputPage $wgOut |
102 | 107 | * @global string $smwgScriptPath |
103 | | - * @return string |
| 108 | + * @return string HTML code for search form |
104 | 109 | */ |
105 | 110 | protected function makeForm() { |
106 | 111 | global $wgOut, $smwgScriptPath; |
| 112 | + |
107 | 113 | SMWOutputs::requireResource( 'jquery' ); |
108 | | - $result = '<div class="smwqcerrors">' . $this->getErrorsHtml() . '</div>'; |
| 114 | + |
109 | 115 | $specTitle = $this->getTitle(); |
110 | 116 | $formatBox = $this->getFormatSelectBoxSep( 'broadtable' ); |
111 | | - $result .= Html::openElement( 'form', array( 'name' => 'qc', 'id'=>'smwqcform', 'action' => $specTitle->escapeLocalURL(), 'method' => 'get' ) ) . "\n" . |
112 | | - Html::hidden( 'title', $specTitle->getPrefixedText() ); |
113 | | - $result .= wfMsg( 'smw_qc_query_help' ); |
114 | | - // Main query and format options |
115 | | - $result .= $this->getQueryFormBox(); |
116 | | - // sorting and prinouts |
117 | | - $result .= '<div class="smwqcsortbox">' . $this->getPoSortFormBox() . '</div>'; |
118 | | - // additional options |
119 | 117 | |
120 | | - // START: show|hide additional options |
121 | | - $result .= '<div class="smwqcformatas">' . Html::element( 'strong', array(), wfMsg( 'smw_ask_format_as' ) ); |
122 | | - $result .= $formatBox[0] . '<span id="show_additional_options" style="display:inline;">' . |
| 118 | + $result = '<div class="smwqcerrors">' . $this->getErrorsHtml() . '</div>'; |
| 119 | + |
| 120 | + $formParameters = array( 'name' => 'qc', 'id'=>'smwqcform', |
| 121 | + 'action' => $specTitle->escapeLocalURL(), 'method' => 'get' ); |
| 122 | + $result .= Html::openElement( 'form', $formParameters ) . "\n" . |
| 123 | + Html::hidden( 'title', $specTitle->getPrefixedText() ) . |
| 124 | + // Header: |
| 125 | + wfMsg( 'smw_qc_query_help' ) . |
| 126 | + // Main query and format options: |
| 127 | + $this->getQueryFormBox() . |
| 128 | + // Sorting and prinouts: |
| 129 | + '<div class="smwqcsortbox">' . $this->getPoSortFormBox() . '</div>'; |
| 130 | + |
| 131 | + // Control to show/hide additional options: |
| 132 | + $result .= '<div class="smwqcformatas">' . |
| 133 | + Html::element( 'strong', array(), wfMsg( 'smw_ask_format_as' ) ) . |
| 134 | + $formatBox[0] . |
| 135 | + '<span id="show_additional_options" style="display:inline;">' . |
123 | 136 | '<a href="#addtional" rel="nofollow" onclick="' . |
124 | 137 | "jQuery('#additional_options').show('blind');" . |
125 | 138 | "document.getElementById('show_additional_options').style.display='none';" . |
126 | 139 | "document.getElementById('hide_additional_options').style.display='inline';" . '">' . |
127 | | - wfMsg( 'smw_qc_show_addnal_opts' ) . '</a></span>'; |
128 | | - $result .= '<span id="hide_additional_options" style="display:none"><a href="#" rel="nofollow" onclick="' . |
| 140 | + wfMsg( 'smw_qc_show_addnal_opts' ) . '</a></span>' . |
| 141 | + '<span id="hide_additional_options" style="display:none"><a href="#" rel="nofollow" onclick="' . |
129 | 142 | "jQuery('#additional_options').hide('blind');;" . |
130 | 143 | "document.getElementById('hide_additional_options').style.display='none';" . |
131 | 144 | "document.getElementById('show_additional_options').style.display='inline';" . '">' . |
132 | | - wfMsg( 'smw_qc_hide_addnal_opts' ) . '</a></span>'; |
133 | | - $result .= '</div>'; |
134 | | - // END: show|hide additional options |
| 145 | + wfMsg( 'smw_qc_hide_addnal_opts' ) . '</a></span>' . |
| 146 | + '</div>'; |
135 | 147 | |
136 | | - $result .= '<div id="additional_options" style="display:none">'; |
137 | | - $result .= $this->getOtherParametersBox(); |
138 | | - $result .= '<fieldset><legend>' . wfMsg( 'smw_qc_formatopt' ) . "</legend>\n" . |
139 | | - $formatBox[1] . // display the format options |
140 | | - "</fieldset>\n"; |
| 148 | + // Controls for additional options: |
| 149 | + $result .= '<div id="additional_options" style="display:none">' . |
| 150 | + $this->getOtherParametersBox() . |
| 151 | + '<fieldset><legend>' . wfMsg( 'smw_qc_formatopt' ) . "</legend>\n" . |
| 152 | + $formatBox[1] . // display the format options |
| 153 | + "</fieldset>\n" . |
| 154 | + '</div>'; // end of hidden additional options |
141 | 155 | |
142 | | - $result .= '</div>'; // end of hidden additional options |
143 | | - $result .= '<br/><input type="submit" value="' . wfMsg( 'smw_ask_submit' ) . '"/><br/>'; |
144 | | - $result .= '<a href="' . htmlspecialchars( wfMsg( 'smw_ask_doculink' ) ) . '">' . wfMsg( 'smw_ask_help' ) . '</a>'; |
| 156 | + // Submit button and documentation link: |
| 157 | + $result .= '<br/><input type="submit" value="' . wfMsg( 'smw_ask_submit' ) . '"/><br/>' . |
| 158 | + '<a href="' . htmlspecialchars( wfMsg( 'smw_ask_doculink' ) ) . '">' . |
| 159 | + wfMsg( 'smw_ask_help' ) . '</a>'; |
145 | 160 | |
146 | | - if ( $this->uiCore->getQueryString() != '' ) { // hide #ask if there isnt any query defined |
| 161 | + // Control for showing #ask syntax of query: |
| 162 | + if ( $this->uiCore->getQueryString() != '' ) { // only show if query given |
147 | 163 | $result .= ' | <a name="show-embed-code" id="show-embed-code" href="##" rel="nofollow">' . |
148 | | - wfMsg( 'smw_ask_show_embed' ) . |
149 | | - '</a>'; |
150 | | - $result .= '<div id="embed-code-dialog">' . $this->getAskEmbedBox() . '</div>'; |
| 164 | + wfMsg( 'smw_ask_show_embed' ) . '</a>' . |
| 165 | + '<div id="embed-code-dialog">' . $this->getAskEmbedBox() . '</div>'; |
| 166 | + |
151 | 167 | SMWOutputs::requireResource( 'jquery.ui.autocomplete' ); |
152 | 168 | SMWOutputs::requireResource( 'jquery.ui.dialog' ); |
153 | 169 | SMWOutputs::requireResource( 'ext.smw.style' ); |
— | — | @@ -174,7 +190,8 @@ |
175 | 191 | |
176 | 192 | $result .= '<input type="hidden" name="eq" value="no"/>' . |
177 | 193 | "\n</form><br/>"; |
178 | | - return $result; |
| 194 | + |
| 195 | + return $result; |
179 | 196 | } |
180 | 197 | |
181 | 198 | /** |