-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
52 lines (44 loc) · 1.63 KB
/
index.php
File metadata and controls
52 lines (44 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Render hierarhical menu from database entries
* @author tvitcom
* @url github.com/tvitcom
* @package test case application
* @license https://www.apache.org/licenses/LICENSE-2.0 tvitcom
*/
require './libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->force_compile = true;
$smarty->debugging = false;
$smarty->caching = true;
$smarty->cache_lifetime = 120;
require_once 'TreeManager.php';
require_once 'HierInterface.php';
if (isset($_GET['driver']) && $_GET['driver'] ==='pdo') {
TreeManager::setSqlDriver('pdo');
TreeManager::$driver_notice = 'work with PDO db driver';
} else {
TreeManager::setSqlDriver('mysqli');
TreeManager::$driver_notice = 'work with mysqli db driver';
}
$smarty->assign("note", TreeManager::$driver_notice);
TreeManager::$language_id=1;
function renderTree($id_current_elem=0, $level=0) {
$arr = TreeManager::getNameOfElement($id_current_elem, TreeManager::$language_id);
$gaps = TreeManager::getGaps($level);
$smarty = new Smarty;
$smarty->assign("gaps", $gaps);
$smarty->assign("item", $arr['item_name']);
$smarty->display('menu.tpl');
$level++;
//Находим массив прямых потомков данного элемента:
$descendant = TreeManager::getNodesOfParentId($id_current_elem);
//Обходим все потомки данного уровня и применяем рекурсивный вызов функции:
foreach ($descendant as $el) {
renderTree($el['item_id'], $level);
}
}
$smarty->display('header.tpl');
TreeManager::renderTree();
$smarty->display('content.tpl');
$smarty->display('footer.tpl');