r95145 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95144‎ | r95145 | r95146 >
Date:15:07, 21 August 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
smaller layout changes and code documentation
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php
@@ -24,47 +24,52 @@
2525 }
2626
2727 /**
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.
3031 *
3132 * @global OutputPage $wgOut
3233 * @param string $p
3334 */
3435 protected function makePage( $p ) {
3536 global $wgOut;
 37+
3638 $htmlOutput = $this->makeForm( $p );
 39+
3740 if ( $this->uiCore->getQueryString() != "" ) {
3841 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 = '';
4451 }
4552
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;
4757
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 - }
5558 }
 59+
5660 $wgOut->addHTML( $htmlOutput );
5761 }
5862
5963 /**
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.
6367 *
6468 * @global WebRequest $wgRequest
6569 * @return array
6670 */
6771 protected function processParams() {
6872 global $wgRequest;
 73+
6974 $params = array_merge(
7075 array(
7176 'format' => $wgRequest->getVal( 'format' ),
@@ -95,58 +100,69 @@
96101 }
97102
98103 /**
99 - * Creates the search form
 104+ * Create the search form.
100105 *
101106 * @global OutputPage $wgOut
102107 * @global string $smwgScriptPath
103 - * @return string
 108+ * @return string HTML code for search form
104109 */
105110 protected function makeForm() {
106111 global $wgOut, $smwgScriptPath;
 112+
107113 SMWOutputs::requireResource( 'jquery' );
108 - $result = '<div class="smwqcerrors">' . $this->getErrorsHtml() . '</div>';
 114+
109115 $specTitle = $this->getTitle();
110116 $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
119117
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;">' .
123136 '<a href="#addtional" rel="nofollow" onclick="' .
124137 "jQuery('#additional_options').show('blind');" .
125138 "document.getElementById('show_additional_options').style.display='none';" .
126139 "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="' .
129142 "jQuery('#additional_options').hide('blind');;" .
130143 "document.getElementById('hide_additional_options').style.display='none';" .
131144 "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>';
135147
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
141155
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>';
145160
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
147163 $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+
151167 SMWOutputs::requireResource( 'jquery.ui.autocomplete' );
152168 SMWOutputs::requireResource( 'jquery.ui.dialog' );
153169 SMWOutputs::requireResource( 'ext.smw.style' );
@@ -174,7 +190,8 @@
175191
176192 $result .= '<input type="hidden" name="eq" value="no"/>' .
177193 "\n</form><br/>";
178 - return $result;
 194+
 195+ return $result;
179196 }
180197
181198 /**