| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Field handler to provide simple renderer that allows linking to a user. 5 */ 6 class views_handler_field_user extends views_handler_field { 7 /** 8 * Override init function to provide generic option to link to user. 9 */ 10 function init(&$view, &$data) { 11 parent::init($view, $data); 12 if (!empty($this->options['link_to_user'])) { 13 $this->additional_fields['uid'] = 'uid'; 14 } 15 } 16 17 function option_definition() { 18 $options = parent::option_definition(); 19 $options['link_to_user'] = array('default' => TRUE); 20 return $options; 21 } 22 23 /** 24 * Provide link to node option 25 */ 26 function options_form(&$form, &$form_state) { 27 parent::options_form($form, $form_state); 28 $form['link_to_user'] = array( 29 '#title' => t('Link this field to its user'), 30 '#description' => t('This will override any other link you have set.'), 31 '#type' => 'checkbox', 32 '#default_value' => $this->options['link_to_user'], 33 ); 34 } 35 36 function render_link($data, $values) { 37 if (!empty($this->options['link_to_user']) && user_access('access user profiles') && $values->{$this->aliases['uid']} && $data !== NULL && $data !== '') { 38 $this->options['alter']['make_link'] = TRUE; 39 $this->options['alter']['path'] = "user/" . $values->{$this->aliases['uid']}; 40 } 41 return $data; 42 } 43 44 function render($values) { 45 return $this->render_link(check_plain($values->{$this->field_alias}), $values); 46 } 47 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |