Esempio n. 1
1
 public function view()
 {
     $dao = DAO::getDAO('UserDAO');
     if (isset($this->params[0]) && trim($this->params[0]) == 'remove') {
         // ex: requesting: /user-list/delete/2
         $id = trim(sanitizeString($this->params[1]));
         $dao->removeById($id);
     } else {
         if (isset($this->params[0]) && trim($this->params[0]) == 'add') {
             $randNum = mt_rand(0, 99999);
             $newUser = new User(array('firstName' => 'First', 'lastName' => 'LastName', 'username' => "test{$randNum}", 'email' => "test{$randNum}@example.com", 'createTime' => dbDateTime()));
             // #TODO: implement UserDao.create($newUser) instead.
             if ($dao->countAll() > 30) {
                 // Demo mode: clean up if too many users
                 $dao->execute("DELETE FROM user");
                 $dao->execute("vacuum");
             }
             $dao->insertInto("firstName, lastName, username, email, createTime", $newUser->getFields());
         }
     }
     $users = $dao->getAll();
     $v = $this->smarty;
     $v->assign('title', 'User List');
     $v->assign('inc_content', v('user_list.html'));
     $v->assign('users', $users);
     $v->assign('totalUsers', $dao->countAll());
     $this->display($v, v('index.html'));
 }
Esempio n. 2
0
 public function view()
 {
     $dao = DAO::getDAO('SearchDAO');
     if (isset($this->params[0]) && trim($this->params[0]) == 'remove') {
         // ex: requesting: /search/delete/2
         $id = trim(sanitizeString($this->params[1]));
         $dao->removeById($id);
     } else {
         if (isset($this->params[0]) && trim($this->params[0]) == 'add') {
             $randNum = mt_rand(0, 99999);
             $newSearch = new Search(array('username' => "test{$randNum}", 'email' => "test{$randNum}@example.com", 'created' => dbDateTime()));
             // #TODO: implement UserDao.create($newUser) instead.
             if ($dao->countAll() > 30) {
                 // Demo mode: clean up if too many searchs
                 $dao->execute("DELETE FROM searchs");
                 $dao->execute("vacuum");
             }
             $dao->insertInto("username, email, created", $newSearch->getFields());
         }
     }
     $search = $dao->getAll();
     $v = $this->smarty;
     $v->assign('title', 'Search List');
     $v->assign('inc_content', v('search.html'));
     $v->assign('search', $search);
     $v->assign('totalSearch', $dao->countAll());
     $this->display($v, v('index.html'));
 }
Esempio n. 3
0
 public function view()
 {
     if ($this->isPosting()) {
         return $this->processPost();
     }
     $dao = DAO::getDAO('PostDAO');
     $v = $this->smarty;
     $v->assign('title', t('home_page_title'));
     $this->processAction($dao, $v);
     $this->display($v, v('index.html'));
 }
Esempio n. 4
0
 public function view()
 {
     $postId = $this->params[0];
     $dao = DAO::getDAO('PostDAO');
     $post = $dao->getById($postId);
     $postContent = html_entity_decode($post['content']);
     $postComments = BaseController::callController(BASEEXT . '/blog', 'BlogComment', array($postId));
     $v = $this->smarty;
     $v->setTemplateDir(BASEEXT . '/blog/view');
     $v->assign('post', $post);
     $v->assign('postContent', $postContent);
     $v->assign('postComments', $postComments);
     $this->display($v, 'blog_show.html');
 }
Esempio n. 5
0
 public function view()
 {
     $dao = DAO::getDAO('PostDAO');
     $posts = $dao->getAll();
     for ($i = 0, $cnt = count($posts); $i < $cnt; $i++) {
         $content = html_entity_decode($posts[$i]['content']);
         $content = str_replace("\n", '<br/>', $content);
         $posts[$i]['content'] = $content;
         $posts[$i]['seoTitle'] = seoTitle($posts[$i]['title']);
     }
     $v = $this->smarty;
     $v->setTemplateDir(BASEEXT . '/blog/view');
     $v->assign('posts', $posts);
     $this->display($v, 'blog_list.html');
 }
Esempio n. 6
0
 public function processPost()
 {
     parent::processPost();
     // #TODO: User submitted data. Save it to DB, email, etc.
     copyArray($_POST, $v, '*');
     $dao = DAO::getDAO('UserDAO');
     $newUser = new User(array('firstName' => 'First', 'lastName' => 'LastName', 'username' => $v['username'], 'email' => $v['email'], 'password' => $v['password'], 'createTime' => dbDateTime()));
     $ret = $dao->insertInto('firstName, lastName, username, email, password, createTime', $newUser->getFields());
     if ($ret[0] != '00000') {
         $err = "<span class='msgErr'>ERROR: {$ret['2']}</span>";
     }
     $v = $this->smarty;
     $v->assign('title', 'Thank you!');
     $v->assign('content', '<h2>Thank you!</h2><p>Thanks for your registration.</p><p>' . $err . '<p/><p><a href="/user-list">Check User List</a><p/>');
     $v->assign('inc_content', 'blank.html');
     $this->display($v, v('index.html'));
 }
Esempio n. 7
0
 public function view()
 {
     if ($this->isPosting()) {
         return $this->processPost();
     }
     $postId = $this->params[0];
     $dao = DAO::getDAO('PostDAO');
     $post = $dao->getById($postId);
     $postContent = $post['content'];
     $postContent = html_entity_decode($postContent);
     $postContent = Wiki2html::process($postContent);
     $v = $this->smarty;
     $v->setTemplateDir(BASEEXT . '/blog/view');
     $v->assign('post', $post);
     $v->assign('postContent', $postContent);
     $this->display($v, 'blog_edit.html');
 }
Esempio n. 8
0
 public function view()
 {
     if ($this->isValidating()) {
         return $this->validate(RT_JSON);
     }
     if ($this->isPosting()) {
         return $this->processPost();
     }
     $itemId = $this->params[0];
     $dao = DAO::getDAO('CommentDAO');
     $comments = $dao->getComments(1, $itemId);
     // prepare Comments for the View
     for ($i = 0, $cnt = count($comments); $i < $cnt; $i++) {
         $cmt = $comments[$i];
         $stEmail = trim($cmt['authorEmail']);
         if ($stEmail != '') {
             $comments[$i]['gravatarImg'] = '<img src="http://www.gravatar.com/avatar/' . md5($stEmail) . '?d=mm&s=64">';
         }
         $content = html_entity_decode($cmt['content']);
         $content = str_replace("\n", '<br/>', $content);
         $comments[$i]['content'] = $content;
         $sWeight = $cmt['weight'] . '';
         // calculate indent (for left-margin) from weight
         if (strpos($sWeight, '.') === false) {
             $comments[$i]['indent'] = 0;
         } else {
             $sWeight = substr($sWeight, strpos($sWeight, '.') + 1);
             $comments[$i]['indent'] = strlen($sWeight) / 2;
         }
     }
     $v = $this->smarty;
     $v->setTemplateDir(BASEEXT . '/blog/view');
     $v->assign('commentTotal', count($comments));
     $v->assign('comments', $comments);
     $v->assign('itemId', $itemId);
     $this->display($v, 'blog_comment.html');
 }
Esempio n. 9
0
 public static function init()
 {
     self::$cache = new CMemCache();
     // set your favourite cache here
     self::$dao = DAO::getDAO('UserDAO');
 }