Ejemplo n.º 1
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');
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
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');
 }