/** * コンストラクタ * * @param Application $application */ public function __construct($application) { $this->controller_name = strtolower(substr(get_class($this), 0, -10)); $this->application = $application; $this->request = $application->getRequest(); $this->response = $application->getResponse(); $this->session = $application->getSession(); $this->db_manager = $application->getDbManager(); }
/** * @param $name * @param $extension * @param Application $app * @return string */ public static function setProperPath($name, $extension, Application $app) { $user_info = $app->getSession()->get('user_info'); $id = $user_info['id']; if (isset($id)) { $name = $id . date('_d_m_y_H_i_s_') . $name; } $chars = array(" ", "/", "\\", "<", ">", ":", "\"", "'", "|", "?", "*", "-"); return strtolower(str_replace($chars, "_", $name) . "." . $extension); }
/** * @param Application $app * @return bool */ public static function clearSession(Application $app) { if (!$app->getSession()->get('is_authenticated')) { return false; } $app->getSession()->set('is_authenticated', false); $app->getSession()->set('user_info', null); return true; }
/** * TemplateManager constructor. * @param Application $app */ function __construct(Application $app) { $this->template = new \Twig_Environment(new \Twig_Loader_Filesystem($app->getConfManager()->getPath()), array('debug' => $app->getConfManager()->getDevelopmentMode())); $this->template->addGlobal("session", $app->getSession()); }
<?php session_start(); //INCLUDE THE FILES NEEDED... require_once 'view/LoginView.php'; require_once 'view/DateTimeView.php'; require_once 'view/LayoutView.php'; require_once 'model/Login.php'; require_once 'controller/Application.php'; //MAKE SURE ERRORS ARE SHOWN... MIGHT WANT TO TURN THIS OFF ON A PUBLIC SERVER error_reporting(E_ALL); ini_set('display_errors', 'On'); //CREATES OBJECTS OF THE MODELS $loginModel = new Login(); //CREATE OBJECTS OF THE VIEWS $v = new LoginView($loginModel); $dtv = new DateTimeView(); $lv = new LayoutView(); //CREATE OBJECTS OF THE CONTROLLERS $appController = new Application($loginModel, $v); $appController->appRun(); $lv->render($appController->getSession(), $v, $dtv);