Source for file web_ctrl.class.php
Documentation is available at web_ctrl.class.php
* Contains class Web_Page
require_once(TANGRA_MAIN_DIR. 'web_site/web_context.class.php');
require_once(TANGRA_MAIN_DIR. 'web_site/web_site_config.class.php');
require_once(TANGRA_MAIN_DIR. 'web_site/redirect_composer_local.class.php');
* Web_Ctrl is base class for Web_Page and Ajax_Ctrl.
* All objects that will be ran by site object must inherit it.
* Holds variables that are added as transit
* @param Web_Context $context
* @param Web_Site_Config $config
public function _init(Web_Context $context, Web_Site_Config $config) {
* Place for user code for initialization.
* Must throw exception (TE_Page_Failed_To_Init) if init fails.
* On failure run() method will not be executed.
* Put in init() all code that:
* - checks for availability of resources
* - it is not essential for concrete page functionality
* Init method is useful for base page classes - if you have some functionality that
* is common for all (most) pages in your site - put it here and then inherit that base
* page class. Don't forget to call parent::init() if you overload it
protected function init() {
* @param Web_Context $context
* Returns reference to context
* Adds value key-value pair exports
public function export($key, $value) {
$this->_exports->add_pair($key, $value);
* Adds exports. This is bulk version of export()
* @param TPLE_exports $exports
* @param Web_Site_Config $config
private function set_config(Web_Site_Config $config) {
* Returns current web site configuration object.
* @return Web_Site_Config Current $WSC
if (ereg("^[a-z]{1}[a-z0-9_]{1,40}$", $var_name)) {
throw new Tangra_Exception('Transit variable '. $var_name. ' already exist.');
throw new Tangra_Exception('Invalid name for transit variable: '. $var_name);
throw new Tangra_Exception('Transit variable "'. $var_name. '" not exist.');
throw new Tangra_Exception('Transit variable "'. $var_name. '" not exist.');
if ($context->exists_in_get(Web_Page::TRANSIT_VARS_PREFIX. $var_name)) {
} elseif($context->exists_in_post(Web_Page::TRANSIT_VARS_PREFIX. $var_name)) {
foreach($_transit_vars_prepared as $var_name => $var_value) {
if ($var_value != NULL) {
$ret[Web_Page::TRANSIT_VARS_PREFIX. $var_name] = $var_value;
$param_pairs_all = array_merge($param_pairs, $_transit_vars_prepared);
$view->set_exported_value('_transit_vars', $_transit_vars_prepared, true);
* Here is the place to add your transit vars
* This method will be called by __constructor automatically. It is provided for convenience (i.e. otherwise you have to add transit vars in __constructor which means that you have to overload it, find the correct declaration, etc.)
* protected function init_transit_vars() {
* add_transit_var('category');
* Put your main page functionalty in run() (if not otherwise specified like for example for WED pages)
* Must return instance of Web_Page_View
abstract public function run();
|