You are here

function ctools_automodal_menu_alter in CTools Auto-modal 7

Implements hook_menu_alter().

File

./ctools_automodal.module, line 18

Code

function ctools_automodal_menu_alter(&$items) {
  $modal_paths = array();
  foreach ($items as $path => $item) {
    if (!empty($item['modal']) && strpos($path, '%ctools_js') === FALSE) {
      if ($item['page callback'] == 'drupal_get_form') {
        $items["{$path}/%ctools_js"] = $item;
        $items["{$path}/%ctools_js"]['page callback'] = 'ctools_automodal_get_form';
        $items["{$path}/%ctools_js"]['page arguments'][] = substr_count($path, '/') + 1;
        $items["{$path}/%ctools_js"]['type'] = MENU_CALLBACK;
      }
      else {
        $items["{$path}/%ctools_js"] = $item + array(
          'page arguments' => array(),
        );
        $items["{$path}/%ctools_js"]['page callback'] = 'ctools_automodal_get_page';
        array_unshift($items["{$path}/%ctools_js"]['page arguments'], $item['page callback']);
        $items["{$path}/%ctools_js"]['page arguments'][] = substr_count($path, '/') + 1;
        $items["{$path}/%ctools_js"]['type'] = MENU_CALLBACK;
      }
      $modal_paths[] = preg_replace('/%[^\\/]*/', '*', $path);
    }
  }
  variable_set('ctools_automodal_paths', $modal_paths);
}