r91865 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91864‎ | r91865 | r91866 >
Date:09:15, 11 July 2011
Author:devayon
Status:deferred
Tags:
Comment:
style cleanup, added getPOString()
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -85,6 +85,7 @@
8686 });
8787 }
8888 });
 89+</script>
8990 END;
9091
9192 $wgOut->addScript( $javascript_autocomplete_text );
@@ -273,9 +274,9 @@
274275 * @param WebRequest $wgRequest
275276 * @return string
276277 */
277 - protected function processQueryFormBox(WebRequest $wgRequest){
278 - $query="";
279 - if($wgRequest->getCheck('q')) $query = $wgRequest->getVal('q');
 278+ protected function processQueryFormBox( WebRequest $wgRequest ) {
 279+ $query = "";
 280+ if ( $wgRequest->getCheck( 'q' ) ) $query = $wgRequest->getVal( 'q' );
280281 return $query;
281282 }
282283
@@ -284,7 +285,6 @@
285286 * Use its complement processPOFormBox() to decode data sent through these
286287 * form elements. UIs may overload both to change the form parameter or the html elements.
287288 *
288 - * @global OutputPage $wgOut
289289 * @param string $content The content expected to appear in the box
290290 * @param boolean $enableAutocomplete If set to true, adds the relevant JS and CSS to the page
291291 * @return string The HTML code
@@ -293,8 +293,8 @@
294294 if ( $enableAutocomplete ) {
295295 global $wgOut;
296296
297 - if ( !$this->autocompleteenabled ) addAutocompletionJavascriptAndCSS();
298 - $javascript_autocomplete_text = <<<END
 297+ $this->addAutocompletionJavascriptAndCSS();
 298+ $javascript_autocomplete_text = <<<EOT
299299 <script type="text/javascript">
300300 jQuery(document).ready(function(){
301301 jQuery("#add_property").autocomplete({
@@ -327,7 +327,7 @@
328328 });
329329 });
330330 </script>
331 -END;
 331+EOT;
332332
333333 $wgOut->addScript( $javascript_autocomplete_text );
334334
@@ -339,14 +339,14 @@
340340
341341 /**
342342 * A method which decodes form data sent through form-elements generated by
343 - * its complement, getPOFormBox. UIs may overload both to change form parameters.
 343+ * its complement, getPOFormBox(). UIs may overload both to change form parameters.
344344 *
345345 * @param WebRequest $wgRequest
346346 * @return array
347347 */
348 - protected function processPOFormBox(WebRequest $wgRequest){
 348+ protected function processPOFormBox( WebRequest $wgRequest ) {
349349 $postring = $wgRequest->getText( 'po' );
350 - $poarray=array();
 350+ $poarray = array();
351351
352352 if ( $postring != '' ) { // parameters from HTML input fields
353353 $ps = explode( "\n", $postring ); // params separated by newlines here (compatible with text-input for printouts)
@@ -522,7 +522,7 @@
523523 * options using ajax. Also, use its complement processFormatSelectBox() to
524524 * decode form data sent by these elements. UI's may overload these methods
525525 * to change behaviour or form parameters.
526 - *
 526+ *
527527 * @param string $defaultformat The default format which remains selected in the form
528528 * @return string
529529 */
@@ -602,11 +602,11 @@
603603 /**
604604 * A method which decodes form data sent through form-elements generated by
605605 * its complement, getFormatSelectBox(). UIs may overload both to change form parameters.
606 - *
 606+ *
607607 * @param WebRequest $wgRequest
608608 * @return array
609609 */
610 - protected function processFormatSelectBox(WebRequest $wgRequest){
 610+ protected function processFormatSelectBox( WebRequest $wgRequest ) {
611611 $query_val = $wgRequest->getVal( 'p' );
612612 if ( !empty( $query_val ) )
613613 $params = SMWInfolink::decodeParameters( $query_val, false );
@@ -648,10 +648,28 @@
649649 return false;
650650 }
651651 }
652 -
 652+
653653 /**
 654+ * Returns the additional printouts as a string.
 655+ *
 656+ * UIs may overload this to change how this string should be displayed.
 657+ *
 658+ * @return string
 659+ */
 660+ public function getPOStrings() {
 661+ $string = "";
 662+ $printouts = $this->m_ui_helper->getPrintOuts();
 663+ if ( !empty( $printouts ) ) {
 664+ foreach ( $printouts as $value ) {
 665+ $string .= $value->getSerialisation() . "\n";
 666+ }
 667+ }
 668+ return $string;
 669+ }
 670+
 671+ /**
654672 * Returns true if this page shows the navigationBar. Overload to change behavior.
655 - *
 673+ *
656674 * @return boolean
657675 */
658676 protected function usesNavigationBar() {
@@ -661,13 +679,10 @@
662680 }
663681
664682 /**
665 - * This class helps to implement a Special Page for creating and executing queries.
666 - *
667 - * It captures the primary activities of what a semantic search pages does:
 683+ * This class captures the core activities of what a semantic search page should do:
668684 * (take parameters, validate them and generate results, or errors, if any).
669685 *
670 - * Query UIs may use this class and override methods to create a customised UI
671 - * interface.
 686+ * Query UIs may use this class to create a customised UI interface.
672687 *
673688 * @author Devayon Das
674689 *
@@ -676,10 +691,11 @@
677692 /*
678693 * Design note:
679694 * This class does not define any format for how parameters should be
680 - * passed from the user to this class, expect those already defined by (Infolink)
681 - *
 695+ * passed from the user to this class, except those already defined by Infolink.
 696+ *
 697+ *
682698 */
683 -
 699+
684700 // members
685701 protected $m_querystring = ''; // The query
686702 protected $m_params = array(); // Parameters controlling how the results should be displayed
@@ -972,21 +988,25 @@
973989 else return 0;
974990
975991 }
 992+
976993 public function getParams() {
977994 return $this->m_params;
978995 }
 996+
979997 /**
 998+ * Returns additional prinouts as an array of SMWPrintRequests
980999 *
981 - * @return array of SMWPrintRequest
 1000+ * @return array SMWPrintRequest or an empty array
9821001 */
9831002 public function getPrintOuts() {
984 - if ( !empty( $this->printouts ) ) {
985 - if ( is_a( $this->printouts[0], 'SMWPrintRequest' ) ) {
 1003+ if ( !empty( $this->m_printouts ) ) {
 1004+ if ( is_a( $this->m_printouts[0], 'SMWPrintRequest' ) ) {
9861005 return $this->m_printouts;
9871006 }
9881007 }
9891008 return array();
9901009 }
 1010+
9911011 /**
9921012 * Constructs a new SMWQueryUIHelper when parameters are passed in the InfoLink style
9931013 *
@@ -1020,7 +1040,7 @@
10211041 $result->setPrintOuts( $printouts, $enable_validation );
10221042 $result->setQueryString( $query, $enable_validation );
10231043 $result->extractParameters( "" );
1024 - //$result->execute();
 1044+ // $result->execute();
10251045 return $result;
10261046 }
10271047 /**