aboutsummaryrefslogtreecommitdiff
path: root/mod/pages/views/default
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2012-12-15 14:10:04 -0500
committerBrett Profitt <brett.profitt@gmail.com>2012-12-15 14:10:04 -0500
commit4d360c11d14768c8a0229b8b2b1f02622f17c48a (patch)
treeae7f01685a08c16a49b551925631c7401dbb79d0 /mod/pages/views/default
parentcd3839cfec814c191ff664faeaf9e9360118d6bf (diff)
parent21eb7616a11906a19260a081070a6b1c51820fa3 (diff)
downloadelgg-4d360c11d14768c8a0229b8b2b1f02622f17c48a.tar.gz
elgg-4d360c11d14768c8a0229b8b2b1f02622f17c48a.tar.bz2
Merge branch 'pr-316' into 1.8
Diffstat (limited to 'mod/pages/views/default')
-rw-r--r--mod/pages/views/default/forms/pages/edit.php7
-rw-r--r--mod/pages/views/default/input/parent.php37
2 files changed, 43 insertions, 1 deletions
diff --git a/mod/pages/views/default/forms/pages/edit.php b/mod/pages/views/default/forms/pages/edit.php
index 9469f5eb9..653a7ee47 100644
--- a/mod/pages/views/default/forms/pages/edit.php
+++ b/mod/pages/views/default/forms/pages/edit.php
@@ -18,6 +18,10 @@ foreach ($variables as $name => $type) {
if (($type == 'access' || $type == 'write_access') && !$can_change_access) {
continue;
}
+ // don't show parent picker input for top or new pages.
+ if ($name == 'parent_guid' && (!$vars['parent_guid'] || !$vars['guid'])) {
+ continue;
+ }
?>
<div>
<label><?php echo elgg_echo("pages:$name") ?></label>
@@ -29,6 +33,7 @@ foreach ($variables as $name => $type) {
echo elgg_view("input/$type", array(
'name' => $name,
'value' => $vars[$name],
+ 'entity' => ($name == 'parent_guid') ? $vars['entity'] : null,
));
?>
</div>
@@ -52,7 +57,7 @@ echo elgg_view('input/hidden', array(
'name' => 'container_guid',
'value' => $vars['container_guid'],
));
-if ($vars['parent_guid']) {
+if (!$vars['guid']) {
echo elgg_view('input/hidden', array(
'name' => 'parent_guid',
'value' => $vars['parent_guid'],
diff --git a/mod/pages/views/default/input/parent.php b/mod/pages/views/default/input/parent.php
new file mode 100644
index 000000000..f354129fe
--- /dev/null
+++ b/mod/pages/views/default/input/parent.php
@@ -0,0 +1,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);