Return form schema for encoded validation message

@param array $message Internal ValidationResult format for this message
@return array Form schema format for this message
967034
protected function getSchemaForMessage($message)
    {
        // Form schema messages treat simple strings as plain text, so nest for html messages
        $value = $message['message'];
        if ($message['messageCast'] === ValidationResult::CAST_HTML) {
            $value = ['html' => $message];
        }
        return [
            'value' => $value,
            'type' => $message['messageType'],
            'field' => empty($message['fieldName']) ? null : $message['fieldName'],
        ];
    }
49925
public function format(string $message): string
    {
        if (null === $this->params) {
            return $message;
        }

        foreach ($this->transformParams($this->params) as $key => $value) {
            $message = str_replace($key, $value, $message);
        }

        return $message;
    }
1023936
protected function formatMessage($message)
    {
        $traces = array();
        foreach ($this->getBacktrace() as $trace) {
            $traces[] = "in {$trace['file']}:{$trace['line']}";
        }

        $str = "[" . date('Y-m-d H:i:s', time()) . "]#" .  $this->getUserIp() . "# - " . $message;
        $str .= (empty($traces) ? '' : "\n    " . implode("\n    ", $traces));
        return $str;
    }
313221
public function a($message) {
        return isset($this->messages[$message]) ? $this->messages[$message] : $message;
    }
949780
public function format($message, array $context = [])
    {
        is_array($context) || $context = [$context];
        return '[' . date('Y-m-d H:i:s') . '] ' . Config::get('log_prefix', 'cml_log') . ': ' . $message . ' ' . json_encode($context, JSON_UNESCAPED_UNICODE);
    }
230618
protected function parseMessage(string $message, array $context): string
    {
        return preg_replace_callback('/\\{([\\w\\.]+)\\}/is', static function ($matches) use ($context) {
            $placeholderName = $matches[1];
            if (isset($context[$placeholderName])) {
                return (string)$context[$placeholderName];
            }
            return $matches[0];
        }, $message);
    }
954639
public function getShortMessage($message)
    {
        static $hasMbString;

        if (null === $hasMbString) {
            $hasMbString = function_exists('mb_strlen');
        }

        $maxLength = 45;

        if ($hasMbString) {
            if (mb_strlen($message, 'UTF-8') > $maxLength) {
                $message = mb_substr($message, 0, $maxLength - 4, 'UTF-8') . ' ...';
            }
        } else {
            if (strlen($message) > $maxLength) {
                $message = substr($message, 0, $maxLength - 4) . ' ...';
            }
        }

        return $message;
    }
28598
public function prepareTranslatedMessage(array $message = [])
    {
        $translatedMessage = \App\Registry::$translate->_($message['message']);
        array_unshift($message['vars'], $translatedMessage);
        return call_user_func_array('sprintf', $message['vars']);
    }
839590
public static function group(array $message) {
    self::checkClient();
    $groupId = !empty($message["groupId"]);
    self::assert($groupId, "Segment::group() expects groupId");
    self::validate($message, "group");

    return self::$client->group($message);
  }
465022
public function formatProfileMessage($message)
    {
        $sqlStart = strpos($message, '(') + 1;
        $sqlEnd = strrpos($message, ')');
        $sqlLength = $sqlEnd - $sqlStart;
        $message = substr($message, $sqlStart, $sqlLength);
        $message = strtr($message, array(
            ' FROM ' => "\nFROM ",
            ' VALUES ' => "\nVALUES ",
            ' WHERE ' => "\nWHERE ",
            ' ORDER BY ' => "\nORDER BY ",
            ' GROUP BY ' => "\nGROUP BY ",
            ' LIMIT ' => "\nLIMIT ",
            ' AND ' => "\n\tAND ",
            ', ' => ",\n\t ",
        ));
        if (strpos($message, '. Bound with ') !== false) {
            list($query, $params) = explode('. Bound with ', $message);
            $binds = array();
            $matchResult = preg_match_all("/(?<key>[a-z0-9\.\_\-\:]+)=(?<value>[\d\.e\-\+]+|''|'.+?(?<!\\\)')/ims", $params, $paramsMatched, PREG_SET_ORDER);
            if ($matchResult) {
                foreach ($paramsMatched as $paramsMatch)
                    if (isset($paramsMatch['key'], $paramsMatch['value']))
                        $binds[':' . trim($paramsMatch['key'], ': ')] = trim($paramsMatch['value']);
            }
            $message = strtr($query, $binds);
        }
        return strip_tags($this->getTextHighlighter()->highlight($message), '<div>,<span>');
    }
105358
private function parseMessage($message)
    {
        $string = $message;

        if (is_array($message)) {
            $format = '"%s" %s';
            $errors = array();

            foreach ($message as $field => $messages) {
                if (is_array($messages)) {
                    $messages = array_unique($messages);
                    foreach ($messages as $error) {
                        $errors[] = sprintf($format, $field, $error);
                    }
                } elseif (is_integer($field)) {
                    $errors[] = $messages;
                } else {
                    $errors[] = sprintf($format, $field, $messages);
                }
            }

            $string = implode(', ', $errors);
        }

        return $string;
    }
227024
public function encodeMessage($message)
    {
        // Get message descriptor
        $pool = DescriptorPool::getGeneratedPool();
        $messageType = $pool->getDescriptorByClassName(get_class($message));
        try {
            return $this->encodeMessageImpl($message, $messageType);
        } catch (\Exception $e) {
            throw new ValidationException(
                "Error encoding message: " . $e->getMessage(),
                $e->getCode(),
                $e
            );
        }
    }
620321
public function transformMessages(array $messages)
    {
        $transformed = null;

        if(count($messages))
        {
            $transformed = [];

            foreach ($messages as $message)
            {
                $attributes = (object) $message->getAttributes();

                $attributes->timestamp = $attributes->t;

                unset($attributes->t);
                
                // Add encryption check 
                $child = is_null($message->getChild(1)) ? $message->getChild(0) : $message->getChild(1);

                $node = new stdClass();
                $node->tag = $child->getTag();
                $node->attributes = (object) $child->getAttributes();
                $node->data = $child->getData();

                $attributes->body = $node;

                if($attributes->type == 'media')
                {
                    if($attributes->body->attributes->type == 'vcard')
                    {
                        $vcard = new VCardReader(null, $child->getChild(0)->getData());

                        if(count($vcard) == 1)
                        {
                            $attributes->body->vcard[] = $vcard->parse($vcard);
                        }
                        else
                        {
                            foreach ($vcard as $card)
                            {
                                $attributes->body->vcard[] = $vcard->parse($card);
                            }
                        }
                    }
                    else
                    {
                        $tmp = $this->media->link($attributes);
                    
                        $attributes->body->file = $tmp->file;
                        $attributes->body->html = $tmp->html;
                        $attributes->body->attributes2 = $node->attributes;
                    }           
                }

                $transformed[] = $attributes;
            }
        }

        return $transformed;
    }
181481
public function translate($message)
    {
        // message must be an array
        if (!is_array($message)) {
            return null;
        }

        // the following keys are required to construct a topic event object
        $keys = ['topic', 'event', 'version'];
        foreach ($keys as $k) {
            if (!isset($message[$k])) {
                return null;
            }
        }

        // don't include the topic, event and version as attributes
        $attributes = $message;
        unset($attributes['topic'], $attributes['event'], $attributes['version']);

        return new TopicEvent($message['topic'], $message['event'], $message['version'], $attributes);
    }
436285
public function Message($Message) {
   
      // htmlspecialchars_decode is being used here to revert any specialchar escaping done by Gdn_Format::Text()
      // which, untreated, would result in &#039; in the message in place of single quotes.
   
      if ($this->PhpMailer->ContentType == 'text/html') {
         $TextVersion = FALSE;
         if (stristr($Message, '<!-- //TEXT VERSION FOLLOWS//')) {
            $EmailParts = explode('<!-- //TEXT VERSION FOLLOWS//', $Message);
            $TextVersion = array_pop($EmailParts);
            $Message = array_shift($EmailParts);
            $TextVersion = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$TextVersion)));
            $Message = trim($Message);
         }
         
         $this->PhpMailer->MsgHTML(htmlspecialchars_decode($Message,ENT_QUOTES));
         if ($TextVersion !== FALSE && !empty($TextVersion)) {
            $TextVersion = html_entity_decode($TextVersion);
            $this->PhpMailer->AltBody = $TextVersion;
         }
      } else {
         $this->PhpMailer->Body = htmlspecialchars_decode($Message,ENT_QUOTES);
      }
      return $this;
   }
1099461
public function parse($message)
  {
    //Checking if the message is a full line
    if (strpos($message, "\r\n") === false) {
        return;
    }

    //Parsing the message
    if (!preg_match($this->messageRegex, $message, $parsed)) {
        $parsed = ['invalid' => $message];

        return $parsed;
    }

    /*
    * Raw message
    */
    $parsed['raw'] = $parsed[0];

    $parsed = $this->parseParameters($parsed);

    return $this->removeIntegerKeys($parsed);
  }
551900
private function formatErrorMessage(array $error) {
        if (isset($error['messageCode'])) {
            $messageCode = $error['messageCode'];
        } elseif (isset($error['message'])) {
            return $error['message'];
        } else {
            $messageCode = $error['error'];
        }

        // Massage the field name for better formatting.
        $msg = $this->formatMessage($messageCode, $error);
        return $msg;
    }