Пример #1
0
 /**
  * Get the error list as a Message object
  *
  * @param string|string[] $shortContext A short enclosing context message name (or an array of
  * message names), to be used when there is a single error.
  * @param string|string[] $longContext A long enclosing context message name (or an array of
  * message names), for a list.
  *
  * @return Message
  */
 public function getMessage($shortContext = false, $longContext = false)
 {
     $rawErrors = $this->sv->getErrors();
     if (count($rawErrors) == 0) {
         if ($this->sv->isOK()) {
             $this->sv->fatal('internalerror_info', __METHOD__ . " called for a good result, this is incorrect\n");
         } else {
             $this->sv->fatal('internalerror_info', __METHOD__ . ": Invalid result object: no error text but not OK\n");
         }
         $rawErrors = $this->sv->getErrors();
         // just added a fatal
     }
     if (count($rawErrors) == 1) {
         $s = $this->getErrorMessage($rawErrors[0]);
         if ($shortContext) {
             $s = wfMessage($shortContext, $s);
         } elseif ($longContext) {
             $wrapper = new RawMessage("* \$1\n");
             $wrapper->params($s)->parse();
             $s = wfMessage($longContext, $wrapper);
         }
     } else {
         $msgs = $this->getErrorMessageArray($rawErrors);
         $msgCount = count($msgs);
         if ($shortContext) {
             $msgCount++;
         }
         $s = new RawMessage('* $' . implode("\n* \$", range(1, $msgCount)));
         $s->params($msgs)->parse();
         if ($longContext) {
             $s = wfMessage($longContext, $s);
         } elseif ($shortContext) {
             $wrapper = new RawMessage("\n\$1\n", $s);
             $wrapper->parse();
             $s = wfMessage($shortContext, $wrapper);
         }
     }
     return $s;
 }
 public static function provideStripOuterParagraph()
 {
     // This mimics the most common use case (stripping paragraphs generated by the parser).
     $message = new RawMessage("Message text.");
     return array(array("<p>Text.</p>", "Text."), array("<p class='foo'>Text.</p>", "<p class='foo'>Text.</p>"), array("<p>Text.\n</p>\n", "Text."), array("<p>Text.</p><p>More text.</p>", "<p>Text.</p><p>More text.</p>"), array($message->parse(), "Message text."));
 }