You are here

function rate_ui_widget_load_layout in Rate 7.2

Load widget layout from database into storage array.

Parameters

int $wid:

array $storage:

1 call to rate_ui_widget_load_layout()
rate_ui_widget_load_widget in ui/rate_ui.form.inc
Load widget settings from database into storage array.

File

ui/rate_ui.form.inc, line 951
This file contains the differtent Rate UI forms.

Code

function rate_ui_widget_load_layout($wid, &$storage) {
  $elements = rate_ui_widget_elements($storage);
  foreach ($elements as $type => $name) {
    $storage["element_{$type}"] = 0;
    foreach (array(
      1,
      2,
      4,
      8,
      16,
    ) as $i) {
      $storage["element_{$type}_{$i}"] = FALSE;
    }
    $storage["element_{$type}_prefix"] = '';
    $storage["element_{$type}_suffix"] = '';
    $storage["element_{$type}_weight"] = 128;
  }
  $elements = db_select('rate_widget_element', 'e')
    ->fields('e', array(
    'type',
    'prefix',
    'suffix',
    'weight',
    'mode',
  ))
    ->condition('e.wid', $wid)
    ->execute()
    ->fetchAll();
  foreach ($elements as $element) {
    $storage["element_{$element->type}"] = $element->mode;
    foreach (array(
      1,
      2,
      4,
      8,
      16,
    ) as $i) {
      $storage["element_{$element->type}_{$i}"] = (bool) ($element->mode & $i);
    }
    $storage["element_{$element->type}_prefix"] = $element->prefix;
    $storage["element_{$element->type}_suffix"] = $element->suffix;
    $storage["element_{$element->type}_weight"] = $element->weight;
  }
}