data_taxonomy_views_handler_field_form.inc

Classes

Namesort descending Description
data_taxonomy_views_handler_field_form Provide a form to associate data records with taxonomy terms.

File

sites/all/modules/local_contrib/data/data_taxonomy/views/data_taxonomy_views_handler_field_form.inc
View source
  1. <?php
  2. /**
  3. * Provide a form to associate data records with taxonomy terms.
  4. */
  5. class data_taxonomy_views_handler_field_form extends views_handler_field {
  6. protected $id;
  7. /**
  8. * Describe provided options and default values.
  9. */
  10. function option_definition() {
  11. $options = parent::option_definition();
  12. $options['vocabularies'] = array('default' => array());
  13. $options['path'] = array('default' => '');
  14. return $options;
  15. }
  16. /**
  17. * Suppress other options and provide a selection of vocabularies for which
  18. * tagging forms will be displayed.
  19. */
  20. function options_form(&$form, &$form_state) {
  21. $options = array();
  22. $table = data_get_table($this->table);
  23. $meta = $table->get('meta');
  24. if (!empty($meta['data_taxonomy']['vocabularies'])) {
  25. foreach ($meta['data_taxonomy']['vocabularies'] as $vid) {
  26. $options[$vid] = data_taxonomy_get_vocabulary($vid)->name;
  27. }
  28. }
  29. if (!empty($options)) {
  30. $form['vocabularies'] = array(
  31. '#title' => t('Enabled vocabularies'),
  32. '#description' => t('Display a tagging form for each of the selected vocabularies. Only vocabularies that are enabled for this table are available. Edit this table\'s definition in admin/build/data to enable vocabularies.'),
  33. '#type' => 'checkboxes',
  34. '#options' => $options,
  35. '#default_value' => $this->options['vocabularies'],
  36. );
  37. }
  38. $form['path'] = array(
  39. '#type' => 'textfield',
  40. '#title' => t('Term path'),
  41. '#default_value' => $this->options['path'],
  42. '#description' => t('Path to link terms with. Use "%" to represent arguments of the current view, use !tid to designate where the term id should be placed, use !term to designate where the term name should be placed. For example "data/%/!tid/%"'),
  43. );
  44. }
  45. /**
  46. * Add field on which we join.
  47. */
  48. function query() {
  49. $this->ensure_my_table();
  50. // Add the id field for this table to the query.
  51. $table = data_get_table($this->table);
  52. $meta = $table->get('meta');
  53. if (!empty($meta['data_taxonomy']['vocabularies']) && isset($meta['data_taxonomy']['id'])) {
  54. $this->id = $this->query->add_field($this->table_alias, $meta['data_taxonomy']['id']);
  55. }
  56. $this->add_additional_fields();
  57. }
  58. /**
  59. * Render form.
  60. */
  61. function render($values) {
  62. $output = '';
  63. $table = data_get_table($this->table);
  64. $meta = $table->get('meta');
  65. if (!empty($meta['data_taxonomy']['vocabularies'])) {
  66. foreach ($meta['data_taxonomy']['vocabularies'] as $vid) {
  67. if (!empty($this->options['vocabularies'][$vid])) {
  68. $vocabulary = data_taxonomy_get_vocabulary($vid);
  69. $output .= drupal_get_form('data_taxonomy_tagging_form', $vocabulary->vid, $values->{$this->id}, $this->table, $this->options['path'], is_array($this->view->args) ? $this->view->args : array());
  70. }
  71. }
  72. }
  73. return $output;
  74. }
  75. /**
  76. * Omit label output.
  77. */
  78. function label() {
  79. return '';
  80. }
  81. }
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.