function rate_ui_widget_form_step_layout in Rate 7.2
Generate form fields for the sixth step in the rate widget form.
1 call to rate_ui_widget_form_step_layout()
- rate_ui_widget_form in ui/
rate_ui.form.inc - Implements hook_form().
File
- ui/
rate_ui.form.inc, line 546 - This file contains the differtent Rate UI forms.
Code
function rate_ui_widget_form_step_layout($form, &$form_state, $widget_type = NULL) {
$modes = array(
t('!abbr = full', array(
'!abbr' => t('f', array(), array(
'context' => 'rate viewmodes',
)),
)),
t('!abbr = compact', array(
'!abbr' => t('c', array(), array(
'context' => 'rate viewmodes',
)),
)),
t('!abbr = full disabled', array(
'!abbr' => t('fd', array(), array(
'context' => 'rate viewmodes',
)),
)),
t('!abbr = compact disabled', array(
'!abbr' => t('cd', array(), array(
'context' => 'rate viewmodes',
)),
)),
t('!abbr = closed', array(
'!abbr' => t('cl', array(), array(
'context' => 'rate viewmodes',
)),
)),
);
$modes = theme('item_list', array(
'items' => $modes,
));
$form['info'] = array(
'#markup' => t('<p>Check which elements should be included in the widget. Modes are: </p>!modes', array(
'!modes' => $modes,
)),
);
$form['elements'] = array(
'#theme' => 'rate_ui_layout',
);
$weight_options = array();
for ($i = 1; $i <= 255; ++$i) {
$weight_options[$i] = $i;
}
$weight = 0;
$elements = rate_ui_widget_elements($form_state['storage']);
foreach ($elements as $type => $name) {
$default = 0;
if (preg_match('/^(button|rating)/', $type)) {
$default = 31;
// all formatters
}
if (preg_match('/^(description)/', $type)) {
$default |= 1;
// full
$default |= 4;
// full disabled
}
$form['elements'][$type] = array();
$form['elements'][$type]["element_{$type}"] = array(
'#markup' => $name,
);
$form['elements'][$type]['mode'] = array();
$form['elements'][$type]['mode']["element_{$type}_1"] = array(
'#type' => 'checkbox',
'#title' => t('f', array(), array(
'context' => 'rate viewmodes',
)),
'#default_value' => isset($form_state['storage']["element_{$type}_1"]) ? $form_state['storage']["element_{$type}_1"] : $default & 1,
);
$form['elements'][$type]['mode']["element_{$type}_2"] = array(
'#type' => 'checkbox',
'#title' => t('c', array(), array(
'context' => 'rate viewmodes',
)),
'#default_value' => isset($form_state['storage']["element_{$type}_2"]) ? $form_state['storage']["element_{$type}_2"] : $default & 2,
);
$form['elements'][$type]['mode']["element_{$type}_4"] = array(
'#type' => 'checkbox',
'#title' => t('fd', array(), array(
'context' => 'rate viewmodes',
)),
'#default_value' => isset($form_state['storage']["element_{$type}_4"]) ? $form_state['storage']["element_{$type}_4"] : $default & 4,
);
$form['elements'][$type]['mode']["element_{$type}_8"] = array(
'#type' => 'checkbox',
'#title' => t('cd', array(), array(
'context' => 'rate viewmodes',
)),
'#default_value' => isset($form_state['storage']["element_{$type}_8"]) ? $form_state['storage']["element_{$type}_8"] : $default & 8,
);
$form['elements'][$type]['mode']["element_{$type}_16"] = array(
'#type' => 'checkbox',
'#title' => t('cl', array(), array(
'context' => 'rate viewmodes',
)),
'#default_value' => isset($form_state['storage']["element_{$type}_16"]) ? $form_state['storage']["element_{$type}_16"] : $default & 16,
);
$form['elements'][$type]["element_{$type}_prefix"] = array(
'#type' => 'textfield',
'#title' => t('Prefix HTML'),
'#default_value' => isset($form_state['storage']["element_{$type}_prefix"]) ? $form_state['storage']["element_{$type}_prefix"] : '',
);
$form['elements'][$type]["element_{$type}_suffix"] = array(
'#type' => 'textfield',
'#title' => t('Suffix HTML'),
'#default_value' => isset($form_state['storage']["element_{$type}_suffix"]) ? $form_state['storage']["element_{$type}_suffix"] : '',
);
$form['elements'][$type]["element_{$type}_weight"] = array(
'#type' => 'select',
'#title' => t('Weight'),
'#options' => $weight_options,
'#default_value' => isset($form_state['storage']["element_{$type}_weight"]) ? $form_state['storage']["element_{$type}_weight"] : ++$weight,
);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['previous'] = array(
'#type' => 'submit',
'#value' => t('Previous'),
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}