Index: menu_minipanels.module =================================================================== --- menu_minipanels.module (révision 195) +++ menu_minipanels.module (copie de travail) @@ -57,16 +57,6 @@ return; } drupal_add_css($path . '/css/menu_minipanels.css', 'module', 'all', TRUE); - - // Most themes will call primary and secondary links on every page. - // They are usually themed by a function call inside page.tpl.php so we can't wait until theme_links is called, - // because by that time, $closure has already been created, and therefore our code would not be included. - // Therefore, we ought to load any mini panels primary and secondary links may have. - $theme_settings = theme_get_settings(); - $primary_links = $theme_settings['toggle_primary_links'] ? menu_primary_links() : array(); - menu_minipanels_preprocess_links_at_init($primary_links); - $secondary_links = $theme_settings['toggle_secondary_links'] ? menu_secondary_links() : array(); - menu_minipanels_preprocess_links_at_init($secondary_links); } /** @@ -201,28 +191,9 @@ $vars['menu_item_link']['old function'] = $vars['menu_item_link']['function']; $vars['menu_item_link']['function'] = 'menu_minipanels_preprocess_menu_item_link'; - // Must come first before template_preprocess, in order to be called before template css - // is set in template_preprocess, so that panels may add its css, and have it included. - $vars['page']['preprocess functions'] = array_merge(array('menu_minipanels_preprocess_page_hidden'), $vars['page']['preprocess functions']); } /** - * Ensure that we capture any mini panel menus that are set in $primary_links or $secondary_links. - * This is run on every page load. See @menu_minipanels_init() - */ -function menu_minipanels_preprocess_links_at_init($links) { - foreach ($links as $link) { - if (!empty($link['minipanel'])) { - $prefix = ''; - if (!empty($link['attributes']['class'])) { - $prefix = $link['attributes']['class'] . ' '; - } - $link['attributes']['class'] = $prefix . _menu_minipanels_include($link['minipanel'], $link['menu_minipanels_hover']); - } - } -} - -/** * * See @menu_minipanels_theme_registry_alter() * Also see @menu_minipanels_init() and menu_minipanels_preprocess_links_at_init() @@ -264,41 +235,24 @@ } /** - * The panels need to be rendered *after* init so as to not cause theme problems, but - * *before* closure, so as be sure that panels css gets included. - * - * We don't do anything with variables, we just use preprocess_page as its at called at time time. + * Implements hook_preprocess_page(). + * + * Add all the required minipanel output to the closure + * and recompute the CSS styles to account for files that + * can have been added by Panels. + * See @_menu_minipanels_include */ -function menu_minipanels_preprocess_page_hidden(&$variables) { +function menu_minipanels_preprocess_page(&$variables) { $output = ''; foreach (menu_minipanels_panels(NULL, NULL) as $mlid => $minipanel_name) { $html = ''; $output .= $html; } - menu_minpanels_html($output); + $variables['closure'] .= $output; + $variables['styles'] = drupal_get_css(); } /** - * Implements hook_footer(). - * - * Add all the required minipanel output to the closure. - * See @_menu_minipanels_include - */ -function menu_minipanels_footer() { - return menu_minpanels_html(); -} - -function menu_minpanels_html($html = NULL) { - static $stored = ''; - if ($html != NULL) { - $stored = $html; - } - else { - return $stored; - } -} - -/** * Stores the names of all rendered minipanels through the page load. * Will later be used by @menu_minipanels_footer to add all required minipanels to $closure. * See @menu_minipanels_footer and @_menu_minipanels_include