Beispiel #1
0
 /**
  * Generate content from static template compilation
  *
  * @param string $template
  * @param array $vars
  * @param array $blocks
  * @return string
  */
 public static function make($template, array $vars = [], array $blocks = [])
 {
     if (!static::$instance) {
         static::$instance = new static();
     }
     return static::$instance->render($template, $vars, $blocks);
 }
Beispiel #2
0
function direct_to_correct_page() {

	$editStylesheet = '<link href="/static/css/edit.css" rel="stylesheet">';
	$uploadStylesheet = '<link href="/static/css/upload.css" rel="stylesheet">';
	$editoruploadStylesheet = '<link href="/static/css/editorupload.css" rel="stylesheet">';

	$templater = new Templater;
	$templater->title = 'Rediger';
	
	if (isset($_GET['path'])) {
		if ($_GET['path'] == 'upload') {
			$templater->extra_headers = array($uploadStylesheet);
			$templater->render('uploadTmpl.php');

		} else if ($_GET['path'] == 'edit') {
			$date = isset($_GET['date']) ? 
					date('Ymd', strtotime($_GET['date'])) :
					date('Ymd');
			$templater->date = date('d-m-Y', strtotime($date));
			$templater->meeting_data = extract_meetings_all_rooms(false, $date); 
			$templater->extra_headers = array($editStylesheet);
			$templater->render('editTmpl.php');

		} else
			echo "I don't know what to do with this get request: " . var_dump($_GET);
	}
	else {
		$templater->extra_headers = array($editoruploadStylesheet);
		$templater->render('editoruploadTmpl.php');
	}
}
Beispiel #3
0
 /**
  * Compile template
  *
  * @param array $vars
  * @return string
  *
  * @throws \Exception
  */
 public function compile(array $vars = [])
 {
     // start compilation
     if ($this->compiling) {
         throw new \LogicException('Template is already compiling.');
     }
     $this->compiling = true;
     // extract user vars
     extract($vars);
     unset($vars);
     // start stream capture
     ob_start();
     // display file
     require $this->file;
     // stop stream capture
     $content = ob_get_clean();
     $content .= "\n\n";
     // compile layout
     if ($this->layout) {
         list($layout, $vars) = $this->layout;
         $blocks = array_merge($this->blocks, ['__CONTENT__' => $content]);
         $content = $this->templater->render($layout, $vars, $blocks);
     }
     // end
     $this->compiling = false;
     return $content;
 }
Beispiel #4
0
 protected function loadTemplate($template)
 {
     $main = new Templater('main');
     $body = new Templater($template);
     $main->attach('Body', $body);
     $main->register('JSPath', 'web/index.php/js/', Templater::URL);
     $main->register('CSSPath', 'web/css/main.css', Templater::URL);
     Messenger::send($main->render());
 }
Beispiel #5
0
 public function sendEmail($tpl)
 {
     $templater = new Templater();
     $templater->user = $this;
     $body = $templater->render('email/' . $tpl);
     list($subject, $body) = preg_split('/\\r|\\n/', $body, 2);
     $mail = new Zend_Mail();
     $mail->addTo($this->profile->email, trim($this->profile->first_name . ' ' . $this->profile->last_name));
     $mail->setFrom(Zend_Registry::get('config')->email->from->email, Zend_Registry::get('config')->email->from->name);
     $mail->setSubject(trim($subject));
     $mail->setBodyText(trim($body));
     $mail->send();
 }
Beispiel #6
0
function direct() {
	$ROOT = $_SERVER['DOCUMENT_ROOT'];
	require_once $ROOT . '/helpers/templater.php';
	require_once $ROOT . '/../mkkauth.php';


	if (isset($_POST['password']) && htmlspecialchars($_POST['password']) === MKK_AUTH_KEY) {
		$_SESSION['login'] = true;
		header('Location: rediger.php');
		exit;
	}
	else {
		$stylesheet = '<link href="static/css/authenticate.css" rel="stylesheet">';
		$templater = new Templater;
		$templater->title = 'Login';
		$templater->extra_headers = array($stylesheet);
		$templater->render('authenticateTmpl.php');
	}
}
Beispiel #7
0
// ------------------------------------
// Vis bilde hvis det er sommerferie
$today = date('d-m-Y', time());
$summerEnd = date('04-08-2014');
if (strtotime($today) < strtotime($summerEnd)) {
	require('static/sommer.html');
	die;
}
// ------------------------------------


$ROOT = $_SERVER['DOCUMENT_ROOT'];
require_once 'helpers/templater.php';
require_once 'helpers/database.php';

$stylesheet1 = '<link href="static/css/mainview.css" rel="stylesheet">';
$stylesheet2 = '<link href="static/css/infoskjerm.css" rel="stylesheet">';
$script1 = '<script src="static/js/infoskjerm.js"></script>';
$script2 = '<script src="static/js/mainview.js"></script>';


$templater = new Templater;
$templater->title = 'Møteromsoversikt';
$templater->date = utf8_encode(strftime('%A %d. %B %Y'));
$templater->last_updated = utf8_encode(strftime('%A %d. %B kl %H:%M', strtotime(extract_last_updated())));
$templater->meeting_data = extract_meetings_all_rooms();
$templater->extra_headers = array($stylesheet1, $stylesheet2);
$templater->extra_footers = array($script1, $script2);

$templater->render('mainviewTmpl.php');
Beispiel #8
0
<?php

// --- Templater init -------------------------------------------------------------------------------------
require_once APPPATH . 'classes/Templater/Templater.php';
$Templater = new Templater();
$templater = $Templater->create(APPPATH . 'views/widgets/w_top.html', array('item_template'));
eval('$doc = $templater[0]; extract($templater[1], EXTR_SKIP);');
// --- /Templater init ------------------------------------------------------------------------------------
$dopitem_box = $doc->find('.dopitem_box');
foreach ($data as $id => $item) {
    //echo '<pre>' . var_dump($item) . '</pre>';
    $item_el = $Templater->get_template('item_template');
    $item_el->find('img')->attr('src', $item['photos'][0]['value']);
    $item_el->find('a')->attr('href', '/' . $item['node'] . $item['url'] . '.html');
    $item_el->find('h2 > a')->text($item['name']);
    $item_el->find('p.catalog-price')->text(number_format(Arr::get($item, 'price'), 0, '', ' ') . ' руб.');
    $item_el->appendTo($dopitem_box);
}
$Templater->render();
Beispiel #9
0
$ROOT = $_SERVER['DOCUMENT_ROOT'];
require_once $ROOT . '/helpers/database.php';
require_once $ROOT . '/helpers/templater.php';

$stylesheet = '<link href="static/css/allmeetings.css" rel="stylesheet">';

if (isset($_GET['room_name'])) {
	$last_updated = fileatime($ROOT . '/last_updated/' . str_replace(' ', '_', $_GET['room_name']));
	$templater = new Templater;
	$templater->title = $_GET['room_name'];
	$templater->meetings = sort_by_date(extract_meetings($_GET['room_name'], true));
	$templater->last_updated = utf8_encode(strftime('%A %d. %B kl %H:%M', strtotime(date('Ymd Hi', $last_updated))));
	$templater->extra_headers = array($stylesheet);

	$templater->render('allmeetingsTmpl.php');
}
else
	echo "No room name available";

function sort_by_date($meetings) {
	$sorted = array();
	foreach ($meetings as $meeting) {
		$meeting_date = date('Ymd', strtotime($meeting['start_datetime']));
		if (isset($sorted[$meeting_date]))
			$sorted[$meeting_date][] = $meeting;
		else
			$sorted[$meeting_date] = array($meeting);
	}
	ksort($sorted);
Beispiel #10
0
 public function attachInline($key, Templater $child)
 {
     $this->register($key, str_replace(array('  ', "\t", "\n", "\r"), ' ', $child->render()));
 }
Beispiel #11
0
 public function sendEmail($tpl)
 {
     $templater = new Templater();
     $templater->user = $this;
     //fetch teh e-amil body
     $body = $templater->render('email/' . $tpl);
     //extract the subject from the first line
     list($subject, $body) = preg_split('/\\r|\\n/', $body, 2);
     //now set up and send teh email
     $mail = new Zend_Mail();
     //set the to address and the user's full name in the 'to' line
     //echo "<br/> here at user email address: ".$this->email."<br/>";
     $mail->addTo($this->email, trim($this->first_name . ' ' . $this->last_name));
     //get the admin 'from details form teh config
     $mail->setFrom('*****@*****.**', 'bt-no-reply');
     //set the subject and boy and send the mail
     $mail->setSubject(trim($subject));
     $mail->setBodyText(trim($body));
     $mail->send();
     //$logger->warn('at send email at usre.php complete<br/>');
 }
Beispiel #12
0
 public function sendEmail($tpl, $secondUser = '', $invoiceID = '')
 {
     $templater = new Templater();
     $templater->user = $this;
     if ($secondUser != '') {
         $templater->member = $secondUser;
     }
     if ($invoiceID != '') {
         $order = new DatabaseObject_Order($this->_db);
         if ($order->loadOrderByUrl($invoiceID)) {
             if ($order->promotion_code == '') {
                 $templater->addPromo = 'true';
             } else {
                 $templater->promoCode = $order->promotion_code;
                 $templater->discount = $order->total_after_p - $order->total_before_p;
                 $templater->finalTotal = $order->total_after_p;
             }
             //echo "promotion code: ";
             $orderProfile = new Profile_Order($this->_db);
             $result = $orderProfile->loadProifleByOrderID($order->getId());
             if ($order->buyer_id > 30000000) {
                 $member = new DatabaseObject_Guest($this->_db);
                 $member->loadByID($order->buyer_id - 30000000);
                 $templater->guest = 'true';
             } else {
                 $member = new DatabaseObject_User($this->_db);
                 if ($type == 'buyer') {
                     $member->loadByUserId($order->user_id);
                     ////echo "here at odertype buyer";
                 }
             }
             echo "order status: " . $order->url . "<br/>";
             echo "count of order in that order: " . count($result) . "<br/>";
             echo $result[0]['profile_id'];
             echo $result[0]['product_name'];
             $templater->member = $member;
             $productProfile = array();
             foreach ($result as $k => $v) {
                 //echo "<br/>here0<br/>";
                 $productProfile[$result[$k]['profile_id']] = new Profile_Order($this->_db);
                 $productProfile[$result[$k]['profile_id']]->loadOrder($result[$k]['profile_id'], $order->url);
                 //echo "<br/>heels are for profile_id: ".$result[$k]['profile_id']." and heels are: ".$productProfileArray[$result[$k]['profile_id']]->orderAttribute->heel."<br/>";
                 //echo "<br/>name: ".$productProfileArray[1]->product_name;
             }
             $templater->productsProfile = $productProfile;
             $templater->invoice = $invoiceID;
             $templater->dateTime = date(date("F j, Y, g:i a"), $order->ts_created);
             $templater->finalTotal = $order->total_after_p;
             //////////////////////////////////////////////////////////////////////////////////
             /*
             					$this->orderShoppingCart = new DatabaseObject_Order($this->_db);
             					
             					$this->orderCartObject=$this->orderShoppingCart->loadOrderByUrl($invoiceID);
             					
             					if($this->orderShoppingCart->promotion_code == '')
             					{
             						$templater->addPromo = 'true';
             						$templater->total = $this->orderShoppingCart->total_before_p;
             	
             					}
             					else
             					{
             						$templater->promoCode = $this->orderShoppingCart->promotion_code;
             						$templater->total = $this->orderShoppingCart->total_before_p;
             						$templater->discount = $this->orderShoppingCart->total_after_p-$this->orderShoppingCart->total_before_p;
             						$templater->finalTotal = $this->orderShoppingCart->total_after_p;
             					}
             					
             					
             					$product = $this->orderCartObject;
             					
             					echo "count product: ".count($product);
             					$templater->shoppingCart = $this->orderShoppingCart;
             					$templater->dateTime= date(date("F j, Y, g:i a"), $this->orderShoppingCart->ts_created);
             					$templater->products = $product;
             					
             					
             					$productProfile=array();
             					
             					foreach($product as $k => $v)
             					{
             						echo $product[$k]->getId();
             						
             						$productProfile[$product[$k]['profile_id']] = new Profile_Order($this->db);
             						
             						$productProfile[$product[$k]['profile_id']]->loadOrder($product[$k]['profile_id'], $order->url);
             						
             						
             						
             															
             					}
             				
             					$templater->productsProfile=$productProfile;*/
         }
     }
     //fetch teh e-amil body
     $body = $templater->render('email/' . $tpl);
     //extract the subject from the first line
     list($subject, $body) = preg_split('/\\r|\\n/', $body, 2);
     //now set up and send teh email
     echo "here at mail" . "<br/>";
     $mail = new Zend_Mail();
     //set the to address and the user's full name in the 'to' line
     echo "the email sent out is: " . $this->email . "<br />";
     $mail->addTo($this->email, trim($this->first_name . ' ' . $this->last_name));
     //get the admin 'from details form teh config
     $mail->setFrom('*****@*****.**', 've-no-reply');
     //set the subject and boy and send the mail
     $mail->setSubject(trim($subject));
     $mail->setBodyText(trim($body));
     $mail->send();
 }