コード例 #1
0
ファイル: ph_recentposts.php プロジェクト: evgrishin/se1614
 public function preparePosts($nb = 4, $cat = null)
 {
     $featured = false;
     if ($cat == 9999) {
         $cat = 0;
         $featured = true;
     }
     if (!Module::isInstalled('ph_simpleblog') || !Module::isEnabled('ph_simpleblog')) {
         return false;
     }
     if (!isset($nb) || !isset($cat)) {
         return false;
     }
     require_once _PS_MODULE_DIR_ . 'ph_simpleblog/models/SimpleBlogPost.php';
     $id_lang = $this->context->language->id;
     $posts = SimpleBlogPost::getPosts($id_lang, $nb, $cat, null, true, 'sbp.date_add', 'DESC', null, $featured);
     return $posts;
 }
コード例 #2
0
ファイル: ph_relatedposts.php プロジェクト: evgrishin/se1614
 /**
 Front end
 */
 public function _prepareRelatedPosts()
 {
     if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'product') {
         return false;
     }
     $id_product = Tools::getValue('id_product', 0);
     $related_posts = array();
     $relatedPosts = SimpleBlogRelatedPost::getByProductId((int) $id_product);
     if (sizeof($relatedPosts) < 1) {
         return false;
     }
     foreach ($relatedPosts as $key => $post) {
         $related_posts[] = $post['id_simpleblog_post'];
     }
     return SimpleBlogPost::getPosts($this->context->language->id, 999, null, null, true, false, false, null, false, false, null, 'IN', $related_posts);
 }
コード例 #3
0
 public function preparePosts($nb = 6, $from = null)
 {
     $featured = false;
     $order_by = 'sbp.date_add';
     if ($from == 'featured') {
         $from = null;
         $featured = true;
     } elseif ($from == 'recent') {
         $from = null;
     } elseif ($from == 'viewed') {
         $from = null;
         $order_by = 'sbp.views';
     } elseif ($from == 'liked') {
         $from = null;
         $order_by = 'sbp.likes';
     } else {
         $from = (int) $from;
     }
     if (!Module::isInstalled('ph_simpleblog') || !Module::isEnabled('ph_simpleblog')) {
         return false;
     }
     require_once _PS_MODULE_DIR_ . 'ph_simpleblog/models/SimpleBlogPost.php';
     $id_lang = $this->context->language->id;
     $posts = SimpleBlogPost::getPosts($id_lang, (int) $nb, $from, null, true, $order_by, 'DESC', null, (bool) $featured);
     return $posts;
 }
コード例 #4
0
 public function hookDisplaySimpleBlogPosts($params)
 {
     return;
     $id_lang = $this->context->language->id;
     $posts = SimpleBlogPost::getPosts($id_lang, 5);
     $this->smarty->assign('posts', $posts);
     return $this->display(__FILE__, 'home.tpl');
 }
コード例 #5
0
ファイル: list.php プロジェクト: evgrishin/se1614
 public function initContent()
 {
     $id_lang = Context::getContext()->language->id;
     parent::initContent();
     $this->context->smarty->assign('is_16', (bool) (version_compare(_PS_VERSION_, '1.6.0', '>=') === true));
     $gridType = Configuration::get('PH_BLOG_COLUMNS');
     $gridColumns = Configuration::get('PH_BLOG_GRID_COLUMNS');
     $blogLayout = Configuration::get('PH_BLOG_LIST_LAYOUT');
     $gridHtmlCols = '';
     if ($blogLayout == 'full') {
         $gridHtmlCols = 'ph_col';
     }
     $this->context->smarty->assign(array('categories' => SimpleBlogCategory::getCategories($id_lang), 'latest_posts' => SimpleBlogPost::getPosts($id_lang, 5), 'blogMainTitle' => Configuration::get('PH_BLOG_MAIN_TITLE', $id_lang), 'grid' => Configuration::get('PH_BLOG_COLUMNS'), 'columns' => $gridColumns, 'gridHtmlCols' => $gridHtmlCols, 'blogLayout' => $blogLayout, 'module_dir' => _MODULE_DIR_ . 'ph_simpleblog/', 'tpl_path' => _PS_MODULE_DIR_ . 'ph_simpleblog/views/templates/front/', 'gallery_dir' => _MODULE_DIR_ . 'ph_simpleblog/galleries/'));
     $page = Tools::getValue('p', 0);
     // How many posts?
     $this->posts_per_page = Configuration::get('PH_BLOG_POSTS_PER_PAGE');
     // Is blog category, author or something else?
     $this->context->smarty->assign('is_category', false);
     $this->context->smarty->assign('is_search', false);
     // Category things
     if ($this->sb_category != '') {
         $this->context->smarty->assign('is_category', true);
         $SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, $id_lang);
         // Category not found so now we looking for categories in same rewrite but other languages and if we found then we redirect 301
         if (!Validate::isLoadedObject($SimpleBlogCategory)) {
             $SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, false);
             if (Validate::isLoadedObject($SimpleBlogCategory)) {
                 $SimpleBlogCategory = new SimpleBlogCategory($SimpleBlogCategory->id, $id_lang);
                 header('HTTP/1.1 301 Moved Permanently');
                 header('Location: ' . SimpleBlogCategory::getLink($SimpleBlogCategory->link_rewrite));
             } else {
                 header('HTTP/1.1 404 Not Found');
                 header('Status: 404 Not Found');
                 Tools::redirect($this->context->link->getPageLink('404'));
             }
         }
         if ($SimpleBlogCategory->id_parent > 0) {
             $parent = new SimpleBlogCategory($SimpleBlogCategory->id_parent, $id_lang);
             $this->context->smarty->assign('parent_category', $parent);
         }
         // @todo: More flexible
         if ($SimpleBlogCategory->meta_title != '') {
             $meta_title = $SimpleBlogCategory->meta_title;
         } else {
             $meta_title = $SimpleBlogCategory->name . ' - ' . $this->module->l('Blog');
         }
         if (!empty($SimpleBlogCategory->meta_description)) {
             $this->context->smarty->assign('meta_description', $SimpleBlogCategory->meta_description);
         }
         if (!empty($SimpleBlogCategory->meta_keywords)) {
             $this->context->smarty->assign('meta_keywords', $SimpleBlogCategory->meta_keywords);
         }
         if ($page > 1) {
             $meta_title .= ' (' . $page . ')';
         }
         $this->context->smarty->assign('meta_title', $meta_title);
         $posts = SimpleBlogPost::getPosts($id_lang, $this->posts_per_page, $SimpleBlogCategory->id, $page);
         $this->assignPagination($this->posts_per_page, sizeof(SimpleBlogPost::getPosts($id_lang, null, $SimpleBlogCategory->id)));
         $this->context->smarty->assign('blogCategory', $SimpleBlogCategory);
         $this->context->smarty->assign('posts', $posts);
         $this->context->smarty->assign('category_rewrite', $SimpleBlogCategory->link_rewrite);
         //$this->setTemplate('list-category.tpl');
     } elseif ($this->is_search) {
         // @todo: complete refactoring "authors" to 2.0.0
         // Posts by author
         $this->context->smarty->assign('is_search', true);
         // echo SimpleBlogPost::getSearchLink('author', 'kpodemski', $id_lang);
         // @todo: meta titles, blog title, specific layout
         switch ($this->simpleblog_search) {
             case 'author':
                 break;
             case 'tag':
                 break;
         }
         $this->context->smarty->assign('meta_title', $this->l('Posts by', 'list') . ' ' . $this->simpleblog_author . ' - ' . $this->l('Blog', 'list'));
         $posts = SimpleBlogPost::findPosts($this->simpleblog_search, $this->simpleblog_keyword, $id_lang, $this->posts_per_page, $page);
         $this->assignPagination($this->posts_per_page, sizeof(SimpleBlogPost::findPosts($this->simpleblog_search, $this->simpleblog_keyword, $id_lang)));
         $this->context->smarty->assign('posts', $posts);
     } else {
         // Home things
         $posts = SimpleBlogPost::getPosts($id_lang, $this->posts_per_page, null, $page);
         $this->assignPagination($this->posts_per_page, sizeof(SimpleBlogPost::getPosts($id_lang, null)));
         // @todo: More flexible
         $meta_title = Configuration::get('PH_BLOG_MAIN_TITLE', Context::getContext()->language->id) ? Configuration::get('PH_BLOG_MAIN_TITLE', Context::getContext()->language->id) : Configuration::get('PS_SHOP_NAME') . ' - Blog';
         $meta_description = Configuration::get('PH_BLOG_MAIN_META_DESCRIPTION', Context::getContext()->language->id) ? Configuration::get('PH_BLOG_MAIN_META_DESCRIPTION', Context::getContext()->language->id) : '';
         if ($page > 1) {
             $meta_title .= ' (' . $page . ')';
         }
         $this->context->smarty->assign('meta_title', $meta_title);
         $this->context->smarty->assign('meta_description', $meta_description);
         $this->context->smarty->assign('posts', $posts);
     }
     $this->setTemplate('list.tpl');
 }
コード例 #6
0
ファイル: list.php プロジェクト: OaSiis/LDDP
 public function initContent()
 {
     $sidebar = Configuration::get('PH_BLOG_LAYOUT');
     if ($sidebar == 'left_sidebar') {
         $this->display_column_left = true;
         $this->display_column_right = false;
     } elseif ($sidebar == 'right_sidebar') {
         $this->display_column_left = false;
         $this->display_column_right = true;
     } elseif ($sidebar == 'full_width') {
         $this->display_column_left = false;
         $this->display_column_right = false;
     } else {
         $this->display_column_left = true;
         $this->display_column_right = true;
     }
     $id_lang = Context::getContext()->language->id;
     parent::initContent();
     $this->context->smarty->assign('is_16', (bool) (version_compare(_PS_VERSION_, '1.6.0', '>=') === true));
     $gridType = Configuration::get('PH_BLOG_COLUMNS');
     $gridColumns = Configuration::get('PH_BLOG_GRID_COLUMNS');
     $blogLayout = Configuration::get('PH_BLOG_LIST_LAYOUT');
     $gridHtmlCols = '';
     $mainTemplate = '';
     // First attempts to support 1.6
     if ($gridType == 'prestashop') {
         $gridHtmlCols = 'ph_col ph_col_' . $gridColumns;
     } elseif ($gridType == 'bootstrap') {
         $mainTemplate = '-bootstrap';
     }
     if ($blogLayout == 'full') {
         $gridHtmlCols = 'ph_col';
     }
     $this->context->smarty->assign(array('categories' => SimpleBlogCategory::getCategories($id_lang), 'latest_posts' => SimpleBlogPost::getPosts($id_lang, 5), 'blogMainTitle' => Configuration::get('PH_BLOG_MAIN_TITLE', $id_lang), 'columns' => $gridColumns, 'grid' => Configuration::get('PH_BLOG_COLUMNS'), 'gridHtmlCols' => $gridHtmlCols, 'module_dir' => _MODULE_DIR_ . 'ph_simpleblog/', 'blogLayout' => $blogLayout));
     $page = Tools::getValue('p', 0);
     // How many posts?
     $this->posts_per_page = Configuration::get('PH_BLOG_POSTS_PER_PAGE');
     // Is blog category, author or something else?
     $this->context->smarty->assign('is_category', false);
     $this->context->smarty->assign('is_search', false);
     // Category things
     if ($this->sb_category != '') {
         $this->context->smarty->assign('is_category', true);
         $SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, $id_lang);
         // Category not found so now we looking for categories in same rewrite but other languages and if we found then we redirect 301
         if (!Validate::isLoadedObject($SimpleBlogCategory)) {
             $SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, false);
             if (Validate::isLoadedObject($SimpleBlogCategory)) {
                 $SimpleBlogCategory = new SimpleBlogCategory($SimpleBlogCategory->id, $id_lang);
                 header('HTTP/1.1 301 Moved Permanently');
                 header('Location: ' . SimpleBlogCategory::getLink($SimpleBlogCategory->link_rewrite));
             }
         }
         // @todo: More flexible
         if ($SimpleBlogCategory->meta_title != '') {
             $meta_title = $SimpleBlogCategory->meta_title;
         } else {
             $meta_title = $SimpleBlogCategory->name . ' - Blog';
         }
         if (!empty($SimpleBlogCategory->meta_description)) {
             $this->context->smarty->assign('meta_description', $SimpleBlogCategory->meta_description);
         }
         if (!empty($SimpleBlogCategory->meta_keywords)) {
             $this->context->smarty->assign('meta_keywords', $SimpleBlogCategory->meta_keywords);
         }
         if ($page > 1) {
             $meta_title .= ' (' . $page . ')';
         }
         $this->context->smarty->assign('meta_title', $meta_title);
         $posts = SimpleBlogPost::getPosts($id_lang, $this->posts_per_page, $SimpleBlogCategory->id, $page);
         $this->assignPagination($this->posts_per_page, sizeof(SimpleBlogPost::getPosts($id_lang, null, $SimpleBlogCategory->id)));
         $this->context->smarty->assign('blogCategory', $SimpleBlogCategory);
         $this->context->smarty->assign('posts', $posts);
         $this->context->smarty->assign('category_rewrite', $SimpleBlogCategory->link_rewrite);
         //$this->setTemplate('list-category.tpl');
     } elseif ($this->is_search) {
         $this->context->smarty->assign('is_search', true);
         // echo SimpleBlogPost::getSearchLink('author', 'kpodemski', $id_lang);
         // @todo: meta titles, blog title, specific layout
         switch ($this->simpleblog_search) {
             case 'author':
                 break;
             case 'tag':
                 break;
         }
         $this->context->smarty->assign('meta_title', $this->l('Posts by') . ' ' . $this->simpleblog_author . ' - Blog');
         $posts = SimpleBlogPost::findPosts($this->simpleblog_search, $this->simpleblog_keyword, $id_lang, $this->posts_per_page, $page);
         $this->assignPagination($this->posts_per_page, sizeof(SimpleBlogPost::findPosts($this->simpleblog_search, $this->simpleblog_keyword, $id_lang)));
         $this->context->smarty->assign('posts', $posts);
     } else {
         $posts = SimpleBlogPost::getPosts($id_lang, $this->posts_per_page, null, $page);
         $this->assignPagination($this->posts_per_page, sizeof(SimpleBlogPost::getPosts($id_lang)));
         // @todo: More flexible
         $meta_title = Configuration::get('PS_SHOP_NAME') . ' - Blog';
         if ($page > 1) {
             $meta_title .= ' (' . $page . ')';
         }
         $this->context->smarty->assign('meta_title', $meta_title);
         $this->context->smarty->assign('posts', $posts);
     }
     $this->setTemplate('list' . $mainTemplate . '.tpl');
 }