|
+-----------------------------------------------------------------------+
$Id: $
*/
/**
* Class for HTML page creation
*
* @package HTML
*
* @author Thomas Bruederli
* @license http://gnu.org GPL
* @todo See about improving performance (__get, __set, sprintf)
*/
class rcube_html_page
{
protected $_store = array();
/**
* Constructor
*
* @return rcube_html_page
* @uses self::reset()
*/
public function __construct()
{
$this->reset();
}
/**
* Link an external script file
*
* @param string File URL
* @param string Target position [head|foot]
*/
public function include_script($file, $position='head')
{
static $sa_files = array();
if (in_array($file, $sa_files)) {
return;
}
if (!is_array($this->script_files[$position])) {
$this->script_files[$position] = array();
}
$this->script_files[$position][] = $file;
}
/**
* Add inline javascript code
*
* @param string JS code snippet
* @param string Target position [head|head_top|foot]
*/
public function add_script($script, $position='head')
{
if (!isset($this->scripts[$position])) {
$this->scripts[$position] = "\n".rtrim($script);
} else {
$this->scripts[$position] .= "\n".rtrim($script);
}
}
/**
* Add HTML code to the page header
*/
public function add_header($str)
{
$this->header .= "\n".$str;
}
/**
* Add HTML code to the page footer
* To be added right befor
*/
public function add_footer($str)
{
$this->footer .= "\n".$str;
}
/**
* Setter for page title
*/
public function set_title($t)
{
$this->title = $t;
}
/**
* Setter for output charset.
* To be specified in a meta tag and sent as http-header
*/
public function set_charset($charset)
{
$this->charset = $charset;
}
/**
* Getter for output charset
*/
public function get_charset()
{
return $this->charset;
}
/**
* Reset all saved properties
*
* @return void
* @see self::__construct
* @uses self::$_store
*/
public function reset()
{
$this->scripts_path = '';
$this->script_files = array();
$this->external_scripts = array();
$this->scripts = array();
$this->charset = 'UTF-8';
// templates
$this->script_tag_file = "\n";
$this->script_tag = "\n";
$this->default_template = "\n