function rate_ui_widget_load_buttons in Rate 7.2
Load widget buttons from database into storage array.
Parameters
int $wid:
array $storage:
1 call to rate_ui_widget_load_buttons()
- 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 887 - This file contains the differtent Rate UI forms.
Code
function rate_ui_widget_load_buttons($wid, &$storage) {
$storage['separate_images'] = TRUE;
$storage['buttoncount'] = 1;
// Select rate widget by widget id.
$buttons = db_select('rate_widget_button', 'b')
->fields('b', array(
'num',
'label',
'value',
'description',
'width',
'height',
'img_default',
'img_highlighted',
'img_default_voted',
'img_highlighted_voted',
'img_disabled',
'img_disabled_voted',
))
->condition('b.wid', $wid)
->execute()
->fetchAll();
foreach ($buttons as $button) {
$num = $button->num;
$storage['buttoncount'] = max($storage['buttoncount'], $num);
$storage["button{$num}_label"] = $button->label;
$storage["button{$num}_value"] = $button->value;
$storage["button{$num}_description"] = $button->description;
$kinds = array(
'default',
'highlighted',
'default_voted',
'highlighted_voted',
'disabled',
'disabled_voted',
);
foreach ($kinds as $kind) {
if (empty($button->{"img_{$kind}"})) {
$storage['images'] = FALSE;
}
elseif (preg_match('/^(.*)\\@([0-9]+),([0-9]+)\\:([0-9]+),([0-9]+)$/', $button->{"img_{$kind}"}, $match)) {
$storage['sprites'] = TRUE;
if (is_numeric($match[1])) {
$storage['upload'] = TRUE;
$storage['sprite_file'] = $match[1];
}
else {
$storage['upload'] = FALSE;
$storage['sprite_filepath'] = $match[1];
}
$storage["button{$num}_{$kind}_x"] = $match[2];
$storage["button{$num}_{$kind}_y"] = $match[3];
$storage["button{$num}_{$kind}_width"] = $match[4];
$storage["button{$num}_{$kind}_height"] = $match[5];
}
elseif (is_numeric($button->{"img_{$kind}"})) {
$storage["button{$num}_{$kind}_file"] = $button->{"img_{$kind}"};
}
else {
$storage["button{$num}_{$kind}_filepath"] = $button->{"img_{$kind}"};
}
}
}
}