r91872 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91871‎ | r91872 | r91873 >
Date:10:57, 11 July 2011
Author:devayon
Status:deferred
Tags:
Comment:
reduced boolean parameter usage. Hides pagination when no results are retrived
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -13,6 +13,8 @@
1414 abstract class SMWQueryUI extends SpecialPage {
1515 protected $m_ui_helper;
1616 private $autocompleteenabled = false;
 17+ const ENABLE_AUTO_SUGGEST = true;
 18+ const DISABLE_AUTO_SUGGEST = false;
1719
1820 protected function addAutocompletionJavascriptAndCSS() {
1921 global $wgOut, $smwgScriptPath, $smwgJQueryIncluded, $smwgJQueryUIIncluded;
@@ -244,7 +246,7 @@
245247 // $result.= getQueryFormBox($contents, $errors);
246248 // $result.= getPOFormBox($content, $enableAutoComplete);
247249 // $result.= getParamBox($content); //avoid ajax, load form elements in the UI by default
248 - $result = "<br>Stub: The Form elements come here<br><br>";
 250+ $result = "<br>Stub: The Form elements come here<br><br>";
249251 return $result;
250252 }
251253 protected function makeHtmlResult() {
@@ -289,7 +291,7 @@
290292 * @param boolean $enableAutocomplete If set to true, adds the relevant JS and CSS to the page
291293 * @return string The HTML code
292294 */
293 - protected function getPOFormBox( $content, $enableAutocomplete = true ) {
 295+ protected function getPOFormBox( $content, $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
294296 if ( $enableAutocomplete ) {
295297 global $wgOut;
296298
@@ -673,7 +675,9 @@
674676 * @return boolean
675677 */
676678 protected function usesNavigationBar() {
677 - return true;
 679+ //hide if no results are found
 680+ if($this->m_ui_helper->getResultCount()==0) return false;
 681+ else return true;
678682 }
679683
680684 }
Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php
@@ -39,8 +39,8 @@
4040 * @param string $p
4141 */
4242 public function execute( $p ) {
43 - global $wgOut, $wgRequest, $smwgQEnabled;
44 -
 43+ global $wgOut, $wgRequest, $smwgQEnabled, $smwgIgnoreQueryErrors;
 44+ $smwgIgnoreQueryErrors= false;
4545 $this->setHeaders();
4646
4747 if ( !$smwgQEnabled ) {
@@ -83,7 +83,7 @@
8484 * Adds the input query form. Overloaded from SMWQueryUI
8585 */
8686 protected function makeResults( $p ) {
87 - global $wgOut, $smwgQSortingSupport, $smwgResultFormats, $smwgAutocompleteInSpecialAsk;
 87+ global $wgOut, $smwgQSortingSupport;
8888 $result = "";
8989 $spectitle = $this->getTitle();
9090 $result .= '<form name="ask" action="' . $spectitle->escapeLocalURL() . '" method="get">' . "\n" .
@@ -109,7 +109,7 @@
110110 $result .= '<div id="additional_options" style="display:none">';
111111 $result .= '<p><strong>' . wfMsg( 'smw_ask_printhead' ) . "</strong></p>\n" .
112112 '<span style="font-weight: normal;">' . wfMsg( 'smw_ask_printdesc' ) . '</span>' . "\n" .
113 - '<p>' . $this->getPOFormBox( $this->getPOStrings(), true ) . '</p>' . "\n";
 113+ '<p>' . $this->getPOFormBox( $this->getPOStrings(), SMWQueryUI::ENABLE_AUTO_SUGGEST ) . '</p>' . "\n";
114114
115115 // sorting inputs
116116 if ( $smwgQSortingSupport ) {