r94781 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94780‎ | r94781 | r94782 >
Date:17:29, 17 August 2011
Author:devayon
Status:deferred
Tags:
Comment:
style clean-up
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php
@@ -37,16 +37,20 @@
3838 if ( $this->uiCore->getQueryString() != "" ) {
3939 if ( $this->usesNavigationBar() ) {
4040 $htmlOutput .= Html::rawElement( 'div', array( 'class' => 'smwqcnavbar' ),
41 - $this->getNavigationBar ( $this->uiCore->getLimit(), $this->uiCore->getOffset(), $this->uiCore->hasFurtherResults() )
42 - );
 41+ $this->getNavigationBar ( $this->uiCore->getLimit(),
 42+ $this->uiCore->getOffset(),
 43+ $this->uiCore->hasFurtherResults() )
 44+ );
4345 }
4446
4547 $htmlOutput .= Html::rawElement( 'div', array( 'class' => 'smwqcresult' ), $this->uiCore->getHTMLResult() );
4648
4749 if ( $this->usesNavigationBar() ) {
4850 $htmlOutput .= Html::rawElement( 'div', array( 'class' => 'smwqcnavbar' ),
49 - $this->getNavigationBar ( $this->uiCore->getLimit(), $this->uiCore->getOffset(), $this->uiCore->hasFurtherResults() )
50 - );
 51+ $this->getNavigationBar ( $this->uiCore->getLimit(),
 52+ $this->uiCore->getOffset(),
 53+ $this->uiCore->hasFurtherResults() )
 54+ );
5155 }
5256 }
5357 $wgOut->addHTML( $htmlOutput );
@@ -63,13 +67,13 @@
6468 protected function processParams() {
6569 global $wgRequest;
6670 $params = array_merge(
67 - array(
68 - 'format' => $wgRequest->getVal( 'format' ),
69 - 'offset' => $wgRequest->getVal( 'offset', '0' ),
70 - 'limit' => $wgRequest->getVal( 'limit', '20' ) ),
71 - $this->processPoSortFormBox( $wgRequest ),
72 - $this->processFormatSelectBox( $wgRequest )
73 - );
 71+ array(
 72+ 'format' => $wgRequest->getVal( 'format' ),
 73+ 'offset' => $wgRequest->getVal( 'offset', '0' ),
 74+ 'limit' => $wgRequest->getVal( 'limit', '20' ) ),
 75+ $this->processPoSortFormBox( $wgRequest ),
 76+ $this->processFormatSelectBox( $wgRequest )
 77+ );
7478 return $params;
7579 }
7680
@@ -88,7 +92,7 @@
8993 protected function showFormatOptions( $format, array $paramValues, array $ignoredAttribs = array() ) {
9094 return parent::showFormatOptions( $format, $paramValues, array(
9195 'format', 'limit', 'offset', 'mainlabel', 'intro', 'outro', 'default'
92 - ) );
 96+ ) );
9397 }
9498
9599 /**
@@ -112,8 +116,9 @@
113117 // sorting and prinouts
114118 $result .= '<div class="smwqcsortbox">' . $this->getPoSortFormBox() . '</div>';
115119 // additional options
 120+
116121 // START: show|hide additional options
117 - $result .= '<div class="smwqcformatas"><strong>' . wfMsg( 'smw_ask_format_as' ) . '</strong>';
 122+ $result .= '<div class="smwqcformatas">' . Html::element( 'strong', array(), wfMsg( 'smw_ask_format_as' ) );
118123 $result .= $formatBox[0] . '<span id="show_additional_options" style="display:inline;">' .
119124 '<a href="#addtional" rel="nofollow" onclick="' .
120125 "jQuery('#additional_options').show('blind');" .
@@ -127,86 +132,50 @@
128133 wfMsg( 'smw_qc_hide_addnal_opts' ) . '</a></span>';
129134 $result .= '</div>';
130135 // END: show|hide additional options
 136+
131137 $result .= '<div id="additional_options" style="display:none">';
132 - $params = $this->uiCore->getParameters();
133 - if ( array_key_exists( 'limit', $params ) ) {
134 - $limit = $params['limit'];
135 - } else {
136 - $limit = '';
137 - }
138 - if ( array_key_exists( 'offset', $params ) ) {
139 - $offset = $params['offset'];
140 - } else {
141 - $offset = '';
142 - }
143 - if ( array_key_exists( 'intro', $params ) ) {
144 - $intro = $params['intro'];
145 - } else {
146 - $intro = '';
147 - }
148 - if ( array_key_exists( 'outro', $params ) ) {
149 - $outro = $params['outro'];
150 - } else {
151 - $outro = '';
152 - }
153 - if ( array_key_exists( 'default', $params ) ) {
154 - $default = $params['default'];
155 - } else {
156 - $default = '';
157 - }
158 - $result .= '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n" .
159 - Html::rawElement( 'div', array( 'style' => 'width: 30%; padding: 5px; float: left;' ),
160 - 'Intro: <input name="p[intro]" value="' . $intro . '"size="32"/> <br/>' . wfMsg( 'smw_paramdesc_intro' )
161 - ) .
162 - Html::rawElement( 'div', array( 'style' => 'width: 30%; padding: 5px; float: left;' ),
163 - 'Outro: <input name="p[outro]" value="' . $outro . '" size="32"/> <br/>' . wfMsg( 'smw_paramdesc_outro' )
164 - ) .
165 - Html::rawElement( 'div', array( 'style' => 'width: 30%; padding: 5px; float: left;' ),
166 - 'Default: <input name="p[default]" value="' . $default . '" size="32"/> <br/>' . wfMsg( 'smw_paramdesc_default' )
167 - ) .
168 - Html::hidden( 'p[limit]', $limit ) .
169 - Html::hidden( 'p[offset]', $offset ) .
170 - '</fieldset>';
 138+ $result .= $this->getOtherParametersBox();
171139 $result .= '<fieldset><legend>' . wfMsg( 'smw_qc_formatopt' ) . "</legend>\n" .
172140 $formatBox[1] . // display the format options
173141 "</fieldset>\n";
174142
175143 $result .= '</div>'; // end of hidden additional options
176 - $result .= '<br /><input type="submit" value="' . wfMsg( 'smw_ask_submit' ) . '"/><br/>';
 144+ $result .= '<br/><input type="submit" value="' . wfMsg( 'smw_ask_submit' ) . '"/><br/>';
 145+ $result .= '<a href="' . htmlspecialchars( wfMsg( 'smw_ask_doculink' ) ) . '">' . wfMsg( 'smw_ask_help' ) . '</a>';
177146
178 - $result .= '<a href="' . htmlspecialchars( wfMsg( 'smw_ask_doculink' ) ) . '">' . wfMsg( 'smw_ask_help' ) . '</a>';
179147 if ( $this->uiCore->getQueryString() != '' ) { // hide #ask if there isnt any query defined
180 - $result .= ' | <a name="show-embed-code" id="show-embed-code" href="##" rel="nofollow">' . wfMsg( 'smw_ask_show_embed' ) . '</a>';
181 - $result .= '<div id="embed-code-dialog">' .
182 - $this->getAskEmbedBox() .
183 - '</div>';
184 - $this->enableJQueryUI();
185 - $wgOut->addScriptFile( "$smwgScriptPath/libs/jquery-ui/jquery-ui.dialog.min.js" );
186 - $wgOut->addStyle( "$smwgScriptPath/skins/SMW_custom.css" );
187 - $javascriptText = <<<EOT
 148+ $result .= ' | <a name="show-embed-code" id="show-embed-code" href="##" rel="nofollow">' .
 149+ wfMsg( 'smw_ask_show_embed' ) .
 150+ '</a>';
 151+ $result .= '<div id="embed-code-dialog">' . $this->getAskEmbedBox() . '</div>';
 152+ $this->enableJQueryUI();
 153+ $wgOut->addScriptFile( "$smwgScriptPath/libs/jquery-ui/jquery-ui.dialog.min.js" );
 154+ $wgOut->addStyle( "$smwgScriptPath/skins/SMW_custom.css" );
 155+
 156+ $javascriptText = <<<EOT
188157 <script type="text/javascript">
189 -jQuery(document).ready(function(){
190 - jQuery('#embed-code-dialog').dialog({
191 - autoOpen:false,
192 - modal: true,
193 - buttons:{
194 - Ok: function(){
195 - jQuery(this).dialog("close");
 158+ jQuery( document ).ready( function(){
 159+ jQuery( '#embed-code-dialog' ).dialog( {
 160+ autoOpen:false,
 161+ modal: true,
 162+ buttons: {
 163+ Ok: function(){
 164+ jQuery( this ).dialog( "close" );
 165+ }
196166 }
197 - }
198 - });
199 - jQuery('#show-embed-code').bind('click', function(){
200 - jQuery('#embed-code-dialog').dialog("open");
201 - });
202 -});
 167+ } );
 168+ jQuery( '#show-embed-code' ).bind( 'click', function(){
 169+ jQuery( '#embed-code-dialog' ).dialog( "open" );
 170+ } );
 171+ } );
203172 </script>
204173 EOT;
205174 $wgOut->addScript( $javascriptText );
206175 }
 176+
207177 $result .= '<input type="hidden" name="eq" value="no"/>' .
208178 "\n</form><br/>";
209179 return $result;
210 -
211180 }
212181
213182 /**
@@ -225,5 +194,63 @@
226195 $this->setUrlArgs( $tmpArray );
227196 return $this->urlArgs;
228197 }
 198+
 199+ /**
 200+ * Creates controls for limit, intro, outro, default and offset
 201+ *
 202+ * @return string
 203+ */
 204+ protected function getOtherParametersBox() {
 205+ $params = $this->uiCore->getParameters();
 206+ if ( array_key_exists( 'limit', $params ) ) {
 207+ $limit = $params['limit'];
 208+ } else {
 209+ $limit = '';
 210+ }
 211+ if ( array_key_exists( 'offset', $params ) ) {
 212+ $offset = $params['offset'];
 213+ } else {
 214+ $offset = '';
 215+ }
 216+ if ( array_key_exists( 'intro', $params ) ) {
 217+ $intro = $params['intro'];
 218+ } else {
 219+ $intro = '';
 220+ }
 221+ if ( array_key_exists( 'outro', $params ) ) {
 222+ $outro = $params['outro'];
 223+ } else {
 224+ $outro = '';
 225+ }
 226+ if ( array_key_exists( 'default', $params ) ) {
 227+ $default = $params['default'];
 228+ } else {
 229+ $default = '';
 230+ }
 231+ $result = '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n" .
 232+ Html::rawElement( 'div',
 233+ array( 'style' => 'width: 30%; padding: 5px; float: left;' ),
 234+ wfMsg( 'smw_qc_intro' ) .
 235+ '<input name="p[intro]" value="' . $intro . '"size="32"/> <br/>' .
 236+ wfMsg( 'smw_paramdesc_intro' )
 237+ ) .
 238+ Html::rawElement( 'div',
 239+ array( 'style' => 'width: 30%; padding: 5px; float: left;' ),
 240+ wfMsg( 'smw_qc_outro' ) .
 241+ '<input name="p[outro]" value="' . $outro . '" size="32"/> <br/>' .
 242+ wfMsg( 'smw_paramdesc_outro' )
 243+ ) .
 244+ Html::rawElement( 'div',
 245+ array( 'style' => 'width: 30%; padding: 5px; float: left;' ),
 246+ wfMsg( 'smw_qc_default' ) .
 247+ '<input name="p[default]" value="' . $default . '" size="32"/> <br/>' .
 248+ wfMsg( 'smw_paramdesc_default' )
 249+ ) .
 250+ Html::hidden( 'p[limit]', $limit ) .
 251+ Html::hidden( 'p[offset]', $offset ) .
 252+ '</fieldset>';
 253+
 254+ return $result;
 255+ }
229256 }
230257
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
@@ -240,6 +240,9 @@
241241 'smw_qc_show_addnal_opts' => 'Show more options',
242242 'smw_qc_hide_addnal_opts' => 'Show less options',
243243 'smw_qc_otheropt' => 'Other options',
 244+ 'smw_qc_intro' => 'Intro:',
 245+ 'smw_qc_outro' => 'Outro:',
 246+ 'smw_qc_default' => 'Default:',
244247 'smw_qc_formatopt' => 'Format options',
245248 'smw_qc_query_help' => 'Enter a query using the form below. Select wiki pages based on
246249 Categories (<strong>[[{{ns:category}}:Actor]]</strong>),