Révision 3461d8cb
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/fivestar/fivestar.install | ||
---|---|---|
37 | 37 |
drupal_load('module', 'fivestar'); |
38 | 38 |
$fields = field_read_fields(array('module' => 'fivestar')); |
39 | 39 |
$tags_numeric = array_values(fivestar_get_tags()); |
40 |
|
|
40 |
|
|
41 | 41 |
foreach ($fields as $field) { |
42 | 42 |
if (is_numeric($field['settings']['axis'])) { |
43 | 43 |
$field['settings']['axis'] = $tags_numeric[$field['settings']['axis']]; |
... | ... | |
60 | 60 |
} |
61 | 61 |
} |
62 | 62 |
|
63 |
|
|
63 |
|
|
64 | 64 |
/** |
65 | 65 |
* Convert all existing fivestar/node_type settings into fields with exposed fivestar formatters |
66 | 66 |
*/ |
... | ... | |
104 | 104 |
'feedback_enable' => variable_get('fivestar_feedback_' . $var_suffix, 1), |
105 | 105 |
'style' => variable_get('fivestar_style_' . $var_suffix, 'average'), |
106 | 106 |
'text' => variable_get('fivestar_text_' . $var_suffix, 'dual'), |
107 |
'title' => variable_get('fivestar_title_' . $var_suffix, 1), |
|
107 | 108 |
); |
108 | 109 |
|
109 | 110 |
if (variable_get('fivestar_' . $var_suffix, FALSE)) { |
... | ... | |
127 | 128 |
); |
128 | 129 |
$field = field_create_field($field_values); |
129 | 130 |
} |
130 |
|
|
131 |
|
|
131 | 132 |
// Create an instance of the field in this bundle |
132 | 133 |
$instance = field_read_instance('node', $field['field_name'], $type, array('include_deleted' => TRUE)); |
133 | 134 |
if (empty($instance)) { |
134 |
$settings['allow_clear'] = $settings['unvote_enable']; |
|
135 |
$settings['style'] = $settings['star_display']; |
|
136 |
$settings['text'] = $settings['text_display']; |
|
137 |
|
|
138 | 135 |
$instance_info = array( |
139 | 136 |
'field_name' => $field['field_name'], |
140 | 137 |
'entity_type' => 'node', |
... | ... | |
160 | 157 |
'settings' => $settings, |
161 | 158 |
); |
162 | 159 |
} |
163 |
|
|
160 |
|
|
161 |
// Set the widget. |
|
162 |
$widget = variable_get('fivestar_widget' . $var_suffix, 'default'); |
|
163 |
$instance_info['widget']['settings']['widget']['fivestar_widget'] = $widget; |
|
164 |
|
|
164 | 165 |
field_create_instance($instance_info); |
165 | 166 |
} |
166 | 167 |
} |
167 | 168 |
} |
168 | 169 |
} |
169 |
|
|
170 |
|
|
170 | 171 |
// Rebuild the menu to remove the node type tag form paths |
171 | 172 |
menu_rebuild(); |
172 | 173 |
_field_info_collate_fields(TRUE); |
... | ... | |
227 | 228 |
} |
228 | 229 |
} |
229 | 230 |
} |
231 |
|
|
232 |
/** |
|
233 |
* Preserve setting after new feature preventing re-votes |
|
234 |
* @see http://drupal.org/node/356605 |
|
235 |
*/ |
|
236 |
function fivestar_update_7206() { |
|
237 |
$fields = field_read_fields(array('type' => 'fivestar')); |
|
238 |
foreach ($fields as $field) { |
|
239 |
// Iterate through the instances of the field. |
|
240 |
$instances = field_read_instances(array('field_name' => $field['field_name'])); |
|
241 |
foreach ($instances as $instance) { |
|
242 |
// The default should be to allow re-voting. |
|
243 |
$instance['settings']['allow_revote'] = TRUE; |
|
244 |
// Update the instance |
|
245 |
field_update_instance($instance); |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
/** |
|
251 |
* Preserve setting after new feature preventing own votes |
|
252 |
* @see http://drupal.org/node/189527 |
|
253 |
*/ |
|
254 |
function fivestar_update_7207() { |
|
255 |
$fields = field_read_fields(array('type' => 'fivestar')); |
|
256 |
foreach ($fields as $field) { |
|
257 |
// Iterate through the instances of the field. |
|
258 |
$instances = field_read_instances(array('field_name' => $field['field_name'])); |
|
259 |
foreach ($instances as $instance) { |
|
260 |
// The default should be to allow own votes. |
|
261 |
$instance['settings']['allow_ownvote'] = TRUE; |
|
262 |
// Update the instance |
|
263 |
field_update_instance($instance); |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
|
|
268 |
/** |
|
269 |
* Change field formatters to ensure unique. |
|
270 |
* @see http://drupal.org/node/1063754 |
|
271 |
*/ |
|
272 |
function fivestar_update_7208() { |
|
273 |
$fields = field_read_fields(array('type' => 'fivestar')); |
|
274 |
foreach ($fields as $field) { |
|
275 |
// Iterate through the instances of the field. |
|
276 |
$instances = field_read_instances(array('field_name' => $field['field_name'])); |
|
277 |
foreach ($instances as $instance) { |
|
278 |
$updated = FALSE; |
|
279 |
foreach ($instance['display'] as &$display) { |
|
280 |
if (in_array($display['type'], array('default', 'percentage', 'rating'))) { |
|
281 |
$updated = TRUE; |
|
282 |
$display['type'] = 'fivestar_formatter_' . $display['type']; |
|
283 |
} |
|
284 |
} |
|
285 |
if ($updated) { |
|
286 |
// Only trigger instance update if we actually changed anything. |
|
287 |
field_update_instance($instance); |
|
288 |
} |
|
289 |
} |
|
290 |
} |
|
291 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules