コード例 #1
1
 public static function getPost($id_post, $id_lang = null)
 {
     $result = array();
     if ($id_lang == null) {
         $id_lang = (int) Context::getContext()->language->id;
     }
     preg_match('/^[\\d]+/', $id_post, $id_post);
     $id_post = $id_post[0];
     $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_post p INNER JOIN 
             ' . _DB_PREFIX_ . 'smart_blog_post_lang pl ON p.id_smart_blog_post=pl.id_smart_blog_post INNER JOIN 
             ' . _DB_PREFIX_ . 'smart_blog_post_shop ps ON pl.id_smart_blog_post = ps.id_smart_blog_post 
             WHERE pl.id_lang=' . $id_lang . '
             AND p.active= 1 AND p.id_smart_blog_post = ' . $id_post;
     if (!($post = Db::getInstance()->executeS($sql))) {
         return false;
     }
     $result['id_post'] = $post[0]['id_smart_blog_post'];
     $result['meta_title'] = $post[0]['meta_title'];
     $result['meta_description'] = $post[0]['meta_description'];
     $result['short_description'] = $post[0]['short_description'];
     $result['meta_keyword'] = $post[0]['meta_keyword'];
     if (Module::isEnabled('smartshortcode') == 1 && Module::isInstalled('smartshortcode') == 1) {
         require_once _PS_MODULE_DIR_ . 'smartshortcode/smartshortcode.php';
         $smartshortcode = new SmartShortCode();
         $result['content'] = $smartshortcode->parse($post[0]['content']);
     } else {
         $result['content'] = $post[0]['content'];
     }
     $result['active'] = $post[0]['active'];
     $result['created'] = $post[0]['created'];
     $result['comment_status'] = $post[0]['comment_status'];
     $result['viewed'] = $post[0]['viewed'];
     $result['is_featured'] = $post[0]['is_featured'];
     $result['post_type'] = $post[0]['post_type'];
     $result['id_category'] = $post[0]['id_category'];
     $employee = new Employee($post[0]['id_author']);
     $result['id_author'] = $post[0]['id_author'];
     $result['lastname'] = $employee->lastname;
     $result['firstname'] = $employee->firstname;
     $result['youtube'] = $post[0]['youtube'];
     if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $post[0]['id_smart_blog_post'] . '.jpg')) {
         $image = $post[0]['id_smart_blog_post'] . '.jpg';
         $result['post_img'] = $image;
     } else {
         $result['post_img'] = NULL;
     }
     return $result;
 }
コード例 #2
0
ファイル: single.php プロジェクト: evgrishin/se1614
 public function initContent()
 {
     $this->context->controller->addJqueryPlugin('cooki-plugin');
     $this->context->controller->addJqueryPlugin('cookie-plugin');
     $this->context->controller->addjqueryPlugin('fancybox');
     $this->context->controller->addCSS(array(_THEME_CSS_DIR_ . 'category.css' => 'all', _THEME_CSS_DIR_ . 'product_list.css' => 'all'));
     parent::initContent();
     $this->SimpleBlogPost->increaseViewsNb();
     /**
     
             Support for SmartShortcode module from CodeCanyon
     
             **/
     if (file_exists(_PS_MODULE_DIR_ . 'smartshortcode/smartshortcode.php')) {
         require_once _PS_MODULE_DIR_ . 'smartshortcode/smartshortcode.php';
     }
     if (Module::isEnabled('smartshortcode')) {
         $smartshortcode = new SmartShortCode();
         $this->SimpleBlogPost->content = $smartshortcode->parse($this->SimpleBlogPost->content);
     }
     $this->context->smarty->assign('post', $this->SimpleBlogPost);
     $this->context->smarty->assign('is_16', version_compare(_PS_VERSION_, '1.6.0', '>=') === true ? true : false);
     $this->context->smarty->assign('gallery_dir', _MODULE_DIR_ . 'ph_simpleblog/galleries/');
     // Comments
     if ($this->SimpleBlogPost->allow_comments == 1) {
         $allow_comments = true;
     } elseif ($this->SimpleBlogPost->allow_comments == 2) {
         $allow_comments = false;
     } elseif ($this->SimpleBlogPost->allow_comments == 3) {
         $allow_comments = Configuration::get('PH_BLOG_COMMENT_ALLOW');
     } else {
         $allow_comments = false;
     }
     $this->context->smarty->assign('allow_comments', $allow_comments);
     if ($allow_comments) {
         $comments = SimpleBlogComment::getComments($this->SimpleBlogPost->id_simpleblog_post);
         $this->context->smarty->assign('comments', $comments);
     }
     if (Configuration::get('PH_BLOG_DISPLAY_RELATED')) {
         $related_products = SimpleBlogPost::getRelatedProducts($this->SimpleBlogPost->id_product);
         $this->context->smarty->assign('related_products', $related_products);
     }
     $this->setTemplate('single.tpl');
 }
コード例 #3
0
ファイル: SmartBlogPost.php プロジェクト: johnulist/smartblog
 public static function getPost($id_post, $id_lang = null)
 {
     $result = array();
     if ($id_lang == null) {
         $id_lang = (int) Context::getContext()->language->id;
     }
     $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_post p INNER JOIN 
             ' . _DB_PREFIX_ . 'smart_blog_post_lang pl ON p.id_smart_blog_post=pl.id_smart_blog_post INNER JOIN 
             ' . _DB_PREFIX_ . 'smart_blog_post_shop ps ON pl.id_smart_blog_post = ps.id_smart_blog_post 
             WHERE pl.id_lang=' . $id_lang . '
             AND p.active= 1 AND p.id_smart_blog_post = ' . $id_post;
     if (!($post = Db::getInstance()->executeS($sql))) {
         return false;
     }
     $result['id_post'] = $post[0]['id_smart_blog_post'];
     $result['meta_title'] = $post[0]['meta_title'];
     $result['meta_description'] = $post[0]['meta_description'];
     $result['short_description'] = $post[0]['short_description'];
     $result['meta_keyword'] = $post[0]['meta_keyword'];
     $result['link_rewrite'] = $post[0]['link_rewrite'];
     if (Module::isEnabled('smartshortcode') == 1 && Module::isInstalled('smartshortcode') == 1) {
         require_once _PS_MODULE_DIR_ . 'smartshortcode/smartshortcode.php';
         $smartshortcode = new SmartShortCode();
         $result['content'] = $smartshortcode->parse($post[0]['content']);
     } else {
         $result['content'] = $post[0]['content'];
     }
     if (Module::isInstalled('jscomposer') && Module::isEnabled('jscomposer')) {
         require_once _PS_MODULE_DIR_ . 'jscomposer/jscomposer.php';
         $result['content'] = JsComposer::do_shortcode($result['content']);
     }
     $result['active'] = $post[0]['active'];
     $result['created'] = $post[0]['created'];
     $result['comment_status'] = $post[0]['comment_status'];
     $result['viewed'] = $post[0]['viewed'];
     $result['is_featured'] = $post[0]['is_featured'];
     $result['post_type'] = $post[0]['post_type'];
     $result['id_category'] = $post[0]['id_category'];
     $employee = new Employee($post[0]['id_author']);
     $result['lastname'] = $employee->lastname;
     $result['firstname'] = $employee->firstname;
     if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $post[0]['id_smart_blog_post'] . '.jpg')) {
         $image = $post[0]['id_smart_blog_post'] . '.jpg';
         $result['post_img'] = $image;
     } else {
         $result['post_img'] = NULL;
     }
     //            post format code
     $post_format = $post[0]['post_type'];
     $result['post_format'] = $post_format;
     if (isset(smartblog::$post_meta_fields[$post_format]) && !empty(smartblog::$post_meta_fields[$post_format])) {
         $importMetadata = array();
         foreach (smartblog::$post_meta_fields[$post_format] as $meta) {
             $meta_key = "{$post_format}-{$meta['name']}";
             $id_lang = null;
             if (isset($meta['lang']) && $meta['lang']) {
                 $id_lang = Context::getContext()->language->id;
             }
             $importMetadata[$meta_key] = BlogPostMeta::get((int) $post[0]['id_smart_blog_post'], $meta_key, false, $id_lang);
         }
         $result['post_format_data'] = $importMetadata;
     }
     return $result;
 }