Source for file web_page_view.class.php
Documentation is available at web_page_view.class.php
// *** Tangra (Application Framework and Tools for PHP)
* Contains class Web_Page_View
require_once(TANGRA_MAIN_DIR. 'web_site/tple_exports.class.php');
require_once(TANGRA_MAIN_DIR. 'web_site/web_page/web_page.class.php');
require_once(TANGRA_MAIN_DIR. 'exceptions/te_key_not_exists.class.php');
* Holds additional CSSes that will be exported to template
* Holds additional Javascript files that will be exported to template
* @param Web_Page $page Page tha view is for
* @param string $name Name of the view
function __construct(Web_Page $page, $name = 'default') {
* @param TPLE_exports $exports
* @param TPLE_exports $exports
* Returns value of exported pair.
* If $forgiving is set to false will throw exception TE_Key_Not_Exists if such key does not exist.
* If $forgiving is set to true will return NULL if such key does not exist.
* @param boolean $forgiving
* @see Web_Page_View::set_exported_value()
$ret = $this->exports->get_pair_value($key, $forgiving);
* Changes the value of exported pair.
* If $create_if_not_exists is set to true this function will create export pair if it does not exist.
* If $create_if_not_exists is set to false exception will be thrown if pair does not exist.
* The purpose of methods set_exported_value and get_exported_value is to give chance to the view class to format values.
* For example, if Page object exported 'total' => 0.54, view object can use number_format() function to change
* the appearance of the value (first it will get value with $var = get_exported_value('some_key'), then will
* set_exported_value('some_key', number_format($var, 2, ','))).
* @param boolean $create_if_not_exists
* @throws TE_Key_Not_Exists
if ($this->exports->key_exists($key, true)) {
$this->exports->update_pair_value($key, $value);
if ($create_if_not_exist) {
$this->exports->add_pair($key, $value);
throw new TE_Key_Not_Exists('Key not exists: '. $key);
* @param unknown_type $http_header
public function add_css($path_to_css_file) {
public function add_js($path_to_js_file) {
* Adds value key-value pair exports
public function export($key, $value) {
$this->exports->add_pair($key, $value);
if (ereg("^[a-z]{1}[a-z0-9_]{1,100}$", $name)) {
throw new Tangra_Exception('Invalid view name ($page_name). Must conform ^[a-z]{1}[a-z0-9_]{1,100}$. Current value: '. $name);
|