protected function RateDefaultWidget::loadButtons in Rate 7.2
Load buttons from database.
1 call to RateDefaultWidget::loadButtons()
- RateDefaultWidget::load in classes/
default.inc - Load the widget from database.
File
- classes/
default.inc, line 57
Class
Code
protected function loadButtons() {
$buttons = db_select('rate_widget_button', 'b')
->fields('b', array(
'num',
'label',
'value',
'width',
'height',
'img_default',
'img_highlighted',
'img_default_voted',
'img_highlighted_voted',
'img_disabled',
'img_disabled_voted',
))
->condition('b.wid', $this->wid)
->orderBy('b.num', 'asc')
->execute()
->fetchAll();
// Loop the result to find files to load.
$fids = array();
foreach ($buttons as $button) {
if (!$this->sprites) {
$img = $button->img_default;
if (is_numeric($img)) {
$fids[] = $img;
}
}
}
if ($fids) {
$fids = array_filter(array_unique($fids));
$files = file_load_multiple($fids);
}
// Second loop to generate buttons.
foreach ($buttons as $button) {
$this->elements["button{$button->num}"] = new RateButton($button->num, $button->label, $button->value, $this
->getToken($button->num), FALSE, '');
}
}