--- includes/menu.inc 2006-09-20 16:19:01.000000000 -0400 +++ includes/menu.inc 2006-09-20 16:20:05.000000000 -0400 @@ -1,4 +1,5 @@ -// $Id: menu.inc,v 1.120.2.5 2006/07/07 08:35:21 killes Exp $ +uid:$locale"; - if ($cached = cache_get($cid)) { + + if ($cached = cache_get($cid)) { $_menu = unserialize($cached->data); } else { @@ -259,7 +261,7 @@ * The menu ID of the menu item to retrieve. * @param $path * The internal path of the menu item to retrieve. Defaults to NULL. Only - * used if $mid is not set. + * used if no item can be found matching $mid. * @param $reset * Optional flag that resets the static variable cache of the menu tree, if * set to TRUE. Default is FALSE. @@ -334,7 +336,7 @@ foreach (array_reverse($location) as $item) { if (isset($_menu['path index'][$item['path']])) { $mid = $_menu['path index'][$item['path']]; - if (isset($_menu['visible'][$mid])) { + if (isset ($_menu['visible'][$mid])) { // Splice in the breadcrumb at this location. if ($prev_id) { $_menu['items'][$prev_id]['pid'] = $mid; @@ -533,7 +535,7 @@ return array(); } - $links[] = l(t('Home'), variable_get('site_frontpage', 'node')); + $links[] = l(t('Home'), ''); $trail = _menu_get_active_trail(); foreach ($trail as $mid) { @@ -694,7 +696,18 @@ * @ingroup themeable */ function theme_menu_item_link($item, $link_item) { - return l($item['title'], $link_item['path'], isset($item['description']) ? array('title' => $item['description']) : array()); + + //BWD + $attributes=array(); + if(isset($item['description'])){ + $attributes['title'] = $item['description']; + } + if(isset($link_item['target'])){ + $attributes['target'] = $link_item['target']; + } +// echo 'here '.$attributes['target']; + + return l($item['title'], $link_item['path'], $attributes); } /** @@ -838,7 +851,6 @@ } $menu = menu_get_menu(); - $links = array(); if ($pid && is_array($menu['visible'][$pid]) && isset($menu['visible'][$pid]['children'])) { $count = 1; foreach ($menu['visible'][$pid]['children'] as $cid) { @@ -1043,6 +1055,12 @@ if (!isset($item['weight'])) { $item['weight'] = 0; } + //-- BWD + if (!isset($item['target'])) { + $item['target'] = '_self'; + + } + $mid = $temp_mid; if (isset($_menu['path index'][$item['path']])) { // Newer menu items overwrite older ones. @@ -1061,11 +1079,22 @@ $temp_mid--; } - // Now fetch items from the DB, reassigning menu IDs as needed. if (module_exist('menu')) { $result = db_query(db_rewrite_sql('SELECT m.mid, m.* FROM {menu} m ORDER BY m.mid ASC', 'm', 'mid')); while ($item = db_fetch_object($result)) { + + //BWD -- get the menu item's target + //$temp_target = db_fetch_array(db_query(db_rewrite_sql('SELECT v.* FROM {variable} v WHERE v.name="menu_target|%d"',$item->mid))); + $temp_target = db_fetch_array(db_query('SELECT v.* FROM {variable} v WHERE v.name="menu_target|%d"',$item->mid)); // JBN + + if(isset($temp_target['value'])){ + $item->target = $temp_target['value']; + }else{ + $item->target = '_self'; + } + + // Handle URL aliases if entered in menu administration. if (!isset($_menu['path index'][$item->path])) { $item->path = drupal_get_normal_path($item->path); @@ -1108,6 +1137,7 @@ $_menu['items'][$item->mid]['pid'] = $item->pid; $_menu['items'][$item->mid]['weight'] = $item->weight; $_menu['items'][$item->mid]['type'] = $item->type; + $_menu['items'][$item->mid]['target'] = $item->target; //BWD } } } @@ -1217,6 +1247,12 @@ if (!isset($item['weight'])) { $item['weight'] = 0; } + //BWD +// if(!isset($item['target'])){ +// echo' manual set to self for '; +// $item['target'] = '_self'; +// } + $_menu['items'][$temp_mid] = $item; $_menu['path index'][$item['path']] = $temp_mid; $new_items[$temp_mid] = $item; @@ -1226,9 +1262,7 @@ $mid = $_menu['path index'][$item['path']]; if ($_menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN) { $_menu['items'][$mid]['access'] = $item['access']; - if (isset($_menu['items'][$mid]['callback'])) { - $_menu['items'][$mid]['callback'] = $item['callback']; - } + $_menu['items'][$mid]['callback'] = $item['callback']; if (isset($_menu['items'][$mid]['callback arguments'])) { $_menu['items'][$mid]['callback arguments'] = $item['callback arguments']; } @@ -1336,7 +1370,7 @@ } /** - * Returns TRUE if the site is off-line for maintenance. + * Returns TRUE if the is off-line for maintenance. */ function _menu_site_is_offline() { // Check if site is set to off-line mode --- modules/menu.module 2006-09-20 16:08:09.000000000 -0400 +++ modules/menu.module 2006-09-20 16:20:29.000000000 -0400 @@ -1,4 +1,5 @@ -// $Id: menu.module,v 1.73 2006/04/07 13:10:17 killes Exp $ + 'fieldset', @@ -201,6 +206,14 @@ '#default_value' => $item['description'], '#description' => t('The description displayed when hovering over a menu item.'), ); + + /* BWD -- how to pop it up */ + $form['menu']['target'] = array('#type' => 'select', + '#title' => t('Target'), + '#default_value' => $item['target'], + '#options' => array('_self' => t('_self'), '_blank' => t('_blank')), + '#description' => t('The target of the link. This can be the same window (_self) or a new one (_blank).'), + ); // Generate a list of possible parents. $options = menu_parent_options($item['mid'], variable_get('menu_parent_items', 0)); @@ -307,6 +320,11 @@ drupal_not_found(); return; } + //BWD emulate above behavior... + $targ_temp = db_fetch_array(db_query("SELECT v.* FROM {variable} v WHERE v.name = 'menu_target|%d'",$mid)); + if(isset($targ_temp['value'])){ + $item['target'] = $targ_temp['value']; + } } else { $item = array('mid' => 0, 'pid' => 0, 'path' => '', 'weight' => 0, 'type' => MENU_CUSTOM_MENU); @@ -321,6 +339,7 @@ $form['pid'] = array('#type' => 'value', '#value' => $item['pid']); $form['path'] = array('#type' => 'value', '#value' => $item['path']); $form['weight'] = array('#type' => 'value', '#value' => $item['weight']); + $form['target'] = array('#type' => 'value', '#value' => $item['target']); //BWD $form['type'] = array('#type' => 'value', '#value' => $item['type']); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); @@ -337,6 +356,11 @@ drupal_not_found(); return; } + //BWD + $targ_temp = db_fetch_array(db_query("SELECT v.* FROM {variable} v WHERE v.name = 'menu_target|%d'",$mid)); + if(isset($targ_temp['value'])){ + $item['target'] = $targ_temp['value']; + } } else { // This is an add form. @@ -394,6 +418,14 @@ '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'), ); + //BWD + $form['target'] = array('#type' => 'select', + '#title' => t('Target'), + '#default_value' => $item['target'], + '#description' => t('Optional. The target window to open your link in. This can be the same window (_self) or a new one (_blank).'), + '#options' => array('_self' => t('_self'), '_blank' => t('_blank')), + ); + // Always enable menu items (but not menus) when editing them. if (!($item['type'] & MENU_IS_ROOT)) { $item['type'] |= MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB; @@ -552,8 +584,17 @@ } if ($item['mid'] && !empty($existing_item)) { - db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', description = '%s', weight = %d, type = %d WHERE mid = %d", $item['pid'], $item['path'], $item['title'], $item['description'], $item['weight'], $item['type'], $item['mid']); - return SAVED_UPDATED; + db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', description = '%s', weight = %d, type = %d WHERE mid = %d", $item['pid'], $item['path'], $item['title'], $item['description'], $item['weight'], $item['type'], $item['mid']); + + $targ_temp = db_fetch_array(db_query("SELECT v.* FROM {variable} v WHERE v.name = 'menu_target|%d'",$item['mid'])); + if(isset($targ_temp['value'])){ + db_query("UPDATE {variable} v SET v.value= '%s' WHERE v.name = 'menu_target|".$item['mid']."'", $item['target']);//BWD + }else{ + db_query("INSERT INTO {variable} (name,value) VALUES ('menu_target|%d','%s')",$item['mid'],$item['target']); + } + + watchdog('menu', t('Updated item '.$item['title'].' with '.$item['target'], $t_args), WATCHDOG_NOTICE, l(t('view'), 'admin/menu')); + return SAVED_UPDATED; } else { $item['mid'] = db_next_id('{menu}_mid'); @@ -563,7 +604,8 @@ while ($item['mid'] <= 2) { $item['mid'] = db_next_id('{menu}_mid'); } - db_query("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) VALUES (%d, %d, '%s', '%s', '%s', %d, %d)", $item['mid'], $item['pid'], $item['path'], $item['title'], $item['description'], $item['weight'], $item['type']); + db_query("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) VALUES (%d, %d, '%s', '%s', '%s', %d, %d)", $item['mid'], $item['pid'], $item['path'], $item['title'], $item['description'], $item['weight'], $item['type']); + db_query("INSERT INTO {variable} (name,value) VALUES ('menu_target|%d','%s')",$item['mid'],$item['target']);//BWD return SAVED_NEW; } } @@ -582,10 +624,17 @@ if ($item['mid']) { db_query('DELETE FROM {menu} WHERE mid = %d', $item['mid']); + // Delete the target info as well -- JBN + db_query('DELETE FROM {variable} WHERE name = "menu_target|%d"', $item['mid']); } elseif ($item['path']) { - db_query("DELETE FROM {menu} WHERE path = '%s'", $item['path']); - } + // First we need the mid to delete target info -- JBN + $item['mid'] = db_query("SELECT mid from {menu} WHERE path='%s'", $item['path']); + db_query("DELETE FROM {menu} WHERE path = '%s'", $item['path']); + + // Delete the target info as well -- JBN + db_query('DELETE FROM {variable} WHERE name = "menu_target|%d"', $item['mid']); + } } /**