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/handlers/views_handler_argument_date.inc
10 10
 *
11 11
 * Adds an option to set a default argument based on the current date.
12 12
 *
13
 * @param $arg_format
14
 *   The format string to use on the current time when
15
 *   creating a default date argument.
13
 * @param string $arg_format
14
 *   The format string to use on the current time when creating a default date
15
 *   argument.
16 16
 *
17 17
 * Definitions terms:
18 18
 * - many to one: If true, the "many to one" helper will be used.
......
24 24
 * @ingroup views_argument_handlers
25 25
 */
26 26
class views_handler_argument_date extends views_handler_argument_formula {
27
  var $option_name = 'default_argument_date';
28
  var $arg_format = 'Y-m-d';
27

  
28
  /**
29
   *
30
   */
31
  public $option_name = 'default_argument_date';
32

  
33
  /**
34
   *
35
   */
36
  public $arg_format = 'Y-m-d';
29 37

  
30 38
  /**
31 39
   * Add an option to set the default value to the current date.
32 40
   */
33
  function default_argument_form(&$form, &$form_state) {
41
  public function default_argument_form(&$form, &$form_state) {
34 42
    parent::default_argument_form($form, $form_state);
35 43
    $form['default_argument_type']['#options'] += array('date' => t('Current date'));
36 44
    $form['default_argument_type']['#options'] += array('node_created' => t("Current node's creation time"));
37
    $form['default_argument_type']['#options'] += array('node_changed' => t("Current node's update time"));  }
45
    $form['default_argument_type']['#options'] += array('node_changed' => t("Current node's update time"));
46
  }
38 47

  
39 48
  /**
40 49
   * Set the empty argument value to the current date,
50
   *
41 51
   * formatted appropriately for this argument.
52
   *
53
   * @return string
54
   *   The default argument.
42 55
   */
43
  function get_default_argument($raw = FALSE) {
56
  public function get_default_argument($raw = FALSE) {
44 57
    if (!$raw && $this->options['default_argument_type'] == 'date') {
45 58
      return date($this->arg_format, REQUEST_TIME);
46 59
    }
47
    else if (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) {
60
    elseif (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) {
48 61
      foreach (range(1, 3) as $i) {
49 62
        $node = menu_get_object('node', $i);
50 63
        if (!empty($node)) {
......
71 84
  }
72 85

  
73 86
  /**
74
   * The date handler provides some default argument types, which aren't argument default plugins,
75
   * so addapt the export mechanism.
87
   * Adapt the export mechanism.
88
   *
89
   * The date handler provides some default argument types, which aren't
90
   * argument default plugins.
76 91
   */
77
  function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) {
78

  
92
  public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) {
79 93
    // Only use a special behaviour for the special argument types, else just
80 94
    // use the default behaviour.
81 95
    if ($option == 'default_argument_type') {
......
94 108
    return parent::export_plugin($indent, $prefix, $storage, $option, $definition, $parents);
95 109
  }
96 110

  
97

  
98
  function get_sort_name() {
111
  /**
112
   * {@inheritdoc}
113
   */
114
  public function get_sort_name() {
99 115
    return t('Date', array(), array('context' => 'Sort order'));
100 116
  }
117

  
101 118
}

Formats disponibles : Unified diff