7565be8ed5
current status: - renders without PHP errors & passes unit tests - displays pastes - responsive navbar - right-to-left support - auto dark mode with toggle to be done: - add "Dark Mode" to translation strings - get expiration and format selections to work - fix modals (password, QR-code, etc.) - replace glyphicons with Bootstrap Icons (no longer included) - test all the different settings and combinations - check tab alignment in HTML source
62 lines
1.3 KiB
PHP
62 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* PrivateBin
|
|
*
|
|
* a zero-knowledge paste bin
|
|
*
|
|
* @link https://github.com/PrivateBin/PrivateBin
|
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
|
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
|
* @version 1.7.1
|
|
*/
|
|
|
|
namespace PrivateBin;
|
|
|
|
use Exception;
|
|
|
|
/**
|
|
* View
|
|
*
|
|
* Displays the templates
|
|
*/
|
|
class View
|
|
{
|
|
/**
|
|
* 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)
|
|
{
|
|
$file = substr($template, 0, 10) === 'bootstrap-' ? 'bootstrap' : $template;
|
|
$path = PATH . 'tpl' . DIRECTORY_SEPARATOR . $file . '.php';
|
|
if (!file_exists($path)) {
|
|
throw new Exception('Template ' . $template . ' not found!', 80);
|
|
}
|
|
extract($this->_variables);
|
|
include $path;
|
|
}
|
|
}
|