? make_phptemplate_links_optional.patch Index: menutrails.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/menutrails/menutrails.module,v retrieving revision 1.22 diff -u -p -r1.22 menutrails.module --- menutrails.module 17 Aug 2009 16:37:50 -0000 1.22 +++ menutrails.module 6 Nov 2009 23:16:01 -0000 @@ -32,6 +32,9 @@ function menutrails_menu() { * @todo Replace TRUE with settings check. */ function menutrails_init() { + if (variable_get('menutrails_phptemplate_links', TRUE)) { + include_once(drupal_get_path('module', 'menutrails') . '/phptemplate_links.inc'); + } if (module_exists('og') && variable_get('menutrails_og_sub_pages', TRUE)) { if ($group = og_get_group_context()) { $item = menu_get_item(); @@ -330,6 +333,13 @@ function menutrails_menutrails_settings( '#description' => t('If a specific group node has an assigned menu item, use this as the trail for nodes which have that group as an audience. If present, this will override all other group settings.'), ); } + // Make inclusion of phptemplate_links() theme function optional: + $form['menutrails_phptemplate_links'] = array( + '#title' => 'Automatically include "active" class on menu links in active trail.', + '#type' => 'checkbox', + '#default_value' => variable_get('menutrails_phptemplate_links', TRUE), + '#description' => 'Selecting yes will include a phptemplate_links() function, which may impact custom themes.', + ); return $form; } @@ -411,81 +421,6 @@ function _menutrails_recurse($tree, $hre } /** - * Return a themed set of links. - * - * The important difference is that we use the in_active_trail bit here to set - * an "active" CSS class, which is what most themes (e.g. garland) use to - * denote an active/open menu item. You should alter/override this as your - * design needs dictate. - * - * @param $links - * A keyed array of links to be themed. - * @param $attributes - * A keyed array of attributes - * @return - * A string containing an unordered list of links. - */ -function phptemplate_links($links, $attributes = array('class' => 'links')) { - global $language; - $output = ''; - - if (count($links) > 0) { - $output = ''; - - $num_links = count($links); - $i = 1; - - foreach ($links as $key => $link) { - $class = $key; - - // Add first, last and active classes to the list of links to help out themers. - if ($i == 1) { - $class .= ' first'; - } - if ($i == $num_links) { - $class .= ' last'; - } - if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '' && drupal_is_front_page())) - && (empty($link['language']) || $link['language']->language == $language->language)) { - $class .= ' active'; - } - - $a = ''; - if (isset($link['href'])) { - // Add active class for containing
  • and if 'active-trail' is set - // on the link itself. - if (isset($link['attributes']['class']) && strpos($link['attributes']['class'], 'active-trail') !== FALSE && strpos($class, 'active') === FALSE) { - $class .= ' active'; - $link['attributes']['class'] .= ' active'; - } - // Pass in $link as $options, they share the same keys. - $a = l($link['title'], $link['href'], $link); - } - else if (!empty($link['title'])) { - // Some links are actually not links, but we wrap these in for adding title and class attributes - if (empty($link['html'])) { - $link['title'] = check_plain($link['title']); - } - $span_attributes = ''; - if (isset($link['attributes'])) { - $span_attributes = drupal_attributes($link['attributes']); - } - $a = ''. $link['title'] .''; - } - - $i++; - $output .= ' $class)) .'>'; - $output .= $a; - $output .= "
  • \n"; - } - - $output .= ''; - } - - return $output; -} - -/** * Implementation of hook_views_pre_view(). * * This is invoked for every view before the it is themed, even if the view is Index: phptemplate_links.inc =================================================================== RCS file: phptemplate_links.inc diff -N phptemplate_links.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ phptemplate_links.inc 6 Nov 2009 23:16:01 -0000 @@ -0,0 +1,75 @@ + 'links')) { + global $language; + $output = ''; + + if (count($links) > 0) { + $output = ''; + + $num_links = count($links); + $i = 1; + + foreach ($links as $key => $link) { + $class = $key; + + // Add first, last and active classes to the list of links to help out themers. + if ($i == 1) { + $class .= ' first'; + } + if ($i == $num_links) { + $class .= ' last'; + } + if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '' && drupal_is_front_page())) + && (empty($link['language']) || $link['language']->language == $language->language)) { + $class .= ' active'; + } + + $a = ''; + if (isset($link['href'])) { + // Add active class for containing
  • and if 'active-trail' is set + // on the link itself. + if (isset($link['attributes']['class']) && strpos($link['attributes']['class'], 'active-trail') !== FALSE && strpos($class, 'active') === FALSE) { + $class .= ' active'; + $link['attributes']['class'] .= ' active'; + } + // Pass in $link as $options, they share the same keys. + $a = l($link['title'], $link['href'], $link); + } + else if (!empty($link['title'])) { + // Some links are actually not links, but we wrap these in for adding title and class attributes + if (empty($link['html'])) { + $link['title'] = check_plain($link['title']); + } + $span_attributes = ''; + if (isset($link['attributes'])) { + $span_attributes = drupal_attributes($link['attributes']); + } + $a = ''. $link['title'] .''; + } + + $i++; + $output .= ' $class)) .'>'; + $output .= $a; + $output .= "
  • \n"; + } + + $output .= ''; + } + + return $output; +} \ No newline at end of file