1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: 17: 18: 19: 20: 21: 22: 23:
24: class cFrontendHelper {
25:
26: 27: 28: 29: 30:
31: private static $_instance = NULL;
32:
33: 34: 35: 36: 37: 38: 39:
40: public static function getInstance() {
41: cDeprecated("The cFrontendHelper getInstance method are no longer supported.");
42:
43: if (self::$_instance === NULL) {
44: self::$_instance = new self();
45: }
46:
47: return self::$_instance;
48: }
49:
50: 51: 52: 53: 54: 55:
56: protected function __construct() {
57: cDeprecated("The cFrontendHelper classes are no longer supported.");
58: }
59:
60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80:
81: protected function _fetchCategoryTree($baseCategoryId, $depth, $currentCategoryId) {
82: cDeprecated("The cFrontendHelper _fetchCategoryTree method are no longer supported.");
83:
84: if ((int) $baseCategoryId == 0) {
85: throw new cUnexpectedValueException("Expect category ID greater than 0.");
86: }
87:
88: $categoryHelper = cCategoryHelper::getInstance();
89: $categoryHelper->setAuth(cRegistry::getAuth());
90:
91: $categoryTree = $categoryHelper->getSubCategories($baseCategoryId, $depth);
92:
93: $tree = array();
94:
95: $parentCategories = $categoryHelper->getParentCategoryIds($currentCategoryId);
96:
97: foreach ($categoryTree as $treeData) {
98: $catId = $treeData['idcat'];
99:
100: $firstChildId = $lastChildId = 0;
101: if (count($treeData['subcats']) > 0) {
102: $lastIndex = count($treeData['subcats']) - 1;
103:
104: $firstChildId = $treeData['subcats'][0]['idcat'];
105: $lastChildId = $treeData['subcats'][$lastIndex]['idcat'];
106: }
107:
108: $markActive = ($currentCategoryId == $catId);
109: if ($markActive == false && in_array($catId, $parentCategories)) {
110: $markActive = true;
111: }
112:
113: $treeItem['first_child_id'] = $firstChildId;
114: $treeItem['last_child_id'] = $lastChildId;
115: $treeItem['tree_data'] = $treeData;
116: $treeItem['active'] = $markActive;
117: $tree[] = $treeItem;
118: }
119:
120: return $tree;
121: }
122:
123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143:
144: public function renderNavigation($baseCategoryId, $depth, $currentCategoryId) {
145: cDeprecated("The cFrontendHelper renderNavigation method are no longer supported.");
146:
147: $tree = $this->_fetchCategoryTree($baseCategoryId, $depth, $currentCategoryId);
148:
149: return $tree;
150: }
151:
152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169:
170: public function renderSitemap($baseCategoryId, $depth, cTemplate &$tpl) {
171: cDeprecated("The cFrontendHelper renderSitemap method are no longer supported.");
172:
173: $tree = $this->_fetchCategoryTree($baseCategoryId, $depth, 0);
174:
175: foreach ($tree as $treeItem) {
176: $treeData = $treeItem['tree_data'];
177: $catId = $treeData['idcat'];
178:
179: $firstChildId = $treeItem['first_child_id'];
180:
181: $tpl->set('d', 'name', $treeData['item']->getField('name'));
182: $tpl->set('d', 'css_level', $treeData['level']);
183: $tpl->set('d', 'url', $treeData['item']->getLink());
184: $tpl->next();
185:
186: if ($firstChildId != 0) {
187: $this->renderSitemap($catId, $depth, $tpl);
188: }
189: }
190: }
191: }