You are here

function _rate_update_templates_data in Rate 7

Same name and namespace in other branches
  1. 6.2 rate.install \_rate_update_templates_data()
  2. 7.2 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
Update paths to JS and CSS files.

File

./rate.install, line 61
Installation/Uninstallation functions for rate module.

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);
}