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
00043
00044
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 }