コード例 #1
0
ファイル: Controller.php プロジェクト: fant0m/VAII
 public function view($name, $data = array())
 {
     $detect = $this->detectDay();
     $data['day'] = $detect[0];
     $data['name_day'] = $detect[1];
     $data['logged'] = Auth::check();
     $data['user'] = Auth::get();
     $view = new View($name, $data);
     return $view->render();
 }
コード例 #2
0
 public function index_action()
 {
     if (Routing::getInstance()->isMethod("GET")) {
         echo View::render();
         return true;
     }
     $userModel = new UserModel();
     if ($userModel->checkUserExist($_REQUEST['username'])) {
         $data['error'] = 'Username already used.';
         echo View::render($data);
         return false;
     }
     foreach ($_REQUEST as $key => $item) {
         if (empty($item)) {
             $data['error'] = 'All fields must be provided';
             echo View::render($data);
             return false;
         }
     }
     if (!$userModel->save($_REQUEST)) {
         $data['error'] = 'Problem with DB Query.';
         echo View::render($data);
         return false;
     }
     $userData = $userModel->getUserByUsernameAndPassword($_REQUEST['username'], $_REQUEST['password']);
     Security::doLogin($userData);
     return header("Location:" . Routing::getInstance()->getBaseUrl());
 }
コード例 #3
0
 /**
  * @param string $actionID
  * @param array $params
  *
  * @return \lib\Response
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  */
 public function runAction($actionID, array $params = [])
 {
     $action = 'action' . ucwords($actionID);
     if (!method_exists($this, $action)) {
         throw new \RuntimeException(sprintf('Method [%s] not exist in class [%s]', $action, get_class($this)));
     }
     $content = $this->{$action}($params);
     if (null !== $this->layout) {
         $meta = isset($params['meta']) ? $params['meta'] : [];
         $currentMenu = isset($params['menu']) ? $params['menu'] : null;
         $layout = new View($this->layout, $meta, $currentMenu);
         $content = $layout->render(['content' => $content]);
     }
     $response = new Response();
     $response->setContent($content);
     return $response;
 }
コード例 #4
0
ファイル: Auth.php プロジェクト: vendetta17/php-mvc-example
 public function login()
 {
     //        if(Security::isAuth()){
     //          return header("Location:".Routing::getInstance()->getBaseUrl());
     //        }
     //
     if (Routing::getInstance()->isMethod("GET")) {
         echo View::render();
         return true;
     }
     $userModel = new UserModel();
     $userData = $userModel->getUserByUsernameAndPassword($_REQUEST['username'], $_REQUEST['password']);
     if ($userData) {
         Security::doLogin($userData);
         if (isset($_REQUEST['remember_me'])) {
             Security::setRemember();
         }
         return header("Location:" . Routing::getInstance()->getBaseUrl());
     }
     return header("Location:" . Routing::getInstance()->getBaseUrl() . '/auth/login');
 }
コード例 #5
0
ファイル: index.php プロジェクト: Adam88Stanley/portfolio
if (!empty($this->args['errors'])) {
    ?>
                    	<ul class="error">
                    <?php 
    foreach ($this->args['errors'] as $error) {
        echo '<li>' . $error . '</li>';
    }
    ?>
                    	</ul>
                   <?php 
}
?>
                    <form method="post" action="<?php 
echo URL . 'registration';
?>
">
                    	<label>Login: <input type="text" name="login" required /></label>
                    	<label>Email: <input type="email" name="email" required /></label>
                        <label>Hasło: <input type="password" name="password" required /></label>
                        <label>Powtórz Hasło: <input type="password" name="password_2" required /></label>
                        <label><input type="checkbox" name="accept" value="1" required />Zapoznałem się z regulaminem sklepu i akceptuje jego treść.</label>
                        <input type="submit" class="btn" value="zarejestruj się"/>
                    </form>
                </div>
            </div>
        
        </div>

<?php 
View::footer();
コード例 #6
0
ファイル: News.php プロジェクト: vendetta17/php-mvc-example
 public function newsList()
 {
     $newsModel = new NewsModel();
     $data['list'] = $newsModel->getList();
     echo View::render($data);
 }
コード例 #7
0
ファイル: Index.php プロジェクト: skybardpf/bookkeeper.moscow
 public function actionAbout()
 {
     $view = new View('views/index/about');
     return $view->render();
 }
コード例 #8
0
 /**
  * @return string
  */
 public function actionList()
 {
     $view = new View('views/articles/list');
     return $view->render();
 }