1 block.admin.inc | block_admin_configure($form, &$form_state, $delta = NULL) |
Form constructor for the block configuration form.
Also used by block_add_block_form() for adding a new custom block.
Parameters
array $form: An associative array containing the structure of a portion of the form.
array $form_state: A keyed array containing the current state of the form.
$delta: Unique ID of the block within the context of $module.
See also
block_admin_configure_validate()
block_admin_configure_submit()
Related topics
File
- core/
modules/ block/ block.admin.inc, line 94 - Admin page callbacks for the Block module.
Code
function block_admin_configure($form, &$form_state, $delta = NULL) {
if ($delta) {
$langcode = isset($form['langcode']) ? $form['langcode']['#value'] : NULL;
$custom_block = block_custom_block_load($delta, $langcode);
if ($langcode) {
$custom_block['langcode'] = $langcode;
}
if (!$custom_block) {
backdrop_not_found();
exit();
}
}
else {
$custom_block = array(
'info' => '',
'title' => '',
'body' => array('value' => '', 'format' => NULL),
'default_langcode' => LANGUAGE_NONE,
);
}
if ($custom_block['info']) {
backdrop_set_title(t("'%name' block", array('%name' => $custom_block['info'])), PASS_THROUGH);
}
else {
backdrop_set_title(t('Add custom block'));
}
// Set title for translate block form.
if (isset($form['langcode'])) {
$language = $language = language_load($form['langcode']['#value']);
backdrop_set_title(t("Translate '%name' block to %language", array('%name' => $custom_block['info'], '%language' => $language->name)), PASS_THROUGH);
}
// Call our own block configuration form (also used by Layout module).
$form += block_custom_block_form($custom_block, TRUE);
// Prepare cancel link.
if (isset($_GET['destination'])) {
$path = $_GET['destination'];
}
elseif (isset($_SERVER['HTTP_REFERER'])) {
$path = $_SERVER['HTTP_REFERER'];
}
elseif (user_access('administer blocks')) {
$path = 'admin/structure/block';
}
else {
$path = '<front>';
}
$options = backdrop_parse_url($path);
$options['attributes']['class'][] = 'form-cancel';
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save block'),
);
if ($delta) {
$form['actions']['delete'] = array(
'#type' => 'link',
'#title' => t('Delete'),
'#href' => 'admin/structure/block/manage/' . $delta . '/delete',
'#attributes' => array('class' => array('button', 'button-secondary', 'form-delete')),
);
}
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => $options['path'],
'#options' => $options,
'#weight' => 1,
);
return $form;
}