1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16:
17: $client = cRegistry::getClientId();
18: $lang = cRegistry::getLanguageId();
19: $idart = cRegistry::getArticleId();
20:
21:
22: $art = new cApiArticleLanguage();
23: $art->loadByArticleAndLanguageId($idart, $lang);
24: $content = $art->getContent('CMS_TEXT', 1);
25: $level = $art->getContent('CMS_TEXT', 2);
26: $article = $art->getContent('CMS_TEXT', 3);
27:
28:
29: $tpl = cSmartyFrontend::getInstance();
30: $tpl->assign('isBackendEditMode', cRegistry::isBackendEditMode());
31:
32:
33: $tpl->assign('trans', array(
34: 'headline' => mi18n("HEADLINE"),
35: 'categoryLabel' => mi18n("CATEGORY_LABEL"),
36: 'levelLabel' => mi18n("LEVEL_LABEL"),
37: 'articleLabel' => mi18n("ARTICLE_LABEL"),
38: 'articleHintLabel' => mi18n("ARTICLE_HINT_LABEL"),
39: 'categoryHintLabel' => mi18n("GATEGORY_HINT_LABEL"),
40: 'levelHintLabel' => mi18n("LEVEL_HINT_LABEL")
41: ));
42:
43:
44: $tpl->assign('category', "CMS_TEXT[1]");
45: $tpl->assign('level', "CMS_TEXT[2]");
46: $tpl->assign('article', "CMS_TEXT[3]");
47: $tpl->assign('first', false);
48:
49:
50: if (false === is_numeric($content) || false === is_numeric($level)) {
51: $tpl->assign('error', mi18n("NOT_NUMERIC_VALUE"));
52: } else if ($article != 0 && $article != 1) {
53: $tpl->assign('error', mi18n("NOT_ZERO_OR_ONE"));
54: } else {
55:
56: $categoryHelper = cCategoryHelper::getInstance();
57: $categoryHelper->setAuth(cRegistry::getAuth());
58: $tree = $categoryHelper->getSubCategories($content, $level);
59: if (1 == $article) {
60: $tree = addArticlesToTree($tree);
61: }
62: $tpl->assign('tree', $tree);
63: }
64:
65: $tpl->display('get.tpl');
66:
67: 68: 69: 70: 71: 72: 73:
74: function addArticlesToTree(array $tree) {
75:
76: foreach ($tree as $key => $wrapper) {
77: $tree[$key]['articles'] = getArticlesFromCategory($wrapper['idcat']);
78: $tree[$key]['subcats'] = addArticlesToTree($tree[$key]['subcats']);
79: }
80:
81: return $tree;
82:
83: }
84:
85: 86: 87: 88: 89:
90: function getArticlesFromCategory($categoryId) {
91:
92: $cfg = cRegistry::getConfig();
93: $db = cRegistry::getDb();
94:
95:
96:
97: $sql = '-- getArticlesFromCategory()
98: SELECT
99: al.idartlang
100: , UNIX_TIMESTAMP(al.lastmodified) AS lastmod
101: , al.changefreq
102: , al.sitemapprio
103: , al.title
104: FROM
105: `' . $cfg['tab']['art_lang'] . '` AS al
106: , `' . $cfg['tab']['cat_art'] . '` AS ca
107: WHERE
108: al.idart = ca.idart
109: AND al.idlang = ' . cSecurity::toInteger(cRegistry::getLanguageId()) . '
110: AND ca.idcat IN (' . $categoryId . ')
111: AND al.online = 1
112: AND al.searchable = 1
113: ;';
114:
115: $ret = $db->query($sql);
116:
117: $array = array();
118: if (false !== $ret) {
119: while ($db->next_record()) {
120: $article = new cApiArticleLanguage();
121: $article->loadByPrimaryKey($db->f('idartlang'));
122: $array[] = $article;
123: }
124: }
125:
126: return $array;
127:
128: }
129:
130: ?>