public function actionLogin()
 {
     /** @noinspection PhpIncludeInspection */
     $form = new FormBuilder(include $this->container->kernel->getAppDir() . '/views/default/loginform.php', new LoginFormModel($this->container), 'POST');
     if ($post = $this->container->request->post('LoginFormModel')) {
         $form->setModelData($post);
         /** @noinspection PhpUndefinedMethodInspection */
         if ($form->validateModel() && $form->getModel()->logined()) {
             $this->redirect('/profile');
         }
     }
     $v = new View($this->container);
     $v->addParameter('form', $form);
     return $v;
 }
 public function actionCreate()
 {
     $blog = new Blog($this->container);
     /** @var array $blogData */
     if ($blogData = $this->container->request->post('Blog')) {
         $blog->name = $blogData['name'];
         $blog->content = $blogData['content'];
         if ($blog->save()) {
             $this->redirect('/blog/post/' . $blog->id);
         }
     }
     $v = new View($this->container);
     $v->addParameter('model', $blog);
     return $v;
 }
Example #3
0
 public function actionIndex()
 {
     $user = User::findByPk($this->container->user->getID(), $this->container);
     if (!$user) {
         $this->redirect('/logout');
     }
     /** @var array $setup */
     if ($setup = $this->container->request->post('Setup')) {
         if (!empty($setup['pass'])) {
             $user->pass = md5($setup['pass']);
         }
         if (!empty($setup['fio'])) {
             $user->fio = $setup['fio'];
         }
         $user->save();
     }
     $v = new View($this->container);
     $v->addParameter('user', $user);
     return $v;
 }
 public function actionIndex()
 {
     $v = new View($this->container);
     $v->addParameter('model', new User($this->container));
     return $v;
 }