1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23:
24: class cApiCategoryTreeCollection extends ItemCollection {
25:
26: 27: 28: 29: 30: 31:
32: public function __construct($select = false) {
33: global $cfg;
34: parent::__construct($cfg['tab']['cat_tree'], 'idtree');
35:
36:
37: $this->_setJoinPartner('cApiCategoryCollection');
38:
39: $this->_setItemClass('cApiCategoryTree');
40: if ($select !== false) {
41: $this->select($select);
42: }
43: }
44:
45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63:
64: function getCategoryTreeStructureByClientIdAndLanguageId($client, $lang) {
65: global $cfg;
66:
67: $aCatTree = array();
68:
69: $sql = 'SELECT * FROM `:cat_tree` AS A, `:cat` AS B, `:cat_lang` AS C ' . 'WHERE A.idcat = B.idcat AND B.idcat = C.idcat AND C.idlang = :idlang AND idclient = :idclient ' . 'ORDER BY idtree';
70:
71: $sql = $this->db->prepare($sql, array(
72: 'cat_tree' => $this->table,
73: 'cat' => $cfg['tab']['cat'],
74: 'cat_lang' => $cfg['tab']['cat_lang'],
75: 'idlang' => (int) $lang,
76: 'idclient' => (int) $client
77: ));
78: $this->db->query($sql);
79:
80: while ($this->db->nextRecord()) {
81: $aCatTree[$this->db->f('idtree')] = array(
82: 'idcat' => $this->db->f('idcat'),
83: 'level' => $this->db->f('level'),
84: 'idtplcfg' => $this->db->f('idtplcfg'),
85: 'visible' => $this->db->f('visible'),
86: 'name' => $this->db->f('name'),
87: 'public' => $this->db->f('public'),
88: 'urlname' => $this->db->f('urlname'),
89: 'is_start' => $this->db->f('is_start')
90: );
91: }
92:
93: return $aCatTree;
94: }
95: }
96:
97: 98: 99: 100: 101: 102:
103: class cApiCategoryTree extends Item {
104:
105: 106: 107: 108: 109:
110: public function __construct($mId = false) {
111: global $cfg;
112: parent::__construct($cfg['tab']['cat_tree'], 'idtree');
113: $this->setFilters(array(), array());
114: if ($mId !== false) {
115: $this->loadByPrimaryKey($mId);
116: }
117: }
118: }
119: