aboutsummaryrefslogtreecommitdiff
path: root/mod/pages/views/default/input/parent.php
blob: f354129fe35cf53b74fd04fcbd5940cfa5f8424c (plain)
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
<?php
/**
 * Parent picker
 *
 * @uses $vars['value'] The current value, if any
 * @uses $vars['options_values']
 * @uses $vars['name'] The name of the input field
 * @uses $vars['entity'] Optional. The child entity (uses container_guid)
 */

elgg_load_library('elgg:pages');

if (empty($vars['entity'])) {
	$container = elgg_get_page_owner_entity();
} else {
	$container = $vars['entity']->getContainerEntity();
}

$pages = pages_get_navigation_tree($container);
$options = array();

foreach ($pages as $page) {
	$spacing = "";
	for ($i = 0; $i < $page['depth']; $i++) {
		$spacing .= "--";
	}
	$options[$page['guid']] = "$spacing " . $page['title'];
}

$defaults = array(
	'class' => 'elgg-input-parent-picker',
	'options_values' => $options,
);

$vars = array_merge($defaults, $vars);

echo elgg_view('input/dropdown', $vars);