summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikestefanello2011-08-11 19:10:31 (GMT)
committer mikestefanello2011-08-11 19:10:31 (GMT)
commitb7eeaf6fc2dca3ffa6d0872d993a331f11271b8c (patch)
tree3985b66d96976d15c0e5ee025c18cc6f643c929b
parentde0a60c1af91b0f3e7262b52f65a721bf670c0c4 (diff)
Added views field options to link all nodes in hierarchy.
-rw-r--r--modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parent.inc33
-rw-r--r--modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parent_title.inc8
-rw-r--r--modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parents.inc16
-rw-r--r--modules/og_subgroups_views/includes/og_subgroups_views_handler_field_siblings.inc16
-rw-r--r--modules/og_subgroups_views/og_subgroups_views.views.inc24
5 files changed, 75 insertions, 22 deletions
diff --git a/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parent.inc b/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parent.inc
new file mode 100644
index 0000000..074a475
--- /dev/null
+++ b/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parent.inc
@@ -0,0 +1,33 @@
+<?php
+class og_subgroups_views_handler_field_parent extends views_handler_field {
+ function init(&$view, $options) {
+ parent::init($view, $options);
+
+ $this->additional_fields = array(
+ 'nid' => array('table' => 'node', 'field' => 'nid'),
+ );
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+ // Add the option to link to the group
+ $form['link'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Link to the parent group'),
+ '#default_value' => isset($this->options['link']) ? $this->options['link'] : 1,
+ );
+ }
+
+ function render($value) {
+ og_subgroups_include('tree');
+ if ($parent = og_subgroups_get_group_parent($value)) {
+ if (!$this->options['link']) {
+ return $parent->title;
+ }
+ else {
+ return l($parent->title, "node/{$parent->nid}");
+ }
+ }
+ return NULL;
+ }
+}
diff --git a/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parent_title.inc b/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parent_title.inc
deleted file mode 100644
index 6ae0f45..0000000
--- a/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parent_title.inc
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-class og_subgroups_views_handler_field_parent_title extends views_handler_field {
- function render($value) {
- og_subgroups_include('tree');
- $parent = og_subgroups_get_group_parent($value);
- return $parent ? $parent->title : NULL;
- }
-}
diff --git a/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parents.inc b/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parents.inc
index f299dd4..667bc1e 100644
--- a/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parents.inc
+++ b/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_parents.inc
@@ -10,6 +10,15 @@ class og_subgroups_views_handler_field_parents extends views_handler_field_prere
function query() {
$this->add_additional_fields();
}
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+ $form['link'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Link to the parent groups'),
+ '#default_value' => isset($this->options['link']) ? $this->options['link'] : 1,
+ );
+ }
function pre_render($values) {
og_subgroups_include('tree');
@@ -18,7 +27,12 @@ class og_subgroups_views_handler_field_parents extends views_handler_field_prere
foreach ($values as $value) {
$parents = og_subgroups_get_group_parents($value);
foreach ($parents as $nid => $parent) {
- $this->items[$value->nid][$parent->nid] = l($parent->title, "node/{$parent->nid}");
+ if ($this->options['link']) {
+ $this->items[$value->nid][$parent->nid] = l($parent->title, "node/{$parent->nid}");
+ }
+ else {
+ $this->items[$value->nid][$parent->nid] = $parent->title;
+ }
}
}
}
diff --git a/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_siblings.inc b/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_siblings.inc
index fb57ae5..a114d8e 100644
--- a/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_siblings.inc
+++ b/modules/og_subgroups_views/includes/og_subgroups_views_handler_field_siblings.inc
@@ -10,6 +10,15 @@ class og_subgroups_views_handler_field_siblings extends views_handler_field_prer
function query() {
$this->add_additional_fields();
}
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+ $form['link'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Link to the sibling groups'),
+ '#default_value' => isset($this->options['link']) ? $this->options['link'] : 1,
+ );
+ }
function pre_render($values) {
og_subgroups_include('tree');
@@ -18,7 +27,12 @@ class og_subgroups_views_handler_field_siblings extends views_handler_field_prer
foreach ($values as $value) {
$siblings = og_subgroups_get_group_siblings($value);
foreach ($siblings as $nid => $sibling) {
- $this->items[$value->nid][$sibling->nid] = l($sibling->title, "node/{$sibling->nid}");
+ if ($this->options['link']) {
+ $this->items[$value->nid][$sibling->nid] = l($sibling->title, "node/{$sibling->nid}");
+ }
+ else {
+ $this->items[$value->nid][$sibling->nid] = $sibling->title;
+ }
}
}
}
diff --git a/modules/og_subgroups_views/og_subgroups_views.views.inc b/modules/og_subgroups_views/og_subgroups_views.views.inc
index 946b5e6..ae7f070 100644
--- a/modules/og_subgroups_views/og_subgroups_views.views.inc
+++ b/modules/og_subgroups_views/og_subgroups_views.views.inc
@@ -37,7 +37,7 @@ function og_subgroups_views_views_handlers() {
'og_subgroups_views_handler_field_parents' => array(
'parent' => 'views_handler_field_prerender_list',
),
- 'og_subgroups_views_handler_field_parent_title' => array(
+ 'og_subgroups_views_handler_field_parent' => array(
'parent' => 'views_handler_field',
),
// filters
@@ -65,7 +65,7 @@ function og_subgroups_views_views_data() {
'field' => 'gid',
'type' => 'left',
);
-
+
$data['og_subgroups']['gid'] = array(
'title' => t('Group ID'),
'help' => t('Use the nid of a group as a starting point to retrieve other groups in the hierarchy.'),
@@ -95,7 +95,7 @@ function og_subgroups_views_views_data() {
$data['og_subgroups']['parent'] = array(
'title' => t('Parent group ID'),
- 'help' => t('The Node ID of the parent group.'),
+ 'help' => t('The parent group node ID.'),
'field' => array(
'handler' => 'views_handler_field',
),
@@ -105,6 +105,15 @@ function og_subgroups_views_views_data() {
),
);
+ $data['og_subgroups']['parent_title'] = array(
+ 'title' => t('Parent group title'),
+ 'help' => t('The parent group node title.'),
+ 'real field' => 'parent',
+ 'field' => array(
+ 'handler' => 'og_subgroups_views_handler_field_parent',
+ ),
+ );
+
$data['og_subgroups']['siblings'] = array(
'title' => t('Sibling groups'),
'help' => t('The siblings of the group.'),
@@ -122,15 +131,6 @@ function og_subgroups_views_views_data() {
'handler' => 'og_subgroups_views_handler_field_parents',
),
);
-
- $data['og_subgroups']['parent_title'] = array(
- 'title' => t('Parent group title'),
- 'help' => t('The Node title of the parent group.'),
- 'real field' => 'gid',
- 'field' => array(
- 'handler' => 'og_subgroups_views_handler_field_parent_title',
- ),
- );
$data['og_subgroups']['has_parent'] = array(
'real field' => 'parent',