context_condition_node_taxonomy.inc

  1. cis7 sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc
  2. cle7 sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc
  3. ecd7 sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc
  4. elmsmedia7 sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc
  5. harmony7 sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc
  6. icor7 sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc
  7. meedjum_blog7 sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc
  8. mooc7 sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc

Classes

Namesort descending Description
context_condition_node_taxonomy Expose node taxonomy terms as a context condition.

File

sites/all/modules/ulmus/context/plugins/context_condition_node_taxonomy.inc
View source
  1. <?php
  2. /**
  3. * Expose node taxonomy terms as a context condition.
  4. */
  5. class context_condition_node_taxonomy extends context_condition_node {
  6. function condition_values() {
  7. $values = array();
  8. if (module_exists('taxonomy')) {
  9. foreach (taxonomy_get_vocabularies() as $vocab) {
  10. if (empty($vocab->tags)) {
  11. foreach (taxonomy_get_tree($vocab->vid) as $term) {
  12. $values[$term->tid] = check_plain($term->name);
  13. }
  14. }
  15. }
  16. }
  17. return $values;
  18. }
  19. function condition_form($context) {
  20. $form = parent::condition_form($context);
  21. $form['#type'] = 'select';
  22. $form['#size'] = 12;
  23. $form['#multiple'] = TRUE;
  24. $vocabularies = taxonomy_get_vocabularies();
  25. $options = array();
  26. foreach ($vocabularies as $vid => $vocabulary) {
  27. $tree = taxonomy_get_tree($vid);
  28. if ($tree && (count($tree) > 0)) {
  29. $options[$vocabulary->name] = array();
  30. foreach ($tree as $term) {
  31. $options[$vocabulary->name][$term->tid] = str_repeat('-', $term->depth) . $term->name;
  32. }
  33. }
  34. }
  35. $form['#options'] = $options;
  36. return $form;
  37. }
  38. function execute($node, $op) {
  39. // build a list of each taxonomy reference field belonging to the bundle for the current node
  40. $fields = field_info_fields();
  41. $instance_fields = field_info_instances('node', $node->type);
  42. $check_fields = array();
  43. foreach ($instance_fields as $key => $field_info) {
  44. if ($fields[$key]['type'] == 'taxonomy_term_reference') {
  45. $check_fields[] = $key;
  46. }
  47. }
  48. if ($this->condition_used() && !empty($check_fields)) {
  49. foreach ($check_fields as $field) {
  50. if ($terms = field_get_items('node', $node, $field)) {
  51. foreach ($terms as $term) {
  52. foreach ($this->get_contexts($term['tid']) as $context) {
  53. // Check the node form option.
  54. if ($op === 'form') {
  55. $options = $this->fetch_from_context($context, 'options');
  56. if (!empty($options['node_form'])) {
  57. $this->condition_met($context, $term['tid']);
  58. }
  59. }
  60. else {
  61. $this->condition_met($context, $term['tid']);
  62. }
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.