Example #1
0
 /**
  * Inserts or updates a box model in the database.
  *
  * @param BoxModel $box
  */
 public function save(BoxModel $box)
 {
     if ($box->getId()) {
         if ($this->getBoxByIdLocale($box->getId(), $box->getLocale())) {
             $this->db()->update('boxes_content')->values(array('title' => $box->getTitle(), 'content' => $box->getContent()))->where(array('box_id' => $box->getId(), 'locale' => $box->getLocale()))->execute();
         } else {
             $this->db()->insert('boxes_content')->values(array('box_id' => $box->getId(), 'title' => $box->getTitle(), 'content' => $box->getContent(), 'locale' => $box->getLocale()))->execute();
         }
     } else {
         $date = new \Ilch\Date();
         $boxId = $this->db()->insert('boxes')->values(array('date_created' => $date->toDb()))->execute();
         $this->db()->insert('boxes_content')->values(array('box_id' => $boxId, 'title' => $box->getTitle(), 'content' => $box->getContent(), 'locale' => $box->getLocale()))->execute();
     }
 }
Example #2
0
 /**
  * Inserts or updates a page model in the database.
  *
  * @param PageModel $page
  */
 public function save(PageModel $page)
 {
     if ($page->getId()) {
         if ($this->getPageByIdLocale($page->getId(), $page->getLocale())) {
             $this->db()->update('pages_content')->values(array('title' => $page->getTitle(), 'description' => $page->getDescription(), 'content' => $page->getContent(), 'perma' => $page->getPerma()))->where(array('page_id' => $page->getId(), 'locale' => $page->getLocale()))->execute();
         } else {
             $this->db()->insert('pages_content')->values(array('page_id' => $page->getId(), 'description' => $page->getDescription(), 'title' => $page->getTitle(), 'content' => $page->getContent(), 'perma' => $page->getPerma(), 'locale' => $page->getLocale()))->execute();
         }
     } else {
         $date = new \Ilch\Date();
         $pageId = $this->db()->insert('pages')->values(array('date_created' => $date->toDb()))->execute();
         $this->db()->insert('pages_content')->values(array('page_id' => $pageId, 'description' => $page->getDescription(), 'title' => $page->getTitle(), 'content' => $page->getContent(), 'perma' => $page->getPerma(), 'locale' => $page->getLocale()))->execute();
     }
 }
Example #3
0
 /**
  * Inserts or updates a article model in the database.
  *
  * @param ArticleModel $article
  */
 public function save(ArticleModel $article)
 {
     if ($article->getId()) {
         if ($this->getArticleByIdLocale($article->getId(), $article->getLocale())) {
             $this->db()->update('articles')->values(array('cat_id' => $article->getCatId()))->where(array('id' => $article->getId()))->execute();
             $this->db()->update('articles_content')->values(array('title' => $article->getTitle(), 'description' => $article->getDescription(), 'content' => $article->getContent(), 'perma' => $article->getPerma(), 'article_img' => $article->getArticleImage(), 'article_img_source' => $article->getArticleImageSource()))->where(array('article_id' => $article->getId(), 'locale' => $article->getLocale()))->execute();
         } else {
             $this->db()->insert('articles_content')->values(array('article_id' => $article->getId(), 'author_id' => $article->getAuthorId(), 'description' => $article->getDescription(), 'title' => $article->getTitle(), 'content' => $article->getContent(), 'perma' => $article->getPerma(), 'locale' => $article->getLocale(), 'article_img' => $article->getArticleImage(), 'article_img_source' => $article->getArticleImageSource()))->execute();
         }
     } else {
         $date = new \Ilch\Date();
         $articleId = $this->db()->insert('articles')->values(array('cat_id' => $article->getCatId(), 'date_created' => $date->toDb()))->execute();
         $this->db()->insert('articles_content')->values(array('article_id' => $articleId, 'author_id' => $article->getAuthorId(), 'description' => $article->getDescription(), 'title' => $article->getTitle(), 'content' => $article->getContent(), 'perma' => $article->getPerma(), 'locale' => $article->getLocale(), 'article_img' => $article->getArticleImage(), 'article_img_source' => $article->getArticleImageSource()))->execute();
     }
 }
Example #4
0
 /**
  * Tests if the class returns the DateTime object with the correct timezone
  * if the db datetime was returned before. The usage of the database timezone
  * string should not manipulate the return of the local date.
  */
 public function testGetDateTimeAfterToDb()
 {
     $ilchDate = new \Ilch\Date('2013-09-24 22:32:46');
     $ilchDate->toDb();
     $this->assertEquals('2013-09-24 22:32:46', $ilchDate->format('Y-m-d H:i:s'), 'A time with the wrong timezone was returned.');
 }
Example #5
0
 /**
  * Insert shoutbox model.
  *
  * @param ShoutboxModel $shoutbox
  */
 public function save(ShoutboxModel $shoutbox)
 {
     $date = new \Ilch\Date();
     $this->db()->insert('shoutbox')->values(array('user_id' => $shoutbox->getUid(), 'name' => $shoutbox->getName(), 'textarea' => $shoutbox->getTextarea(), 'time' => $date->toDb()))->execute();
 }