Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/modules/profile/views_handler_field_profile_date.inc
6 6
 */
7 7

  
8 8
/**
9
 * Field handler display a profile date
9
 * Field handler display a profile date.
10 10
 *
11 11
 * The dates are stored serialized, which makes them mostly useless from
12 12
 * SQL. About all we can do is unserialize and display them.
......
14 14
 * @ingroup views_field_handlers
15 15
 */
16 16
class views_handler_field_profile_date extends views_handler_field_date {
17
  function options_form(&$form, &$form_state) {
17

  
18
  /**
19
   * {@inheritdoc}
20
   */
21
  public function options_form(&$form, &$form_state) {
18 22
    parent::options_form($form, $form_state);
19 23
    // we can't do "time ago" so remove it from the form.
20 24
    unset($form['date_format']['#options']['time ago']);
21 25
  }
22 26

  
23 27
  /**
24
   * Display a profile field of type 'date'
28
   * Display a profile field of type 'date'.
25 29
   */
26
  function render($values) {
30
  public function render($values) {
27 31
    $value = $this->get_value($values);
28 32
    if (!$value) {
29 33
      return;
......
34 38
      case 'custom':
35 39
        $format = $this->options['custom_date_format'];
36 40
        break;
41

  
37 42
      case 'small':
38 43
        $format = variable_get('date_format_short', 'm/d/Y - H:i');
39 44
        break;
45

  
40 46
      case 'medium':
41 47
        $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
42 48
        break;
49

  
43 50
      case 'large':
44 51
        $format = variable_get('date_format_long', 'l, F j, Y - H:i');
45 52
        break;
......
48 55
    // Note: Avoid PHP's date() because it does not handle dates before
49 56
    // 1970 on Windows. This would make the date field useless for e.g.
50 57
    // birthdays.
51

  
52
    // But we *can* deal with non-year stuff:
58
    // But we *can* deal with non-year stuff.
53 59
    $date = gmmktime(0, 0, 0, $value['month'], $value['day'], $value['year']);
54 60

  
55 61
    $replace = array(
56
      // day
62
      // day.
57 63
      'd' => sprintf('%02d', $value['day']),
58 64
      'D' => NULL,
59 65
      'l' => NULL,
......
61 67
      'S' => gmdate('S', $date),
62 68
      'w' => NULL,
63 69
      'j' => $value['day'],
64
      // month
70
      // month.
65 71
      'F' => gmdate('F', $date),
66 72
      'm' => sprintf('%02d', $value['month']),
67 73
      'M' => gmdate('M', $date),
......
70 76
      'Y' => $value['year'],
71 77
      'y' => substr($value['year'], 2, 2),
72 78

  
73
      // kill time stuff
79
      // kill time stuff.
74 80
      'a' => NULL,
75 81
      'A' => NULL,
76 82
      'g' => NULL,
......
87 93

  
88 94
    return strtr($format, $replace);
89 95
  }
96

  
90 97
}

Formats disponibles : Unified diff