function sharedblocks_publish_form in Shared Blocks 7.2
Same name and namespace in other branches
- 6 sharedblocks.module \sharedblocks_publish_form()
- 7 sharedblocks.module \sharedblocks_publish_form()
From constructor for the publish blocks form.
See also
sharedblocks_publish_form_submit()
1 string reference to 'sharedblocks_publish_form'
- sharedblocks_menu in ./
sharedblocks.module - Implements hook_menu().
File
- ./
sharedblocks.admin.inc, line 99 - Administration page callbacks for the sharedblocks module.
Code
function sharedblocks_publish_form($form, &$form_state) {
module_load_include('inc', 'sharedblocks', 'sharedblocks.publish');
$form = array();
$form['sharedblocks_publish'] = array(
'#tree' => TRUE,
'#title' => t('Published Blocks'),
);
// Get a list of all the available blocks in the system.
foreach (module_implements('block_info') as $module) {
if ($module_blocks = module_invoke($module, 'block_info')) {
// Loop through the list.
foreach ($module_blocks as $delta => $block_info) {
if (!sharedblocks_is_block_publishable($module, $delta, $block_info)) {
continue;
}
// This block is published if it's set to 1 in the array.
$is_published = sharedblocks_is_block_published($module, $delta);
// Make checkboxes for each one.
$form['sharedblocks_publish'][$module][$delta] = array(
'#type' => 'checkbox',
'#title' => check_plain($block_info['info']),
'#default_value' => $is_published,
);
if ($is_published && ($uri = sharedblocks_get_publish_uri($module, $delta))) {
$form['sharedblocks_publish'][$module][$delta]['#description'] = url($uri['path'], $uri['options']);
}
}
}
}
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Settings'),
);
$form['settings']['sharedblocks_require_token'] = array(
'#type' => 'checkbox',
'#title' => t('Require a unique security token in the URL for sites to fetch published these blocks.'),
'#default_value' => variable_get('sharedblocks_require_token', 1),
);
if (empty($form['settings']['sharedblocks_require_token']['#default_value'])) {
$form['settings']['sharedblocks_require_token']['#description'] = t('Enabling this option may break sites that are currently subscribed to your blocks. Make sure to update all sites subscribed to these blocks.');
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}