Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/plugins/views_plugin_cache_time.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_cache_plugins |
12 | 12 |
*/ |
13 | 13 |
class views_plugin_cache_time extends views_plugin_cache { |
14 |
function option_definition() { |
|
14 |
|
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function option_definition() { |
|
15 | 19 |
$options = parent::option_definition(); |
16 | 20 |
$options['results_lifespan'] = array('default' => 3600); |
17 | 21 |
$options['results_lifespan_custom'] = array('default' => 0); |
... | ... | |
21 | 25 |
return $options; |
22 | 26 |
} |
23 | 27 |
|
24 |
function options_form(&$form, &$form_state) { |
|
28 |
/** |
|
29 |
* {@inheritdoc} |
|
30 |
*/ |
|
31 |
public function options_form(&$form, &$form_state) { |
|
25 | 32 |
parent::options_form($form, $form_state); |
26 | 33 |
$options = array(60, 300, 1800, 3600, 21600, 518400); |
27 | 34 |
$options = drupal_map_assoc($options, 'format_interval'); |
... | ... | |
67 | 74 |
); |
68 | 75 |
} |
69 | 76 |
|
70 |
function options_validate(&$form, &$form_state) { |
|
77 |
/** |
|
78 |
* {@inheritdoc} |
|
79 |
*/ |
|
80 |
public function options_validate(&$form, &$form_state) { |
|
71 | 81 |
$custom_fields = array('output_lifespan', 'results_lifespan'); |
72 | 82 |
foreach ($custom_fields as $field) { |
73 | 83 |
if ($form_state['values']['cache_options'][$field] == 'custom' && !is_numeric($form_state['values']['cache_options'][$field . '_custom'])) { |
74 |
form_error($form[$field .'_custom'], t('Custom time values must be numeric.')); |
|
84 |
form_error($form[$field . '_custom'], t('Custom time values must be numeric.'));
|
|
75 | 85 |
} |
76 | 86 |
} |
77 | 87 |
} |
78 | 88 |
|
79 |
function summary_title() { |
|
89 |
/** |
|
90 |
* {@inheritdoc} |
|
91 |
*/ |
|
92 |
public function summary_title() { |
|
80 | 93 |
$results_lifespan = $this->get_lifespan('results'); |
81 | 94 |
$output_lifespan = $this->get_lifespan('output'); |
82 | 95 |
return format_interval($results_lifespan, 1) . '/' . format_interval($output_lifespan, 1); |
83 | 96 |
} |
84 | 97 |
|
85 |
function get_lifespan($type) { |
|
98 |
/** |
|
99 |
* {@inheritdoc} |
|
100 |
*/ |
|
101 |
public function get_lifespan($type) { |
|
86 | 102 |
$lifespan = $this->options[$type . '_lifespan'] == 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan']; |
87 | 103 |
return $lifespan; |
88 | 104 |
} |
89 | 105 |
|
90 |
function cache_expire($type) { |
|
106 |
/** |
|
107 |
* {@inheritdoc} |
|
108 |
*/ |
|
109 |
public function cache_expire($type) { |
|
91 | 110 |
$lifespan = $this->get_lifespan($type); |
92 | 111 |
if ($lifespan) { |
93 | 112 |
$cutoff = REQUEST_TIME - $lifespan; |
... | ... | |
98 | 117 |
} |
99 | 118 |
} |
100 | 119 |
|
101 |
function cache_set_expire($type) { |
|
120 |
/** |
|
121 |
* {@inheritdoc} |
|
122 |
*/ |
|
123 |
public function cache_set_expire($type) { |
|
102 | 124 |
$lifespan = $this->get_lifespan($type); |
103 | 125 |
if ($lifespan) { |
104 | 126 |
return time() + $lifespan; |
... | ... | |
108 | 130 |
} |
109 | 131 |
} |
110 | 132 |
|
111 |
function cache_set($type) { |
|
133 |
/** |
|
134 |
* {@inheritdoc} |
|
135 |
*/ |
|
136 |
public function cache_set($type) { |
|
112 | 137 |
$lifespan = $this->get_lifespan($type); |
113 | 138 |
if ($lifespan >= 0) { |
114 | 139 |
parent::cache_set($type); |
115 | 140 |
} |
116 | 141 |
} |
117 | 142 |
|
118 |
function cache_get($type) { |
|
143 |
/** |
|
144 |
* {@inheritdoc} |
|
145 |
*/ |
|
146 |
public function cache_get($type) { |
|
119 | 147 |
$lifespan = $this->get_lifespan($type); |
120 | 148 |
if ($lifespan >= 0) { |
121 | 149 |
return parent::cache_get($type); |
... | ... | |
124 | 152 |
return FALSE; |
125 | 153 |
} |
126 | 154 |
} |
155 |
|
|
127 | 156 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules