• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

modules/taxonomy/views_handler_field_term_link_edit.inc

00001 <?php
00002 
00008 class views_handler_field_term_link_edit extends views_handler_field {
00009   function construct() {
00010     parent::construct();
00011     $this->additional_fields['tid'] = 'tid';
00012     $this->additional_fields['vid'] = 'vid';
00013     $this->additional_fields['vocabulary_machine_name'] = array(
00014       'table' => 'taxonomy_vocabulary',
00015       'field' => 'machine_name',
00016     );
00017   }
00018 
00019   function option_definition() {
00020     $options = parent::option_definition();
00021 
00022     $options['text'] = array('default' => '', 'translatable' => TRUE);
00023 
00024     return $options;
00025   }
00026 
00027   function options_form(&$form, &$form_state) {
00028     $form['text'] = array(
00029       '#type' => 'textfield',
00030       '#title' => t('Text to display'),
00031       '#default_value' => $this->options['text'],
00032     );
00033     parent::options_form($form, $form_state);
00034   }
00035 
00036   function query() {
00037     $this->ensure_my_table();
00038     $this->add_additional_fields();
00039   }
00040 
00041   function render($values) {
00042     // Mock a term object for taxonomy_term_edit_access(). Use machine name and
00043     // vid to ensure compatibility with vid based and machine name based
00044     // access checks. See http://drupal.org/node/995156
00045     $term = new stdClass();
00046     $term->vid = $values->{$this->aliases['vid']};
00047     $term->vocabulary_machine_name = $values->{$this->aliases['vocabulary_machine_name']};
00048     if (taxonomy_term_edit_access($term)) {
00049       $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
00050       $tid = $this->get_value($values, 'tid');
00051       return l($text, 'taxonomy/term/'. $tid . '/edit', array('query' => drupal_get_destination()));
00052     }
00053   }
00054 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1