1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Oledrion; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* oledrion |
17
|
|
|
* |
18
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
19
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
20
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com/) |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
use XoopsModules\Oledrion; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Gestion des fabricants |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class ManufacturerHandler |
31
|
|
|
*/ |
32
|
|
|
class ManufacturerHandler extends OledrionPersistableObjectHandler |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* ManufacturerHandler constructor. |
36
|
|
|
* @param \XoopsDatabase|null $db |
37
|
|
|
*/ |
38
|
|
|
public function __construct(\XoopsDatabase $db = null) |
39
|
|
|
{ |
40
|
|
|
// Table Classe Id Identifiant |
41
|
|
|
parent::__construct($db, 'oledrion_manufacturer', Manufacturer::class, 'manu_id', 'manu_commercialname'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Renvoie l'alphabet à partir de la première lettre du nom des fabricants |
46
|
|
|
* |
47
|
|
|
* @return array l'alphabet des lettres utilisées ! |
48
|
|
|
*/ |
49
|
|
|
public function getAlphabet() |
50
|
|
|
{ |
51
|
|
|
global $myts; |
52
|
|
|
$ret = []; |
53
|
|
|
$sql = 'SELECT DISTINCT (UPPER(SUBSTRING(manu_name, 1, 1))) AS oneletter FROM ' . $this->table; |
54
|
|
|
$result = $this->db->query($sql); |
55
|
|
|
if (!$result) { |
56
|
|
|
return $ret; |
57
|
|
|
} |
58
|
|
|
while (false !== ($myrow = $this->db->fetchArray($result))) { |
59
|
|
|
$ret[] = $myts->htmlSpecialChars($myrow['oneletter']); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $ret; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Supprime un fabricant et tout ce qui est relatif |
67
|
|
|
* |
68
|
|
|
* @param Manufacturer $manufacturer |
69
|
|
|
* @return bool Le résultat de la suppression |
70
|
|
|
*/ |
71
|
|
|
public function deleteManufacturer(Manufacturer $manufacturer) |
72
|
|
|
{ |
73
|
|
|
$manufacturer->deletePictures(); |
74
|
|
|
|
75
|
|
|
return $this->delete($manufacturer, true); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Retourne le nombre de produits associés à un fabricant |
80
|
|
|
* |
81
|
|
|
* @param int $manu_id L'identifiant du fabricant |
82
|
|
|
* @return int Le nombre de produis associés à un fabricant |
83
|
|
|
*/ |
84
|
|
|
public function getManufacturerProductsCount($manu_id) |
85
|
|
|
{ |
86
|
|
|
global $productsmanuHandler; |
87
|
|
|
|
88
|
|
|
return $productsmanuHandler->getManufacturerProductsCount($manu_id); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Retourne des fabricants en fonction de leur IDs |
93
|
|
|
* |
94
|
|
|
* @param array $ids Les identifiants des produits |
95
|
|
|
* @return array Tableau d'objets de type Productsmanu |
96
|
|
|
*/ |
97
|
|
|
public function getManufacturersFromIds($ids) |
98
|
|
|
{ |
99
|
|
|
$ret = []; |
100
|
|
|
if ($ids && is_array($ids)) { |
101
|
|
|
$criteria = new \Criteria('manu_id', '(' . implode(',', $ids) . ')', 'IN'); |
102
|
|
|
$ret = $this->getObjects($criteria, true, true, '*', false); |
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $ret; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Retourne les produits d'un fabricant (note, ce code serait mieux dans une facade) |
110
|
|
|
* |
111
|
|
|
* @param int $manu_id Le fabricant dont on veut récupérer les produits |
112
|
|
|
* @param int $start Position de départ |
113
|
|
|
* @param int $limit Nombre maximum d'enregistrements à renvoyer |
114
|
|
|
* @return array Objects de type Products |
115
|
|
|
*/ |
116
|
|
|
public function getManufacturerProducts($manu_id, $start = 0, $limit = 0) |
117
|
|
|
{ |
118
|
|
|
$ret = $productsIds = []; |
|
|
|
|
119
|
|
|
global $productsmanuHandler, $productsHandler; |
120
|
|
|
// On commence par récupérer les ID des produits |
121
|
|
|
$productsIds = $productsmanuHandler->getProductsIdsFromManufacturer($manu_id, $start, $limit); |
122
|
|
|
// Puis les produits eux même |
123
|
|
|
$ret = $productsHandler->getProductsFromIDs($productsIds); |
124
|
|
|
|
125
|
|
|
return $ret; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.