function _rate_update_templates_data in Rate 6.2
Same name and namespace in other branches
- 7.2 rate.install \_rate_update_templates_data()
- 7 rate.install \_rate_update_templates_data()
Update css and js attributes in the widget objects.
This function has to be called when the information from hook_rate_templates() is changed.
1 call to _rate_update_templates_data()
- rate_update_6001 in ./
rate.install - Implements hook_update_N().
File
- ./
rate.install, line 15
Code
function _rate_update_templates_data() {
$templates = array();
foreach (module_implements('rate_templates') as $module) {
foreach (module_invoke($module, 'rate_templates') as $name => $template) {
$templates[$name] = $template;
}
}
$widgets = variable_get('rate_widgets', array());
foreach ($widgets as $widget_id => $widget) {
$template = isset($widget->template) ? $widget->template : NULL;
if (isset($templates[$template])) {
if (isset($widget->css)) {
unset($widget->css);
}
if (isset($templates[$template]->css)) {
$widget->css = $templates[$template]->css;
}
if (isset($widget->js)) {
unset($widget->js);
}
if (isset($templates[$template]->js)) {
$widget->js = $templates[$template]->js;
}
}
$widgets[$widget_id] = $widget;
}
variable_set('rate_widgets', $widgets);
}