oct_blogarticle.php
3.09 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
<?php
/**
* @copyright OCTemplates
* @support https://octemplates.net/
* @license LICENSE.txt
*/
class ControllerExtensionModuleOCTBlogArticle extends Controller {
public function index($setting) {
if (!$this->config->get('oct_blogsettings_status')) {
return;
}
if ($this->registry->has('oct_mobiledetect')) {
if ($this->oct_mobiledetect->isMobile() && !$this->oct_mobiledetect->isTablet()) {
$data['oct_isMobile'] = $this->oct_mobiledetect->isMobile();
}
if ($this->oct_mobiledetect->isTablet()) {
$data['oct_isTablet'] = $this->oct_mobiledetect->isTablet();
}
}
static $module = 0;
$this->load->language('octemplates/module/oct_blogarticle');
$this->load->model('octemplates/blog/oct_blogarticle');
$this->load->model('octemplates/blog/oct_blogcategory');
$this->load->model('tool/image');
$data['position'] = isset($setting['position']) ? $setting['position'] : '';
$data['limit'] = $setting['limit'] ? $setting['limit'] : 8;
$data['articles'] = [];
$filter_data = array(
'filter_blogcategory_id' => isset($setting['blog_categories']) && !empty($setting['blog_categories']) ? $setting['blog_categories'] : '',
'sort' => $setting['sort'],
'order' => $setting['order'],
'start' => 0,
'limit' => $setting['limit'] ? $setting['limit'] : 8
);
$data['heading_title'] = (isset($setting['title'][(int)$this->config->get('config_language_id')]) && !empty($setting['title'][(int)$this->config->get('config_language_id')])) ? $setting['title'][(int)$this->config->get('config_language_id')] : $this->language->get('heading_title');
$results = $this->model_octemplates_blog_oct_blogarticle->getArticles($filter_data);
if ($results) {
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
// Get categories
$blog_category_badge = $this->model_octemplates_blog_oct_blogcategory->getBlogCategoryBadges($result['blogarticle_id']);
$description = !empty(trim(strip_tags($result['shot_description']))) ? $result['shot_description'] : $result['description'];
$data['articles'][] = array(
'blogarticle_id' => $result['blogarticle_id'],
'thumb' => $image,
'blog_categories' => $blog_category_badge,
'width' => $setting['width'],
'height' => $setting['height'],
'name' => $result['name'],
'description' => utf8_substr(trim(strip_tags(html_entity_decode($description, ENT_QUOTES, 'UTF-8'))), 0, $setting['limit_description']) . '..',
'date_added' => $this->load->controller('octemplates/main/oct_functions/OctDateTime', array($result['date_added'], 0)),
'href' => $this->url->link('octemplates/blog/oct_blogarticle', 'blogarticle_id=' . $result['blogarticle_id'])
);
}
$data['module'] = $module++;
if ($data['articles']) {
return $this->load->view('octemplates/module/oct_blogarticle', $data);
}
}
}
}