Ejemplo n.º 1
0
 /**
  * [render description]
  * @method render
  * @return [type] [description]
  */
 public function render()
 {
     echo $this->twigHandler->render($this->twigTemplate, array("lists" => $this->getLists()));
     if (isPostback()) {
         var_dump($_POST);
     }
 }
Ejemplo n.º 2
0
 /**
  * /
  * @param  [type] $app [description]
  * @return [type]      [description]
  */
 public function route($app)
 {
     $app->view->setLayout('frontend');
     $app->get('/login', function () use($app) {
         $app->render('login');
     })->name('user_login_form');
     $app->post('/login', function () use($app) {
         $credentials = $app->handler->handlePostRequest();
         $app->doorman->login($credentials);
         if ($app->doorman->isUserAuthenticated()) {
             $app->redirect('admin_panel');
         } else {
             $app->redirect('user_login_form');
         }
     })->name('user_login');
     $app->get('/signup', function () use($app) {
         $app->render('signup');
     })->name('user_signup_form');
     $app->post('/signup', function () use($app) {
         $record = new Record($app->request->post());
         $token = User::query($app->db, 'signUp', $record);
         $sent = $app->handler->sendSignUpConfirmation($record, $token);
         $app->redirect('user_login_form');
     })->name('user_signup');
     $app->get('/signup/confirm/:token', function ($user_id, $token) use($app) {
         $result = User::query($app->db, 'validate', $token, 'activation');
         if ((int) $result->isSuccessful()) {
             $app->redirect('user_login');
         }
         $app->errorForbidden();
     })->name('confirm_signup')->conditions(array('token' => '\\w+'));
     $app->get('/password/forgot', function () use($app) {
         $app->render('password.forgot');
     })->name('forgot_password_form');
     $app->post('/password/forgot', function () use($app) {
         $record = new Record($app->request->post());
         $token = User::query($app->db, 'forgot', $record->get('user_id'));
         $sent = $app->handler->sendPasswordReset($record, $token);
         $app->redirect('user_login_form');
     })->name('forgot_password');
     $app->get('/password/new/:token', function ($token) use($app) {
         $result = User::query($app->db, 'validate', $token, 'forgot');
         if ($result->isSuccessful()) {
             $app->render('password.new');
             $app->stop();
         } else {
             $app->handler->errorForbidden();
         }
     })->name('new_password_form')->conditions(array('token' => '\\w+'));
     $app->post('/password/new', function () use($app) {
         $record = new Record($app->request->post());
         $result = User::query($app->db, 'resetPassword', $record->get('new_password'));
         $app->redirect($app->urlFor('user_login_form'));
     })->name('new_password');
     return $app;
 }
Ejemplo n.º 3
0
 /**
  * /
  * @param  [type] $app [description]
  * @return [type]      [description]
  */
 public function route($app)
 {
     /*
      * UPLOAD
      */
     $app->get('/upload', function () use($app) {
         $app->render('upload');
     });
     $app->post('/upload', function () use($app) {
         $validator = new \FileUpload\Validator\Simple(1024 * 1024 * 2, $app->allowedFileTypes);
         $pathresolver = new \FileUpload\PathResolver\Simple('/var/www/html/files/');
         $filesystem = new \FileUpload\FileSystem\Simple();
         $fileupload = new \FileUpload\FileUpload($_FILES['files'], $_SERVER);
         $fileupload->setPathResolver($pathresolver);
         $fileupload->setFileSystem($filesystem);
         $fileupload->addValidator($validator);
         list($files, $headers) = $fileupload->processAll();
         foreach ($headers as $header => $value) {
             $app->response->headers->set($header . ': ' . $value);
         }
         $body = json_encode(array('files' => $files));
         $app->response->setBody($body);
         $app->stop();
     });
     return $app;
 }
Ejemplo n.º 4
0
 /**
  * /
  * @param  [type] $status  [description]
  * @param  [type] $message [description]
  * @return [type]          [description]
  */
 public function error($status, $message)
 {
     $this->app->response->setStatus($status);
     $result = array('success' => false, 'message' => $message);
     if ($this->app->request->isAjax()) {
         $this->app->response->headers->set('Content-Type', 'application/json');
         $this->response->setBody($result->toJson());
     } else {
         $this->app->response->headers->set('Content-Type', 'text/html');
         $this->setDefaultViewResources();
         $this->app->view->setLayout('frontend');
         $this->app->render('error', $result);
     }
     $this->app->stop();
 }