Exemplo n.º 1
0
 /**
  * @throws HTTP_Exception_404
  *
  * edit book
  */
 public function action_editbook()
 {
     $id = $this->request->param('id');
     $id = Security::encode_php_tags(HTML::chars($id));
     $session = Session::instance();
     $data['page'] = $session->get("page", '');
     $book = new Model_Guestbook();
     $data = $book->getBook($id);
     if ($data) {
         if ($_POST) {
             $book->insBook($id);
             $data['msg'] = 'Запись добавлена';
             HTTP::redirect($_SERVER['HTTP_REFERER']);
         } else {
             $data['msg'] = 'Запись не добавлена';
         }
         $content = View::factory($this->itemBookView);
         $content->bind('data', $data);
         $this->template->content = $content;
     } else {
         throw new HTTP_Exception_404('File not found!');
     }
 }
Exemplo n.º 2
0
 /**
  * add book
  */
 public function action_addguest()
 {
     $data = array('msg' => '');
     $captcha = Captcha::instance('default');
     $session = Session::instance();
     $data['page'] = $session->get("page", '');
     if (isset($_POST['btnSubmit'])) {
         $book = new Model_Guestbook();
         if (Captcha::valid($_POST['captcha'])) {
             if ($book->insBook()) {
                 $data['msg'] = 'Запись добавлена';
             } else {
                 $data['msg'] = 'Запись не добавлена';
             }
         } else {
             $data['msg'] = 'Капча не верна';
         }
     }
     $content = View::factory('addguestview');
     $content->captcha = $captcha;
     $content->bind('data', $data);
     $this->template->content = $content;
 }
 public function fetchAll()
 {
     $entries = array();
     for ($i = 1; $i < 11; $i++) {
         $entry = new Model_Guestbook();
         $entry->setId($i)
               ->setEmail('*****@*****.**')
               ->setComment('testing')
               ->setCreated('2009-04-24 15:54:00')
               ->setMapper($this);
         $entries[] = $entry;
     }
     return $entries;
 }