bintzwing/lib/View.php
El RIDO 05402ef304 remove version from doc blocs
- @version in file header level isn't used on code docs, it is intended
  for API versions at class or method level
- avoids needing to update all these files on version increment
- avoids needing to regenerate SRI hashes for privatebin.js through
  extra phpunit run
- simplifies VERSION_FILES list
- avoids having to filter above list during loop
- adds a few missing doc bloc headers
2024-05-28 21:03:22 +02:00

60 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
*/
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;
}
}