1 | <?php |
||
2 | /** |
||
3 | * Parent picker |
||
4 | * |
||
5 | * @uses $vars['value'] The current value, if any |
||
6 | * @uses $vars['options_values'] |
||
7 | * @uses $vars['name'] The name of the input field |
||
8 | * @uses $vars['entity'] Optional. The child entity (uses container_guid) |
||
9 | */ |
||
10 | |||
11 | $entity = elgg_extract('entity', $vars); |
||
12 | if ($entity instanceof ElggPage) { |
||
13 | $container = $entity->getContainerEntity(); |
||
14 | } else { |
||
15 | $container = elgg_get_page_owner_entity(); |
||
16 | } |
||
17 | |||
18 | $pages = pages_get_navigation_tree($container); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
19 | |||
20 | $options = []; |
||
21 | foreach ($pages as $page) { |
||
22 | $spacing = ''; |
||
23 | $spacing .= str_repeat('--', $page['depth']); |
||
24 | |||
25 | $options[$page['guid']] = "$spacing " . $page['title']; |
||
26 | } |
||
27 | |||
28 | $defaults = [ |
||
29 | 'class' => 'elgg-pages-input-parent-picker', |
||
30 | 'options_values' => $options, |
||
31 | ]; |
||
32 | |||
33 | $vars = array_merge($defaults, $vars); |
||
34 | |||
35 | echo elgg_view('input/select', $vars); |
||
36 |