Révision b720ea3e
Ajouté par Assos Assos il y a plus de 8 ans
drupal7/sites/all/modules/date/tests/date_field.test | ||
---|---|---|
52 | 52 |
$repeat = !empty($repeat) ? $repeat : 0; |
53 | 53 |
$todate = !empty($todate) ? $todate : 'optional'; |
54 | 54 |
$widget_type = !empty($widget_type) ? $widget_type : 'date_select'; |
55 |
$tz_handling = !empty($tz_handing) ? $tz_handling : 'site'; |
|
55 |
$tz_handling = !empty($tz_handling) ? $tz_handling : 'site';
|
|
56 | 56 |
$granularity = !empty($granularity) ? $granularity : array('year', 'month', 'day', 'hour', 'minute'); |
57 | 57 |
$year_range = !empty($year_range) ? $year_range : '2010:+1'; |
58 | 58 |
$input_format = !empty($input_format) ? $input_format : date_default_format($widget_type); |
... | ... | |
151 | 151 |
|
152 | 152 |
} |
153 | 153 |
|
154 |
/** |
|
155 |
* Creates a date field from an array of settings values. |
|
156 |
* |
|
157 |
* All values have defaults, only need to specify values that need to be |
|
158 |
* different. |
|
159 |
*/ |
|
160 |
protected function createMultiDateField($values = array()) { |
|
161 |
extract($values); |
|
162 |
|
|
163 |
$field_name = !empty($field_name) ? $field_name : 'field_test'; |
|
164 |
$entity_type = !empty($entity_type) ? $entity_type : 'node'; |
|
165 |
$bundle = !empty($bundle) ? $bundle : 'story'; |
|
166 |
$label = !empty($label) ? $label : 'Test'; |
|
167 |
$field_type = !empty($field_type) ? $field_type : 'datetime'; |
|
168 |
$repeat = !empty($repeat) ? $repeat : 0; |
|
169 |
$todate = !empty($todate) ? $todate : 'optional'; |
|
170 |
$widget_type = !empty($widget_type) ? $widget_type : 'date_select'; |
|
171 |
$this->verbose(!empty($tz_handling)); |
|
172 |
$tz_handling = !empty($tz_handling) ? $tz_handling : 'site'; |
|
173 |
$granularity = !empty($granularity) ? $granularity : array('year', 'month', 'day', 'hour', 'minute'); |
|
174 |
$year_range = !empty($year_range) ? $year_range : '2010:+1'; |
|
175 |
$input_format = !empty($input_format) ? $input_format : date_default_format($widget_type); |
|
176 |
$input_format_custom = !empty($input_format_custom) ? $input_format_custom : ''; |
|
177 |
$text_parts = !empty($text_parts) ? $text_parts : array(); |
|
178 |
$increment = !empty($increment) ? $increment : 15; |
|
179 |
$default_value = !empty($default_value) ? $default_value : 'now'; |
|
180 |
$default_value2 = !empty($default_value2) ? $default_value2 : 'blank'; |
|
181 |
$default_format = !empty($default_format) ? $default_format : 'long'; |
|
182 |
$cache_enabled = !empty($cache_enabled); |
|
183 |
$cache_count = !empty($cache_count) ? $cache_count : 4; |
|
184 |
$cardinality = !empty($cardinality) ? $cardinality : 1; |
|
185 |
|
|
186 |
$field = array( |
|
187 |
'field_name' => $field_name, |
|
188 |
'type' => $field_type, |
|
189 |
'cardinality' => $cardinality, |
|
190 |
'settings' => array( |
|
191 |
'granularity' => $granularity, |
|
192 |
'tz_handling' => $tz_handling, |
|
193 |
'timezone_db' => date_get_timezone_db($tz_handling), |
|
194 |
'repeat' => $repeat, |
|
195 |
'todate' => $todate, |
|
196 |
'cache_enabled' => $cache_enabled, |
|
197 |
'cache_count' => $cache_count, |
|
198 |
), |
|
199 |
); |
|
200 |
$instance = array( |
|
201 |
'entity_type' => $entity_type, |
|
202 |
'field_name' => $field_name, |
|
203 |
'label' => $label, |
|
204 |
'bundle' => $bundle, |
|
205 |
// Move the date right below the title. |
|
206 |
'weight' => -4, |
|
207 |
'widget' => array( |
|
208 |
'type' => $widget_type, |
|
209 |
// Increment for minutes and seconds, can be 1, 5, 10, 15, or 30. |
|
210 |
'settings' => array( |
|
211 |
'increment' => $increment, |
|
212 |
// The number of years to go back and forward in drop-down year |
|
213 |
// selectors. |
|
214 |
'year_range' => $year_range, |
|
215 |
'input_format' => $input_format, |
|
216 |
'input_format_custom' => $input_format_custom, |
|
217 |
'text_parts' => $text_parts, |
|
218 |
'label_position' => 'above', |
|
219 |
'repeat_collapsed' => 0, |
|
220 |
), |
|
221 |
'weight' => -4, |
|
222 |
), |
|
223 |
'settings' => array( |
|
224 |
'default_value' => $default_value, |
|
225 |
'default_value2' => $default_value2, |
|
226 |
), |
|
227 |
); |
|
228 |
|
|
229 |
$instance['display'] = array( |
|
230 |
'default' => array( |
|
231 |
'label' => 'above', |
|
232 |
'type' => 'date_default', |
|
233 |
'settings' => array( |
|
234 |
'format_type' => $default_format, |
|
235 |
'show_repeat_rule' => 'show', |
|
236 |
'multiple_number' => '', |
|
237 |
'multiple_from' => '', |
|
238 |
'multiple_to' => '', |
|
239 |
'fromto' => 'both', |
|
240 |
), |
|
241 |
'module' => 'date', |
|
242 |
'weight' => 0 , |
|
243 |
), |
|
244 |
'teaser' => array( |
|
245 |
'label' => 'above', |
|
246 |
'type' => 'date_default', |
|
247 |
'weight' => 0, |
|
248 |
'settings' => array( |
|
249 |
'format_type' => $default_format, |
|
250 |
'show_repeat_rule' => 'show', |
|
251 |
'multiple_number' => '', |
|
252 |
'multiple_from' => '', |
|
253 |
'multiple_to' => '', |
|
254 |
'fromto' => 'both', |
|
255 |
), |
|
256 |
'module' => 'date', |
|
257 |
), |
|
258 |
); |
|
259 |
|
|
260 |
$field = field_create_field($field); |
|
261 |
$instance = field_create_instance($instance); |
|
262 |
|
|
263 |
field_info_cache_clear(TRUE); |
|
264 |
field_cache_clear(TRUE); |
|
265 |
|
|
266 |
// Look at how the field got configured. |
|
267 |
$this->drupalGet("admin/structure/types/manage/$bundle/fields/$field_name"); |
|
268 |
$this->drupalGet("admin/structure/types/manage/$bundle/display"); |
|
269 |
} |
|
270 |
|
|
154 | 271 |
/** |
155 | 272 |
* @todo. |
156 | 273 |
*/ |
Formats disponibles : Unified diff
Weekly update of contrib modules