/**
  * Getter. Get htmlBody.
  * prepend to the content the html header tags with any CSS if found, and
  * add the html footer;
  * @return string the content of the email (can have any html tags but <script>)
  * @access protected
  */
 function getHtmlBody()
 {
     if ($this->format != 'text') {
         $content = $this->getHeader();
         $content .= $this->content;
         $content .= $this->getFooter();
         return KT_transformsPaths(KT_getUri(), $content, true);
     } else {
         return;
     }
 }
Esempio n. 2
0
 /**
  * Getter. Get htmlBody.
  * @return string the content of the email (can have any html tags but <script>)
  * @access protected
  */
 function getHtmlBody()
 {
     if ($this->format != 'text') {
         $text = KT_DynamicData($this->content, $this->getTng(), $this->escapeMethod, $this->getUseSavedData(), array(), false);
         $text = $this->removeScript($text);
         return KT_transformsPaths(KT_makeIncludedURL($this->file), $text, true);
     } else {
         return;
     }
 }
Esempio n. 3
0
function mxi_ParseHtml($text, $relPath)
{
    if (!isset($GLOBALS['mxi_scripts_hash'])) {
        $GLOBALS['mxi_scripts_hash'] = array();
    }
    if (!isset($GLOBALS['mxi_links_hash'])) {
        $GLOBALS['mxi_links_hash'] = array();
    }
    if (!isset($GLOBALS['mxi_styles_hash'])) {
        $GLOBALS['mxi_styles_hash'] = array();
    }
    $ret = KT_transformsPaths($relPath, $text, false);
    // get the <body>
    $body = $ret;
    $body = preg_replace("/^[\\w\\W]*<body[^>]*>/i", "", $body);
    $body = preg_replace("/<\\/body>[\\w\\W]*\$/i", "", $body);
    // get the <head>
    $head = $ret;
    $head = preg_replace("/^[\\w\\W]*<head[^>]*>/i", "", $head);
    $head = preg_replace("/<\\/head>[\\w\\W]*\$/i", "", $head);
    $links = "";
    $styles = "";
    if (isset($GLOBALS['KT_MXI_parse_css']) && $GLOBALS['KT_MXI_parse_css'] == true) {
        // get the external CSS
        preg_match_all("/<link[^>]*>[\n\r]*/i", $head, $links);
        if (sizeof($links) == 1) {
            $links = $links[0];
            foreach ($links as $k => $link) {
                $md5_link = md5($link);
                if (in_array($md5_link, $GLOBALS['mxi_links_hash'])) {
                    unset($links[$k]);
                } else {
                    array_push($GLOBALS['mxi_links_hash'], $md5_link);
                }
            }
            $links = implode("", $links);
        }
        // get the inline CSS
        preg_match_all("/<style[^>]*>[\\w\\W]*?<\\/style>[\n\r]*/i", $head, $styles);
        if (sizeof($styles) == 1) {
            $styles = $styles[0];
            foreach ($styles as $k => $style) {
                $md5_style = md5($style);
                if (in_array($md5_style, $GLOBALS['mxi_styles_hash'])) {
                    unset($styles[$k]);
                } else {
                    array_push($GLOBALS['mxi_styles_hash'], $md5_style);
                }
            }
            $styles = implode("", $styles);
        }
    }
    // get the JavaScripts
    preg_match_all("/<script[^>]*>[\\w\\W]*?<\\/script>[\n\r]*/i", $head, $scripts);
    if (sizeof($scripts) == 1) {
        $scripts = $scripts[0];
        foreach ($scripts as $k => $script) {
            $md5_script = md5($script);
            if (in_array($md5_script, $GLOBALS['mxi_scripts_hash'])) {
                unset($scripts[$k]);
            } else {
                array_push($GLOBALS['mxi_scripts_hash'], $md5_script);
            }
        }
        $scripts = implode("", $scripts);
    } else {
        $scripts = "";
    }
    $ret = $links . $styles . $scripts . $body;
    return $ret;
}