?
<?php
require_once '../priv/fonctions.php';
require_once '../priv/AC.php';
require_once '../priv/event.php';
require_once("Custom.php");
require_once("Mailchimp.php");
require_once('../priv/newsletter2.php');
class Template{
public $debug = false;
public function __construct($apikeyperso=null, $template_id=null, $opts=array()) {
$Custom = new Custom();
$this->apikeyperso = $Custom->getapiKEY();
$this->template_id = $Custom->GetTemplateID();
$this->httpapi = $Custom->gethttpAPI();
$this->groupid = $Custom->getgroupList();
$this->MailChimp = new Mailchimp($this->apikeyperso);
}
public function Getapikey() {
return $this->apikeyperso;
}
public function GetTemplateID() {
return $this->template_id;
}
public function gethttpAPI() {
return $this->httpapi;
}
public function affichecontenu($prog, $court, $event){
$nl = new Newsletter($prog, $court, $event);
$contenu = $nl->getContent();
$ac = str_replace('%%ROOTURL%%',__BASESITE__,$contenu["ac"]);
$evenements = str_replace('%%ROOTURL%%',__BASESITE__,$contenu["evenements"]);
$court = str_replace('%%ROOTURL%%',__BASESITE__,$contenu["court"]);
return $ac.$evenements.$court;
}
public function afficheheader(){
$header = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html style="margin: 0; padding: 0;"><head><meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>
<body style="margin: 0 auto; padding: 0; background: fixed black url(\'http://helios-cinema.fr/styles/images/bg2.png\') top center repeat-x; color: white; max-width: 600px; width: auto !important; width: 600px;">
<div style="font-family: Calibri, Candara, Segoe, \'Segoe UI\', Optima, Arial, sans-serif; font-size: 14px;">
<div style="font-size: 40px; margin: 20px -25px;">
<a href="http://helios-cinema.fr" style="color: white;">
<img src="http://helios.geo/images/helios.png" alt="Cinéma le Palace" width="306" height="87" style="border: none;">
</a>
</div>
<div style="background: white; border-radius: 10px; color: black; padding: 40px; padding-bottom: 20px;">';
return $header;
}
public function affichetitreh1($titre) {
$MailChimp = $this->MailChimp;
$result = $MailChimp->call('templates/info', array(
'template_id' => $this->template_id,
));
//return '<h1 style="font-family: \'Avant Garde\', Avantgarde, \'Century Gothic\', CenturyGothic, \'AppleGothic\', sans-serif; color: #be1621; text-align: center;">'.$result['default_content']['titreh1'].'</h1>';
return '<h1 mc:edit="titreh1" style="font-family: \'Avant Garde\', Avantgarde, \'Century Gothic\', CenturyGothic, \'AppleGothic\', sans-serif; color: #be1621; text-align: center;">'.$titre.'</h1>';
}
public function affichetextmain($texte){
$MailChimp = $this->MailChimp;
$result = $MailChimp->call('templates/info', array(
'template_id' => $this->template_id,
));
//return '<div style="font-size: 16px; margin-bottom: 20px; padding: 5px 0;">'.$result['default_content']['textmain'].'</div>';
return '<div mc:edit="textmain" style="font-size: 16px; margin-bottom: 20px; padding: 5px 0;">'.$texte.'</div>';
}
function afficheimagemain ($image) {
$h = 240;
$w = $h * 3/4;
if(!isset($image))
{
$fichier = "rien";
$img = "";
}
else{
$img = "";
if($image != "")
{
$img = '<img src="%%ROOTURL%%/images/nl/'._h($image).'?q=,520;.jpg" />';
}
}
$img = str_replace('%%ROOTURL%%', __BASESITE__,$img);
return '<div mc:edit="imagemain" style="margin: 40px auto; text-align: center;">'.$img.'</div>';
}
public function pdfdownload($fichier){
if(!isset($fichier))
{
$fichier = "#!";
$pdf = "";
}
else
{
$pdf = "";
if($fichier != "")
{
$pdf = '<div id="pdf" style="background: #be1621; border-radius: 5px; display: block; float: right; font-weight: bold; padding: 5px 10px; text-transform: uppercase;"">';
$pdf .= '<a style="color:white;" href="%%ROOTURL%%/docs/nl/'._h($fichier).'" target="_blank">Télécharger le PDF</a>';
$pdf .= '</div>';
}
}
$pdf = str_replace('%%ROOTURL%%', __BASESITE__,$pdf);
return '<div mc:edit="pdfdownload" >'.$pdf.'</div>';
}
function createCONTENTAC () {
$contenu = $this->getContent();
$template = new Template;
$ac = str_replace('%%ROOTURL%%',self::$rootUrl,$contenu["ac"]);
$evenements = str_replace('%%ROOTURL%%',self::$rootUrl,$contenu["evenements"]);
$court = str_replace('%%ROOTURL%%',self::$rootUrl,$contenu["court"]);
$affichecontentallocine = $template->affichecontentallocine($ac, $evenements, $court);
$html = str_replace('%%ROOTURL%%',self::$rootUrl,$affichecontentallocine);
return $html;
}
public function afficheh2(){
return '<h2 style="font-family: \'Avant Garde\', Avantgarde, \'Century Gothic\', CenturyGothic, \'AppleGothic\', sans-serif; border-bottom: 1px dotted black; color: #be1621; margin-top: 30px; padding-bottom: 5px; padding-top: 0; text-transfomr: uppercase;">Programme de la semaine</h2>';
}
public function affichecontentallocine($content){
//exit($content);
return $content;
}
public function affichefooter(){
$footer = '</div>
<div style="background: #dddddd; border-radius: 10px 10px 0 0; color: #444444; font-size: 10px; margin-top: 20px; padding: 10px;">'.
$this->affichepieds()
.'
</div>
</div>
</body>
</html>';
return $footer;
}
public function affichepieds(){
$MailChimp = $this->MailChimp;
$result = $MailChimp->call('templates/info', array(
'template_id' => $this->template_id,
));
return $result['default_content']['pieds'];
}
}