Location: PHPKode > projects > PHP Web Toolkit > phpwebtk/view.class.php
<?php
/**
 * $Id: view.class.php,v 1.3 2004/11/25 06:05:38 bbisaillon Exp $
 * PHP Web Toolkit Version 1.0.3 Alpha
 *
 * @package phpwebtk
 */
/**
 * class View
 *
 * This class knows how to perform the operation(s) associated with
 * carrying out the request.
 *
 * @author Brian Bisaillon <hide@address.com>
 * @copyright Copyright (C) 2004 by Brian Bisaillon
 * @package phpwebtk
 * @subpackage http
 */
class View {
    // Private members
    private static $View;
    /**
     * function GetInstance
     *
     * This method instantiates a new object from this class; more
     * specifically, it's a singleton instance.
     *
     * @access public
     * @static
     * @return Controller object instance
     */
    public static function GetInstance() {
        $View = null;
        if (TRUE !== View::$View) {
            View::$View = new View();
        }
        return(View::$View);
    }
    /**
     * function Action
     *
     * This method defines the operation(s) to be executed by the
     * invoker.
     *
     * @access private
     */
    public function Action(Request $Request) {
        if (!empty($Request->HTTP_GET['page'])) {
            $Exception = null;
            try {
                if (file_exists(CLASS_PATH . $Request->HTTP_GET['page'] . 'view.class.php')) {
                    return($Request->HTTP_GET['page'] . 'view');
                } else {
                    throw new Exception("<h1>\n  Not Found\n</h1>\n<strong>Notice:</strong> Action(): The requested view does not exist. : phpwebtk.http.View.Exception <strong>");
                }
            } catch (Exception $Exception) {
                PException::Display($Exception);
            }
        } else {
            header('Location: http://' . $Request->HTTP_HOST . dirname($Request->REQUEST_URI) . '/index.php?action=view&page=sample');
        }
    }
}
?>
Return current item: PHP Web Toolkit