You are here

function accordion_menu_config in Accordion Menu 6

Same name and namespace in other branches
  1. 7 accordion_menu.module \accordion_menu_config()

Returns the block configuration settings.

Parameters

string $delta: The delta that uniquely identifies the block in the block system. If not specified, the default configuration will be returned.

Return value

array An associative array of configuration settings.

3 calls to accordion_menu_config()
_accordion_menu_block_configure in includes/configure.inc
Implements hook_block_configure().
_accordion_menu_block_save in includes/configure.inc
Implements hook_block_save().
_accordion_menu_block_view in includes/view.inc
Implements hook_block_view().

File

./accordion_menu.module, line 125
Provides primary Drupal hook implementations.

Code

function accordion_menu_config($delta = NULL) {
  $config = array(
    // Our settings.
    'menu_name' => 'Menu ' . $delta,
    'menu_source' => 'navigation',
    'block_source' => '',
    'script_scope' => 'footer',
    'header_link' => FALSE,
    'menu_expanded' => FALSE,
    // jQuery UI accordion settings.
    'animated' => 'slide',
    'auto_height' => FALSE,
    'clear_style' => FALSE,
    'fill_space' => FALSE,
    'event' => 'mousedown',
    'header' => 'h3',
    'collapsible' => TRUE,
    // in jQuery UI 1.6 this is 'alwaysOpen'
    'navigation' => FALSE,
  );
  if ($delta) {

    // Get the block configuration settings.
    foreach ($config as $key => $value) {
      $config[$key] = variable_get("accordion_menu_{$delta}_{$key}", $config[$key]);
      if (in_array($key, array(
        'animated',
        'event',
        'script_scope',
      ))) {

        // Value may include letters only.
        // This is not validating the string, but simply requiring one.
        if (preg_match('@[^a-z]@', strtolower($config[$key]))) {
          $config[$key] = $value;
        }
      }
      elseif ($key == 'header') {

        // Value may include letters and a digit only.
        // This is not a true test for an HTML tag, but should prevent foul play.
        preg_match('@^([a-z]+([1-9]|)).*@', strtolower($config[$key]), $matches);
        if (empty($matches) || $matches[0] != $matches[1]) {
          $config[$key] = $value;
        }
      }
    }
  }
  $config['delta'] = $delta;
  return $config;
}