init
[garradin.git] / www / admin / wiki / _chercher_parent.php
1 <?php
2 namespace Garradin;
3
4 require_once __DIR__ . '/_inc.php';
5
6 if ((trim(utils::get('parent')) == '') || !is_numeric(utils::get('parent')))
7 {
8 throw new UserException('Numéro de page parent invalide.');
9 }
10
11 $parent = (int) utils::get('parent');
12
13 $tpl->assign('parent', $parent);
14 $tpl->assign('list', $wiki->listBackParentTree($parent));
15
16 function tpl_display_tree($params)
17 {
18 if (isset($params['tree']))
19 $tree = $params['tree'];
20 else
21 $tree = $params;
22
23 $out = '<ul>';
24
25 foreach ($tree as $node)
26 {
27 $out .= '<li'.(utils::get('parent') == $node['id'] ? ' class="current"' : '').'><h3><a href="?parent='.(int)$node['id'].'">'.htmlspecialchars($node['titre'], ENT_QUOTES, 'UTF-8', false).'</a></h3>';
28
29 if (!empty($node['children']))
30 {
31 $out .= tpl_display_tree($node['children']);
32 }
33
34 $out .= '</li>';
35 }
36
37 $out .= '</ul>';
38
39 return $out;
40 }
41
42 $tpl->register_function('display_tree', 'Garradin\tpl_display_tree');
43
44 $tpl->display('admin/wiki/_chercher_parent.tpl');
45
46 ?>