public function build(Template $template, array $data = [])
 {
     $buffer = $template->getContent();
     preg_match_all('/\\{{(.*?)\\}}/', $template->getContent(), $logic);
     foreach ($logic[1] as $key => $value) {
         $tmp = trim($value);
         $mustEcho = false;
         if (strpos($tmp, " ") === false && strpos($tmp, "--") === false && strpos($tmp, "++") === false && strpos($tmp, "=") === false && $tmp[0] === "\$") {
             $mustEcho = true;
         }
         $buffer = str_replace($logic[0][$key], ($mustEcho ? "<?=" : '<?php ') . $value . ' ?>', $buffer);
     }
     //$buffer = '<?php $viewData = ' . serialize($data) . ';' . $buffer;
     return $buffer;
 }
Example #2
0
 public function build(Template $template, array $data = [])
 {
     $buffer = $template->getContent();
     if (strpos($buffer, '@SET_LAYOUT') !== false) {
         $layoutTemp = explode("SET_LAYOUT '", $buffer)[1];
         $layoutTemp = explode("';", $layoutTemp)[0];
         $layout = new Template();
         $layout->setFile(\Framework\Kernel::instance()->getApplicationRoot() . "/../App/Views/" . $layoutTemp . ".phtml");
         $layoutContent = $layout->getContent();
         $data = explode("\n", $buffer);
         $data[0] = "";
         $buffer = implode("\n", $data);
         $buffer = str_replace("@BODY_SECTION", $buffer, $layoutContent);
     }
     $temp = $buffer;
     preg_match_all('/\\{{(.*?)\\}}/', $temp, $logic);
     foreach ($logic[1] as $key => $value) {
         $tmp = trim($value);
         $mustEcho = false;
         if (strpos($tmp, " ") === false && strpos($tmp, "--") === false && strpos($tmp, "++") === false && strpos($tmp, "=") === false && $tmp[0] === "\$") {
             $mustEcho = true;
         }
         $buffer = str_replace($logic[0][$key], ($mustEcho ? "<?=" : '<?php ') . $value . ' ?>', $buffer);
     }
     return $buffer;
 }
Example #3
0
# The main objective of this project is to see the way do something similar,#
#  such as sending messages via e-mail, files Read the content and create   #
#  templates or other                                                       #
#   and saved on the server within a specific folder.                       #
# Can anyone who want to modify or development (add some functions, styles),#
# and use it in his dite, or commercially.                                  #
#                                                                           #
#  so if you have any question -> ask me on m.anzawi2013@gmail.com          #
# or visit my blog on http://www.phptricks.org                              #
#---------------------------------------------------------------------------#
$temp = new Template();
$subsc = new Subscribe();
if (isset($_POST['send'])) {
    $send = new Sender();
    $tempName = str_replace('.html', '', $_POST['tempName']);
    $templ['content'] = $temp->getContent($tempName);
    $templ['title'] = $_POST['title'];
    $emails = $_POST['subsc'];
    if ($send->sendNewsLitter($emails, $templ)) {
        echo "Send Succcessfuly";
    } else {
        echo "Unabl to Send";
    }
}
?>
<form method="POST">
    <div style="width:20%; float: left;">
        Message Title : <input type="text" name="title"><br><br>
        <h3>Choice Template</h3>

Example #4
0
    function getContent($args)
    {
        global $structureMgr, $templatesMgr, $authenticationMgr;
        $userId = $authenticationMgr->getUserID();
        $userData = $authenticationMgr->getUserData($userId, '');
        $userName = $userData['FirstName'] . " " . $userData['LastName'];
        $this->setItemData('userData', $userData);
        $this->setItemData('userName', $userName);
        $blocks = $templatesMgr->getValidTags($templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Cart/cart.xml"), array("container", "goods", "cart", "emptycart", "order", "quickorder", "login", "comment"));
        $sessionID = $authenticationMgr->getSessionID();
        $tpl = $blocks["container"];
        $goodsline = $blocks["goods"];
        $qr = mysql_query("SELECT p.sID, p.accID, p.ptID, ShortTitle, salePrice, accCount, ptPercent, p.accPlantID, logotype, p.smallPicture, s.MetaDesc, s.pms_sID, pc.PicturePath FROM pm_as_parts p \n                               LEFT JOIN pm_structure s ON (p.sID = s.sID) \n\t\t\t\t\t\t\t   LEFT JOIN pm_as_producer ap ON (ap.accPlantID = p.accPlantID)\n                               LEFT JOIN pm_as_cart c ON (c.accID = p.accID)\n                               LEFT JOIN pm_as_pricetypes pt ON (pt.ptID = p.ptID)\n                               LEFT JOIN pm_as_categories pc ON (s.pms_sID = pc.sID)\n                               WHERE c.sessionID='{$sessionID}'");
        if (!$qr) {
            trigger_error("Error getting cart items - \n" . mysql_error(), PM_FATAL);
        }
        $goodsCount = mysql_num_rows($qr);
        $goods = "";
        $cardSum = 0;
        $curSum = 0;
        $sum = 0;
        $total = 0;
        if (mysql_num_rows($qr) > 0) {
            $cat = new Catalogue();
            //goods list from $qr
            $goodsArray = array();
            while (false !== ($r = mysql_fetch_assoc($qr))) {
                /*
                	if ($catItem["ptPercent"] == 0)
                		$firstPrice = "<strong>" . round($catItem["salePrice"] - ($catItem["salePrice"] * 5 / 100)) . "</strong>";
                	else
                		$firstPrice = "<strong><font class=\"".$typeClass."\">" . 
                					  round($catItem["salePrice"] - ($catItem["salePrice"] * $catItem["ptPercent"] / 100)) . 
                					  "</font></strong>";
                */
                $gl = $goodsline;
                $URL = $structureMgr->getPathByPageID($r['sID'], false);
                $isCardInCart = Cart::isItemInCart(GetCfg('Club.GoodID'));
                $isClubMember = isset($userData['cardID']) && $userData['cardID'] != '0' || $isCardInCart;
                switch ($r['ptID']) {
                    case 1:
                        if ($userData['cardID'] || $isCardInCart) {
                            $curPrice = round($r["salePrice"] - $r["salePrice"] * 5 / 100);
                        } else {
                            $curPrice = $r['salePrice'];
                        }
                        $cardPrice = round($r["salePrice"] - $r["salePrice"] * 5 / 100);
                        break;
                    case 2:
                        if ($userData['cardID'] || $isCardInCart) {
                            $curPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        } else {
                            $curPrice = $r['salePrice'];
                        }
                        $cardPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        break;
                    case 3:
                        if ($userData['cardID'] || $isCardInCart) {
                            $curPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        } else {
                            $curPrice = $r['salePrice'];
                        }
                        $cardPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        break;
                    case 4:
                        if ($userData['cardID'] || $isCardInCart) {
                            $curPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        } else {
                            $curPrice = $r['salePrice'];
                        }
                        $cardPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        break;
                    case 5:
                        $curPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        $cardPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        break;
                    case 6:
                        $curPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        $cardPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        break;
                    case 7:
                        $curPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        $cardPrice = round($r["salePrice"] - $r["salePrice"] * $r["ptPercent"] / 100);
                        break;
                    default:
                        $curPrice = $r['salePrice'];
                        $cardPrice = $r['salePrice'];
                        break;
                }
                $curPrice *= $r["accCount"];
                $cardPrice *= $r["accCount"];
                $price = $r['salePrice'] * $r["accCount"];
                //must calc as needed
                $priceCells = '<td class="gray"><p> <a href="%good_link%" class="bluem" target="_blank">%good_name%</a></p></td>
                            <td><strong>%card_price%</strong></td>
                            <td>%cur_price%</td>';
                if ($isClubMember) {
                    $priceCells = '<td>%cur_price%</td>';
                }
                $gl = str_replace("%good_name%", $r['ShortTitle'], $gl);
                $gl = str_replace("%good_link%", $URL, $gl);
                $gl = str_replace("%card_price%", $cardPrice . " * " . $r["accCount"], $gl);
                $gl = str_replace("%cur_price%", $curPrice . " * " . $r["accCount"], $gl);
                $gl = str_replace("%price%", $price . " * " . $r["accCount"], $gl);
                $gl = str_replace("%good_count%", $r['accCount'], $gl);
                $gl = str_replace("%goodID%", $r['accID'], $gl);
                $cardSum += $cardPrice;
                $curSum += $curPrice;
                $sum += $price;
                $total += $r['accCount'];
                //echo "$curSum in Cart<br>";
                if (file_exists(GetCfg("ROOT") . $r["PicturePath"] . "/" . $r["sID"] . ".gif")) {
                    $r["smallPicture"] = $r["PicturePath"] . "/" . $r["sID"] . ".gif";
                } else {
                    if ($r["logotype"] == NULL) {
                        $r["smallPicture"] = "/products/empty.gif";
                    } else {
                        $r["smallPicture"] = $r["logotype"];
                    }
                }
                $good = new Good(array('goodID' => $r['sID'], 'good_name' => $r['ShortTitle'], 'PicturePath' => $r['PicturePath'], 'good_link' => $URL, 'card_price' => $cardPrice, 'smallPicture' => $r["smallPicture"], 'cur_price' => $curPrice, 'price' => $price, 'good_count' => $r['accCount']));
                foreach ($r as $var => $val) {
                    $good->setItemData($var, $val);
                }
                $good->setItemData('priceClass', $this->getPriceClass($r['ptID']));
                $good->setItemData('ptID', $r['ptID']);
                $good->setItemData('ptPercent', $r['ptPercent']);
                $good->setItemData('props', $props = $cat->getCatItemProperties($r['sID'], "CatItem", $structureMgr->getParentPageID($r['sID'])));
                $this->goods[$r['sID']] = $good;
                $imgRes = mysql_query("SELECT accPlantName, logotype FROM pm_as_producer WHERE accPlantID = '{$r["accPlantID"]}'");
                if (mysql_num_rows($imgRes) > 0) {
                    $imgRow = mysql_fetch_assoc($imgRes);
                    $this->goods[$r['sID']]->setItemData('accPlantName', $imgRow['accPlantName']);
                    $this->goods[$r['sID']]->setItemData('logotype', $imgRow['logotype']);
                }
                $goods .= $gl;
            }
            $tcart = $blocks["cart"];
        } else {
            $tcart = $blocks["emptycart"];
        }
        if ($total > 0) {
            $order = $blocks["order"];
            $qorder = $blocks["quickorder"];
            if ($authenticationMgr->getUserID() == 1) {
                $blocks["login"] = str_replace("%currentpath%", getenv("REQUEST_URI"), $blocks["login"]);
                $order = str_replace("%right%", $blocks["login"], $order);
                $order = str_replace("%left%", $qorder, $order);
            } else {
                $order = str_replace("%right%", $blocks["comment"], $order);
                $order = str_replace("%left%", $qorder, $order);
                //echo $order;
            }
        } else {
            $order = "";
        }
        $ret = '';
        $isCardInCart = Cart::isItemInCart(GetCfg('Club.GoodID'));
        $isClubMember = isset($userData['cardID']) && $userData['cardID'] != '0' || $isCardInCart;
        $this->setItemData('isCardInCart', $isCardInCart);
        $this->setItemData('isClubMember', $isClubMember);
        $this->setItemData('userID', $userId);
        $this->userData = $userData;
        $carName = 'марка автомобиля не определена';
        if ($userId > 1 && $isClubMember && $userData['carID'] != 0) {
            $carRow = mysql_fetch_assoc(mysql_query("SELECT * FROM pm_as_cars WHERE carID='{$userData['carID']}'"));
            $carName = "ВАЗ " . $carRow['carModel'] . (isset($carRow['carName']) && $carRow['carName'] != '' ? "({$carRow['carName']})" : '');
        }
        $this->setItemData('carName', $carName);
        if ($userId == 1) {
            $ret .= '<p><strong>Внимание!:</strong></p>
						<p>Для вашего удобства мы предлагаем вам:</p>
						<p><a href="/registration" class="levm"><img src="/images/arr_gray2.gif" width="7" height="9" border="0" align="absmiddle"/>Зарегестрироваться</a><br/>
						<a href="/main/club" class="levm"><img src="/images/arr_gray2.gif" width="7" height="9" border="0" align="absmiddle"/>Стать членом клуба</a></p>';
        } elseif ($userId > 1 && !$isClubMember) {
            $ret .= '<p><strong>Внимание:</strong></p>
						<p>Для вашего удобства мы предлагаем вам:</p>
						<a href="/main/club" class="levm"><img src="/images/arr_gray2.gif" width="7" height="9" border="0" align="absmiddle"/>Стать членом клуба</a></p>';
        } elseif ($userId > 1 && $isClubMember) {
            $carName = 'марка автомобиля не определена';
            if ($userData['carID'] != 0) {
                $carRow = mysql_fetch_assoc(mysql_query("SELECT * FROM pm_as_cars WHERE carID='{$userData['carID']}'"));
                $carName = "ВАЗ " . $carRow['carModel'] . (isset($carRow['carName']) && $carRow['carName'] != '' ? "({$carRow['carName']})" : '');
            }
            $ret .= '<p><strong>Здравствуйте!</strong></p>
						<p>' . $userName . '</p>
						<p>№ Вашей карты: ' . ($userData['cardID'] == '0' ? 'Будет присвоен после оплаты.' : $userData['cardID']) . '</p>
						<p>' . $carName . '</p>
						<p>
							<a href="#" class="levm"><img src="/images/arr_gray2.gif" width="7" height="9" border="0" align="absmiddle"/>Изменить анкету </a> 
						<a href="#" class="levm"><img src="/images/arr_gray2.gif" width="7" height="9" border="0" align="absmiddle"/>Выход (log out)</a></p>
						';
        }
        $club = $ret;
        $this->setItemData('cart', $tcart);
        $this->setItemData('cardsum', $cardSum);
        $this->setItemData('cursum', $curSum);
        $this->setItemData('sum', $sum);
        $this->setItemData('total', $total);
        $this->setItemData('goods', $goods);
        $this->setItemData('order', $order);
        $this->setItemData('club', $club);
        $dost = new Template('blockdost', $this);
        $this->setItemData('blockdost', $dost->getContent());
        if ($userId == 1) {
            $header = new Template('header', 'Быстрый заказ');
            $of = new Template('orderQuick');
            $orderForm = $header->getContent() . $of->getContent();
        } else {
            $header = new Template('header', 'Контактная информация');
            $of = new Template('orderUser', $this->getItemData('userData'));
            $orderForm = $header->getContent() . $of->getContent();
        }
        $this->setItemData('orderForm', $orderForm);
        $cartTpl = new Template('cart', $this);
        $tpl = $cartTpl->getContent();
        $msg = _get("msg");
        if ($msg == 1) {
            $msg = '<div class="podbor">Заполните пожалуйства поле &quot;Ваше имя&quot;</div>';
        } elseif ($msg == 2) {
            $msg = '<div class="podbor">Заполните пожалуйства поле &quot;Ваше имя&quot;</div>';
        }
        return $msg . $tpl;
    }
 public function demostracao2($args = array())
 {
     $temp = new Template('../templates/demostracao2.htm');
     $this->tmpBox($temp->getContent(), $args[0]);
 }
$templates = new Template();
echo "<ul>";
foreach ($templates->show() as $template) {
    $template = str_replace(".html", '', $template);
    echo "<li> <a href='" . $prifex . $template . "'>" . $template . "</a></li>";
}
echo "</ul>" . "</div>";
if (isset($_GET['temp'])) {
    $temp = htmlspecialchars($_GET['temp']);
    if (file_exists(ROOT . 'email_templates/' . $temp . '.html')) {
        ?>
     <form method="POST" style="float:left; width: 70% !important;">
        Name :  <input type="text" name="title" value="<?php 
        echo $temp;
        ?>
">
         <br><br>Content :<br>
         <textarea id="textEditor" name="temp_content" style="height:500px;resize:none; width: 70% !important;">
                 <?php 
        echo $templates->getContent($temp);
        ?>
        </textarea>
         <br>
         <input type="submit" value="Save Template" name="save_temp">
    </form>
        
        <?php 
    } else {
        echo "error No Template Found ....   ";
    }
}