Same name and namespace in other branches
  1. 4.6.x modules/block.module \block_admin_configure()
  2. 5.x modules/block/block.module \block_admin_configure()
  3. 6.x modules/block/block.admin.inc \block_admin_configure()
  4. 7.x modules/block/block.admin.inc \block_admin_configure()

Menu callback; displays the block configuration form.

1 string reference to 'block_admin_configure'
block_menu in modules/block.module
Implementation of hook_menu().

File

modules/block.module, line 359
Controls the boxes that are displayed around the main content.

Code

function block_admin_configure($module = NULL, $delta = 0) {
  $form['module'] = array(
    '#type' => 'value',
    '#value' => $module,
  );
  $form['delta'] = array(
    '#type' => 'value',
    '#value' => $delta,
  );
  $edit = db_fetch_array(db_query("SELECT pages, visibility, custom FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));

  // Module-specific block configurations.
  if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
    $form['block_settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('Block specific settings'),
      '#collapsible' => true,
    );
    foreach ($settings as $k => $v) {
      $form['block_settings'][$k] = $v;
    }
  }

  // Get the block subject for the page title.
  $info = module_invoke($module, 'block', 'list');
  drupal_set_title(t("'%name' block", array(
    '%name' => $info[$delta]['info'],
  )));

  // Standard block configurations.
  $form['user_vis_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('User specific visibility settings'),
    '#collapsible' => true,
  );
  $form['user_vis_settings']['custom'] = array(
    '#type' => 'radios',
    '#title' => t('Custom visibility settings'),
    '#options' => array(
      t('Users cannot control whether or not they see this block.'),
      t('Show this block by default, but let individual users hide it.'),
      t('Hide this block by default but let individual users show it.'),
    ),
    '#description' => t('Allow individual users to customize the visibility of this block in their account settings.'),
    '#default_value' => $edit['custom'],
  );
  $form['page_vis_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Page specific visibility settings'),
    '#collapsible' => true,
  );
  $access = user_access('use PHP for block visibility');
  if ($edit['visibility'] == 2 && !$access) {
    $form['page_vis_settings'] = array();
    $form['page_vis_settings']['visibility'] = array(
      '#type' => 'value',
      '#value' => 2,
    );
    $form['page_vis_settings']['pages'] = array(
      '#type' => 'value',
      '#value' => $edit['pages'],
    );
  }
  else {
    $options = array(
      t('Show on every page except the listed pages.'),
      t('Show on only the listed pages.'),
    );
    $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '%blog' for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
      '%blog' => theme('placeholder', 'blog'),
      '%blog-wildcard' => theme('placeholder', 'blog/*'),
      '%front' => theme('placeholder', '<front>'),
    ));
    if ($access) {
      $options[] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
      $description .= t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array(
        '%php' => theme('placeholder', '<?php ?>'),
      ));
    }
    $form['page_vis_settings']['visibility'] = array(
      '#type' => 'radios',
      '#title' => t('Show block on specific pages'),
      '#options' => $options,
      '#default_value' => $edit['visibility'],
    );
    $form['page_vis_settings']['pages'] = array(
      '#type' => 'textarea',
      '#title' => t('Pages'),
      '#default_value' => $edit['pages'],
      '#description' => $description,
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save block'),
  );
  return drupal_get_form('block_admin_configure', $form);
}