00001 <?php 00002 00008 class views_handler_field_node_type extends views_handler_field_node { 00009 function option_definition() { 00010 $options = parent::option_definition(); 00011 $options['machine_name'] = array('default' => FALSE); 00012 00013 return $options; 00014 } 00015 00019 function options_form(&$form, &$form_state) { 00020 parent::options_form($form, $form_state); 00021 00022 $form['machine_name'] = array( 00023 '#title' => t('Output machine name'), 00024 '#description' => t('Display field as the content type machine name.'), 00025 '#type' => 'checkbox', 00026 '#default_value' => !empty($this->options['machine_name']), 00027 '#fieldset' => 'more', 00028 ); 00029 } 00030 00034 function render_name($data, $values) { 00035 if ($this->options['machine_name'] != 1 && $data !== NULL && $data !== '') { 00036 return t($this->sanitize_value(node_type_get_name($data))); 00037 } 00038 return $this->sanitize_value($data); 00039 } 00040 00041 function render($values) { 00042 $value = $this->get_value($values); 00043 return $this->render_link($this->render_name($value, $values), $values); 00044 } 00045 }