diff -rupN ../views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc ./modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
--- ../views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc 2010-12-10 06:30:27.000000000 +1100
+++ ./modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc 2011-02-14 12:46:01.000000000 +1100
@@ -11,8 +11,6 @@ class views_plugin_argument_default_taxo
$options['term_page'] = array('default' => TRUE);
$options['node'] = array('default' => FALSE);
- $options['limit'] = array('default' => FALSE);
- $options['vids'] = array('default' => array());
return $options;
}
@@ -31,7 +29,7 @@ class views_plugin_argument_default_taxo
);
$form['node'] = array(
'#type' => 'checkbox',
- '#title' => t('Load default argument from node page. Good for related taxonomy blocks.'),
+ '#title' => t('Load default argument from node page. Useful for related taxonomy blocks.'),
'#default_value' => $this->argument->options['node'],
'#process' => array('views_process_dependency'),
'#dependency' => array(
@@ -40,48 +38,6 @@ class views_plugin_argument_default_taxo
),
'#dependency_count' => 2,
);
-
- $form['limit'] = array(
- '#type' => 'checkbox',
- '#title' => t('Limit terms by vocabulary'),
- '#default_value'=> $this->argument->options['limit'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'radio:options[default_action]' => array('default'),
- 'radio:options[default_argument_type]' => array($this->id),
- 'edit-options-node' => array(1)
- ),
- '#dependency_count' => 3,
- );
-
- $options = array();
- $vocabularies = taxonomy_get_vocabularies();
- foreach ($vocabularies as $voc) {
- $options[$voc->vid] = check_plain($voc->name);
- }
-
- $form['vids'] = array(
- '#prefix' => '
',
- '#type' => 'checkboxes',
- '#title' => t('Vocabularies'),
- '#description' => t('If you wish to limit terms for specific vocabularies, check them; if none are checked, all terms will be included.'),
- '#options' => $options,
- '#default_value' => isset($this->argument->options['vids']) ? $this->argument->options['vids'] : array(),
- '#process' => array('expand_checkboxes', 'views_process_dependency'),
- '#dependency' => array(
- 'radio:options[default_action]' => array('default'),
- 'radio:options[default_argument_type]' => array($this->id),
- 'edit-options-node' => array(1),
- 'edit-options-limit' => array(1)
- ),
- '#dependency_count' => 4,
- );
- }
-
- function options_submit(&$form, &$form_state, &$options) {
- // Clear checkbox values.
- $options['vids'] = array_filter($options['vids']);
}
function get_argument() {
@@ -93,30 +49,32 @@ class views_plugin_argument_default_taxo
}
// Load default argument from node.
if (!empty($this->argument->options['node'])) {
- foreach (range(1, 3) as $i) {
- $node = menu_get_object('node', $i);
- if (!empty($node)) {
- break;
- }
- }
- // Just check, if a node could be detected.
- if ($node) {
- if (!empty($this->argument->options['limit'])) {
- $tids = array();
- // Filter by vid.
+ // Load default argument from node.
+ // First, try to get a node from the menu router system.
+ $node = menu_get_object('node', 1);
+ if (!empty($node)) {
+ // If our argument is set to validate the term, only pick out
+ // terms from the node that are in those vocabularies.
+ if ($this->argument->options['validate_type'] == 'taxonomy_term') {
+ $valid_vids = $this->argument->options['validate_argument_vocabulary'];
foreach ($node->taxonomy as $tid => $term) {
- if (!empty($this->argument->options['vids'][$term->vid])) {
+ // This has VID => VID for selected ones, and VID => 0 otherwise.
+ if ($valid_vids[$term->vid]) {
$tids[] = $tid;
}
}
- return implode(",", $tids);
}
- // Return all tids.
+ // Otherwise, take all terms from the node.
else {
- return implode(",", array_keys($node->taxonomy));
+ $tids = array_keys($node->taxonomy);
+ }
+
+ if ($tids) {
+ // Transform the argument to a string of comma-separated tids.
+ return implode(',', $tids);
}
}
}
+ // Views will just do nothing for this argument if we end up here.
}
}
-
diff -rupN ../views/modules/taxonomy.views.inc ./modules/taxonomy.views.inc
--- ../views/modules/taxonomy.views.inc 2011-01-12 10:45:14.000000000 +1100
+++ ./modules/taxonomy.views.inc 2011-02-14 11:20:30.931960000 +1100
@@ -458,14 +458,14 @@ function taxonomy_views_plugins() {
'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
),
),
-// 'argument default' => array(
-// 'taxonomy_tid' => array(
-// 'title' => t('Taxonomy Term ID from URL'),
-// 'handler' => 'views_plugin_argument_default_taxonomy_tid',
-// 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
-// 'parent' => 'fixed',
-// ),
-// ),
+ 'argument default' => array(
+ 'taxonomy_tid' => array(
+ 'title' => t('Taxonomy Term ID from URL'),
+ 'handler' => 'views_plugin_argument_default_taxonomy_tid',
+ 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
+ 'parent' => 'fixed',
+ ),
+ ),
);
}