. * * @package NanoMvc * @author Nicolas Joseph * @copyright 2008 Nicolas Joseph * @license http://www.opensource.org/licenses/gpl-3.0.html GPL v3 * @filesource */ $path = dirname (__FILE__); require_once ($path .'/view.php'); require_once ($path .'/helper/page.php'); abstract class Page { /** * @var View */ public $view; /** * @var Request */ protected $request; /** * @var Response */ protected $response; public function __construct (View $view) { $this->view = $view; $this->request = Request::get_instance (); $this->response = Response::get_instance (); } /** * Execute l'action demandee. * * @param string action : nom de l'action */ public function execute ($action) { try { $method = $action .'Action'; if (method_exists ($this, $method)) { $this->$method (); } else { throw new Exception ('Action inconnue : '. get_class ($this) .'::'. $action); } } catch (Exception $e) { if (method_exists ($this, 'errorAction')) { $this->errorAction ($e); } else { throw new Exception ($e); } } } }