function sharedblocks_subscribe_form in Shared Blocks 6
Same name and namespace in other branches
- 7 sharedblocks.module \sharedblocks_subscribe_form()
Form for adding new subscription block.
1 string reference to 'sharedblocks_subscribe_form'
- sharedblocks_menu in ./
sharedblocks.module - Implementation of hook_menu().
File
- ./
sharedblocks.module, line 200
Code
function sharedblocks_subscribe_form(&$form_state, $id = NULL) {
// Populate the default values.
$edit = array();
if (!is_null($id) && is_numeric($id)) {
$edit = db_fetch_array(db_query('SELECT * FROM {sharedblocks} WHERE id = %d', $id));
}
$edit += array(
'id' => NULL,
'name' => '',
'label' => '',
'url' => '',
'update_interval' => 3600,
);
$form = array();
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $edit['name'],
'#description' => t('Machine readable name of this block. Alphanumeric and underscore characters only.'),
'#required' => TRUE,
);
$form['url'] = array(
'#type' => 'textfield',
'#title' => t('Subscribe URL'),
'#default_value' => $edit['url'],
'#description' => t('The URL to the block you wish to subscribe to, supplied by publishing site.'),
'#required' => TRUE,
);
$period = drupal_map_assoc(array(
60,
300,
600,
1200,
1800,
3600,
10800,
21600,
32400,
43200,
86400,
172800,
259200,
604800,
1209600,
2419200,
4838400,
9676800,
), 'format_interval');
$form['update_interval'] = array(
'#type' => 'select',
'#title' => t('Refresh rate'),
'#options' => $period,
'#description' => t("How frequently should this block's content be updated? Note that this can only run as often as cron runs."),
'#default_value' => $edit['update_interval'],
);
if (!is_null($id)) {
$form['id'] = array(
'#type' => 'value',
'#value' => $id,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}