diff --git a/modalframe.info b/modalframe.info index b1b4ead..51e05c9 100644 --- a/modalframe.info +++ b/modalframe.info @@ -1,5 +1,4 @@ name = Modal Frame API description = Provides an API to render an iframe within a modal dialog based on the jQuery UI Dialog plugin. package = Modal frame -dependencies[] = jquery_ui -core = 6.x +core = 7.x diff --git a/modalframe.module b/modalframe.module index 3f044c6..3bf045f 100644 --- a/modalframe.module +++ b/modalframe.module @@ -49,14 +49,39 @@ * @ingroup themeable */ function modalframe_theme_registry_alter(&$theme_registry) { - if (isset($theme_registry['page']) && isset($theme_registry['page']['theme paths'])) { + if (isset($theme_registry['page'])) { + $theme_registry['page']['theme paths'] = array(); $module_path = drupal_get_path('module', 'modalframe'); - array_unshift($theme_registry['page']['theme paths'], $module_path); + $theme = list_themes(); + $theme_registry_copy = $theme_registry; // munge on a copy + _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'pow', $module_path); + $theme_registry += array_diff_key($theme_registry_copy, $theme_registry); + $hooks = array('page', 'html'); + foreach ($hooks as $h) { + _modalframe_insert_after_first_element($theme_registry[$h]['theme paths'], $module_path); + } + + // Add pre-preprocess function for page template. array_unshift($theme_registry['page']['preprocess functions'], 'modalframe_pre_preprocess_page'); } } /** + * Helper function for modalframe_theme_registry_alter() + * + * Alters order of elements in theme paths array. + * + * @param array $a + * @param array $element + */ +function _modalframe_insert_after_first_element(&$a, $element) { + if(is_array($a)) { + $first_element = array_shift($a); + array_unshift($a, $first_element, $element); + } +} + +/** * Preprocess template variables for page.tpl.php - step 1. * * Performance enhancement: prevent template_preprocess_page() from generating @@ -69,6 +94,15 @@ function modalframe_pre_preprocess_page(&$variables) { } /** + * Preprocess template variables for html.tpl.php + */ +function modalframe_preprocess_html(&$variables) { + if (!empty($GLOBALS['modalframe_page_template'])) { + $variables['theme_hook_suggestions'][] = 'html__modalframe'; + } +} + +/** * Preprocess template variables for page.tpl.php - step 2. * * Now that we have altered the registry entry for theme('page'), we can tell @@ -85,10 +119,7 @@ function modalframe_pre_preprocess_page(&$variables) { */ function modalframe_preprocess_page(&$variables) { if (!empty($GLOBALS['modalframe_page_template'])) { - if (!isset($variables['template_files'])) { - $variables['template_files'] = array(); - } - $variables['template_files'][] = 'modalframe-page'; + $variables['theme_hook_suggestions'][] = 'page__modalframe'; } } @@ -125,7 +156,7 @@ function modalframe_preprocess_page(&$variables) { * * @ingroup forms */ -function modalframe_form_alter(&$form, $form_state, $form_id) { +function modalframe_form_alter(&$form, &$form_state, $form_id) { // Here we simply want to install a form after_build callback. if (!isset($form['#after_build'])) { $form['#after_build'] = array(); @@ -217,7 +248,8 @@ function modalframe_parent_js() { } $processed = TRUE; - jquery_ui_add(array('ui.dialog', 'ui.draggable')); + drupal_add_library('system', 'ui.dialog'); + drupal_add_library('system', 'ui.draggable'); $module_path = drupal_get_path('module', 'modalframe'); drupal_add_css($module_path .'/css/modalframe.parent.css'); drupal_add_js($module_path .'/js/parent.js'); @@ -240,10 +272,6 @@ function modalframe_child_js() { // is something child windows don't need. module_invoke_all('suppress'); - // This is required to get access to jQuery UI extensions to jQuery itself, - // such as the ':focusable' and ':tabbable' selectors. - jquery_ui_add(array('ui.core')); - // Add javascript and stylesheets to the child page. $module_path = drupal_get_path('module', 'modalframe'); drupal_add_css($module_path .'/css/modalframe.child.css');