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

modules/comment/views_handler_field_comment_username.inc

00001 <?php
00007 class views_handler_field_comment_username extends views_handler_field {
00011   function init(&$view, &$data) {
00012     parent::init($view, $data);
00013     $this->additional_fields['uid'] = 'uid';
00014     $this->additional_fields['homepage'] = 'homepage';
00015   }
00016 
00017   function option_definition() {
00018     $options = parent::option_definition();
00019     $options['link_to_user'] = array('default' => TRUE);
00020     return $options;
00021   }
00022 
00023   function options_form(&$form, &$form_state) {
00024     $form['link_to_user'] = array(
00025       '#title' => t("Link this field to its user or an author's homepage"),
00026       '#type' => 'checkbox',
00027       '#default_value' => $this->options['link_to_user'],
00028     );
00029     parent::options_form($form, $form_state);
00030   }
00031 
00032   function render_link($data, $values) {
00033     if (!empty($this->options['link_to_user'])) {
00034       $account = new stdClass();
00035       $account->uid = $this->get_value($values, 'uid');
00036       $account->name = $this->get_value($values);
00037       $account->homepage = $this->get_value($values, 'homepage');
00038 
00039       return theme('username', array(
00040         'account' => $account
00041       ));
00042     }
00043     else {
00044       return $data;
00045     }
00046   }
00047 
00048   function render($values) {
00049     $value = $this->get_value($values);
00050     return $this->render_link($this->sanitize_value($value), $values);
00051   }
00052 }

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