IMP_Compose::forwardMessageText PHP Méthode

forwardMessageText() public méthode

Returns the forward text for a message.
public forwardMessageText ( IMP_Contents $contents, array $opts = [] ) : array
$contents IMP_Contents An IMP_Contents object.
$opts array Additional options: - format: (string) Force to this format. DEFAULT: Auto-determine.
Résultat array An array with the following keys: - body: (string) The text of the body part. - charset: (string) The guessed charset to use for the forward. - format: (string) The format of the body message ('html', 'text').
    public function forwardMessageText($contents, array $opts = array())
    {
        $h = $contents->getHeader();
        $from = strval($h['from']);
        $msg_pre = "\n----- " . ($from ? sprintf(_("Forwarded message from %s"), $from) : _("Forwarded message")) . " -----\n" . $this->_getMsgHeaders($h) . "\n";
        $msg_post = "\n\n----- " . _("End forwarded message") . " -----\n";
        list($compose_html, $force_html) = $this->_msgTextFormat($opts, 'forward_format');
        $msg_text = $this->_getMessageText($contents, array('html' => $compose_html));
        if (!empty($msg_text) && ($msg_text['mode'] == 'html' || $force_html)) {
            $msg = $this->text2html($msg_pre) . ($msg_text['mode'] == 'text' ? $this->text2html($msg_text['text']) : $msg_text['text']) . $this->text2html($msg_post);
            $format = 'html';
        } else {
            $msg = $msg_pre . $msg_text['text'] . $msg_post;
            $format = 'text';
        }
        // Bug #10148: Message text might be us-ascii, but forward headers may
        // contain 8-bit characters.
        if ($msg_text['charset'] == 'us-ascii' && (Horde_Mime::is8bit($msg_pre) || Horde_Mime::is8bit($msg_post))) {
            $msg_text['charset'] = 'UTF-8';
        }
        return array('body' => $msg, 'charset' => $msg_text['charset'], 'format' => $format);
    }