Exemple #1
0
 /**
  *
  */
 public function delete()
 {
     //delete comment
     $result_comment = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT `id_comment` as id FROM `' . _DB_PREFIX_ . 'leoblog_comment` WHERE `id_leoblog_blog` = ' . (int) $this->id . '');
     foreach ($result_comment as $value) {
         $comment = new LeoBlogComment($value['id']);
         $comment->delete();
     }
     if (parent::delete()) {
         return $this->cleanPositions($this->id_leoblogcat);
     }
     return false;
 }
 public function renderView()
 {
     $link = $this->context->link;
     $quicktools = array();
     $quicktools[] = array('title' => $this->l('Categories'), 'href' => $link->getAdminLink('AdminLeoblogCategories'), 'icon' => 'icon-desktop', 'class' => '');
     $quicktools[] = array('title' => $this->l('Add Category'), 'href' => $link->getAdminLink('AdminLeoblogCategories'), 'icon' => 'icon-list', 'class' => '');
     $quicktools[] = array('title' => $this->l('Blogs'), 'href' => $link->getAdminLink('AdminLeoblogBlogs'), 'icon' => 'icon-list', 'class' => '');
     $quicktools[] = array('title' => $this->l('Add Blog'), 'href' => $link->getAdminLink('AdminLeoblogBlogs') . '&addleoblog_blog', 'icon' => 'icon-list', 'class' => '');
     $quicktools[] = array('title' => $this->l('Comments'), 'href' => $link->getAdminLink('AdminLeoblogBlogs') . '&listcomments', 'icon' => 'icon-list', 'class' => '');
     $onoff = array(array('id' => 'indexation_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'indexation_off', 'value' => 0, 'label' => $this->l('Disabled')));
     //$obj           = new Leoblogcat();
     //$menus         = $obj->getDropdown(null, $obj->id_parent);
     $templates = LeoBlogHelper::getTemplates();
     $url_rss = Tools::htmlentitiesutf8('http://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__) . 'modules/leoblog/rss.php';
     $form = '';
     $this->fields_form[0]['form'] = array('tinymce' => true, 'legend' => array('title' => $this->l('General Setting'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'select', 'label' => $this->l('Theme - Template'), 'name' => 'template', 'options' => array('query' => $templates, 'id' => 'template', 'name' => 'template'), 'default' => 'default'), array('type' => 'text', 'label' => $this->l('Root Link Title'), 'name' => 'blog_link_title', 'required' => true, 'lang' => true, 'desc' => $this->l('Make Link Title For Blog Root Link, Example http://domain/blog'), 'default' => 'Blog'), array('type' => 'text', 'label' => $this->l('Root Friendly URL'), 'name' => 'link_rewrite', 'required' => true, 'lang' => true, 'desc' => $this->l('Make seo start with this, Example http://domain/blog'), 'default' => 'blog'), array('type' => 'text', 'label' => $this->l('Meta Title'), 'name' => 'meta_title', 'lang' => true, 'cols' => 40, 'rows' => 10, 'default' => 'Blog', 'desc' => $this->l('Display browser title on frontpage blog')), array('type' => 'textarea', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'cols' => 40, 'rows' => 10, 'default' => '', 'desk' => $this->l('Display meta descrition on frontpage blog') . 'note: note <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'default' => '', 'lang' => true, 'desc' => array($this->l('Invalid characters:') . ' <>;=#{}', $this->l('To add "tags" click in the field, write something, and then press "Enter."'))), array('type' => 'switch', 'label' => $this->l('Enable Rss:'), 'name' => 'indexation', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '', 'values' => $onoff, 'desc' => $url_rss), array('type' => 'text', 'label' => $this->l('Rss Limit Items'), 'name' => 'rss_limit_item', 'default' => '20', 'desc' => 'Set Maximun shows in rss'), array('type' => 'text', 'label' => $this->l('Rss Title'), 'name' => 'rss_title_item', 'default' => 'RSS FEED', 'desc' => 'Set title in rss')), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-danger'));
     $this->fields_form[1]['form'] = array('tinymce' => true, 'default' => '', 'legend' => array('title' => $this->l('Listing Blog Setting'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'switch', 'label' => $this->l('Show Category Info:'), 'name' => 'listing_show_categoryinfo', 'required' => false, 'class' => 't', 'desc' => $this->l('Display category information in listing blogs'), 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Sub Categories:'), 'name' => 'listing_show_subcategories', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff, 'desc' => $this->l('Display subcategory in listing blog')), array('type' => 'text', 'label' => $this->l('Leading Column:'), 'name' => 'listing_leading_column', 'required' => false, 'class' => 't', 'default' => '1'), array('type' => 'text', 'label' => $this->l('Leading Limit Items:'), 'name' => 'listing_leading_limit_items', 'required' => false, 'class' => 't', 'default' => '2'), array('type' => 'text', 'label' => $this->l('Leading Image Width:'), 'name' => 'listing_leading_img_width', 'required' => false, 'class' => 't', 'default' => '690'), array('type' => 'text', 'label' => $this->l('Leading Image Height:'), 'name' => 'listing_leading_img_height', 'required' => false, 'class' => 't', 'default' => '300'), array('type' => 'text', 'label' => $this->l('Secondary Column:'), 'name' => 'listing_secondary_column', 'required' => false, 'class' => 't', 'default' => '3'), array('type' => 'text', 'label' => $this->l('Secondary Limit Items:'), 'name' => 'listing_secondary_limit_items', 'required' => false, 'class' => 't', 'default' => '6'), array('type' => 'text', 'label' => $this->l('Secondary Image Width:'), 'name' => 'listing_secondary_img_width', 'required' => false, 'class' => 't', 'default' => '390'), array('type' => 'text', 'label' => $this->l('Secondary Image Height:'), 'name' => 'listing_secondary_img_height', 'required' => false, 'class' => 't', 'default' => '220'), array('type' => 'switch', 'label' => $this->l('Show Title:'), 'name' => 'listing_show_title', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Description:'), 'name' => 'listing_show_description', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Readmore:'), 'name' => 'listing_show_readmore', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Image:'), 'name' => 'listing_show_image', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Author:'), 'name' => 'listing_show_author', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Category:'), 'name' => 'listing_show_category', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Created Date:'), 'name' => 'listing_show_created', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Hits:'), 'name' => 'listing_show_hit', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Counter:'), 'name' => 'listing_show_counter', 'required' => false, 'class' => 't', 'default' => '1', 'values' => $onoff)), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-danger'));
     $this->fields_form[2]['form'] = array('tinymce' => true, 'default' => '', 'legend' => array('title' => $this->l('Item Blog Setting'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'text', 'label' => $this->l('Item Image Width:'), 'name' => 'item_img_width', 'required' => false, 'class' => 't', 'default' => '690'), array('type' => 'text', 'label' => $this->l('Item Image Height:'), 'name' => 'item_img_height', 'required' => false, 'class' => 't', 'default' => '350'), array('type' => 'switch', 'label' => $this->l('Show Description:'), 'name' => 'item_show_description', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Image:'), 'name' => 'item_show_image', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Author:'), 'name' => 'item_show_author', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Category:'), 'name' => 'item_show_category', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Created Date:'), 'name' => 'item_show_created', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Hits:'), 'name' => 'item_show_hit', 'required' => false, 'class' => 't', 'is_bool' => true, 'default' => '1', 'values' => $onoff), array('type' => 'switch', 'label' => $this->l('Show Counter:'), 'name' => 'item_show_counter', 'required' => false, 'class' => 't', 'default' => '1', 'values' => $onoff), array('type' => 'textarea', 'label' => $this->l('Social Sharing CODE'), 'name' => 'social_code', 'required' => false, 'default' => '', 'desc' => 'put sharing social code from sharethis service....to replace current sharing social.'), array('type' => 'select', 'label' => $this->l('Comment Engine:'), 'name' => 'item_comment_engine', 'id' => 'item_comment_engine', 'options' => array('query' => array(array('id' => 'local', 'name' => $this->l('Local')), array('id' => 'facebook', 'name' => $this->l('Facebook')), array('id' => 'diquis', 'name' => $this->l('Diquis'))), 'id' => 'id', 'name' => 'name'), 'default' => 'local'), array('type' => 'text', 'label' => $this->l('Limit Local Comment'), 'name' => 'item_limit_comments', 'required' => false, 'class' => 't', 'default' => '10'), array('type' => 'text', 'label' => $this->l('Diquis Account:'), 'name' => 'item_diquis_account', 'required' => false, 'class' => 't', 'default' => 'demo4leotheme', 'desc' => '<a target="_blank" href="https://disqus.com/admin/signup/">' . $this->l('Sign Up Diquis') . '</a>'), array('type' => 'text', 'label' => $this->l('Facebook Application ID:'), 'name' => 'item_facebook_appid', 'required' => false, 'class' => 't', 'default' => '100858303516', 'desc' => '<a target="_blank" href="http://developers.facebook.com/docs/reference/plugins/comments/">' . $this->l('Register A Comment Box, Then Get Application ID in Script Or Register Facebook Application ID to moderate comments') . '</a>'), array('type' => 'text', 'label' => $this->l('Facebook Width:'), 'name' => 'item_facebook_width', 'required' => false, 'class' => 't', 'default' => '600')), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-danger'));
     $data = LeoBlogConfig::getConfigValue('cfg_global');
     $obj = new stdClass();
     if ($data && ($tmp = unserialize($data))) {
         foreach ($tmp as $key => $value) {
             # validate module
             $obj->{$key} = $value;
         }
     }
     $fields_value = $this->getConfigFieldsValues($obj);
     $helper = new HelperForm($this);
     $this->setHelperDisplay($helper);
     $helper->fields_value = $fields_value;
     $helper->tpl_vars = $this->tpl_form_vars;
     !is_null($this->base_tpl_form) ? $helper->base_tpl = $this->base_tpl_form : '';
     if ($this->tabAccess['view']) {
         $helper->tpl_vars['show_toolbar'] = false;
         $helper->tpl_vars['submit_action'] = 'saveConfiguration';
         if (Tools::getValue('back')) {
             $helper->tpl_vars['back'] = '';
         } else {
             $helper->tpl_vars['back'] = '';
         }
     }
     $form = $helper->generateForm($this->fields_form);
     $template = $this->createTemplate('panel.tpl');
     $comments = LeoBlogComment::getComments(null, 10, $this->context->language->id);
     $blogs = LeoBlogBlog::getListBlogs(null, $this->context->language->id, 0, 10, 'hits', 'DESC');
     $template->assign(array('quicktools' => $quicktools, 'showed' => 1, 'comment_link' => $link->getAdminLink('AdminLeoblogComments'), 'blog_link' => $link->getAdminLink('AdminLeoblogBlogs'), 'blogs' => $blogs, 'count_blogs' => LeoBlogBlog::countBlogs(null, $this->context->language->id), 'count_cats' => Leoblogcat::countCats(), 'count_comments' => LeoBlogComment::countComments(), 'latest_comments' => $comments, 'globalform' => $form));
     return $template->fetch();
 }
Exemple #3
0
 public static function buildBlog($helper, $blog, $image_w = 0, $image_h = 0, $config)
 {
     $url = _PS_BASE_URL_;
     if (Tools::usingSecureMode()) {
         # validate module
         $url = _PS_BASE_URL_SSL_;
     }
     $blog['preview_url'] = '';
     $blog['image_url'] = '';
     if ($blog['image']) {
         $blog['image_url'] = $url . _LEOBLOG_BLOG_IMG_URI_ . 'b/' . $blog['image'];
         if (!file_exists(_LEOBLOG_CACHE_IMG_DIR_ . 'b/' . $blog['id_leoblog_blog'] . '/' . $image_w . '_' . $image_h . '/' . $blog['image'])) {
             @mkdir(_LEOBLOG_CACHE_IMG_DIR_ . 'b/' . $blog['id_leoblog_blog'], 0777);
             @mkdir(_LEOBLOG_CACHE_IMG_DIR_ . 'b/' . $blog['id_leoblog_blog'] . '/' . $image_w . '_' . $image_h, 0777);
             if (ImageManager::resize(_LEOBLOG_BLOG_IMG_DIR_ . 'b/' . $blog['image'], _LEOBLOG_CACHE_IMG_DIR_ . 'b/' . $blog['id_leoblog_blog'] . '/' . $image_w . '_' . $image_h . '/' . $blog['image'], $image_w, $image_h)) {
                 # validate module
                 $blog['preview_url'] = _LEOBLOG_CACHE_IMG_DIR_ . 'b/' . $blog['id_leoblog_blog'] . '/' . $image_w . '_' . $image_h . '/' . $blog['image'];
             }
         }
         $blog['image_url'] = $url . _LEOBLOG_BLOG_IMG_URI_ . 'b/' . $blog['image'];
         $blog['preview_url'] = $url . _LEOBLOG_CACHE_IMG_URI_ . 'b/' . $blog['id_leoblog_blog'] . '/' . $image_w . '_' . $image_h . '/' . $blog['image'];
     }
     $params = array('rewrite' => $blog['category_link_rewrite'], 'id' => $blog['id_leoblogcat']);
     //	if( !$config->get( 'listing_show_counter' , 1)  ) {
     if ($config->get('item_comment_engine', 'local') == 'local') {
         # validate module
         $blog['comment_count'] = LeoBlogComment::countComments($blog['id_leoblog_blog'], true, true);
     }
     //	}else {
     //	$blog['comment_count'] = 0;
     //	}
     $blog['category_link'] = $helper->getBlogCatLink($params);
     $blog['link'] = $helper->getBlogLink($blog);
     return $blog;
 }
 public function renderView()
 {
     $link = $this->context->link;
     $quicktools = array();
     $quicktools[] = array('title' => $this->l('Categories'), 'href' => $link->getAdminLink('AdminLeoblogCategories'), 'icon' => 'icon-desktop', 'class' => '');
     $quicktools[] = array('title' => $this->l('Add Category'), 'href' => $link->getAdminLink('AdminLeoblogCategories'), 'icon' => 'icon-list', 'class' => '');
     $quicktools[] = array('title' => $this->l('Blogs'), 'href' => $link->getAdminLink('AdminLeoblogBlogs'), 'icon' => 'icon-list', 'class' => '');
     $quicktools[] = array('title' => $this->l('Add Blog'), 'href' => $link->getAdminLink('AdminLeoblogBlogs') . '&addleoblog_blog', 'icon' => 'icon-list', 'class' => '');
     $quicktools[] = array('title' => $this->l('Comments'), 'href' => $link->getAdminLink('AdminLeoblogBlogs') . '&listcomments', 'icon' => 'icon-list', 'class' => '');
     $onoff = array(array('id' => 'indexation_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'indexation_off', 'value' => 0, 'label' => $this->l('Disabled')));
     $obj = new Leoblogcat();
     $menus = $obj->getDropdown(null, $obj->id_parent);
     $templates = LeoBlogHelper::getTemplates();
     $url_rss = Tools::htmlentitiesutf8('http://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__) . 'modules/leoblog/rss.php';
     $form = '';
     $this->fields_form[0]['form'] = array('tinymce' => true, 'legend' => array('title' => $this->l('General Setting'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'html', 'html_content' => 'Please access <a href="http://apollotheme.com/" target="_blank" title="apollo site">Apollotheme.com</a> to buy professional version to use this '), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/how-to-buy-pro-version/" target="_blank" title="How to buy">How to buy Professional Version</a>'), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/different-between-free-pro-version/" target="_blank" title="Why should use">Why should use Professional Version</a>')), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-danger'));
     $this->fields_form[1]['form'] = array('tinymce' => true, 'default' => '', 'legend' => array('title' => $this->l('Listing Blog Setting'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'html', 'html_content' => 'Please access <a href="http://apollotheme.com/" target="_blank" title="apollo site">Apollotheme.com</a> to buy professional version to use this '), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/how-to-buy-pro-version/" target="_blank" title="How to buy">How to buy Professional Version</a>'), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/different-between-free-pro-version/" target="_blank" title="Why should use">Why should use Professional Version</a>')), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-danger'));
     $this->fields_form[2]['form'] = array('tinymce' => true, 'default' => '', 'legend' => array('title' => $this->l('Item Blog Setting'), 'icon' => 'icon-folder-close'), 'input' => array(array('type' => 'html', 'html_content' => 'Please access <a href="http://apollotheme.com/" target="_blank" title="apollo site">Apollotheme.com</a> to buy professional version to use this '), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/how-to-buy-pro-version/" target="_blank" title="How to buy">How to buy Professional Version</a>'), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/different-between-free-pro-version/" target="_blank" title="Why should use">Why should use Professional Version</a>')), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-danger'));
     $data = LeoBlogConfig::getConfigValue('cfg_global');
     $obj = new stdClass();
     if ($data && ($tmp = unserialize($data))) {
         foreach ($tmp as $key => $value) {
             $obj->{$key} = $value;
         }
     }
     $fields_value = $this->getConfigFieldsValues($obj);
     $helper = new HelperForm($this);
     $this->setHelperDisplay($helper);
     $helper->fields_value = $fields_value;
     $helper->tpl_vars = $this->tpl_form_vars;
     !is_null($this->base_tpl_form) ? $helper->base_tpl = $this->base_tpl_form : '';
     if ($this->tabAccess['view']) {
         $helper->tpl_vars['show_toolbar'] = false;
         $helper->tpl_vars['submit_action'] = 'saveConfiguration';
         if (Tools::getValue('back')) {
             $helper->tpl_vars['back'] = '';
         } else {
             $helper->tpl_vars['back'] = '';
         }
     }
     $form = $helper->generateForm($this->fields_form);
     $template = $this->createTemplate('panel.tpl');
     $comments = LeoBlogComment::getComments(null, 10, $this->context->language->id);
     $blogs = LeoBlogBlog::getListBlogs(null, $this->context->language->id, 0, 10, 'hits', 'DESC');
     $template->assign(array('quicktools' => $quicktools, 'showed' => 1, 'comment_link' => $link->getAdminLink('AdminLeoblogComments'), 'blog_link' => $link->getAdminLink('AdminLeoblogBlogs'), 'blogs' => $blogs, 'count_blogs' => LeoBlogBlog::countBlogs(null, $this->context->language->id), 'count_cats' => Leoblogcat::countCats(), 'count_comments' => LeoBlogComment::countComments(), 'latest_comments' => $comments, 'globalform' => $form));
     return $template->fetch();
 }
Exemple #5
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Tools::getValue('captchaimage')) {
         $this->captcha();
         exit;
     }
     $config = LeoBlogConfig::getInstance();
     /* Load Css and JS File */
     LeoBlogHelper::loadMedia($this->context, $this);
     parent::initContent();
     if (Tools::isSubmit('submitcomment')) {
         # validate module
         $this->comment();
     }
     $helper = LeoBlogHelper::getInstance();
     $blog = new LeoBlogBlog(Tools::getValue('id'), $this->context->language->id);
     //		$_GET['rewrite'] = $blog->link_rewrite;
     if (!$blog->id_leoblog_blog) {
         $full_path = '<a href="' . $helper->getFontBlogLink() . '">' . htmlentities($config->get('blog_link_title_' . $this->context->language->id, 'Blog'), ENT_NOQUOTES, 'UTF-8') . '</a>';
         $vars = array('error' => true, 'path' => $full_path);
         $this->context->smarty->assign($vars);
         return $this->setTemplate($config->get('template', 'default') . '/blog.tpl');
     }
     $category = new leoblogcat($blog->id_leoblogcat, $this->context->language->id);
     $image_w = $config->get('item_img_width', 690);
     $image_h = $config->get('item_img_height', 300);
     $template = !empty($category->template) ? $category->template : 'default';
     // have to have a value ( not empty )
     $this->template_path .= $template . '/';
     $module_tpl = $this->template_path;
     $url = _PS_BASE_URL_;
     if (Tools::usingSecureMode()) {
         # validate module
         $url = _PS_BASE_URL_SSL_;
     }
     $blog->preview_url = '';
     if ($blog->image) {
         $blog->image_url = $url . _LEOBLOG_BLOG_IMG_URI_ . 'b/' . $blog->image;
         if (ImageManager::resize(_LEOBLOG_BLOG_IMG_DIR_ . 'b/' . $blog->image, _LEOBLOG_CACHE_IMG_DIR_ . 'b/lg-' . $blog->image, $image_w, $image_h)) {
             # validate module
             $blog->preview_url = $url . _LEOBLOG_CACHE_IMG_URI_ . 'b/lg-' . $blog->image;
         }
     }
     $captcha_image = $helper->getBlogLink(get_object_vars($blog), array('captchaimage' => 1));
     $blog_link = $helper->getBlogLink(get_object_vars($blog));
     $params = array('rewrite' => $category->link_rewrite, 'id' => $category->id_leoblogcat);
     $blog->category_link = $helper->getBlogCatLink($params);
     $blog->category_title = $category->title;
     $employee = new Employee($blog->id_employee);
     $blog->author = $employee->firstname . ' ' . $employee->lastname;
     $blog->author_link = $helper->getBlogAuthorLink($employee->id);
     $tags = array();
     if ($blog->tags && ($tmp = explode(',', $blog->tags))) {
         foreach ($tmp as $tag) {
             $tags[] = array('tag' => $tag, 'link' => $helper->getBlogTagLink($tag));
         }
     }
     $blog->hits = $blog->hits + 1;
     //$blog->save();
     $blog->updateField($blog->id, array('hits' => $blog->hits));
     /* breadscrumb */
     $params = array('rewrite' => $category->link_rewrite, 'id' => $category->id_leoblogcat);
     $category_link = $helper->getBlogCatLink($params);
     $full_path = '<a href="' . $helper->getFontBlogLink() . '">' . htmlentities($config->get('blog_link_title_' . $this->context->language->id, 'Blog'), ENT_NOQUOTES, 'UTF-8') . '</a><span class="navigation-pipe">' . Configuration::get('PS_NAVIGATION_PIPE') . '</span>';
     $full_path .= '<a href="' . Tools::safeOutput($category_link) . '">' . htmlentities($category->title, ENT_NOQUOTES, 'UTF-8') . '</a><span class="navigation-pipe">' . Configuration::get('PS_NAVIGATION_PIPE') . '</span>' . $blog->meta_title;
     $limit = 5;
     $samecats = LeoBlogBlog::getListBlogs($category->id_leoblogcat, $this->context->language->id, 0, $limit, 'date_add', 'DESC', array('type' => 'samecat', 'id_leoblog_blog' => $blog->id_leoblog_blog), true);
     foreach ($samecats as $key => $sblog) {
         $sblog['link'] = $helper->getBlogLink($sblog);
         $samecats[$key] = $sblog;
     }
     $tagrelated = array();
     if ($blog->tags) {
         $tagrelated = LeoBlogBlog::getListBlogs($category->id_leoblogcat, $this->context->language->id, 0, $limit, 'id_leoblog_blog', 'DESC', array('type' => 'tag', 'tag' => $blog->tags), true);
         foreach ($tagrelated as $key => $tblog) {
             $tblog['link'] = $helper->getBlogLink($tblog);
             $tagrelated[$key] = $tblog;
         }
     }
     /* Comments */
     $evars = array();
     if ($config->get('item_comment_engine', 'local') == 'local') {
         $count_comment = 0;
         if ($config->get('comment_engine', 'local') == 'local') {
             # validate module
             $count_comment = LeoBlogComment::countComments($blog->id_leoblog_blog, true);
         }
         $blog_link = $helper->getBlogLink(get_object_vars($blog));
         $limit = (int) $config->get('item_limit_comments', 10);
         $n = $limit;
         $p = abs((int) Tools::getValue('p', 1));
         $comment = new LeoBlogComment();
         $comments = $comment->getList($blog->id_leoblog_blog, $this->context->language->id, $p, $limit);
         $nb_blogs = $count_comment;
         $range = 2;
         /* how many pages around page selected */
         if ($p > $nb_blogs / $n + 1) {
             Tools::redirect(preg_replace('/[&?]p=\\d+/', '', $_SERVER['REQUEST_URI']));
         }
         $pages_nb = ceil($nb_blogs / (int) $n);
         $start = (int) ($p - $range);
         if ($start < 1) {
             $start = 1;
         }
         $stop = (int) ($p + $range);
         if ($stop > $pages_nb) {
             $stop = (int) $pages_nb;
         }
         $evars = array('pages_nb' => $pages_nb, 'nb_items' => $count_comment, 'p' => (int) $p, 'n' => (int) $n, 'requestPage' => $blog_link, 'requestNb' => $blog_link, 'start' => $start, 'comments' => $comments, 'range' => $range, 'blog_count_comment' => $count_comment, 'stop' => $stop);
     }
     if ((bool) Module::isEnabled('smartshortcode')) {
         if (context::getcontext()->controller->controller_type == 'front') {
             $smartshortcode = Module::getInstanceByName('smartshortcode');
             $blog->content = $smartshortcode->parse($blog->content);
         }
     }
     $vars = array('tags' => $tags, 'meta_title' => Tools::ucfirst($blog->meta_title) . ' - ' . $this->context->shop->name, 'meta_keywords' => $blog->meta_keywords, 'meta_description' => $blog->meta_description, 'blog' => $blog, 'samecats' => $samecats, 'tagrelated' => $tagrelated, 'path' => $full_path, 'config' => $config, 'id_leoblog_blog' => $blog->id_leoblog_blog, 'is_active' => $blog->active, 'productrelated' => array(), 'module_tpl' => $module_tpl, 'captcha_image' => $captcha_image, 'blog_link' => $blog_link);
     $vars = array_merge($vars, $evars);
     $this->context->smarty->assign($vars);
     $this->setTemplate($template . '/blog.tpl');
 }