Example #1
0
/**
 * This function changes the <body> tag into a <div> tag since we
 * can't really have a body-within-body.
 *
 * @param  $attary   an array of attributes and values of <body>
 * @param  $mailbox  mailbox we're currently reading (for cid2http)
 * @param  $message  current message (for cid2http)
 * @param  $id       current message id (for cid2http)
 * @return           a modified array of attributes to be set for <div>
 */
function sq_body2div($attary, $mailbox, $message, $id)
{
    $me = 'sq_body2div';
    $divattary = array('class' => "'bodyclass'");
    $bgcolor = '#ffffff';
    $text = '#000000';
    $styledef = '';
    if (is_array($attary) && sizeof($attary) > 0) {
        foreach ($attary as $attname => $attvalue) {
            $quotchar = substr($attvalue, 0, 1);
            $attvalue = str_replace($quotchar, "", $attvalue);
            switch ($attname) {
                case 'background':
                    $attvalue = sq_cid2http($message, $id, $attvalue, $mailbox);
                    $styledef .= "background-image: url('{$attvalue}'); ";
                    break;
                case 'bgcolor':
                    $styledef .= "background-color: {$attvalue}; ";
                    break;
                case 'text':
                    $styledef .= "color: {$attvalue}; ";
                    break;
            }
        }
        if (strlen($styledef) > 0) {
            $divattary["style"] = "\"{$styledef}\"";
        }
    }
    return $divattary;
}
Example #2
0
/**
 * This function changes the <body> tag into a <div> tag since we
 * can't really have a body-within-body.
 *
 * @param  $attary   an array of attributes and values of <body>
 * @param  $mailbox  mailbox we're currently reading (for cid2http)
 * @param  $message  current message (for cid2http)
 * @param  $id       current message id (for cid2http)
 * @return           a modified array of attributes to be set for <div>
 */
function sq_body2div($attary, $mailbox, $message, $id)
{
    $me = 'sq_body2div';
    $divattary = array('class' => "'bodyclass'");
    $bgcolor = '#ffffff';
    $text = '#000000';
    $has_bgc_stl = $has_txt_stl = false;
    $styledef = '';
    if (is_array($attary) && sizeof($attary) > 0) {
        foreach ($attary as $attname => $attvalue) {
            $quotchar = substr($attvalue, 0, 1);
            $attvalue = str_replace($quotchar, "", $attvalue);
            switch ($attname) {
                case 'background':
                    $attvalue = sq_cid2http($message, $id, $attvalue, $mailbox);
                    $styledef .= "background-image: url('{$attvalue}'); ";
                    break;
                case 'bgcolor':
                    $has_bgc_stl = true;
                    $styledef .= "background-color: {$attvalue}; ";
                    break;
                case 'text':
                    $has_txt_stl = true;
                    $styledef .= "color: {$attvalue}; ";
                    break;
            }
        }
        // Outlook defines a white bgcolor and no text color. This can lead to
        // white text on a white bg with certain themes.
        if ($has_bgc_stl && !$has_txt_stl) {
            $styledef .= "color: {$text}; ";
        }
        if (strlen($styledef) > 0) {
            $divattary["style"] = "\"{$styledef}\"";
        }
    }
    return $divattary;
}