Index: dhtml_menu.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/dhtml_menu/dhtml_menu.admin.inc,v retrieving revision 1.5 diff -u -p -r1.5 dhtml_menu.admin.inc --- dhtml_menu.admin.inc 14 Jul 2008 21:58:51 -0000 1.5 +++ dhtml_menu.admin.inc 16 Jul 2008 11:30:41 -0000 @@ -10,6 +10,10 @@ * Module settings form. */ function dhtml_menu_settings(&$form_state) { + if (!defined('DHTML_MENU_INITIALIZED')) { + module_invoke('dhtml_menu', 'init'); + } + $form['dhtml_menu_effects'] = array( '#type' => 'checkboxes', '#title' => t('DHTML Menu effects'), @@ -25,3 +29,13 @@ function dhtml_menu_settings(&$form_stat return system_settings_form($form); } +/** + * Implementation of hook_help(). + */ +function dhtml_menu_help($path) { + switch ($path) { + case 'admin/settings/dhtml_menu': + return t('DHTML Menu adds dynamic functionality to the menus of your site. Ordinarily, reaching the child elements below an item requires you to visit its page. With DHTML Menu, clicking on an item with child elements will expand it without leaving the page, saving time. You can reach the actual page of such an item either by double-clicking on it or visiting the small extra link that will be shown right below it when expanded.'); + } +} + Index: dhtml_menu.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/dhtml_menu/dhtml_menu.info,v retrieving revision 1.6 diff -u -p -r1.6 dhtml_menu.info --- dhtml_menu.info 11 Jul 2008 22:15:58 -0000 1.6 +++ dhtml_menu.info 16 Jul 2008 11:30:41 -0000 @@ -1,5 +1,10 @@ ; $Id: dhtml_menu.info,v 1.6 2008/07/11 22:15:58 arancaytar Exp $ name = DHTML Menu description = Opens menus dynamically to reduce page refreshes. -core = 6.x +core = 7.x +files[] = dhtml_menu.module +files[] = dhtml_menu.install +files[] = dhtml_menu.admin.inc +files[] = dhtml_menu.init.inc +files[] = dhtml_menu.theme.inc Index: dhtml_menu.init.inc =================================================================== RCS file: dhtml_menu.init.inc diff -N dhtml_menu.init.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ dhtml_menu.init.inc 16 Jul 2008 11:30:41 -0000 @@ -0,0 +1,45 @@ + $settings), 'setting'); + + // This module is now fully initialized. + define('DHTML_MENU_INITIALIZED', TRUE); +} + Index: dhtml_menu.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/dhtml_menu/dhtml_menu.js,v retrieving revision 1.17 diff -u -p -r1.17 dhtml_menu.js --- dhtml_menu.js 14 Jul 2008 21:58:51 -0000 1.17 +++ dhtml_menu.js 16 Jul 2008 11:30:41 -0000 @@ -26,6 +26,16 @@ Drupal.behaviors.dhtmlMenu = function() $('.collapsed').removeClass('expanded'); + // Get cookie + var cookie = Drupal.dhtmlMenu.cookieGet(); + for (var i in cookie) { + // If the cookie was not applied to the HTML code yet, do so now. + var li = $('#menu-' + cookie[i]).parents('li:first'); + if ($(li).hasClass('collapsed')) { + Drupal.dhtmlMenu.toggleMenu(li); + } + } + /* Add jQuery effects and listeners to all menu items. * The ~ (sibling) selector is unidirectional and selects * only the latter element, so we must use siblings() to get Index: dhtml_menu.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/dhtml_menu/dhtml_menu.module,v retrieving revision 1.29 diff -u -p -r1.29 dhtml_menu.module --- dhtml_menu.module 14 Jul 2008 21:58:51 -0000 1.29 +++ dhtml_menu.module 16 Jul 2008 11:30:41 -0000 @@ -8,140 +8,22 @@ */ /** - * Effects enabled by default. This is an array and - * must be split to be used. Constants can not contain arrays. - */ -define('DHTML_MENU_DEFAULT', 'slide,clone'); - -/** - * Implementation of hook_init(). - * Adds CSS, Javascript and settings to the page. - */ -function dhtml_menu_init() { - drupal_add_css(drupal_get_path('module', 'dhtml_menu') .'/dhtml_menu.css'); - drupal_add_js(drupal_get_path('module', 'dhtml_menu') .'/dhtml_menu.js'); - $settings = variable_get('dhtml_menu_effects', explode(',', DHTML_MENU_DEFAULT)); - $valid = array('slide', 'clone', 'siblings', 'doubleclick', 'children'); - $settings = array_intersect($settings, $valid); - foreach (variable_get('dhtml_menu_effects', explode(',', DHTML_MENU_DEFAULT)) as $effect) { - if (in_array($effect, $valid)) { - $settings[$effect] = TRUE; - } - } - drupal_add_js(array('dhtmlMenu' => $settings), 'setting'); -} - -/** Implementation of hook_theme_registry_alter(). - * Replaces the theme functions for the menu_item functions + * Implementation of hook_theme_registry_alter(). + * Replaces the theme functions for the menu_item theming hooks */ function dhtml_menu_theme_registry_alter(&$theme_registry) { - $theme_registry['menu_item']['function'] = 'dhtml_menu_theme_menu_item'; - $theme_registry['menu_item_link']['function'] = 'dhtml_menu_theme_menu_item_link'; -} - -/** - * Preprocessor for menu_item_link. - * Adds an ID attribute to menu links and helps the module - * follow the recursion of menu_tree_output(). - */ -function dhtml_menu_theme_menu_item_link($link) { - // The ID is the mlid or a stripped form of the link path. It just must be unique. - $id = isset($link['mlid']) ? $link['mlid'] : preg_replace('/[^a-z0-9]/', '0', $link['href']); - $link['localized_options']['attributes']['id'] = "menu-". $id; - - // Each link in series is another level of recursion. Add it to the stack. - _dhtml_menu_stack($link); - - // Pass the altered variables to the normal menu themer. - return theme_menu_item_link($link); -} - -/** - * Preprocessor for menu_item. - * Checks whether the current item has children that - * were not rendered, and loads and renders them. - */ -function dhtml_menu_theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) { - static $cookie; - if (!isset($cookie)) { - $cookie = explode(',', @$_COOKIE['dhtml_menu']); - } - - /* When theme('menu_item') is called, the menu tree below it has been - * rendered already. Since we are done on this recursion level, - * one element must be popped off the stack. - */ - $stack = _dhtml_menu_stack(); - - // If there are children, but they were not loaded... - if ($has_children && !$menu) { - // Load the tree below the current position. - $tree = _dhtml_menu_subtree($stack); - - // Render it... - $menu = menu_tree_output($tree); - } - - // Move to the last element in the stack (the current item). - end($stack); - - // If this item can expand, and is neither saved as open nor in the active trail, close it. - if ($menu && !($in_active_trail || in_array(substr(key($stack), 5), $cookie))) { - $extra_class .= ' collapsed start-collapsed'; - } - - return theme_menu_item($link, $has_children, $menu, $in_active_trail, $extra_class); -} - -/** - * Helper function for storing recursion levels. - * - * @param $link - * If a menu item link is passed, it will be appended to the stack. - * If none is given, the stack will be returned and popped by one. - * - * @return - * The stack, if no parameter is given. - */ -function _dhtml_menu_stack($link = FALSE) { - static $stack; - if ($link) { - $stack[$link['localized_options']['attributes']['id']] = $link; - } - else { - $copy = $stack; - array_pop($stack); - return $copy; - } -} - -/** - * Traverses the menu tree and returns the sub-tree of the item - * indicated by the parameter. - * - * @param $stack - * An array of menu item links that are nested in each other in the tree. - * - * @return - * The items below the lowest item in the stack. - */ -function _dhtml_menu_subtree($stack) { - reset($stack); - $start = current($stack); - $tree = menu_tree_all_data($start['menu_name']); - foreach ($stack as $item) { - // Generate the sortable array key of an item: - $path[] = (50000 + $item['weight']) .' '. $item['title'] .' '. $item['mlid']; - } - - // Traverse the tree. - foreach ($path as $key) { - if (!isset($tree[$key])) { - $tree = $tree[key($tree)]['below']; - } - $tree = $tree[$key]['below']; - } - return $tree; + $path = drupal_get_path('module', 'dhtml_menu'); + $theme_registry['menu_item'] = array( + 'function' => 'dhtml_menu_theme_menu_item', + 'theme path' => $path, + 'file' => $path . '/dhtml_menu.theme.inc', + ); + + $theme_registry['menu_item_link'] = array( + 'function' => 'dhtml_menu_theme_menu_item_link', + 'theme path' => $path, + 'file' => $path . '/dhtml_menu.theme.inc', + ); } /** @@ -150,23 +32,21 @@ function _dhtml_menu_subtree($stack) { */ function dhtml_menu_menu() { $menu['admin/settings/dhtml_menu'] = array( - 'title' => 'DHTML Menu', - 'description' => 'Configure the effects of DHTML Menu', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('dhtml_menu_settings'), - 'access arguments' => array('administer site configuration'), - 'file' => 'dhtml_menu.admin.inc', + 'title' => 'DHTML Menu', + 'description' => 'Configure the effects of DHTML Menu', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('dhtml_menu_settings'), + 'access arguments' => array('administer dhtml_menu'), ); return $menu; } /** - * Implementation of hook_help(). + * Implementation of hook_perm(). + * Adds a special permission for configuring this module. */ -function dhtml_menu_help($path) { - switch ($path) { - case 'admin/settings/dhtml_menu': - return t('DHTML Menu adds dynamic functionality to the menus of your site. Ordinarily, reaching the child elements below an item requires you to visit its page. With DHTML Menu, clicking on an item with child elements will expand it without leaving the page, saving time. You can reach the actual page of such an item either by double-clicking on it or visiting the small extra link that will be shown right below it when expanded.'); - } +function dhtml_menu_perm() { + $perm['administer dhtml_menu'] = t('Administer DHTML Menu settings'); + return $perm; } Index: dhtml_menu.theme.inc =================================================================== RCS file: dhtml_menu.theme.inc diff -N dhtml_menu.theme.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ dhtml_menu.theme.inc 16 Jul 2008 11:30:41 -0000 @@ -0,0 +1,118 @@ + @@ -11,7 +11,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" -"POT-Creation-Date: 2008-07-14 14:59-0700\n" +"POT-Creation-Date: 2008-07-16 04:25-0700\n" "PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n" "Last-Translator: NAME \n" "Language-Team: LANGUAGE \n" @@ -20,47 +20,55 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -#: dhtml_menu.admin.inc:15 +#: dhtml_menu/dhtml_menu.admin.inc:18 msgid "DHTML Menu effects" msgstr "" -#: dhtml_menu.admin.inc:17 +#: dhtml_menu/dhtml_menu.admin.inc:20 msgid "Animated sliding effect" msgstr "" -#: dhtml_menu.admin.inc:18 +#: dhtml_menu/dhtml_menu.admin.inc:21 msgid "Keep only one menu open at a time." msgstr "" -#: dhtml_menu.admin.inc:19 +#: dhtml_menu/dhtml_menu.admin.inc:22 msgid "Close menus when their parent menu is closed." msgstr "" -#: dhtml_menu.admin.inc:20 +#: dhtml_menu/dhtml_menu.admin.inc:23 msgid "Add an extra page link to each expanding menu item." msgstr "" -#: dhtml_menu.admin.inc:21 +#: dhtml_menu/dhtml_menu.admin.inc:24 msgid "Go to the page on double-click." msgstr "" -#: dhtml_menu.module:169 +#: dhtml_menu/dhtml_menu.admin.inc:37 msgid "DHTML Menu adds dynamic functionality to the menus of your site. Ordinarily, reaching the child elements below an item requires you to visit its page. With DHTML Menu, clicking on an item with child elements will expand it without leaving the page, saving time. You can reach the actual page of such an item either by double-clicking on it or visiting the small extra link that will be shown right below it when expanded." msgstr "" -#: dhtml_menu.module:153 dhtml_menu.info:0 +#: dhtml_menu/dhtml_menu.module:49;49 +msgid "Administer DHTML Menu settings" +msgstr "" + +#: dhtml_menu/dhtml_menu.module:49 +msgid "administer dhtml_menu" +msgstr "" + +#: dhtml_menu/dhtml_menu.module:35 dhtml_menu/dhtml_menu.info:0 msgid "DHTML Menu" msgstr "" -#: dhtml_menu.module:154 +#: dhtml_menu/dhtml_menu.module:36 msgid "Configure the effects of DHTML Menu" msgstr "" -#: dhtml_menu.module:0 +#: dhtml_menu/dhtml_menu.module:0 msgid "dhtml_menu" msgstr "" -#: dhtml_menu.info:0 +#: dhtml_menu/dhtml_menu.info:0 msgid "Opens menus dynamically to reduce page refreshes." msgstr ""