-
Notifications
You must be signed in to change notification settings - Fork 0
/
public.php
executable file
·109 lines (103 loc) · 3.87 KB
/
public.php
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
100
101
102
103
104
105
106
107
108
109
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of Magix CMS.
# Magix CMS, a CMS optimized for SEO
# Copyright (C) 2010 - 2011 Gerits Aurelien <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# -- END LICENSE BLOCK -----------------------------------
class plugins_homebrands_public extends plugins_homebrands_db {
/**
* @var frontend_model_template
*/
protected frontend_model_template $template;
protected frontend_model_data $data;
protected component_files_images $imagesComponent;
/**
* @var string $lang
*/
public string $lang;
/**
* @param ?frontend_model_template $t
*/
public function __construct(?frontend_model_template $t = null) {
$this->template = $t instanceof frontend_model_template ? $t : new frontend_model_template();
$this->data = new frontend_model_data($this,$this->template);
$this->lang = $this->template->lang;
}
/**
* Assign data to the defined variable or return the data
* @param string $type
* @param array|int|null $id
* @param ?string $context
* @param bool|string $assign
* @return mixed
*/
private function getItems(string $type, $id = null, ?string $context = null, $assign = true) {
return $this->data->getItems($type, $id, $context, $assign);
}
/**
* @return void
*/
private function initImageComponent(): void {
if(!isset($this->imagesComponent)) $this->imagesComponent = new component_files_images($this->template);
}
/**
* @param array $homebrands
* @throws Exception
*/
private function setHomeBrandsData(array $slides)
{
/*if(!empty($homebrands['img_slide'])) {
$this->initImageComponents();
$homebrands['img'] = $this->imagesComponent->setModuleImage('slideshow','slideshow', $homebrands['img_slide'], $homebrands['id_slide']);
}
return $homebrands;*/
$arr = [];
if(!empty($slides)) {
$this->initImageComponent();
foreach ($slides as $slide) {
$arr[$slide['id_slide']] = [
'id_slide' => $slide['id_slide'],
'id_lang' => $slide['id_lang'],
'title_slide' => $slide['title_slide'],
'desc_slide' => $slide['desc_slide'],
'link_slide' => [
'url' => $slide['url_slide'],
'label' => $slide['title_slide'],
'title' => $slide['title_slide']
],
'blank_slide' => $slide['blank_slide'],
'img' => $this->imagesComponent->setModuleImage('homebrands','homebrands',$slide['img_slide'],$slide['id_slide'])
];
}
}
return $arr;
}
/**
* @return mixed
* @throws Exception
*/
public function getHomeBrands(){
$homebrands = $this->getItems('homeSlides',['lang' => $this->lang],'all', false);
return $this->setHomeBrandsData($homebrands);
/*if(!empty($homebrands)) {
foreach ($homebrands as &$homebrand) {
$homebrand = $this->setHomeBrandsData($homebrand);
}
return $homebrands;
}*/
}
}