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

modules/profile/views_handler_field_profile_date.inc

00001 <?php
00010 class views_handler_field_profile_date extends views_handler_field_date {
00011   function options_form(&$form, &$form_state) {
00012     parent::options_form($form, $form_state);
00013     // we can't do "time ago" so remove it from the form.
00014     unset($form['date_format']['#options']['time ago']);
00015   }
00016 
00020   function render($values) {
00021     $value = $this->get_value($values);
00022     if (!$value) {
00023       return;
00024     }
00025     $value = unserialize($value);
00026     $format = $this->options['date_format'];
00027     switch ($format) {
00028       case 'custom':
00029         $format = $this->options['custom_date_format'];
00030         break;
00031       case 'small':
00032         $format = variable_get('date_format_short', 'm/d/Y - H:i');
00033         break;
00034       case 'medium':
00035         $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
00036         break;
00037       case 'large':
00038         $format = variable_get('date_format_long', 'l, F j, Y - H:i');
00039         break;
00040     }
00041 
00042     // Note: Avoid PHP's date() because it does not handle dates before
00043     // 1970 on Windows. This would make the date field useless for e.g.
00044     // birthdays.
00045 
00046     // But we *can* deal with non-year stuff:
00047     $date = gmmktime(0, 0, 0, $value['month'], $value['day'], $value['year']);
00048     $replace = array(
00049       // day
00050       'd' => sprintf('%02d', $value['day']),
00051       'D' => NULL,
00052       'l' => NULL,
00053       'N' => NULL,
00054       'S' => date('S', $date),
00055       'w' => NULL,
00056       'j' => $value['day'],
00057       // month
00058       'F' => date('F', $date),
00059       'm' => sprintf('%02d', $value['month']),
00060       'M' => date('M', $date),
00061       'n' => date('n', $date),
00062 
00063       'Y' => $value['year'],
00064       'y' => substr($value['year'], 2, 2),
00065 
00066       // kill time stuff
00067       'a' => NULL,
00068       'A' => NULL,
00069       'g' => NULL,
00070       'G' => NULL,
00071       'h' => NULL,
00072       'H' => NULL,
00073       'i' => NULL,
00074       's' => NULL,
00075       ':' => NULL,
00076       'T' => NULL,
00077       ' - ' => NULL,
00078       ':' => NULL,
00079     );
00080 
00081     return strtr($format, $replace);
00082   }
00083 }

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