コード例 #1
0
 public function initContent()
 {
     parent::initContent();
     Hook::exec('actionsbsingle', array('id_post' => Tools::getValue('id_post')));
     $blogcomment = new Blogcomment();
     $SmartBlogPost = new SmartBlogPost();
     $BlogCategory = new BlogCategory();
     $id_post = Tools::getValue('id_post');
     $id_lang = $this->context->language->id;
     $id_lang_defaut = Configuration::get('PS_LANG_DEFAULT');
     $post = $SmartBlogPost->getPost($id_post, $id_lang);
     $tags = $SmartBlogPost->getProductTags($id_post);
     $comment = $blogcomment->getComment($id_post);
     $countcomment = $blogcomment->getToltalComment($id_post);
     $id_cate = $post['id_category'];
     $title_category = $BlogCategory->getNameCategory($id_cate);
     // die(print_r($post));
     // die(_PS_MODULE_DIR_.'smartblog/images/'. $post['id_author'] . '/' . $post['id_post'] . '.jpg');
     if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $post['id_author'] . '/' . $post['id_post'] . '.jpg')) {
         $post_img = $post['id_post'];
     } else {
         $post_img = 'no';
     }
     SmartBlogPost::postViewed($id_post);
     $this->context->smarty->assign(array('post' => $post, 'comments' => $comment, 'tags' => $tags, 'title_category' => $title_category[0]['meta_title'], 'cat_link_rewrite' => $title_category[0]['link_rewrite'], 'meta_title' => $post['meta_title'], 'post_active' => $post['active'], 'content' => htmlspecialchars_decode($post['content']), 'id_post' => $post['id_post'], 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'created' => $post['created'], 'firstname' => $post['firstname'], 'lastname' => $post['lastname'], 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'comment_status' => $post['comment_status'], 'countcomment' => $countcomment, 'post_img' => $post_img, '_report' => $this->_report, 'id_category' => $post['id_category'], 'id_author' => $post['id_author'], 'youtube' => $this->convertYoutube($post['youtube'])));
     $this->context->smarty->assign('HOOK_SMART_BLOG_POST_FOOTER', Hook::exec('displaySmartAfterPost'));
     $this->setTemplate('posts.tpl');
 }
コード例 #2
0
ファイル: tagpost.php プロジェクト: johnulist/smartblog
 public function initContent()
 {
     parent::initContent();
     $blogcomment = new Blogcomment();
     $keyword = urldecode(pSQL(Tools::getValue('tag')));
     $id_lang = (int) $this->context->language->id;
     $title_category = '';
     $posts_per_page = Configuration::get('smartpostperpage');
     $limit_start = 0;
     $limit = $posts_per_page;
     if ((bool) Tools::getValue('page')) {
         $c = (int) Tools::getValue('page');
         $limit_start = $posts_per_page * ($c - 1);
     }
     $smartblogurlpattern = (int) Configuration::get('smartblogurlpattern');
     //now we will check whihc option we need to url rewrite
     switch ($smartblogurlpattern) {
         case 1:
             $SmartBlog = new smartblog();
             $keyword = urldecode(Tools::getValue('tag'));
             break;
         case 2:
             $keyword = urldecode(Tools::getValue('tag'));
             break;
         case 3:
             $keyword = urldecode(Tools::getValue('tag'));
             break;
         default:
             $keyword = urldecode(Tools::getValue('tag'));
     }
     $id_lang = (int) $this->context->language->id;
     $result = SmartBlogPost::tagsPost($keyword, $id_lang);
     $total = count($result);
     $totalpages = ceil($total / $posts_per_page);
     $i = 0;
     $to = array();
     if (!empty($result)) {
         foreach ($result as $item) {
             $to[$i] = $blogcomment->getToltalComment($item['id_post']);
             $i++;
         }
         $j = 0;
         foreach ($to as $item) {
             if ($item == '') {
                 $result[$j]['totalcomment'] = 0;
             } else {
                 $result[$j]['totalcomment'] = $item;
             }
             $j++;
         }
     }
     $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
     $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
     $smartbloglink = new SmartBlogLink($protocol_link, $protocol_content);
     $this->context->smarty->assign(array('keyword' => $keyword, 'postcategory' => $result, 'title_category' => 'ok working', 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartshowviewed' => Configuration::get('smartshowviewed'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'totalpages' => $totalpages, 'smartbloglink' => $smartbloglink));
     $template_name = 'tagresult.tpl';
     $this->setTemplate($template_name);
 }
コード例 #3
0
 public function initContent()
 {
     parent::initContent();
     $rer = SmartBlogPost::tagsPost('asd');
     $blogcomment = new Blogcomment();
     $result = '';
     $keyword = Tools::getValue('smartsearch');
     Hook::exec('actionsbsearch', array('keyword' => Tools::getValue('smartsearch')));
     $id_lang = (int) $this->context->language->id;
     $title_category = '';
     $posts_per_page = Configuration::get('smartpostperpage');
     $limit_start = 0;
     $limit = $posts_per_page;
     if ((bool) Tools::getValue('page')) {
         $c = (int) Tools::getValue('page');
         $limit_start = $posts_per_page * ($c - 1);
     }
     $keyword = Tools::getValue('smartsearch');
     $id_lang = (int) $this->context->language->id;
     $result = SmartBlogPost::SmartBlogSearchPost($keyword, $id_lang, $limit_start, $limit);
     $total = SmartBlogPost::SmartBlogSearchPostCount($keyword, $id_lang);
     $totalpages = ceil($total / $posts_per_page);
     $i = 0;
     if (!empty($result)) {
         foreach ($result as $item) {
             $to[$i] = $blogcomment->getToltalComment($item['id_post']);
             $i++;
         }
         $j = 0;
         foreach ($to as $item) {
             if ($item == '') {
                 $result[$j]['totalcomment'] = 0;
             } else {
                 $result[$j]['totalcomment'] = $item;
             }
             $j++;
         }
     }
     $this->context->smarty->assign(array('postcategory' => $result, 'title_category' => $title_category, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartshowviewed' => Configuration::get('smartshowviewed'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'post_per_page' => $posts_per_page, 'smartsearch' => Tools::getValue('smartsearch'), 'pagenums' => $totalpages - 1, 'totalpages' => $totalpages));
     $template_name = 'searchresult.tpl';
     $this->setTemplate($template_name);
 }
コード例 #4
0
ファイル: archive.php プロジェクト: johnulist/smartblog
 public function initContent()
 {
     parent::initContent();
     $blogcomment = new Blogcomment();
     $year = Tools::getvalue('year');
     $month = Tools::getvalue('month');
     $title_category = '';
     $posts_per_page = Configuration::get('smartpostperpage');
     $limit_start = 0;
     $limit = $posts_per_page;
     if ((bool) Tools::getValue('page')) {
         $c = (int) Tools::getValue('page');
         $limit_start = $posts_per_page * ($c - 1);
     }
     $result = SmartBlogPost::getArchiveResult($month, $year, $limit_start, $limit);
     $total = count($result);
     $totalpages = ceil($total / $posts_per_page);
     $i = 0;
     $to = array();
     if (!empty($result)) {
         foreach ($result as $item) {
             $to[$i] = $blogcomment->getToltalComment($item['id_post']);
             $i++;
         }
         $j = 0;
         foreach ($to as $item) {
             if ($item == '') {
                 $result[$j]['totalcomment'] = 0;
             } else {
                 $result[$j]['totalcomment'] = $item;
             }
             $j++;
         }
     }
     $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
     $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
     $smartbloglink = new SmartBlogLink($protocol_link, $protocol_content);
     $this->context->smarty->assign(array('smartbloglink' => $smartbloglink, 'postcategory' => $result, 'title_category' => $title_category, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartshowviewed' => Configuration::get('smartshowviewed'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'totalpages' => $totalpages));
     $template_name = 'archivecategory.tpl';
     $this->setTemplate($template_name);
 }
コード例 #5
0
ファイル: details.php プロジェクト: johnulist/smartblog
 /**
  * Sets default medias for this controller
  */
 public function setMedia()
 {
     parent::setMedia();
     if (!$this->useMobileTheme()) {
         //TODO : check why cluetip css is include without js file
         $this->addCSS(array(_THEME_CSS_DIR_ . 'product_list.css' => 'all'));
     }
 }
コード例 #6
0
ファイル: category.php プロジェクト: johnulist/smartblog
 public function initContent()
 {
     $category_status = '';
     $totalpages = '';
     $cat_image = 'no';
     $categoryinfo = '';
     $title_category = '';
     $cat_link_rewrite = '';
     $blogcomment = new Blogcomment();
     $SmartBlogPost = new SmartBlogPost();
     $BlogCategory = new BlogCategory();
     $BlogPostCategory = new BlogPostCategory();
     $smartblogurlpattern = (int) Configuration::get('smartblogurlpattern');
     //now we will check whihc option we need to url rewrite
     switch ($smartblogurlpattern) {
         case 1:
             $SmartBlog = new smartblog();
             $slug = Tools::getValue('slug');
             $id_category = $SmartBlog->categoryslug2id($slug);
             break;
         case 2:
             $SmartBlog = new smartblog();
             $id_category = Tools::getValue('id_category');
             //                if($id_category==''){
             //                   $id_category = $SmartBlog->categoryslug2id($slug);
             //                }
             break;
         default:
             $id_category = Tools::getValue('id_category');
     }
     //$categoryinfo = $BlogCategory->getNameCategory($id_category);
     $posts_per_page = Configuration::get('smartpostperpage');
     $limit_start = 0;
     $limit = $posts_per_page;
     if (!$id_category) {
         $total = (int) $SmartBlogPost->getToltal($this->context->language->id);
     } else {
         $total = (int) $SmartBlogPost->getToltalByCategory($this->context->language->id, $id_category);
         Hook::exec('actionsbcat', array('id_category' => pSQL(Tools::getvalue('id_category'))));
     }
     if ($total != '' || $total != 0) {
         $totalpages = ceil($total / $posts_per_page);
     }
     if ((bool) Tools::getValue('page')) {
         $c = (int) Tools::getValue('page');
         $limit_start = $posts_per_page * ($c - 1);
     }
     if (!$id_category) {
         $allNews = $SmartBlogPost->getAllPost($this->context->language->id, $limit_start, $limit);
     } else {
         if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/category/' . $id_category . '.jpg')) {
             $cat_image = $id_category;
         } else {
             $cat_image = 'no';
         }
         $categoryinfo = $BlogCategory->getNameCategory($id_category);
         $title_category = $categoryinfo[0]['name'];
         $category_status = $categoryinfo[0]['active'];
         $cat_link_rewrite = $categoryinfo[0]['link_rewrite'];
         if ($category_status == 1) {
             $allNews = $BlogPostCategory->getToltalByCategory($this->context->language->id, $id_category, $limit_start, $limit);
         } elseif ($category_status == 0) {
             $allNews = '';
         }
     }
     $i = 0;
     $to = array();
     if (!empty($allNews)) {
         foreach ($allNews as $item) {
             $to[$i] = $blogcomment->getToltalComment($item['id_post']);
             $i++;
             if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $item['id_post'] . '.jpg')) {
                 $item['post_img'] = $item['id_post'] . '.jpg';
             } else {
                 $item['post_img'] = 'no';
             }
         }
         $j = 0;
         foreach ($to as $item) {
             if ($item == '') {
                 $allNews[$j]['totalcomment'] = 0;
             } else {
                 $allNews[$j]['totalcomment'] = $item;
             }
             $j++;
         }
     }
     $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
     $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
     $smartbloglink = new SmartBlogLink($protocol_link, $protocol_content);
     $i = 0;
     foreach ($allNews as $post) {
         $allNews[$i]['created'] = Smartblog::displayDate($post['created']);
         $i++;
     }
     parent::initContent();
     $this->canonicalRedirection();
     $this->context->smarty->assign(array('smartbloglink' => $smartbloglink, 'postcategory' => $allNews, 'category_status' => $category_status, 'title_category' => $title_category, 'cat_link_rewrite' => $cat_link_rewrite, 'id_category' => $id_category, 'cat_image' => $cat_image, 'categoryinfo' => $categoryinfo, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartdisablecatimg' => Configuration::get('smartdisablecatimg'), 'smartshowviewed' => Configuration::get('smartshowviewed'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'totalpages' => $totalpages));
     $template_name = 'postcategory.tpl';
     $this->setTemplate($template_name);
 }
コード例 #7
0
ファイル: category.php プロジェクト: abdoumej/libsamy
 public function initContent()
 {
     parent::initContent();
     $category_status = '';
     $totalpages = '';
     $cat_image = 'no';
     $categoryinfo = '';
     $title_category = '';
     $cat_link_rewrite = '';
     $blogcomment = new Blogcomment();
     $SmartBlogPost = new SmartBlogPost();
     $BlogCategory = new BlogCategory();
     $BlogPostCategory = new BlogPostCategory();
     $id_category = Tools::getvalue('id_category');
     $posts_per_page = Configuration::get('smartpostperpage');
     $limit_start = 0;
     $limit = $posts_per_page;
     if (!($id_category = Tools::getvalue('id_category'))) {
         $total = $SmartBlogPost->getToltal($this->context->language->id);
     } else {
         $total = $SmartBlogPost->getToltalByCategory($this->context->language->id, $id_category);
         Hook::exec('actionsbcat', array('id_category' => Tools::getvalue('id_category')));
     }
     if ($total != '' || $total != 0) {
         $totalpages = ceil($total / $posts_per_page);
     }
     if ((bool) Tools::getValue('page')) {
         $c = Tools::getValue('page');
         $limit_start = $posts_per_page * ($c - 1);
     }
     if (!($id_category = Tools::getvalue('id_category'))) {
         $allNews = $SmartBlogPost->getAllPost($this->context->language->id, $limit_start, $limit);
     } else {
         if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/category/' . $id_category . '.jpg')) {
             $cat_image = $id_category;
         } else {
             $cat_image = 'no';
         }
         $categoryinfo = $BlogCategory->getNameCategory($id_category);
         $title_category = $categoryinfo[0]['meta_title'];
         $category_status = $categoryinfo[0]['active'];
         $cat_link_rewrite = $categoryinfo[0]['link_rewrite'];
         if ($category_status == 1) {
             $allNews = $BlogPostCategory->getToltalByCategory($this->context->language->id, $id_category, $limit_start, $limit);
         } elseif ($category_status == 0) {
             $allNews = '';
         }
     }
     $i = 0;
     if (!empty($allNews)) {
         foreach ($allNews as $item) {
             $to[$i] = $blogcomment->getToltalComment($item['id_post']);
             $i++;
         }
         $j = 0;
         foreach ($to as $item) {
             if ($item == '') {
                 $allNews[$j]['totalcomment'] = 0;
             } else {
                 $allNews[$j]['totalcomment'] = $item;
             }
             $j++;
         }
     }
     $this->context->smarty->assign(array('postcategory' => $allNews, 'category_status' => $category_status, 'title_category' => $title_category, 'cat_link_rewrite' => $cat_link_rewrite, 'id_category' => $id_category, 'cat_image' => $cat_image, 'categoryinfo' => $categoryinfo, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartdisablecatimg' => Configuration::get('smartdisablecatimg'), 'smartshowviewed' => Configuration::get('smartshowviewed'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'totalpages' => $totalpages));
     $template_name = 'postcategory.tpl';
     $this->setTemplate($template_name);
 }