r23871 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23870‎ | r23871 | r23872 >
Date:15:58, 8 July 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Tooltip-based error reporting also for inline queries
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -257,17 +257,7 @@
258258 * Return error message or empty string if no error occurred.
259259 */
260260 public function getErrorString() {
261 - $result = '';
262 - $first = true;
263 - foreach ($this->m_errors as $e) {
264 - if ($first) {
265 - $first = false;
266 - } else {
267 - $result .= ', ';
268 - }
269 - $result .= '<span class="smwwarning">' . $e . '</span>';
270 - }
271 - return $result;
 261+ return smwfEncodeMessages($this->m_errors);
272262 }
273263
274264 /**
@@ -639,7 +629,7 @@
640630 // TODO: needs extension for n-ary values
641631 $dv = SMWDataValueFactory::newAttributeObjectValue($att, $value);
642632 if (!$dv->isValid()) {
643 - $this->m_errors[] = $dv->getError();
 633+ $this->m_errors = $this->m_errors + $dv->getErrors();
644634 $vd = new SMWValueDescription($dv, SMW_CMP_ANY);
645635 } else {
646636 $vd = new SMWValueDescription($dv, $comparator);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php
@@ -209,12 +209,7 @@
210210 * an empty string if no errors happened.
211211 */
212212 public function getErrorText() {
213 - if (count($this->m_errors) > 0) {
214 - $errors = implode(', ', $this->m_errors);
215 - return '<span class="smwttpersist"><span class="smwtticon">warning.png</span><span class="smwttcontent">' . $errors . '</span></span>';
216 - } else {
217 - return '';
218 - }
 213+ return smwfEncodeMessages($this->m_errors);
219214 }
220215
221216 /**
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -373,6 +373,18 @@
374374 }
375375
376376 /**
 377+ * Formats an array of message strings so that it appears as a tooltip.
 378+ */
 379+ function smwfEncodeMessages($msgarray) {
 380+ if (count($msgarray) > 0) {
 381+ $msgs = implode(', ', $msgarray);
 382+ return '<span class="smwttpersist"><span class="smwtticon">warning.png</span><span class="smwttcontent">' . $msgs . '</span></span>';
 383+ } else {
 384+ return '';
 385+ }
 386+ }
 387+
 388+ /**
377389 * Initialise storage objects based on user settings. Called once during init.
378390 */
379391 function smwfInitStore() {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php
@@ -116,20 +116,7 @@
117117 * TODO: use joined code for this and the similar method in SMWQueryParser?
118118 */
119119 protected function getErrorString($res) {
120 - $result = '';
121 - $first = true;
122 - foreach ($res->getErrors() as $e) {
123 - if ($first) {
124 - $first = false;
125 - } else {
126 - $result .= ', ';
127 - }
128 - $result .= '<span class="smwwarning">' . $e . '</span>';
129 - }
130 - if ($result != '') {
131 - $result = '(' . $result . ')';
132 - }
133 - return $result;
 120+ return smwfEncodeMessages($res->getErrors());
134121 }
135122
136123

Status & tagging log