modules[\'localize\']->string';
/**
* The name of the function phrases are sprintf() parsed with
* @var string
*/
var $langconst = 'sprintf';
/**
* Array of pre-compiled templates that are stored to decrease server load
* @var array
*/
var $cache = array();
/**
* A list of the number of times each template has been used
* @var array
*/
var $usage = array();
/**
* A list of templates that weren't cached, but are still used
* @var array
*/
var $uncached = array();
/**
* Whether or not the page has been flush()'d already
* @var bool
*/
var $doneflush = false;
/**
* Constructor
*/
function __construct(&$registry)
{
$this->registry =& $registry;
}
/**
* (PHP 4) Constructor
*/
function Template(&$registry)
{
$this->__construct($registry);
}
/**
* Takes an array of template names, loads them, and then stores
* a parsed version for optimum speed.
*
* @param array List of template names to be cached
*/
function cache($namearray)
{
if (sizeof($this->cache) > 0)
{
trigger_error('You cannot cache templates more than once per initialization', E_USER_WARNING);
}
else
{
$templates = $this->registry->modules['db_mysql']->query("SELECT * FROM " . $this->tablename . " WHERE " . $this->namecolumn . " IN ('" . implode("', '", $namearray) . "')" . ($this->extrawhere ? $this->extrawhere : ''));
while ($template = $this->registry->modules['db_mysql']->fetch_array($templates))
{
$this->cache[ $template[ $this->namecolumn ] ] = $this->_parse($template[ $this->datacolumn ]);
$this->usage["$name"] = 0;
}
}
}
/**
* Loads a template from the cache or the _load function and
* stores the parsed version of it
*
* @param string The name of the template
*
* @return string A parsed and loaded template
*/
function fetch($name)
{
if (isset($this->cache["$name"]))
{
$template = $this->cache["$name"];
}
else
{
$this->uncached[] = $name;
$this->registry->debug("Manually loading template `$name`");
$template = $this->_load($name);
$template = $this->_parse($template);
}
if (!isset($this->usage["$name"]))
{
$this->usage["$name"] = 0;
}
$this->usage["$name"]++;
return $template;
}
/**
* Output a template fully compiled to the browser
*
* @param string Compiled and ready template
*/
function flush($template)
{
ob_start();
if (empty($template))
{
trigger_error('There was no output to print', E_USER_ERROR);
exit;
}
if ($this->registry->debug AND isset($_GET['query']))
{
if (is_array($this->registry->modules['db_mysql']->history))
{
echo '
';
}
exit;
}
if ($this->doneflush)
{
trigger_error('A template has already been sent to the output buffer', E_USER_ERROR);
exit;
}
if ($this->registry->debug)
{
// --- START
$debug = "\n