eXtension Templates for PHP (XTP for short)

WebControlX class - form data, redirecting and similar

To facilitate access to form data, query string, and so on WebControlX class has protected property Request with few useful properties (Please note that property Request also acts as associative array itself, performing search for variable in the following order: QueryString, Form, Cookies):

In order to facilitate access to session class WebControlX has protected property Session which acts as case insensitive associative array with session data. This property has additional methods Clear (to clear all session data) and Remove (to remove single piece of data from session).

For manipulating user response class WebControlX has protected property Response with method Redirect (for redirecting user to some other location); this method causes current page execution to stop.

Simple example to illustrate usage of all this:

class Index extends WebControlX {
    public $Content;

    public function PreRender() {
        // if user is logged in then show him/her appropriate page,
        // otherwise ask for credentials
        if (self::$Session['user'])
            $this->Content = WebControlX::LoadControl('Controls/user_page.phpx');
        else
            $this->Content = WebControlX::LoadControl('Controls/login_page.phpx');

        // Button logout depressed - clear session data and transfer her/him home
        if (self::$Request['logout']) {
            self::$Session->Remove('user');
            self::$Response->Redirect('index.php');
        }
    }
}

« Previous
WebControlX - base class
Next »
Builtin controls