Beispiel #1
0
 public function renderContent($setting)
 {
     $t = array('sub_title' => '', 'name' => '', 'html' => '', 'height' => 130, 'width' => 170, 'nbr' => 6, 'columns' => 4, 'show' => 1, 'show_image' => 1, 'show_title_blog' => 1, 'show_category' => 0, 'show_dateadd' => 1, 'show_comment' => 0, 'show_description' => 1, 'show_readmore' => 0, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
     $setting = array_merge($t, $setting);
     if (file_exists(_PS_MODULE_DIR_ . 'leoblog/classes/config.php')) {
         require_once _PS_MODULE_DIR_ . 'leoblog/loader.php';
         $authors = array();
         $config = LeoBlogConfig::getInstance();
         $config->setVar('blockpts_blogs_height', $setting['height']);
         $config->setVar('blockpts_blogs_width', $setting['width']);
         $config->setVar('blockpts_blogs_limit', $setting['nbr']);
         $config->setVar('blockpts_blogs_col', $setting['columns']);
         $config->setVar('blockpts_blogs_show', $setting['show']);
         $limit = (int) $config->get('blockpts_blogs_limit', 6);
         $blogs = LeoBlogBlog::getListBlogs(null, $this->lang_id, 0, $limit, 'date_add', 'DESC', array(), true);
         $helper = LeoBlogHelper::getInstance();
         $image_w = (int) $config->get('blockpts_blogs_width', 170);
         $image_h = (int) $config->get('blockpts_blogs_height', 130);
         $link = LeoBlogHelper::getInstance()->getFontBlogLink();
         foreach ($blogs as $key => $blog) {
             $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
             if ($blog['id_employee']) {
                 if (!isset($authors[$blog['id_employee']])) {
                     $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
                 }
                 $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname;
                 $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
             } else {
                 $blog['author'] = '';
                 $blog['author_link'] = '';
             }
             $blogs[$key] = $blog;
         }
         $columnspage = (int) $config->get('blockpts_blogs_col', 3);
         $setting['blogs'] = $blogs;
         $setting['config'] = $config;
         $setting['view_all_link'] = $link;
         $setting['columnspage'] = $columnspage;
         $setting['modid'] = time();
         $setting['tabname'] = rand() + $setting['modid'];
         $list_mode_tpl = _PS_MODULE_DIR_ . '/pspagebuilder/views/templates/front/widgets/sub/item_blog_' . $setting['list_mode'] . '.tpl';
         $tlist_mode_tpl = _PS_ALL_THEMES_DIR_ . _THEME_NAME_ . '/modules/pspagebuilder/views/templates/front/widgets/sub/item_blog_' . $setting['list_mode'] . '.tpl';
         if (file_exists($tlist_mode_tpl)) {
             $list_mode_tpl = $tlist_mode_tpl;
         }
         $setting['list_mode_tpl'] = $list_mode_tpl;
         $language_id = Context::getContext()->language->id;
         $setting['sub_title'] = isset($setting['sub_title_' . $language_id]) ? $setting['sub_title_' . $language_id] : '';
         $output = array('type' => 'bloglatest', 'data' => $setting);
         return $output;
     }
 }
Beispiel #2
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $config = LeoBlogConfig::getInstance();
     /* Load Css and JS File */
     LeoBlogHelper::loadMedia($this->context, $this);
     $this->php_self = 'category';
     parent::initContent();
     $id_category = (int) Tools::getValue('id');
     $helper = LeoBlogHelper::getInstance();
     $limit_leading_blogs = (int) $config->get('listing_leading_limit_items', 1);
     $limit_secondary_blogs = (int) $config->get('listing_secondary_limit_items', 6);
     $limit = (int) $limit_leading_blogs + (int) $limit_secondary_blogs;
     $n = $limit;
     $p = abs((int) Tools::getValue('p', 1));
     $category = new Leoblogcat($id_category, $this->context->language->id);
     $template = isset($category->template) && $category->template ? $category->template : $config->get('template', 'default');
     if ($category->id_leoblogcat && $category->active) {
         //			$_GET['rewrite'] = $category->link_rewrite;
         $this->template_path .= $template . '/';
         if ($category->image) {
             # validate module
             $category->image = _LEOBLOG_BLOG_IMG_URI_ . 'c/' . $category->image;
         }
         $blogs = LeoBlogBlog::getListBlogs($id_category, $this->context->language->id, $p, $limit, 'id_leoblog_blog', 'DESC', array(), true);
         $count = LeoBlogBlog::countBlogs($id_category, $this->context->language->id, true);
         $authors = array();
         $leading_blogs = array();
         $secondary_blogs = array();
         //			$links 	   =  array();
         if (count($blogs)) {
             $leading_blogs = array_slice($blogs, 0, $limit_leading_blogs);
             $secondary_blogs = array_splice($blogs, $limit_leading_blogs, count($blogs));
         }
         $image_w = (int) $config->get('listing_leading_img_width', 690);
         $image_h = (int) $config->get('listing_leading_img_height', 300);
         foreach ($leading_blogs as $key => $blog) {
             $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
             if ($blog['id_employee']) {
                 if (!isset($authors[$blog['id_employee']])) {
                     # validate module
                     $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
                 }
                 $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname;
                 $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
             } else {
                 $blog['author'] = '';
                 $blog['author_link'] = '';
             }
             $leading_blogs[$key] = $blog;
         }
         $image_w = (int) $config->get('listing_secondary_img_width', 390);
         $image_h = (int) $config->get('listing_secondary_img_height', 200);
         foreach ($secondary_blogs as $key => $blog) {
             $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
             if ($blog['id_employee']) {
                 if (!isset($authors[$blog['id_employee']])) {
                     # validate module
                     $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
                 }
                 $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname;
                 $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
             } else {
                 $blog['author'] = '';
                 $blog['author_link'] = '';
             }
             $secondary_blogs[$key] = $blog;
         }
         $nb_blogs = $count;
         $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;
         }
         $params = array('rewrite' => $category->link_rewrite, 'id' => $category->id_leoblogcat);
         /* breadcrumb */
         $r = $helper->getPaginationLink('module-leoblog-category', 'category', $params, false, true);
         $path = '';
         $all_cats = array();
         self::parentCategories($category, $all_cats);
         foreach ($all_cats as $key => $cat) {
             if ($cat->id == 1) {
                 # validate module
                 $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>';
             } elseif (count($all_cats) - 1 == $key) {
                 # validate module
                 $path .= $cat->title;
             } else {
                 $params = array('rewrite' => $cat->link_rewrite, 'id' => $cat->id);
                 $path .= '<a href="' . $helper->getBlogCatLink($params) . '">' . htmlentities($cat->title, ENT_NOQUOTES, 'UTF-8') . '</a><span class="navigation-pipe">' . Configuration::get('PS_NAVIGATION_PIPE') . '</span>';
             }
         }
         /* sub categories */
         $categories = $category->getChild($category->id_leoblogcat, $this->context->language->id);
         $childrens = array();
         if ($categories) {
             foreach ($categories as $child) {
                 $params = array('rewrite' => $child['link_rewrite'], 'id' => $child['id_leoblogcat']);
                 $child['thumb'] = _LEOBLOG_BLOG_IMG_URI_ . 'c/' . $child['image'];
                 $child['category_link'] = $helper->getBlogCatLink($params);
                 $childrens[] = $child;
             }
         }
         $this->context->smarty->assign(array('leading_blogs' => $leading_blogs, 'secondary_blogs' => $secondary_blogs, 'listing_leading_column' => $config->get('listing_leading_column', 1), 'listing_secondary_column' => $config->get('listing_secondary_column', 3), 'module_tpl' => $this->template_path, 'config' => $config, 'range' => $range, 'category' => $category, 'start' => $start, 'childrens' => $childrens, 'stop' => $stop, 'path' => $path, 'pages_nb' => $pages_nb, 'nb_items' => $count, 'p' => (int) $p, 'n' => (int) $n, 'meta_title' => Tools::ucfirst($category->title) . ' - ' . $this->context->shop->name, 'meta_keywords' => $category->meta_keywords, 'meta_description' => $category->meta_description, 'requestPage' => $r['requestUrl'], 'requestNb' => $r, 'category' => $category));
     } else {
         $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>';
         $this->context->smarty->assign(array('active' => '0', 'path' => $path, 'leading_blogs' => array(), 'secondary_blogs' => array(), 'controller' => 'category', 'category' => $category));
     }
     $this->setTemplate($template . '/category.tpl');
 }
Beispiel #3
0
 public function hookRightColumn($params)
 {
     if (file_exists(_PS_MODULE_DIR_ . 'leoblog/classes/config.php')) {
         $this->isInstalled = true;
         require_once _PS_MODULE_DIR_ . 'leoblog/loader.php';
         $authors = array();
         $config = LeoBlogConfig::getInstance();
         $config->setVar('blockleo_blogs_height', Configuration::get('BLEOBLOGS_HEIGHT'));
         $config->setVar('blockleo_blogs_width', Configuration::get('BLEOBLOGS_WIDTH'));
         $config->setVar('blockleo_blogs_limit', Configuration::get('BLEOBLOGS_NBR'));
         $config->setVar('blockleo_blogs_page', Configuration::get('BLEOBLOGS_PAGE'));
         $config->setVar('blockleo_blogs_col', Configuration::get('BLEOBLOGS_COL'));
         $config->setVar('blockleo_blogs_intv', Configuration::get('BLEOBLOGS_INTV'));
         $config->setVar('blockleo_blogs_show', Configuration::get('BLEOBLOGS_SHOW'));
         $config->setVar('blockleo_blogs_des', Configuration::get('BLEOBLOGS_SDES'));
         $config->setVar('blockleo_blogs_img', Configuration::get('BLEOBLOGS_SIMA'));
         $config->setVar('blockleo_blogs_aut', Configuration::get('BLEOBLOGS_SAUT'));
         $config->setVar('blockleo_blogs_cat', Configuration::get('BLEOBLOGS_SCAT'));
         $config->setVar('blockleo_blogs_cre', Configuration::get('BLEOBLOGS_SCRE'));
         $config->setVar('blockleo_blogs_cout', Configuration::get('BLEOBLOGS_SCOUN'));
         $config->setVar('blockleo_blogs_title', Configuration::get('BLEOBLOGS_STITLE'));
         $config->setVar('blockleo_blogs_hits', Configuration::get('BLEOBLOGS_SHITS'));
         $limit = (int) $config->get('blockleo_blogs_limit', 6);
         $blogs = LeoBlogBlog::getListBlogs(null, $this->context->language->id, 0, $limit, 'date_add', 'DESC', array(), true);
         $helper = LeoBlogHelper::getInstance();
         $image_w = (int) $config->get('blockleo_blogs_width', 690);
         $image_h = (int) $config->get('blockleo_blogs_height', 300);
         $link = LeoBlogHelper::getInstance()->getFontBlogLink();
         foreach ($blogs as $key => $blog) {
             $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
             if ($blog['id_employee']) {
                 if (!isset($authors[$blog['id_employee']])) {
                     $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
                 }
                 $blog['author'] = $authors[$blog['id_employee']]->firstname . " " . $authors[$blog['id_employee']]->lastname;
                 $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
             } else {
                 $blog['author'] = '';
                 $blog['author_link'] = '';
             }
             $blogs[$key] = $blog;
         }
         $itemsperpage = (int) $config->get('blockleo_blogs_page', 3);
         $columnspage = (int) $config->get('blockleo_blogs_col', 3);
         //			$interval = (int)$config->get( 'blockleo_blogs_inteval', 8000 );
         $interval = (int) Configuration::get('BLEOBLOGS_INTV');
         $this->smarty->assign('view_all_link', $link);
         $this->smarty->assign('blogs', $blogs);
         $this->smarty->assign('config', $config);
         $this->smarty->assign(array('itemsperpage' => $itemsperpage, 'columnspage' => $columnspage, 'scolumn' => 12 / $columnspage, 'interval' => $interval));
         $this->context->controller->addCSS($this->_path . 'blogcarousel.css', 'all');
         return $this->display(__FILE__, 'blockleoblogs.tpl');
     } else {
         return;
     }
 }
Beispiel #4
0
 public function hookRightColumn($params)
 {
     # validate module
     unset($params);
     if (file_exists(_PS_MODULE_DIR_ . 'leoblog/classes/config.php')) {
         $this->is_installed = true;
         require_once _PS_MODULE_DIR_ . 'leoblog/loader.php';
         $authors = array();
         $config = LeoBlogConfig::getInstance();
         $config->setVar('blockleo_blogs_height', Configuration::get('BLEOBLOGS_HEIGHT'));
         $config->setVar('blockleo_blogs_width', Configuration::get('BLEOBLOGS_WIDTH'));
         $config->setVar('blockleo_blogs_limit', Configuration::get('BLEOBLOGS_NBR'));
         $config->setVar('blockleo_blogs_page', Configuration::get('BLEOBLOGS_PAGE'));
         $config->setVar('blockleo_blogs_col', Configuration::get('BLEOBLOGS_COL'));
         $config->setVar('blockleo_blogs_intv', Configuration::get('BLEOBLOGS_INTV'));
         $config->setVar('blockleo_blogs_show', Configuration::get('BLEOBLOGS_SHOW'));
         $config->setVar('blockleo_blogs_des', Configuration::get('BLEOBLOGS_SDES'));
         $config->setVar('blockleo_blogs_img', Configuration::get('BLEOBLOGS_SIMA'));
         $config->setVar('blockleo_blogs_aut', Configuration::get('BLEOBLOGS_SAUT'));
         $config->setVar('blockleo_blogs_cat', Configuration::get('BLEOBLOGS_SCAT'));
         $config->setVar('blockleo_blogs_cre', Configuration::get('BLEOBLOGS_SCRE'));
         $config->setVar('blockleo_blogs_cout', Configuration::get('BLEOBLOGS_SCOUN'));
         $config->setVar('blockleo_blogs_title', Configuration::get('BLEOBLOGS_STITLE'));
         $config->setVar('blockleo_blogs_hits', Configuration::get('BLEOBLOGS_SHITS'));
         $limit = (int) $config->get('blockleo_blogs_limit', 6);
         $blogs = LeoBlogBlog::getListBlogs(null, $this->context->language->id, 0, $limit, 'id_leoblog_blog', 'DESC', array(), true);
         $helper = LeoBlogHelper::getInstance();
         $image_w = (int) $config->get('blockleo_blogs_width', 690);
         $image_h = (int) $config->get('blockleo_blogs_height', 300);
         $link = LeoBlogHelper::getInstance()->getFontBlogLink();
         foreach ($blogs as $key => $blog) {
             $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
             if ($blog['id_employee']) {
                 if (!isset($authors[$blog['id_employee']])) {
                     # validate
                     $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
                 }
                 $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname;
                 $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
             } else {
                 $blog['author'] = '';
                 $blog['author_link'] = '';
             }
             $is_https = array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on' ? 1 : 0;
             if ($is_https == 1) {
                 $blog['preview_url'] = preg_replace('/^http:/i', 'https:', $blog['preview_url']);
                 $blog['image_url'] = preg_replace('/^http:/i', 'https:', $blog['image_url']);
             }
             $blogs[$key] = $blog;
         }
         $itemsperpage = (int) $config->get('blockleo_blogs_page', 3);
         $columnspage = (int) $config->get('blockleo_blogs_col', 3);
         //			$interval = (int)$config->get( 'blockleo_blogs_inteval', 8000 );
         $interval = (int) Configuration::get('BLEOBLOGS_INTV');
         $this->smarty->assign('view_all_link', $link);
         $this->smarty->assign('blogs', $blogs);
         $this->smarty->assign('config', $config);
         $this->smarty->assign('tab', 'blockleoblogs_' . rand(20, rand()));
         $mytab = 'blockleoblogs' . rand(20, rand());
         $this->smarty->assign('mytab', $mytab);
         $this->smarty->assign(array('itemsperpage' => $itemsperpage, 'columnspage' => $columnspage, 'scolumn' => 12 / $columnspage, 'interval' => $interval));
         $data = BlockleoblogsModel::getParamOwlCarousel();
         $data['owl_rtl'] = $this->context->language->is_rtl;
         if (file_exists(_PS_THEME_DIR_ . 'modules/blockleoblogs/blockleoblogs.tpl')) {
             $file_name = 'blockleoblogs.tpl';
         } else {
             $file_name = 'views/templates/front/blockleoblogs.tpl';
         }
         if (isset($data['carousel_type']) && $data['carousel_type'] == LeoblogOwlCarousel::CAROUSEL_OWL) {
             $this->smarty->assign($data);
             if (file_exists(_PS_THEME_DIR_ . 'modules/blockleoblogs/blockleoblogs_owl.tpl')) {
                 $file_name = 'blockleoblogs_owl.tpl';
             } else {
                 $file_name = 'views/templates/front/blockleoblogs_owl.tpl';
             }
         }
         return $this->display(__FILE__, $file_name);
     } else {
         # validate module
         return;
     }
 }
 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();
 }
 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 &lt;&gt;;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'default' => '', 'lang' => true, 'desc' => array($this->l('Invalid characters:') . ' &lt;&gt;;=#{}', $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();
 }
Beispiel #7
0
 }
 # Get data
 $authors = array();
 $config = LeoBlogConfig::getInstance();
 $enbrss = (int) $config->get('indexation', 0);
 if ($enbrss != 1) {
     exit;
 }
 $config->setVar('blockleo_blogs_height', Configuration::get('BLEOBLOGS_HEIGHT'));
 $config->setVar('blockleo_blogs_width', Configuration::get('BLEOBLOGS_WIDTH'));
 $config->setVar('blockleo_blogs_limit', Configuration::get('BLEOBLOGS_NBR'));
 $limit = (int) $config->get('rss_limit_item', 4);
 $helper = LeoBlogHelper::getInstance();
 $image_w = (int) $config->get('blockleo_blogs_width', 690);
 $image_h = (int) $config->get('blockleo_blogs_height', 300);
 $blogs = LeoBlogBlog::getListBlogs(null, Context::getContext()->language->id, 0, $limit, 'id_leoblog_blog', 'DESC', array(), true);
 foreach ($blogs as $key => $blog) {
     $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
     if ($blog['id_employee']) {
         if (!isset($authors[$blog['id_employee']])) {
             # validate module
             $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
         }
         $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname;
         $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
     } else {
         $blog['author'] = '';
         $blog['author_link'] = '';
     }
     $blogs[$key] = $blog;
 }
Beispiel #8
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');
 }
Beispiel #9
0
 /**
  * Get lastest blog for ApPageBuilder module
  * @param type $params
  * @return type
  */
 public function getBlogsFont($params)
 {
     $config = LeoBlogConfig::getInstance();
     $id_categories = '';
     if (isset($params['chk_cat'])) {
         # validate module
         $id_categories = $params['chk_cat'];
     }
     $order_by = isset($params['order_by']) ? $params['order_by'] : 'id_leoblog_blog';
     $order_way = isset($params['order_way']) ? $params['order_way'] : 'DESC';
     $helper = LeoBlogHelper::getInstance();
     $limit = (int) $params['nb_blogs'];
     $blogs = LeoBlogBlog::getListBlogsForApPageBuilder($id_categories, $this->context->language->id, $limit, $order_by, $order_way, array(), true);
     $authors = array();
     $image_w = (int) $config->get('listing_leading_img_width', 690);
     $image_h = (int) $config->get('listing_leading_img_height', 300);
     foreach ($blogs as $key => &$blog) {
         $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
         if ($blog['id_employee']) {
             if (!isset($authors[$blog['id_employee']])) {
                 $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
             }
             $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname;
             $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
         } else {
             $blog['author'] = '';
             $blog['author_link'] = '';
         }
         unset($key);
         # validate module
     }
     return $blogs;
 }
Beispiel #10
0
 public function delete()
 {
     if ($this->id == 1) {
         return false;
     }
     $this->clearCache();
     // Get children categories
     $to_delete = array((int) $this->id);
     $this->recursiveDelete($to_delete, (int) $this->id);
     $to_delete = array_unique($to_delete);
     // Delete CMS Category and its child from database
     $list = count($to_delete) > 1 ? implode(',', $to_delete) : (int) $this->id;
     //delete blog
     //get all blog from category ID
     //$where   = '`id_leoblogcat` IN (' . $list . ')';
     $result_blog = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT `id_leoblog_blog` as id FROM `' . _DB_PREFIX_ . 'leoblog_blog` WHERE `id_leoblogcat` IN (' . $list . ')');
     foreach ($result_blog as $value) {
         $blog = new LeoBlogBlog($value['id']);
         $blog->delete();
     }
     Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'leoblogcat` WHERE `id_leoblogcat` IN (' . $list . ')');
     Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'leoblogcat_shop` WHERE `id_leoblogcat` IN (' . $list . ')');
     Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'leoblogcat_lang` WHERE `id_leoblogcat` IN (' . $list . ')');
     leoblogcat::cleanPositions($this->id_parent);
     return true;
 }
Beispiel #11
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $config = LeoBlogConfig::getInstance();
     $authors = array();
     /* Load Css and JS File */
     LeoBlogHelper::loadMedia($this->context, $this);
     parent::initContent();
     $helper = LeoBlogHelper::getInstance();
     $limit_leading_blogs = (int) $config->get('listing_leading_limit_items', 1);
     $limit_secondary_blogs = (int) $config->get('listing_secondary_limit_items', 6);
     //$latest_limit_items = (int)$config->get( 'latest_limit_items', 20 );
     $author = (int) Tools::getValue('author');
     $tag = trim(Tools::getValue('tag'));
     $n = (int) $limit_leading_blogs + (int) $limit_secondary_blogs;
     $p = abs((int) Tools::getValue('p', 1));
     $template = $config->get('template', 'default');
     $this->template_path .= $template . '/';
     $condition = array();
     if ($author) {
         $condition = array('type' => 'author', 'id_employee' => $author, 'employee' => new Employee($author));
         $r = $helper->getPaginationLink('module-leoblog-list', 'list', array('author' => $author));
     }
     if ($tag) {
         $condition = array('type' => 'tag', 'tag' => urldecode($tag));
         $r = $helper->getPaginationLink('module-leoblog-list', 'list', array('tag' => $tag));
     }
     $blogs = LeoBlogBlog::getListBlogs(null, $this->context->language->id, $p, $n, 'id_leoblog_blog', 'DESC', $condition, true);
     $count = LeoBlogBlog::countBlogs(null, $this->context->language->id, $condition, true);
     $leading_blogs = array();
     $secondary_blogs = array();
     //		$links 	   		 =  array();
     if (count($blogs)) {
         $leading_blogs = array_slice($blogs, 0, $limit_leading_blogs);
         $secondary_blogs = array_splice($blogs, $limit_leading_blogs, count($blogs));
     }
     $image_w = (int) $config->get('listing_leading_img_width', 690);
     $image_h = (int) $config->get('listing_leading_img_height', 300);
     foreach ($leading_blogs as $key => $blog) {
         $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
         if ($blog['id_employee']) {
             if (!isset($authors[$blog['id_employee']])) {
                 # validate module
                 $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
             }
             $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname;
             $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
         } else {
             $blog['author'] = '';
             $blog['author_link'] = '';
         }
         $leading_blogs[$key] = $blog;
     }
     $image_w = (int) $config->get('listing_secondary_img_width', 390);
     $image_h = (int) $config->get('listing_secondary_img_height', 200);
     foreach ($secondary_blogs as $key => $blog) {
         $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config);
         if ($blog['id_employee']) {
             if (!isset($authors[$blog['id_employee']])) {
                 # validate module
                 $authors[$blog['id_employee']] = new Employee($blog['id_employee']);
             }
             $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname;
             $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
         } else {
             $blog['author'] = '';
             $blog['author_link'] = '';
         }
         $secondary_blogs[$key] = $blog;
     }
     $module_tpl = $this->template_path;
     //$nbBlogs = $count > $latest_limit_items?$latest_limit_items:$count;
     $nb_blogs = $count;
     $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;
     }
     if (!isset($r)) {
         $r = $helper->getPaginationLink('module-leoblog-list', 'list', array(), false, true);
     }
     $module_tpl = $this->template_path;
     /* breadcrumb */
     $path = '<a href="' . $helper->getFontBlogLink() . '">' . htmlentities($config->get('blog_link_title_' . $this->context->language->id, 'Blog'), ENT_NOQUOTES, 'UTF-8') . '</a>';
     $this->context->smarty->assign(array('leading_blogs' => $leading_blogs, 'secondary_blogs' => $secondary_blogs, 'listing_leading_column' => $config->get('listing_leading_column', 1), 'listing_secondary_column' => $config->get('listing_secondary_column', 3), 'filter' => $condition, 'module_tpl' => $module_tpl, 'nb_items' => $count, 'range' => $range, 'path' => $path, 'start' => $start, 'stop' => $stop, 'pages_nb' => $pages_nb, 'config' => $config, 'p' => (int) $p, 'n' => (int) $n, 'meta_title' => $config->get('meta_title_' . Context::getContext()->language->id) . ' - ' . $this->context->shop->name, 'meta_keywords' => $config->get('meta_keywords_' . Context::getContext()->language->id), 'meta_description' => $config->get('meta_description_' . Context::getContext()->language->id), 'requestPage' => $r['requestUrl'], 'requestNb' => $r, 'controller' => 'latest'));
     $this->setTemplate($template . '/listing.tpl');
 }