r95148 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95147‎ | r95148 | r95149 >
Date:15:32, 21 August 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
some layout changes and minor modifications
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUI.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUI.php
@@ -55,55 +55,69 @@
5656
5757 if ( !$smwgQEnabled ) {
5858 $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();
7775 }
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+ }
8979
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() );
9191 }
 92+
 93+ $wgOut->addHTML( $this->makePage( $p ) );
9294 }
9395
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 );
9598 }
9699
97100 /**
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.
101103 *
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
104109 */
105110 protected abstract function processParams();
106111
107112 /**
 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+ /**
108122 * To enable/disable syndicated feeds of results to appear in the UI
109123 * header.
110124 *
@@ -114,15 +128,6 @@
115129 }
116130
117131 /**
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 - /**
127132 * Builds a read-only #ask embed code of the given query. The code is
128133 * presented in html code.
129134 *
@@ -1876,8 +1881,8 @@
18771882 /**
18781883 * Generates form elements for a (web)requested format.
18791884 *
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(),
18821887 * processFormatSelectBox() and getFormatSelectBox() to change behavior.
18831888 *
18841889 * @param WebRequest $wgRequest
Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php
@@ -56,7 +56,7 @@
5757
5858 }
5959
60 - $wgOut->addHTML( $htmlOutput );
 60+ return $htmlOutput;
6161 }
6262
6363 /**