/[drupal]/contributions/modules/facebook_status/facebook_status_views_handler_field_latest_update_date.inc
ViewVC logotype

Contents of /contributions/modules/facebook_status/facebook_status_views_handler_field_latest_update_date.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Apr 9 06:10:38 2009 UTC (7 months, 2 weeks ago) by icecreamyou
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--2
File MIME type: text/x-php
Better Views integration... a little more is needed still
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Allows showing the posted time of users' most recent status in Views.
7 */
8
9 /**
10 * Field handler to provide the time for the most recent status update.
11 */
12 class facebook_status_views_handler_field_latest_update_date extends views_handler_field_date {
13
14 function construct() {
15 parent::construct();
16 $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');
17 }
18
19 function query() {
20 $this->add_additional_fields();
21 $this->field_alias = $this->aliases['uid'];
22 }
23
24 function render($values) {
25 $status = facebook_status_get_status($values->uid, 1, -1, TRUE);
26 $value = $status[0]->status_time;
27 $format = $this->options['date_format'];
28 if ($format == 'custom' || $format == 'time ago' || $format == 'raw time ago') {
29 $custom_format = $this->options['custom_date_format'];
30 }
31
32 switch ($format) {
33 case 'raw time ago':
34 return $value ? format_interval(time() - $value, is_numeric($custom_format) ? $custom_format : 2) : theme('views_nodate');
35 case 'time ago':
36 return $value ? t('%time ago', array('%time' => format_interval(time() - $value, is_numeric($custom_format) ? $custom_format : 2))) : theme('views_nodate');
37 case 'custom':
38 return $value ? format_date($value, $format, $custom_format) : theme('views_nodate');
39 default:
40 return $value ? format_date($value, $format) : theme('views_nodate');
41 }
42
43 }
44 }

  ViewVC Help
Powered by ViewVC 1.1.2