public function manageAction($id = false)
 {
     $this->permission('manage');
     $userInfo = $this->permissions->getUserInformation();
     if ($id) {
         $model = new \modules\blog\models\Blog_posts('edit');
         $model->blog_post_id = $id;
     } else {
         $model = new \modules\blog\models\Blog_posts('add');
         $model->created = date("Y-m-d H:i:s");
         $model->user_id = $userInfo->user_id;
         $model->language_id = $this->language->getDefaultLanguage();
     }
     $model->set('title', $this->Input->post('title'));
     $model->set('seo', $this->Input->post('seo'));
     $model->set('short_content', $this->Input->post('short_content'));
     $model->set('content', $this->Input->post('content'));
     $model->set('blog_category_id', $this->Input->post('blog_category_id'));
     $model->set('language_id', $this->Input->post('language_id'));
     $blog_category = Form_helper::queryToDropdown('blog_categories', 'blog_category_id', 'title');
     if ($model->save()) {
         Uri_helper::redirect("management/blog_posts");
     } else {
         return $this->render('blog_posts/manage', ['item' => $id ? $model->get() : null, 'blog_category' => $blog_category]);
     }
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     $this->language->load('home');
     //      --------start sliders---------
     $this->language->load('sliders');
     $slides = new \modules\sliders\models\Slides();
     $slides->_select = 'slide_id, title, caption, url, image';
     $slides->where('slider_id', '1');
     //      -----------end sliders--------------
     //      ----------start news home-----------
     $this->Language->load('blog_posts');
     $posts = new \modules\blog\models\Blog_posts();
     $posts->_select = 'blog_post_id,title,image,short_content,seo,created';
     $posts->_limit = 4;
     //        $posts->_orderby = 4;
     $post = $posts->get();
     //      ----------end news home------------
     //      -------start testonmials home------
     $this->Language->load('testimonials');
     $testimonials = new \modules\testimonials\models\Testimonials();
     $testimonials->_select = 'testimonial_id,client_name,client_position,message,image';
     $testimonial = $testimonials->get();
     //      --------end testonmials home-------
     //      ----------start clients home-----------
     $this->Language->load('clients');
     $clients = new \modules\clients\models\Clients();
     $clients->_select = 'client_id, name, image';
     $client = $clients->get();
     //      ----------end clients home------------
     $this->Language->load('portfolio_categories');
     $portfolio_categories = new \modules\portfolio\models\Portfolio_categories();
     $portfolio_categories->_select = 'portfolio_category_id, title';
     $portfolio_categories = $portfolio_categories->get();
     $recent_portfolio = $this->Database->query("SELECT portfolio.*" . "FROM `portfolio` " . "ORDER BY portfolio.portfolio_id DESC LIMIT 4")->result();
     $recent_portfolio_ = $this->Database->query("SELECT portfolio.*" . "FROM `portfolio` " . "ORDER BY portfolio.portfolio_id ASC LIMIT 4")->result();
     return $this->render('home', ['slides' => $slides->get(), 'post' => $post, 'testimonial' => $testimonial, 'client' => $client, 'recent_portfolio' => $recent_portfolio, 'recent_portfolio_' => $recent_portfolio_, 'portfolio_category' => $portfolio_categories]);
 }
Exemplo n.º 3
0
 public function postAction($seo = null)
 {
     if (!$seo) {
         return Brightery::error404();
     }
     $userInfo = $this->permissions->getUserInformation();
     $model = new \modules\blog\models\Blog_posts();
     $categories = new \modules\blog\models\Blog_categories();
     $comments = new \modules\blog\models\Blog_post_comments($userInfo ? 'registered' : 'unregistered');
     $comments->_joins = ['users' => ['users.user_id = blog_post_comments.user_id', 'left']];
     $model->seo = $seo;
     $item = $model->get();
     if (!$item) {
         return Brightery::error404();
     }
     if ($userInfo) {
         $comments->set(['name' => $userInfo->fullname, 'email' => $userInfo->email, 'user_id' => $userInfo->user_id, 'comment' => $this->input->post('comment'), 'datetime' => date('Y-m-d H:i:s')]);
     } else {
         $comments->set(['name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'comment' => $this->input->post('comment'), 'datetime' => date('Y-m-d H:i:s')]);
     }
     $comments->blog_post_id = $item->blog_post_id;
     $comments->save();
     return $this->render('blog/post', ['item' => $item, 'categories' => $categories->get(), 'comments' => $comments->get(), 'comments_no' => $comments->get(1), 'user' => $userInfo]);
 }