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: public function __construct($select = false) {
27: global $cfg;
28: parent::__construct($cfg['tab']['cat_tree'], 'idtree');
29:
30:
31: $this->_setJoinPartner('cApiCategoryCollection');
32:
33: $this->_setItemClass('cApiCategoryTree');
34: if ($select !== false) {
35: $this->select($select);
36: }
37: }
38:
39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57:
58: function getCategoryTreeStructureByClientIdAndLanguageId($client, $lang) {
59: global $cfg;
60:
61: $aCatTree = array();
62:
63: $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';
64:
65: $sql = $this->db->prepare($sql, array(
66: 'cat_tree' => $this->table,
67: 'cat' => $cfg['tab']['cat'],
68: 'cat_lang' => $cfg['tab']['cat_lang'],
69: 'idlang' => (int) $lang,
70: 'idclient' => (int) $client
71: ));
72: $this->db->query($sql);
73:
74: while ($this->db->nextRecord()) {
75: $aCatTree[$this->db->f('idtree')] = array(
76: 'idcat' => $this->db->f('idcat'),
77: 'level' => $this->db->f('level'),
78: 'idtplcfg' => $this->db->f('idtplcfg'),
79: 'visible' => $this->db->f('visible'),
80: 'name' => $this->db->f('name'),
81: 'public' => $this->db->f('public'),
82: 'urlname' => $this->db->f('urlname'),
83: 'is_start' => $this->db->f('is_start')
84: );
85: }
86:
87: return $aCatTree;
88: }
89:
90: }
91:
92: 93: 94: 95: 96: 97:
98: class cApiCategoryTree extends Item {
99:
100: 101: 102: 103: 104:
105: public function __construct($mId = false) {
106: global $cfg;
107: parent::__construct($cfg['tab']['cat_tree'], 'idtree');
108: $this->setFilters(array(), array());
109: if ($mId !== false) {
110: $this->loadByPrimaryKey($mId);
111: }
112: }
113:
114: }
115: