refactoring away RainTPL and templating, resolves #36

This commit is contained in:
El RIDO
2016-07-19 14:02:26 +02:00
parent b94e019719
commit c5606a47fe
15 changed files with 1369 additions and 2237 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -423,10 +423,8 @@ class privatebin
setcookie('lang', $languageselection);
}
$page = new RainTPL;
$page::$path_replace = false;
// we escape it here because ENT_NOQUOTES can't be used in RainTPL templates
$page->assign('CIPHERDATA', htmlspecialchars($this->_data, ENT_NOQUOTES));
$page = new view;
$page->assign('CIPHERDATA', $this->_data);
$page->assign('ERROR', i18n::_($this->_error));
$page->assign('STATUS', i18n::_($this->_status));
$page->assign('VERSION', self::VERSION);

59
lib/view.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
/**
* PrivateBin
*
* a zero-knowledge paste bin
*
* @link https://github.com/PrivateBin/PrivateBin
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 0.22
*/
/**
* 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
* @return void
*/
public function assign($name, $value)
{
$this->_variables[$name] = $value;
}
/**
* render a template
*
* @access public
* @param string $template
* @throws Exception
* @return void
*/
public function draw($template)
{
$path = PATH . 'tpl' . DIRECTORY_SEPARATOR . $template . '.php';
if (!file_exists($path))
{
throw new Exception('Template ' . $template . ' not found!', 80);
}
extract($this->_variables);
include $path;
}
}