2016-07-19 12:02:26 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* PrivateBin
|
|
|
|
*
|
|
|
|
* a zero-knowledge paste bin
|
|
|
|
*
|
|
|
|
* @link https://github.com/PrivateBin/PrivateBin
|
|
|
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
2022-11-18 04:36:33 +00:00
|
|
|
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
2023-12-04 20:07:17 +00:00
|
|
|
* @version 1.6.1
|
2016-07-19 12:02:26 +00:00
|
|
|
*/
|
2016-12-12 17:43:23 +00:00
|
|
|
|
2016-12-12 17:50:00 +00:00
|
|
|
namespace PrivateBin;
|
2016-08-11 13:05:43 +00:00
|
|
|
|
2016-07-21 15:09:48 +00:00
|
|
|
use Exception;
|
|
|
|
|
2016-07-19 12:02:26 +00:00
|
|
|
/**
|
2016-08-09 09:54:42 +00:00
|
|
|
* View
|
2016-07-19 12:02:26 +00:00
|
|
|
*
|
|
|
|
* Displays the templates
|
|
|
|
*/
|
2016-08-09 09:54:42 +00:00
|
|
|
class View
|
2016-07-19 12:02:26 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* variables available in the template
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
private $_variables = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* assign variables to be used inside of the template
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @param string $name
|
|
|
|
* @param mixed $value
|
|
|
|
*/
|
|
|
|
public function assign($name, $value)
|
|
|
|
{
|
|
|
|
$this->_variables[$name] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* render a template
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @param string $template
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function draw($template)
|
|
|
|
{
|
2017-01-08 09:02:07 +00:00
|
|
|
$file = substr($template, 0, 9) === 'bootstrap' ? 'bootstrap' : $template;
|
|
|
|
$path = PATH . 'tpl' . DIRECTORY_SEPARATOR . $file . '.php';
|
2016-07-26 06:19:35 +00:00
|
|
|
if (!file_exists($path)) {
|
2016-07-19 12:02:26 +00:00
|
|
|
throw new Exception('Template ' . $template . ' not found!', 80);
|
|
|
|
}
|
|
|
|
extract($this->_variables);
|
|
|
|
include $path;
|
|
|
|
}
|
|
|
|
}
|