-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathBlogPostCategory.php
More file actions
executable file
·99 lines (87 loc) · 4.24 KB
/
BlogPostCategory.php
File metadata and controls
executable file
·99 lines (87 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class BlogPostCategory extends ObjectModel
{
public $id_smart_blog_post_category;
public $id_author;
public static $definition = array(
'table' => 'smart_blog_post_category',
'primary' => 'id_smart_blog_post_category',
'multilang' => false,
'fields' => array(
'id_smart_blog_post_category' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt'),
'id_smart_blog_category' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt')
),
);
public static function getToltalByCategory($id_lang, $id_category, $limit_start, $limit)
{
$result = array();
$sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_post_lang pl INNER JOIN
' . _DB_PREFIX_ . 'smart_blog_post p ON pl.id_smart_blog_post=p.id_smart_blog_post INNER JOIN
' . _DB_PREFIX_ . 'smart_blog_post_category pc ON p.id_smart_blog_post=pc.id_smart_blog_post
WHERE pl.id_lang=' . (int) $id_lang . ' and p.active = 1 AND pc.id_smart_blog_category = ' . (int) $id_category . '
ORDER BY p.id_smart_blog_post DESC LIMIT ' . (int) $limit_start . ',' . (int) $limit;
if (!$posts = Db::getInstance()->executeS($sql))
return false;
$context = Context::getContext();
$i = 0;
// $BlogCategory = new BlogCategory();
foreach ($posts as $post) {
$selected_cat = BlogCategory::getPostCategoriesFull((int) $post['id_smart_blog_post'], Context::getContext()->language->id);
$result[$i]['id_category'] = 1;
$result[$i]['cat_link_rewrite'] = '';
$result[$i]['cat_name'] = 'Home';
foreach ($selected_cat as $key => $value) {
$result[$i]['id_category'] = $selected_cat[$key]['id_category'];
$result[$i]['cat_link_rewrite'] = $selected_cat[$key]['link_rewrite'];
$result[$i]['cat_name'] = $selected_cat[$key]['name'];
}
$result[$i]['id_post'] = $post['id_smart_blog_post'];
$result[$i]['viewed'] = $post['viewed'];
//$result[$i]['name'] = $post['name'];
$result[$i]['meta_title'] = $post['meta_title'];
$result[$i]['meta_description'] = $post['meta_description'];
$result[$i]['short_description'] = $post['short_description'];
$result[$i]['content'] = $post['content'];
$result[$i]['meta_keyword'] = $post['meta_keyword'];
// $result[$i]['id_category'] = $post['id_category'];
$result[$i]['link_rewrite'] = $post['link_rewrite'];
// $result[$i]['cat_link_rewrite'] = $BlogCategory->getCatLinkRewrite($post['id_category']);
$employee = new Employee($post['id_author']);
$result[$i]['lastname'] = $employee->lastname;
$result[$i]['firstname'] = $employee->firstname;
if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $post['id_smart_blog_post'] . '.jpg')) {
$image = $post['id_smart_blog_post'];
$result[$i]['post_img'] = $image;
} else {
$result[$i]['post_img'] = 'no';
}
$result[$i]['created'] = $post['created'];
$i++;
}
return $result;
}
}