public function _posts() { $SmartBlogPost = new SmartBlogPost(); if (Tools::isSubmit('addComment')) { $id_lang = $this->context->language->id; $id_post = Tools::getValue('id_post'); $post = $SmartBlogPost->getPost($id_post, $id_lang); if ($post['comment_status'] == 1) { $blogcomment = new Blogcomment(); $name = Tools::getValue('name'); $comment = Tools::getValue('comment'); $mail = Tools::getValue('mail'); if (Tools::getValue('mail') == '') { $website = '#'; } else { $website = Tools::getValue('website'); } $id_parent_post = (int) Tools::getValue('id_parent_post'); if (empty($name)) { $this->_report .= '<p class="error">' . $this->module->l('Name is required') . '</p>'; } elseif (empty($comment)) { $this->_report .= '<p class="error">' . $this->module->l('Comment is required') . '</p>'; } elseif (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { $this->_report .= '<p class="error">' . $this->module->l('E-mail is not valid') . '</p>'; } else { $comments['name'] = $name; $comments['mail'] = $mail; $comments['comment'] = $comment; $comments['website'] = $website; if (!($id_parent_post = Tools::getvalue('comment_parent'))) { $id_parent_post = 0; } $value = Configuration::get('smartacceptcomment'); if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) { $value = Configuration::get('smartacceptcomment'); } else { $value = 0; } $bc = new Blogcomment(); $bc->id_post = (int) $id_post; $bc->name = $name; $bc->email = $mail; $bc->content = $comment; $bc->website = $website; $bc->id_parent = (int) $id_parent_post; $bc->active = (int) $value; if ($bc->add()) { $this->_report .= '<p class="success">' . $this->module->l('Comment added !') . '</p>'; Hook::exec('actionsbpostcomment', array('bc' => $bc)); $this->smartsendMail($name, $mail, $comment); } } } } }
public static function ImageDelete() { $get_blog_image = SmartBlogPost::getBlogImage(); $get_author_image = __PS_BASE_URI__ . 'modules/smartblog/images/avatar/avatar.jpg'; $get_cate_image = BlogCategory::getCatImage(); $category_types = BlogImageType::GetImageAllType('category'); $posts_types = BlogImageType::GetImageAllType('post'); $author_types = BlogImageType::GetImageAllType('author'); foreach ($category_types as $image_type) { foreach ($get_cate_image as $cat_img) { $dir = _PS_MODULE_DIR_ . 'smartblog/images/category/' . $cat_img['id_smart_blog_category'] . '-' . stripslashes($image_type['type_name']) . '.jpg'; if (file_exists($dir)) { unlink($dir); } } } foreach ($posts_types as $image_type) { foreach ($get_blog_image as $blog_img) { $dir = _PS_MODULE_DIR_ . 'smartblog/images/' . $blog_img['id_smart_blog_post'] . '-' . stripslashes($image_type['type_name']) . '.jpg'; if (file_exists($dir)) { unlink($dir); } } } foreach ($author_types as $image_type) { $dir = _PS_MODULE_DIR_ . 'smartblog/images/avatar/avatar-' . stripslashes($image_type['type_name']) . '.jpg'; if (file_exists($dir)) { unlink($dir); } } }
public function initContent() { parent::initContent(); if ($id_category = Tools::getvalue('id_category') && Tools::getvalue('id_category') != Null) { $this->context->smarty->assign(BlogCategory::GetMetaByCategory(Tools::getvalue('id_category'))); } if ($id_post = Tools::getvalue('id_post') && Tools::getvalue('id_post') != Null) { $this->context->smarty->assign(SmartBlogPost::GetPostMetaByPost(Tools::getvalue('id_post'))); } if (Tools::getvalue('id_category') == Null && Tools::getvalue('id_post') == Null) { $meta['meta_title'] = Configuration::get('smartblogmetatitle'); $meta['meta_description'] = Configuration::get('smartblogmetadescrip'); $meta['meta_keywords'] = Configuration::get('smartblogmetakeyword'); $this->context->smarty->assign($meta); } if (Configuration::get('smartshowcolumn') == 0) { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } elseif (Configuration::get('smartshowcolumn') == 1) { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'))); } elseif (Configuration::get('smartshowcolumn') == 2) { $this->context->smarty->assign(array('HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } elseif (Configuration::get('smartshowcolumn') == 3) { $this->context->smarty->assign(array()); } else { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } }
public function hookLeftColumn($params) { if (Module::isInstalled('smartblog') != 1) { $this->smarty->assign(array('smartmodname' => $this->name)); return $this->display(__FILE__, 'views/templates/front/install_required.tpl'); } else { if (!$this->isCached('smartblogarchive.tpl', $this->getCacheId())) { $view_data = array(); $id_lang = $this->context->language->id; $SmartBlogPost = new SmartBlogPost(); $archives = $SmartBlogPost->getArchive(); $this->smarty->assign(array('archives' => $archives)); } return $this->display(__FILE__, 'views/templates/front/smartblogarchive.tpl', $this->getCacheId()); } }
public function hookLeftColumn($params) { if (Module::isInstalled('smartblog') != 1) { $this->smarty->assign(array('smartmodname' => $this->name)); return $this->display(__FILE__, 'views/templates/front/install_required.tpl'); } else { if (!$this->isCached('smartblogrecentposts.tpl', $this->getCacheId())) { global $smarty; $id_lang = $this->context->language->id; $posts = SmartBlogPost::getRecentPosts($id_lang); $i = 0; foreach ($posts as $post) { if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $post['id_smart_blog_post'] . '.jpg')) { $image = $post['id_smart_blog_post']; $posts[$i]['post_img'] = $image; } else { $posts[$i]['post_img'] = 'no'; } $i++; } $smarty->assign(array('posts' => $posts)); } return $this->display(__FILE__, 'views/templates/front/smartblogrecentposts.tpl', $this->getCacheId()); } }
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); }
public function hookDisplayPreFooter($params) { if (Module::isInstalled('smartblog') != 1) { $this->smarty->assign(array('smartmodname' => $this->name)); return $this->display(__FILE__, 'views/templates/front/install_required.tpl'); } else { if (!$this->isCached('smartblog_latest_news.tpl', $this->getCacheId())) { $view_data['posts'] = SmartBlogPost::GetPostLatestHome(4); $this->smarty->assign(array('view_data' => $view_data['posts'])); } return $this->display(__FILE__, 'views/templates/front/smartblog_latest_news.tpl', $this->getCacheId()); } }
public function hookdisplaySmartAfterPost($params) { if (Module::isInstalled('smartblog') != 1) { $this->smarty->assign(array('smartmodname' => $this->name)); return $this->display(__FILE__, 'views/templates/front/install_required.tpl'); } else { if (!$this->isCached('smartblogrelatedposts.tpl', $this->getCacheId())) { $id_cat = BlogCategory::getCategoryNameByPost(Tools::getvalue('id_post')); $id_lang = $this->context->language->id; $posts = SmartBlogPost::getRelatedPosts($id_lang, $id_cat, Tools::getvalue('id_post')); $this->smarty->assign(array('posts' => $posts)); } return $this->display(__FILE__, 'views/templates/front/smartblogrelatedposts.tpl', $this->getCacheId()); } }
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); }
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); }
public function smartblogrelatedproductHookdisplayProductTabContent($params) { $id_lang = $this->context->language->id; $posts = SmartBlogPost::getRelatedPostsByProduct($id_lang, Tools::getvalue('id_product')); $this->smarty->assign(array('posts' => $posts)); return $this->display(__FILE__, 'views/templates/front/plugins/smart_product_tab_creator.tpl'); }
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); }
public function postProcess() { if (Tools::isSubmit('deletesmart_blog_category') && Tools::getValue('id_smart_blog_category') != '') { $id_lang = (int) Context::getContext()->language->id; $catpost = (int) SmartBlogPost::getToltalByCategory($id_lang, Tools::getValue('id_smart_blog_category')); if ((int) $catpost != 0) { $this->errors[] = Tools::displayError('You need to delete all posts associate with this category .'); } else { $BlogCategory = new BlogCategory((int) Tools::getValue('id_smart_blog_category')); if (!$BlogCategory->delete()) { $this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>'; } else { Hook::exec('actionsbdeletecat', array('BlogCategory' => $BlogCategory)); Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory')); } } } elseif (Tools::isSubmit('submitAddsmart_blog_category')) { parent::validateRules(); if (count($this->errors)) { return false; } if (!($id_smart_blog_category = (int) Tools::getValue('id_smart_blog_category'))) { $BlogCategory = new BlogCategory(); $languages = Language::getLanguages(false); foreach ($languages as $language) { $title = str_replace('"', '', htmlspecialchars_decode(html_entity_decode(Tools::getValue('meta_title_' . $language['id_lang'])))); $BlogCategory->meta_title[$language['id_lang']] = $title; $BlogCategory->meta_keyword[$language['id_lang']] = Tools::getValue('meta_keyword_' . $language['id_lang']); $BlogCategory->meta_description[$language['id_lang']] = Tools::getValue('meta_description_' . $language['id_lang']); $BlogCategory->description[$language['id_lang']] = Tools::getValue('description_' . $language['id_lang']); if (Tools::getValue('link_rewrite_' . $language['id_lang']) == '' && Tools::getValue('link_rewrite_' . $language['id_lang']) == null) { $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('meta_title_' . $language['id_lang'])); } else { $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('link_rewrite_' . $language['id_lang'])); } } $BlogCategory->id_parent = Tools::getValue('id_parent'); $BlogCategory->position = Tools::getValue('position'); $BlogCategory->desc_limit = Tools::getValue('desc_limit'); $BlogCategory->active = Tools::getValue('active'); $BlogCategory->created = Date('y-m-d H:i:s'); $BlogCategory->modified = Date('y-m-d H:i:s'); if (!$BlogCategory->save()) { $this->errors[] = Tools::displayError('An error has occurred: Can\'t save the current object'); } else { Hook::exec('actionsbnewcat', array('BlogCategory' => $BlogCategory)); $this->processImageCategory($_FILES, $BlogCategory->id); Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory')); } } elseif ($id_smart_blog_category = Tools::getValue('id_smart_blog_category')) { $BlogCategory = new BlogCategory($id_smart_blog_category); $languages = Language::getLanguages(false); foreach ($languages as $language) { $title = str_replace('"', '', htmlspecialchars_decode(html_entity_decode(Tools::getValue('meta_title_' . $language['id_lang'])))); $BlogCategory->meta_title[$language['id_lang']] = $title; $BlogCategory->meta_keyword[$language['id_lang']] = Tools::getValue('meta_keyword_' . $language['id_lang']); $BlogCategory->meta_description[$language['id_lang']] = Tools::getValue('meta_description_' . $language['id_lang']); $BlogCategory->description[$language['id_lang']] = Tools::getValue('description_' . $language['id_lang']); $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('link_rewrite_' . $language['id_lang'])); } $BlogCategory->id_parent = Tools::getValue('id_parent'); $BlogCategory->position = Tools::getValue('position'); $BlogCategory->desc_limit = Tools::getValue('desc_limit'); $BlogCategory->active = Tools::getValue('active'); $BlogCategory->modified = Date('y-m-d H:i:s'); if (!$BlogCategory->update()) { $this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>'; } else { Hook::exec('actionsbupdatecat', array('BlogCategory' => $BlogCategory)); } $this->processImageCategory($_FILES, $BlogCategory->id_smart_blog_category); Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory')); } } elseif (Tools::isSubmit('statussmart_blog_category') && Tools::getValue($this->identifier)) { if ($this->tabAccess['edit'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject())) { if ($object->toggleStatus()) { Hook::exec('actionsbtogglecat', array('SmartBlogCat' => $this->object)); $identifier = (int) $object->id_parent ? '&id_smart_blog_category=' . (int) $object->id_parent : ''; Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory')); } else { $this->errors[] = Tools::displayError('An error occurred while updating the status.'); } } else { $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)'); } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('smart_blog_categoryOrderby') && Tools::isSubmit('smart_blog_categoryOrderway')) { $this->_defaultOrderBy = Tools::getValue('smart_blog_categoryOrderby'); $this->_defaultOrderWay = Tools::getValue('smart_blog_categoryOrderway'); } }
function _posts() { $SmartBlogPost = new SmartBlogPost(); $SmartBlog = new SmartBlog(); $array_error = array(); $context = $id_lang = (int) Context::getContext()->language->id; $id_post = Tools::getValue('id_post'); $post = $SmartBlogPost->getPost($id_post, $id_lang); if ($post['comment_status'] == 1) { $blogcomment = new Blogcomment(); $name = Tools::getValue('name'); $comment = Tools::getValue('comment'); $mail = Tools::getValue('mail'); $captcha = Tools::getvalue('smartblogcaptcha'); $m_captcha = $_SESSION['ssmartblogcaptcha']; if (Tools::getValue('website') == '') { $website = '#'; } else { $website = Tools::getValue('website'); } $id_parent_post = (int) Tools::getValue('id_parent_post'); //'name'=>'Name between 2 - 25 characters !', if (empty($name)) { $array_error['name'] = $SmartBlog->l('Name is required'); } if (empty($comment)) { $array_error['comment'] = $SmartBlog->l('Comment must be between 25 and 1500 characters!'); } if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { $array_error['mail'] = $SmartBlog->l('E-mail address not valid !'); } if (Configuration::get('smartcaptchaoption') == '1') { if ($captcha != $m_captcha) { $array_error['captcha'] = $SmartBlog->l('Captcha is not valid'); } } if (is_array($array_error) && count($array_error)) { $array_error['common'] = $SmartBlog->l('Warning: Please check required form bellow!'); die(Tools::jsonEncode(array('error' => $array_error))); } else { $array_success = array(); $comments['name'] = $name; $comments['mail'] = $mail; $comments['comment'] = $comment; $comments['website'] = $website; if (!($id_parent_post = Tools::getvalue('comment_parent'))) { $id_parent_post = 0; } $value = Configuration::get('smartacceptcomment'); if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) { $value = Configuration::get('smartacceptcomment'); } else { $value = 0; } $bc = new Blogcomment(); $bc->id_post = (int) $id_post; $bc->name = $name; $bc->email = $mail; $bc->content = $comment; $bc->website = $website; $bc->id_parent = (int) $id_parent_post; $bc->active = (int) $value; $bc->created = Date('y-m-d H:i:s'); if ($bc->add()) { $array_success['common'] = $SmartBlog->l('Your comment successfully submitted.'); $array_success['success'] = $SmartBlog->l('Your comment successfully submitted'); Hook::exec('actionsbpostcomment', array('bc' => $bc)); die(Tools::jsonEncode($array_success)); } } } }
/** * Update product accessories * * @param object $product Product */ public function updateAccessories($id_smart_blog_post) { $SmartBlogPost = new SmartBlogPost($id_smart_blog_post); $SmartBlogPost->deleteAccessories($id_smart_blog_post); if ($accessories = Tools::getValue('inputAccessories')) { $accessories_id = array_unique(explode('-', $accessories)); if (count($accessories_id)) { array_pop($accessories_id); $SmartBlogPost->changeAccessories($accessories_id); } } }
public function updateTags($languages, $post) { $tag_success = true; if (!SmartBlogPost::deleteTagsForProduct((int) $post->id)) { $this->errors[] = Tools::displayError('An error occurred while attempting to delete previous tags.'); } foreach ($languages as $language) { if ($value = Tools::getValue('tags_' . $language['id_lang'])) { $tag_success &= SmartBlogPost::addTags($language['id_lang'], (int) $post->id, $value); } } if (!$tag_success) { $this->errors[] = Tools::displayError('An error occurred while adding tags.'); } return $tag_success; }
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); }
function _posts() { $SmartBlogPost = new SmartBlogPost(); $SmartBlog = new SmartBlog(); $array_error = array(); $id_lang = (int) Context::getContext()->language->id; $id_post = pSQL(Tools::getValue('id_post')); $post = $SmartBlogPost->getPost($id_post, $id_lang); $context = Context::getContext(); if ($post['comment_status'] == 1) { $name = pSQL(Tools::getValue('name')); $comment = pSQL(Tools::getValue('comment')); $mail = pSQL(Tools::getValue('mail')); $captcha = pSQL(Tools::getvalue('smartblogcaptcha')); $m_captcha = $context->cookie->__get('ssmartblogcaptcha'); if (Tools::getValue('website') == '') { $website = '#'; } else { $website = pSQL(Tools::getValue('website')); } $id_parent_post = (int) pSQL(Tools::getValue('id_parent_post')); //'name'=>'Name between 2 - 25 characters !', if (empty($name)) { $array_error['name'] = $SmartBlog->nrl; } if (empty($comment)) { $array_error['comment'] = $SmartBlog->crl; } if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { $array_error['mail'] = $SmartBlog->erl; } if (Configuration::get('smartcaptchaoption') == '1') { if ($captcha != $m_captcha) { $array_error['captcha'] = $SmartBlog->capl; } } if (is_array($array_error) && count($array_error)) { $array_error['common'] = $SmartBlog->warl; die(Tools::jsonEncode(array('error' => $array_error))); } else { $array_success = array(); $comments = array(); $comments['name'] = $name; $comments['mail'] = $mail; $comments['comment'] = $comment; $comments['website'] = $website; if (!($id_parent_post = Tools::getvalue('comment_parent'))) { $id_parent_post = 0; } $value = Configuration::get('smartacceptcomment'); if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) { $value = Configuration::get('smartacceptcomment'); } else { $value = 0; } $bc = new Blogcomment(); $bc->id_post = (int) $id_post; $bc->name = $name; $bc->email = $mail; $bc->content = $comment; $bc->website = $website; $bc->id_parent = (int) $id_parent_post; $bc->active = (int) $value; $bc->created = Date('y-m-d H:i:s'); if ($bc->add()) { $array_success['common'] = $SmartBlog->sucl; $array_success['success'] = $SmartBlog->sucl; Hook::exec('actionsbpostcomment', array('bc' => $bc)); die(Tools::jsonEncode($array_success)); } } } }
public static function getLatestComments($id_lang = null) { $result = array(); if ($id_lang == null) { $id_lang = (int) Context::getContext()->language->id; } if (Configuration::get('smartshowhomecomments') != '' && Configuration::get('smartshowhomecomments') != null) { $limit = Configuration::get('smartshowhomecomments'); } else { $limit = 5; } $sql = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_comment bc INNER JOIN ' . _DB_PREFIX_ . 'smart_blog_post_shop bps ON bc.id_post=bps.id_smart_blog_post and bps.id_shop = ' . (int) Context::getContext()->shop->id . ' WHERE bc.active= 1 ORDER BY bc.id_smart_blog_comment DESC limit 0, ' . $limit); $i = 0; foreach ($sql as $post) { $result[$i]['id_smart_blog_comment'] = $post['id_smart_blog_comment']; $result[$i]['id_parent'] = $post['id_parent']; $result[$i]['id_customer'] = $post['id_customer']; $result[$i]['id_post'] = $post['id_post']; $result[$i]['name'] = $post['name']; $result[$i]['email'] = $post['email']; $result[$i]['website'] = $post['website']; $result[$i]['active'] = $post['active']; $result[$i]['created'] = $post['created']; $result[$i]['content'] = $post['content']; $SmartBlogPost = new SmartBlogPost(); $result[$i]['slug'] = $SmartBlogPost->GetPostSlugById($post['id_post']); $i++; } return $result; }
public static function getArchive() { $result = array(); $sql = 'SELECT YEAR(p.created) as year FROM ' . _DB_PREFIX_ . 'smart_blog_post p INNER JOIN ' . _DB_PREFIX_ . 'smart_blog_post_shop ps ON p.id_smart_blog_post = ps.id_smart_blog_post AND ps.id_shop = ' . (int) Context::getContext()->shop->id . ' GROUP BY YEAR(p.created)'; if (!($posts = Db::getInstance()->executeS($sql))) { return false; } $i = 0; foreach ($posts as $value) { $result[$i]['year'] = $value['year']; $result[$i]['month'] = SmartBlogPost::getArchiveM($value['year']); $months = SmartBlogPost::getArchiveM($value['year']); $j = 0; foreach ($months as $month) { $result[$i]['month'][$j]['day'] = SmartBlogPost::getArchiveD($month['month'], $value['year']); $j++; } $i++; } return $result; }