00001 <?php
00007 class views_handler_field_node_link extends views_handler_field_entity {
00008
00009 function option_definition() {
00010 $options = parent::option_definition();
00011 $options['text'] = array('default' => '', 'translatable' => TRUE);
00012 return $options;
00013 }
00014
00015 function options_form(&$form, &$form_state) {
00016 $form['text'] = array(
00017 '#type' => 'textfield',
00018 '#title' => t('Text to display'),
00019 '#default_value' => $this->options['text'],
00020 );
00021 parent::options_form($form, $form_state);
00022
00023
00024 $form['alter']['path'] = array('#access' => FALSE);
00025 $form['alter']['external'] = array('#access' => FALSE);
00026 }
00027
00028 function render($values) {
00029 if ($entity = $this->get_value($values)) {
00030 return $this->render_link($entity, $values);
00031 }
00032 }
00033
00034 function render_link($node, $values) {
00035 if (node_access('view', $node)) {
00036 $this->options['alter']['make_link'] = TRUE;
00037 $this->options['alter']['path'] = "node/$node->nid";
00038 $text = !empty($this->options['text']) ? $this->options['text'] : t('view');
00039 return $text;
00040 }
00041 }
00042 }