r87435 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87434‎ | r87435 | r87436 >
Date:18:54, 4 May 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
show errors of result format parameter error handling in info window
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -704,6 +704,9 @@
705705
706706 $params = method_exists( $printer, 'getParameters' ) ? $printer->getParameters() : array();
707707
 708+ // Ignore the format parameter, as we got a special control in the GUI for it already.
 709+ unset( $params['format'] );
 710+
708711 $optionsHtml = array();
709712
710713 foreach ( $params as $param ) {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinter.php
@@ -59,6 +59,15 @@
6060 protected $mLinker; // Linker object as needed for making result links. Might come from some skin at some time.
6161
6262 /**
 63+ * List of errors that occured while processing the parameters.
 64+ *
 65+ * @since 1.6
 66+ *
 67+ * @var array
 68+ */
 69+ protected $mErrors = array();
 70+
 71+ /**
6372 * If set, treat result as plain HTML. Can be used by printer classes if wiki mark-up is not enough.
6473 * This setting is used only after the result text was generated.
6574 * @note HTML query results cannot be used as parameters for other templates or in any other way
@@ -285,7 +294,7 @@
286295 throw new Exception( 'Validator: fatal param validation error' );
287296 }
288297 else {
289 - // TODO: keep track of non-fatal errors to display
 298+ $this->mErrors = $validator->getErrorMessages();
290299 return $validator->getParameterValues();
291300 }
292301 }
@@ -469,10 +478,12 @@
470479 * Can be used if not specific error formatting is desired. Compatible with HTML
471480 * and Wiki.
472481 *
 482+ * @param SMWQueryResult $res
 483+ *
473484 * @return string
474485 */
475 - public function getErrorString( $res ) {
476 - return $this->mShowErrors ? smwfEncodeMessages( $res->getErrors() ) : '';
 486+ public function getErrorString( SMWQueryResult $res ) {
 487+ return $this->mShowErrors ? smwfEncodeMessages( array_merge( $this->mErrors, $res->getErrors() ) ) : '';
477488 }
478489
479490 /**
@@ -514,6 +525,18 @@
515526 protected function linkFurtherResults( $results ) {
516527 return ( $this->mInline && $results->hasFurtherResults() && ( $this->mSearchlabel !== '' ) );
517528 }
 529+
 530+ /**
 531+ * Adds an error message for a parameter handling error so a list
 532+ * of errors can be created later on.
 533+ *
 534+ * @since 1.6
 535+ *
 536+ * @param string $errorMessage
 537+ */
 538+ protected function addError( $errorMessage ) {
 539+ $this->mErrors[] = $errorMessage;
 540+ }
518541
519542 /**
520543 * Return an array describing the parameters of specifically text-based
@@ -572,6 +595,8 @@
573596 public function getParameters() {
574597 $params = array();
575598
 599+ $params['format'] = new Parameter( 'format' );
 600+
576601 $params['limit'] = new Parameter( 'limit', Parameter::TYPE_INTEGER );
577602 $params['limit']->setDescription( wfMsg( 'smw_paramdesc_limit' ) );
578603 $params['limit']->setDefault( 20 );

Status & tagging log