/** * This is the REAL serve function, and should only be invoked INTERNALLY from Fwork::serve. */ protected function _serve($path) { // load the controller $controllerprovider = $path[0]; $controllername = ucfirst($path[0]) . "Controller"; // send the name of the controller to savant $this->savant->controller = $controllerprovider; if (!file_exists(dirname(__FILE__) . "/../controllers/" . $controllerprovider . ".php")) { $this->error("Cannot find controller file"); return; } else { require_once dirname(__FILE__) . "/../controllers/" . $controllerprovider . ".php"; } if (!class_exists($controllername)) { $this->error("Cannot find controller class"); return; } if (!is_subclass_of($controllername, "Controller")) { $this->error("Controller class does not extend Controller"); return; } $controller = new $controllername(); $controller->session = $this->savant->session = SesMan::getInstance(); $action = isset($path[1]) && !empty($path[1]) ? $path[1] : "index"; if (!method_exists($controller, $action) || $action[0] == "_") { $this->error("Controller does not provide a behaviour for the provided action"); return; } $controller->{$action}(isset($path[2]) ? array_slice($path, 2) : array()); if ($controller->view !== null) { // two formats possible for view: array(controller, action) // or just action (if same controller) if (is_array($controller->view)) { $controllerprovider = $controller->view[0]; $action = $controller->view[1]; } elseif (!empty($controller->view)) { $action = $controller->view; } // load the view if (!file_exists(dirname(__FILE__) . "/../themes/" . "fraculous" . "/" . $controllerprovider . "/" . $action . ".php")) { $this->error("View not found"); return; } else { $vars = $controller->vars; $vars["pagename"] = isset($vars["pagename"]) ? $vars["pagename"] : ucfirst($controllerprovider); $this->savant->assign($vars); $this->savant->view = $controllerprovider . "/" . $action . ".php"; // execute the hook if there is one if (file_exists(dirname(__FILE__) . "/../hooks/predisplay.php")) { require_once dirname(__FILE__) . "/../hooks/predisplay.php"; } $this->savant->display("layout.php"); } } }
public function logout($args) { $session = SesMan::getInstance(); $session->flush(); $this->view = null; Utils::redirect('staff/login'); }
<?php /* * Frac * Copyright (c) 2009 Frac Development Team * * See COPYING for license conditions. */ // commands to run after Fwork::__destruct is executed. Full access to the Fwork object is provided in its state at the end of Fwork::__destruct. $session = SesMan::getInstance(); unset($session);
/** * Keikaku doori message. * * @param $message Message to display. */ public static function success($message, $view = null) { $session = SesMan::getInstance(); $session['flash'] = array('type' => 'success', 'message' => $message); }