Esempio n. 1
0
 public function loginAction()
 {
     // $this->template = 'pages/default';
     $this->status = 200;
     $this->title = _("Login");
     $errors = array();
     $user = \Kiki\Core::getUser();
     if ($user->id()) {
         \Kiki\Core::getFlashBag()->add('warning', _("You are already logged in."));
     }
     if (!count($errors) && $_POST) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $userId = $user->getIdByLogin($email, $password);
         if ($userId) {
             $user->load($userId);
             if (!$user->isVerified()) {
                 $errors[] = "Your e-mail address has not been verified yet.";
             } else {
                 \Kiki\Core::setUser($user);
                 \Kiki\Auth::setCookie($userId);
                 $this->status = 303;
                 $this->content = $this->getBaseUri();
                 return true;
             }
         } else {
             $errors[] = "Invalid email/password combination";
         }
     }
     $template = new \Kiki\Template('content/account-login');
     $template->assign('errors', $errors);
     $this->content = $template->fetch();
     return true;
 }
Esempio n. 2
0
 public function content($fullHTML = true)
 {
     // Log::debug( "begin template engine" );
     // TODO: don't always auto-include html framework, desired template
     // output could just as well be another format (json, xml, ...)
     $content = null;
     if ($fullHTML) {
         $content = "{include 'html'}" . PHP_EOL;
         $content .= "{include 'head'}" . PHP_EOL;
     }
     if (!$this->template) {
         $this->template = 'pages/default';
     }
     // Log::beginTimer( "Template::content ". $this->template );
     // Don't load a template when setContent has been used.
     $content .= $this->content ? $this->content : file_get_contents($this->file($this->template)) . PHP_EOL;
     if ($fullHTML) {
         $content .= "{include 'html-end'}";
     }
     $this->content = $content;
     // Log::debug( "content: ". $this->content );
     $this->data['kiki']['flashBag'] = array('notice' => \Kiki\Core::getFlashBag()->get('notice', false), 'warning' => \Kiki\Core::getFlashBag()->get('warning', false), 'error' => \Kiki\Core::getFlashBag()->get('error', false));
     $this->normalise($this->data);
     $this->preparse();
     $this->parse();
     if ($this->cleanup) {
         $this->cleanup();
     }
     // Log::debug( "done parsing" );
     // Log::debug( "content: ". $this->content );
     // Log::endTimer( "Template::content ". $this->template );
     if ($fullHTML) {
         \Kiki\Core::getFlashBag()->reset();
     }
     return $this->content;
 }
Esempio n. 3
0
            $album->setTitle($article->title());
            $album->save();
        }
    }
    if (isset($_POST['json'])) {
        $response = array();
        $response['formId'] = $_POST['formId'];
        $response['articleId'] = $article->id();
        if ($showAsPage) {
            $template = new Template('content/pages-single');
            $template->assign('page', $article->templateData());
        } else {
            $template = new Template('content/articles-single');
            $template->assign('article', $article->templateData());
        }
        $response['article'] = $template->fetch();
        $response['errors'] = $errors;
        header('Content-type: application/json');
        echo json_encode($response);
        exit;
    }
    if (!count($errors)) {
        \Kiki\Core::getFlashBag()->add('notice', sprintf("Article '%s' saved succesfully. (id: %d, cname: %s)", $article->title(), $article->id(), $article->cname()));
        Router::redirect($_SERVER['HTTP_REFERER'], 303);
        exit;
    }
    $template = Template::getInstance();
    $template->load('pages/admin');
    $template->assign('content', "fouten bij opslaan:<pre>" . print_r($errors, true) . "</pre>");
    echo $template->content();
}