function sharebar_addbutton in ShareBar 6
Same name and namespace in other branches
- 7.2 sharebar.admin.inc \sharebar_addbutton()
- 7 sharebar.admin.inc \sharebar_addbutton()
Form builder: create buttons.
1 string reference to 'sharebar_addbutton'
- sharebar_menu in ./
sharebar.module - Implements hook_menu().
File
- ./
sharebar.admin.inc, line 54 - Admin page callbacks for the block module.
Code
function sharebar_addbutton(&$form_state, $edit = array()) {
$mname = arg(4);
$button = new stdClass();
$button->name = $button->machine_name = $button->big_button = $button->small_button = $button->enabled = $button->weight = '';
if ($mname) {
$buttons = unserialize(variable_get('sharebar_buttons', sharebar_buttons_def()));
if (is_array($buttons) && count($buttons)) {
$button = $buttons[$mname];
}
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $button->name,
'#maxlength' => 255,
'#required' => TRUE,
);
$form['old_machine_name'] = array(
'#type' => 'value',
'#value' => $button->machine_name,
);
$form['big_button'] = array(
'#type' => 'textarea',
'#title' => t('Big button'),
'#default_value' => $button->big_button,
'#required' => TRUE,
);
$form['small_button'] = array(
'#type' => 'textarea',
'#title' => t('Small button'),
'#default_value' => $button->small_button,
'#required' => TRUE,
);
$form['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enabled'),
'#default_value' => $button->enabled,
);
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#delta' => 50,
'#default_value' => $button->weight,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}