- Patch #22215 by Richard Archer: refactored primary and secondary links.
Deprecates the primary_links module. This patch was much needed. Thanks Richards! NOTE: if some themers could investigate if there is room for improvement with regard to theming, that would be awesome.4.7.x
parent
cbcb85560a
commit
ea53aad7c8
|
@ -817,6 +817,7 @@ INSERT INTO system VALUES ('modules/block.module','block','module','',1,0,0);
|
|||
INSERT INTO system VALUES ('modules/comment.module','comment','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/filter.module','filter','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/help.module','help','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/menu.module','menu','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/node.module','node','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/page.module','page','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/story.module','story','module','',1,0,0);
|
||||
|
@ -842,7 +843,7 @@ REPLACE variable SET name='theme_default', value='s:10:"bluemarine";';
|
|||
REPLACE blocks SET module = 'user', delta = '0', theme = 'bluemarine', status = '1';
|
||||
REPLACE blocks SET module = 'user', delta = '1', theme = 'bluemarine', status = '1';
|
||||
|
||||
INSERT INTO sequences (name, id) VALUES ('menu_mid', 1);
|
||||
INSERT INTO sequences (name, id) VALUES ('menu_mid', 2);
|
||||
|
||||
INSERT INTO node_access VALUES (0, 0, 'all', 1, 0, 0);
|
||||
|
||||
|
@ -860,3 +861,7 @@ INSERT INTO locales_meta (locale, name, enabled, isdefault) VALUES ('en', 'Engli
|
|||
INSERT INTO url_alias (src, dst) VALUES ('node/feed', 'rss.xml');
|
||||
|
||||
INSERT INTO variable (name, value) VALUES ('node_options_forum', 'a:1:{i:0;s:6:"status";}');
|
||||
|
||||
INSERT INTO menu VALUES (2, 0, '', 'Primary links', '', 0, 115);
|
||||
INSERT INTO variable VALUES ('menu_primary_menu', 'i:2;');
|
||||
INSERT INTO variable VALUES ('menu_secondary_menu', 'i:2;');
|
||||
|
|
|
@ -811,6 +811,7 @@ INSERT INTO system VALUES ('modules/block.module','block','module','',1,0,0);
|
|||
INSERT INTO system VALUES ('modules/comment.module','comment','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/filter.module','filter','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/help.module','help','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/menu.module','menu','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/node.module','node','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/page.module','page','module','',1,0,0);
|
||||
INSERT INTO system VALUES ('modules/story.module','story','module','',1,0,0);
|
||||
|
@ -852,10 +853,14 @@ INSERT INTO url_alias (src, dst) VALUES ('node/feed', 'rss.xml');
|
|||
|
||||
INSERT INTO variable (name, value) VALUES ('node_options_forum', 'a:1:{i:0;s:6:"status";}');
|
||||
|
||||
INSERT INTO menu VALUES (2, 0, '', 'Primary links', '', 0, 115);
|
||||
INSERT INTO variable VALUES ('menu_primary_menu', 'i:2;');
|
||||
INSERT INTO variable VALUES ('menu_secondary_menu', 'i:2;');
|
||||
|
||||
---
|
||||
--- Alter some sequences
|
||||
---
|
||||
ALTER SEQUENCE menu_mid_seq RESTART 2;
|
||||
ALTER SEQUENCE menu_mid_seq RESTART 3;
|
||||
|
||||
---
|
||||
--- Functions
|
||||
|
|
|
@ -67,7 +67,8 @@ $sql_updates = array(
|
|||
"2005-09-07" => "update_147",
|
||||
"2005-09-18" => "update_148",
|
||||
"2005-09-27" => "update_149",
|
||||
"2005-10-15" => "update_150"
|
||||
"2005-10-15" => "update_150",
|
||||
"2005-10-23" => "update_151",
|
||||
);
|
||||
|
||||
function update_110() {
|
||||
|
@ -919,6 +920,81 @@ function update_150() {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
function update_151() {
|
||||
$ret = array();
|
||||
|
||||
$ts = variable_get('theme_settings', null);
|
||||
|
||||
// set up data array so we can loop over both sets of links
|
||||
$menus = array(0 => array('links_var' => 'primary_links',
|
||||
'toggle_var' => 'toggle_primary_links',
|
||||
'more_var' => 'primary_links_more',
|
||||
'menu_name' => t('Primary links'),
|
||||
'menu_var' => 'menu_primary_menu',
|
||||
'pid' => 0),
|
||||
1 => array('links_var' => 'secondary_links',
|
||||
'toggle_var' => 'toggle_secondary_links',
|
||||
'more_var' => 'secondary_links_more',
|
||||
'menu_name' => t('Secondary links'),
|
||||
'menu_var' => 'menu_secondary_menu',
|
||||
'pid' => 0));
|
||||
|
||||
for ($loop = 0; $loop <= 1 ; $loop ++) {
|
||||
// create new Primary and Secondary links menus
|
||||
$menus[$loop]['pid'] = db_next_id('{menu}_mid');
|
||||
$ret[] = update_sql("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) " .
|
||||
"VALUES ({$menus[$loop]['pid']}, 0, '', '{$menus[$loop]['menu_name']}', '', 0, 115)");
|
||||
|
||||
// insert all entries from theme links into new menus
|
||||
$num_inserted = 0;
|
||||
if (is_array($ts) && is_array($ts[$menus[$loop]['links_var']])) {
|
||||
$links = $ts[$menus[$loop]['links_var']];
|
||||
for ($i = 0; $i < count($links['text']); $i++) {
|
||||
if ($links['text'][$i] != "" && $links['link'][$i] != "") {
|
||||
$num_inserted ++;
|
||||
$node_unalias = db_fetch_array(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $links['link'][$i]));
|
||||
if (is_array($node_unalias)) {
|
||||
$link_path = $node_unalias['src'];
|
||||
}
|
||||
else {
|
||||
$link_path = $links['link'][$i];
|
||||
}
|
||||
|
||||
$mid = db_next_id('{menu}_mid');
|
||||
$ret[] = update_sql("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) " .
|
||||
"VALUES ($mid, {$menus[$loop]['pid']}, '$link_path', '{$links['text'][$i]}', '{$links['description'][$i]}', 0, 118)");
|
||||
}
|
||||
}
|
||||
// delete Secondary links if not populated.
|
||||
if ($loop == 1 && $num_inserted == 0) {
|
||||
db_query("DELETE FROM {menu} WHERE mid={$menus[$loop]['pid']}");
|
||||
}
|
||||
}
|
||||
|
||||
// set menu_primary_menu variable appropriately
|
||||
if (!$ts[$menus[$loop]['toggle_var']] || $num_inserted == 0) {
|
||||
variable_set($menus[$loop]['menu_var'], 0);
|
||||
}
|
||||
else {
|
||||
variable_set($menus[$loop]['menu_var'], $menus[$loop]['pid']);
|
||||
}
|
||||
variable_del($menus[$loop]['toggle_var']);
|
||||
unset($ts[$menus[$loop]['toggle_var']]);
|
||||
variable_del($menus[$loop]['links_var']);
|
||||
unset($ts[$menus[$loop]['links_var']]);
|
||||
variable_del($menus[$loop]['more_var']);
|
||||
unset($ts[$menus[$loop]['more_var']]);
|
||||
}
|
||||
|
||||
if (is_array($ts)) {
|
||||
variable_set('theme_settings', $ts);
|
||||
}
|
||||
|
||||
$ret[] = update_sql("UPDATE {system} SET status = 1 WHERE name = 'menu'");
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function update_sql($sql) {
|
||||
$edit = $_POST["edit"];
|
||||
$result = db_query($sql);
|
||||
|
|
|
@ -492,6 +492,25 @@ function menu_in_active_trail($mid) {
|
|||
return in_array($mid, $trail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when the menu item is in the active trail within a
|
||||
* specific subsection of the menu tree.
|
||||
*
|
||||
* @param $mid
|
||||
* The menu item being considered.
|
||||
* @param $pid
|
||||
* The root of the subsection of the menu tree in which to look.
|
||||
*/
|
||||
function menu_in_active_trail_in_submenu($mid, $pid) {
|
||||
$trail = _menu_get_active_trail_in_submenu($pid);
|
||||
|
||||
if (!$trail) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return in_array($mid, $trail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the database representation of the menu.
|
||||
*
|
||||
|
@ -707,6 +726,125 @@ function theme_menu_local_task($mid, $active, $primary) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the primary links.
|
||||
* Can optionally descend from the root of the Primary links menu towards the
|
||||
* current node for a specified number of levels and return that submenu.
|
||||
* Used to generate a primary/secondary menu from different levels of one menu.
|
||||
*
|
||||
* @param $start_level
|
||||
* This optional parameter can be used to retrieve a context-sensitive array
|
||||
* of links at $start_level levels deep into the Primary links menu.
|
||||
* The default is to return the top-level links.
|
||||
* @param $pid
|
||||
* The parent menu ID from which to search for children. Defaults to the
|
||||
* menu_primary_menu setting.
|
||||
* @return An array containing the themed links as the values. The keys of
|
||||
* the array contain some extra encoded information about the results.
|
||||
* The format of the key is {level}-{num}{-active}.
|
||||
* level is the depth within the menu tree of this list.
|
||||
* num is the number within this array, used only to make the key unique.
|
||||
* -active is appended if this element is in the active trail.
|
||||
*/
|
||||
function menu_primary_links($start_level = 1, $pid = 0) {
|
||||
if (!module_exist('menu')) {
|
||||
return NULL;
|
||||
}
|
||||
if (!$pid) {
|
||||
$pid = variable_get('menu_primary_menu', 0);
|
||||
}
|
||||
if (!$pid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ($start_level < 1) {
|
||||
$start_level = 1;
|
||||
}
|
||||
|
||||
if ($start_level > 1) {
|
||||
$trail = _menu_get_active_trail_in_submenu($pid);
|
||||
if (!$trail) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
$pid = $trail[$start_level - 1];
|
||||
}
|
||||
}
|
||||
|
||||
$menu = menu_get_menu();
|
||||
if ($pid && is_array($menu['visible'][$pid]) && array_key_exists('children', $menu['visible'][$pid])) {
|
||||
$count = 1;
|
||||
foreach ($menu['visible'][$pid]['children'] as $cid) {
|
||||
$index = "$start_level-$count";
|
||||
if (menu_in_active_trail_in_submenu($cid, $pid)) {
|
||||
$index .= "-active";
|
||||
}
|
||||
$links[$index] = menu_item_link($cid);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
// special case - provide link to admin/menu if primary links is empty.
|
||||
if (is_null($links) && $start_level == 1 && $pid == variable_get('menu_primary_menu', 0)) {
|
||||
$links['1-1'] = l(t('edit primary links'),'admin/menu');
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the secondary links.
|
||||
* Secondary links can be either a second level of the Primary links
|
||||
* menu or generated from their own menu.
|
||||
*/
|
||||
function menu_secondary_links() {
|
||||
$msm = variable_get('menu_secondary_menu', 0);
|
||||
if ($msm == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ($msm == variable_get('menu_primary_menu', 0)) {
|
||||
return menu_primary_links(2, $msm);
|
||||
}
|
||||
|
||||
return menu_primary_links(1, $msm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the themed HTML for primary and secondary links.
|
||||
* Note that this function is overridden by most core themes because
|
||||
* those themes display links in "link | link" format, not from a list.
|
||||
* Also note that by default links rendered with this function are
|
||||
* displayed with the same CSS as is used for the local tasks.
|
||||
* If a theme wishes to render links from a ul it is expected that
|
||||
* the theme will provide suitable CSS.
|
||||
*
|
||||
* @param $links
|
||||
* An array containing links to render.
|
||||
* @return
|
||||
* A string containing the themed links.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_menu_links($links) {
|
||||
if (!count($links)) {
|
||||
return '';
|
||||
}
|
||||
$level_tmp = split('-', key($links));
|
||||
$level = $level_tmp[0];
|
||||
$output = "<ul class=\"links-$level\">\n";
|
||||
foreach ($links as $index => $link) {
|
||||
$output .= '<li';
|
||||
if (stristr($index, 'active')) {
|
||||
$output .= ' class="active"';
|
||||
}
|
||||
$output .= ">$link</li>\n";
|
||||
}
|
||||
$output .= '</ul>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "defgroup menu".
|
||||
*/
|
||||
|
@ -733,6 +871,56 @@ function _menu_get_active_trail() {
|
|||
return $trail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the active trail through a specific subsection of the menu tree.
|
||||
*
|
||||
* @param $pid
|
||||
* The root item from which the active trail must descend.
|
||||
*/
|
||||
function _menu_get_active_trail_in_submenu($pid) {
|
||||
static $trails;
|
||||
static $built;
|
||||
|
||||
if (!$built) {
|
||||
// Find all menu items which point to the current node and for each
|
||||
// follow the parents up the chain to build an active trail.
|
||||
$built = TRUE;
|
||||
$menu = menu_get_menu();
|
||||
$path = $_GET['q'];
|
||||
$count = 0;
|
||||
while ($path && !$count) {
|
||||
foreach ($menu['items'] as $key => $item) {
|
||||
if (array_key_exists('path', $item) && $item['path'] == $path) {
|
||||
$trails[$count] = array();
|
||||
$mid = $key;
|
||||
while ($mid && $menu['items'][$mid]) {
|
||||
array_unshift($trails[$count], $mid);
|
||||
$mid = $menu['items'][$mid]['pid'];
|
||||
}
|
||||
$count ++;
|
||||
}
|
||||
}
|
||||
$path = substr($path, 0, strrpos($path, '/'));
|
||||
}
|
||||
}
|
||||
|
||||
if ($trails) {
|
||||
foreach ($trails as $key => $trail) {
|
||||
for ($i = 0 ; $i < count($trail); $i++) {
|
||||
if ($trail[$i] == $pid) {
|
||||
// create a trail from $pid to the current page inclusive.
|
||||
for ( ; $i < count($trail) ; $i++) {
|
||||
$subtrail[] = $trail[$i];
|
||||
}
|
||||
return $subtrail;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator routine for use in sorting menu items.
|
||||
*/
|
||||
|
|
|
@ -212,8 +212,6 @@ function path_to_theme() {
|
|||
*/
|
||||
function theme_get_settings($key = NULL) {
|
||||
$defaults = array(
|
||||
'primary_links' => array(),
|
||||
'secondary_links' => array(),
|
||||
'mission' => '',
|
||||
'default_logo' => 1,
|
||||
'logo_path' => '',
|
||||
|
@ -225,8 +223,6 @@ function theme_get_settings($key = NULL) {
|
|||
'toggle_search' => 1,
|
||||
'toggle_slogan' => 0,
|
||||
'toggle_mission' => 1,
|
||||
'toggle_primary_links' => 1,
|
||||
'toggle_secondary_links' => 1,
|
||||
'toggle_node_user_picture' => 0,
|
||||
'toggle_comment_user_picture' => 0,
|
||||
);
|
||||
|
@ -307,41 +303,6 @@ function theme_get_setting($setting_name, $refresh = FALSE) {
|
|||
}
|
||||
}
|
||||
|
||||
foreach (array('primary', 'secondary') as $type) {
|
||||
// Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.
|
||||
$value = $settings[$type . '_links'];
|
||||
|
||||
// Clear out existing (internal) values
|
||||
$settings[$type .'_links'] = array();
|
||||
|
||||
// Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
|
||||
$count = variable_get($type . '_link_count', 5);
|
||||
if (isset($value['link']) && $count > sizeof($value['link'])) {
|
||||
$count = sizeof($value['link']);
|
||||
}
|
||||
|
||||
if ($settings['toggle_' . $type . '_links']) {
|
||||
for ($i =0; $i < $count; $i++) {
|
||||
unset($attributes);
|
||||
if (!empty($value['text'][$i])) {
|
||||
if (!empty($value['description'][$i])) {
|
||||
$attributes['title'] = $value['description'][$i];
|
||||
}
|
||||
$text = $value['text'][$i];
|
||||
$link = $value['link'][$i];
|
||||
if (substr($link, 0, 7) == 'http://') {
|
||||
$settings[$type .'_links'][] = '<a href="'. check_url($link) .'"'. drupal_attributes($attributes) .'>'. check_plain($text) .'</a>';
|
||||
}
|
||||
else {
|
||||
$settings[$type .'_links'][] = l($text, $link, $attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($settings[$type .'_links'] == array()) {
|
||||
$settings[$type .'_links'] = array(l(t('edit %type links', array('%type' => $type)),'admin/themes/settings'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isset($settings[$setting_name]) ? $settings[$setting_name] : NULL;
|
||||
|
@ -509,6 +470,9 @@ function theme_status_messages() {
|
|||
* A string containing the themed links.
|
||||
*/
|
||||
function theme_links($links, $delimiter = ' | ') {
|
||||
if (!is_array($links)) {
|
||||
return '';
|
||||
}
|
||||
return implode($delimiter, $links);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,11 @@ function menu_menu($may_cache) {
|
|||
'callback' => 'menu_reset',
|
||||
'access' => user_access('administer menu'),
|
||||
'type' => MENU_LOCAL_TASK);
|
||||
|
||||
$items[] = array('path' => 'admin/settings/menu',
|
||||
'title' => t('menus'),
|
||||
'callback' => 'menu_configure',
|
||||
'access' => user_access('administer menu'));
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
@ -84,9 +89,52 @@ function menu_help($section) {
|
|||
return t('<p>Enter the name for your new menu. Remember to enable the newly created block in the %blocks administration page.</p>', array('%blocks' => l(t('blocks'), 'admin/block')));
|
||||
case 'admin/menu/item/add':
|
||||
return t('<p>Enter the title, path, position and the weight for your new menu item.</p>');
|
||||
case 'admin/settings/menu':
|
||||
return t('<p>Customize the menu settings.</p>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu callback; presents menu configuration options.
|
||||
*/
|
||||
function menu_configure() {
|
||||
$menu = menu_get_menu();
|
||||
|
||||
$primary_options[0] = t('No primary links');
|
||||
foreach ($menu['items'][0]['children'] as $mid) {
|
||||
$primary_options[$mid] = $menu['items'][$mid]['title'];
|
||||
}
|
||||
|
||||
$form['settings_links'] = array('#type' => 'fieldset', '#title' => t('Primary links settings'));
|
||||
$form['settings_links']['intro'] = array(
|
||||
'#type' => 'markup',
|
||||
'#value' => t('Primary links is a navigation system which usually (depending on your theme) appears at the top-right of the browser window. There are usually two rows of links, primary and secondary. You may control which links appear in this area by choosing a menu from which the links will be generated and then placing your links into the menu using the <a href="%menu">menu administration</a> or the \'Menu settings\' pane on each edit node form.', array('%menu' => url('admin/menu')))
|
||||
);
|
||||
|
||||
$form['settings_links']['menu_primary_menu'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Menu containing primary links'),
|
||||
'#default_value' => variable_get('menu_primary_menu', 0),
|
||||
'#options' => $primary_options
|
||||
);
|
||||
|
||||
$secondary_options[0] = t('No secondary links');
|
||||
foreach ($menu['items'][0]['children'] as $mid) {
|
||||
$secondary_options[$mid] = $menu['items'][$mid]['title'];
|
||||
}
|
||||
|
||||
$form['settings_links']['menu_secondary_menu'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Menu containing secondary links'),
|
||||
'#default_value' => variable_get('menu_secondary_menu', 0),
|
||||
'#options' => $secondary_options,
|
||||
'#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.')
|
||||
);
|
||||
|
||||
return system_settings_form('menu_configure', $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_block().
|
||||
*/
|
||||
|
|
|
@ -47,6 +47,11 @@ function menu_menu($may_cache) {
|
|||
'callback' => 'menu_reset',
|
||||
'access' => user_access('administer menu'),
|
||||
'type' => MENU_LOCAL_TASK);
|
||||
|
||||
$items[] = array('path' => 'admin/settings/menu',
|
||||
'title' => t('menus'),
|
||||
'callback' => 'menu_configure',
|
||||
'access' => user_access('administer menu'));
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
@ -84,9 +89,52 @@ function menu_help($section) {
|
|||
return t('<p>Enter the name for your new menu. Remember to enable the newly created block in the %blocks administration page.</p>', array('%blocks' => l(t('blocks'), 'admin/block')));
|
||||
case 'admin/menu/item/add':
|
||||
return t('<p>Enter the title, path, position and the weight for your new menu item.</p>');
|
||||
case 'admin/settings/menu':
|
||||
return t('<p>Customize the menu settings.</p>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Menu callback; presents menu configuration options.
|
||||
*/
|
||||
function menu_configure() {
|
||||
$menu = menu_get_menu();
|
||||
|
||||
$primary_options[0] = t('No primary links');
|
||||
foreach ($menu['items'][0]['children'] as $mid) {
|
||||
$primary_options[$mid] = $menu['items'][$mid]['title'];
|
||||
}
|
||||
|
||||
$form['settings_links'] = array('#type' => 'fieldset', '#title' => t('Primary links settings'));
|
||||
$form['settings_links']['intro'] = array(
|
||||
'#type' => 'markup',
|
||||
'#value' => t('Primary links is a navigation system which usually (depending on your theme) appears at the top-right of the browser window. There are usually two rows of links, primary and secondary. You may control which links appear in this area by choosing a menu from which the links will be generated and then placing your links into the menu using the <a href="%menu">menu administration</a> or the \'Menu settings\' pane on each edit node form.', array('%menu' => url('admin/menu')))
|
||||
);
|
||||
|
||||
$form['settings_links']['menu_primary_menu'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Menu containing primary links'),
|
||||
'#default_value' => variable_get('menu_primary_menu', 0),
|
||||
'#options' => $primary_options
|
||||
);
|
||||
|
||||
$secondary_options[0] = t('No secondary links');
|
||||
foreach ($menu['items'][0]['children'] as $mid) {
|
||||
$secondary_options[$mid] = $menu['items'][$mid]['title'];
|
||||
}
|
||||
|
||||
$form['settings_links']['menu_secondary_menu'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Menu containing secondary links'),
|
||||
'#default_value' => variable_get('menu_secondary_menu', 0),
|
||||
'#options' => $secondary_options,
|
||||
'#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.')
|
||||
);
|
||||
|
||||
return system_settings_form('menu_configure', $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_block().
|
||||
*/
|
||||
|
|
|
@ -1043,11 +1043,6 @@ function system_theme_settings($key = '') {
|
|||
|
||||
// System wide only settings.
|
||||
if (!$key) {
|
||||
// Menu settings
|
||||
|
||||
$form['primary_links'] = system_navigation_links_form('primary', 'Primary');
|
||||
$form['secondary_links'] = system_navigation_links_form('secondary', 'Secondary');
|
||||
|
||||
// Toggle node display.
|
||||
$node_types = module_invoke('node', 'get_types');
|
||||
if ($node_types) {
|
||||
|
@ -1066,8 +1061,6 @@ function system_theme_settings($key = '') {
|
|||
'toggle_name' => t('Site name'),
|
||||
'toggle_slogan' => t('Site slogan'),
|
||||
'toggle_mission' => t('Mission statement'),
|
||||
'toggle_primary_links' => t('Primary links'),
|
||||
'toggle_secondary_links' => t('Secondary links'),
|
||||
'toggle_node_user_picture' => t('User pictures in posts'),
|
||||
'toggle_comment_user_picture' => t('User pictures in comments'),
|
||||
'toggle_search' => t('Search box'),
|
||||
|
@ -1117,62 +1110,6 @@ function system_theme_settings($key = '') {
|
|||
|
||||
}
|
||||
|
||||
function system_navigation_links_form($type, $utype) {
|
||||
$settings = theme_get_settings('');
|
||||
$value = $settings[$type . '_links'];
|
||||
|
||||
if (!is_array($value)) {
|
||||
$value = array();
|
||||
}
|
||||
// Increment the link count, if the user has requested more links.
|
||||
if (variable_get($type . '_links_more', false)) {
|
||||
variable_del($type . '_links_more');
|
||||
variable_set($type . '_link_count', variable_get($type . '_link_count', 5) + 5);
|
||||
}
|
||||
|
||||
// Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
|
||||
$count = variable_get($type . '_link_count', 5);
|
||||
$count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
|
||||
|
||||
if (variable_get($type . '_link_count', 5) != $count) {
|
||||
variable_set($type . '_link_count', $count);
|
||||
}
|
||||
$form = array(
|
||||
'#type' => 'item', '#title' => t('_TYPE_ link settings', array('_TYPE_' => $utype)), '#theme' => 'system_navigation_links_form',
|
||||
'#description' => t('You can specify your _TYPE_ links here, one link per line.<br /> The link text field is the text you want to link.<br /> The url field is the location the link points to.<br /> The description field is an optional description of where the link points.', array('_TYPE_' => $type))
|
||||
);
|
||||
|
||||
$form['#tree'] = TRUE;
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
foreach (array('text', 'link', 'description') as $field) {
|
||||
$form[$field][$i] = array('#type' => 'textfield', '#default_value' => $value[$field][$i], '#size' => 15, '#maxlength' => 90);
|
||||
}
|
||||
}
|
||||
|
||||
$form[$type . '_links_more'] = array(
|
||||
'#type' => 'checkbox', '#title' => t('I need more _TYPE_ links.', array('_TYPE_' => $type)), '#default_value' => FALSE,
|
||||
'#description' => t('Checking this box will give you 5 additional _TYPE_ links.', array('_TYPE_' => $type))
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
function theme_system_navigation_links_form(&$form) {
|
||||
$header = array(t('link text'), t('url'), t('description'));
|
||||
foreach (element_children($form['text']) as $key) {
|
||||
$row = array();
|
||||
$row[] = form_render($form['text'][$key]);
|
||||
$row[] = form_render($form['link'][$key]);
|
||||
$row[] = form_render($form['description'][$key]);
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
$output = theme('table', $header, $rows);
|
||||
$output .= form_render($form);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
function search_box() {
|
||||
$form['#action'] = url('search');
|
||||
$form['keys'] = array('#type' => 'textfield', '#size'=> 15, '#value' => '', '#attributes' => array('alt' => t('Enter the terms you wish to search for.'), 'class' => 'form-text'));
|
||||
|
|
|
@ -1043,11 +1043,6 @@ function system_theme_settings($key = '') {
|
|||
|
||||
// System wide only settings.
|
||||
if (!$key) {
|
||||
// Menu settings
|
||||
|
||||
$form['primary_links'] = system_navigation_links_form('primary', 'Primary');
|
||||
$form['secondary_links'] = system_navigation_links_form('secondary', 'Secondary');
|
||||
|
||||
// Toggle node display.
|
||||
$node_types = module_invoke('node', 'get_types');
|
||||
if ($node_types) {
|
||||
|
@ -1066,8 +1061,6 @@ function system_theme_settings($key = '') {
|
|||
'toggle_name' => t('Site name'),
|
||||
'toggle_slogan' => t('Site slogan'),
|
||||
'toggle_mission' => t('Mission statement'),
|
||||
'toggle_primary_links' => t('Primary links'),
|
||||
'toggle_secondary_links' => t('Secondary links'),
|
||||
'toggle_node_user_picture' => t('User pictures in posts'),
|
||||
'toggle_comment_user_picture' => t('User pictures in comments'),
|
||||
'toggle_search' => t('Search box'),
|
||||
|
@ -1117,62 +1110,6 @@ function system_theme_settings($key = '') {
|
|||
|
||||
}
|
||||
|
||||
function system_navigation_links_form($type, $utype) {
|
||||
$settings = theme_get_settings('');
|
||||
$value = $settings[$type . '_links'];
|
||||
|
||||
if (!is_array($value)) {
|
||||
$value = array();
|
||||
}
|
||||
// Increment the link count, if the user has requested more links.
|
||||
if (variable_get($type . '_links_more', false)) {
|
||||
variable_del($type . '_links_more');
|
||||
variable_set($type . '_link_count', variable_get($type . '_link_count', 5) + 5);
|
||||
}
|
||||
|
||||
// Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
|
||||
$count = variable_get($type . '_link_count', 5);
|
||||
$count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
|
||||
|
||||
if (variable_get($type . '_link_count', 5) != $count) {
|
||||
variable_set($type . '_link_count', $count);
|
||||
}
|
||||
$form = array(
|
||||
'#type' => 'item', '#title' => t('_TYPE_ link settings', array('_TYPE_' => $utype)), '#theme' => 'system_navigation_links_form',
|
||||
'#description' => t('You can specify your _TYPE_ links here, one link per line.<br /> The link text field is the text you want to link.<br /> The url field is the location the link points to.<br /> The description field is an optional description of where the link points.', array('_TYPE_' => $type))
|
||||
);
|
||||
|
||||
$form['#tree'] = TRUE;
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
foreach (array('text', 'link', 'description') as $field) {
|
||||
$form[$field][$i] = array('#type' => 'textfield', '#default_value' => $value[$field][$i], '#size' => 15, '#maxlength' => 90);
|
||||
}
|
||||
}
|
||||
|
||||
$form[$type . '_links_more'] = array(
|
||||
'#type' => 'checkbox', '#title' => t('I need more _TYPE_ links.', array('_TYPE_' => $type)), '#default_value' => FALSE,
|
||||
'#description' => t('Checking this box will give you 5 additional _TYPE_ links.', array('_TYPE_' => $type))
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
function theme_system_navigation_links_form(&$form) {
|
||||
$header = array(t('link text'), t('url'), t('description'));
|
||||
foreach (element_children($form['text']) as $key) {
|
||||
$row = array();
|
||||
$row[] = form_render($form['text'][$key]);
|
||||
$row[] = form_render($form['link'][$key]);
|
||||
$row[] = form_render($form['description'][$key]);
|
||||
$rows[] = $row;
|
||||
|
||||
}
|
||||
$output = theme('table', $header, $rows);
|
||||
$output .= form_render($form);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
function search_box() {
|
||||
$form['#action'] = url('search');
|
||||
$form['keys'] = array('#type' => 'textfield', '#size'=> 15, '#value' => '', '#attributes' => array('alt' => t('Enter the terms you wish to search for.'), 'class' => 'form-text'));
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
<?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
|
||||
</td>
|
||||
<td id="menu">
|
||||
<?php if ($secondary_links) { ?><div id="secondary"><?php print theme('links', $secondary_links) ?></div><?php } ?>
|
||||
<?php if ($primary_links) { ?><div id="primary"><?php print theme('links', $primary_links) ?></div><?php } ?>
|
||||
<?php if ($secondary_links) { ?><div id="secondary"><?php print theme('menu_links', $secondary_links) ?></div><?php } ?>
|
||||
<?php if ($primary_links) { ?><div id="primary"><?php print theme('menu_links', $primary_links) ?></div><?php } ?>
|
||||
<?php print $search_box ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -11,9 +11,7 @@ function chameleon_features() {
|
|||
'logo',
|
||||
'toggle_favicon',
|
||||
'toggle_name',
|
||||
'toggle_slogan',
|
||||
'toggle_primary_links',
|
||||
'toggle_secondary_links');
|
||||
'toggle_slogan');
|
||||
}
|
||||
|
||||
function chameleon_regions() {
|
||||
|
@ -55,8 +53,8 @@ function chameleon_page($content) {
|
|||
|
||||
$output .= "</div>\n";
|
||||
|
||||
$primary_links = theme('links', theme_get_setting('primary_links'));
|
||||
$secondary_links = theme('links', theme_get_setting('secondary_links'));
|
||||
$primary_links = theme('links', menu_primary_links());
|
||||
$secondary_links = theme('links', menu_secondary_links());
|
||||
if ($primary_links || $secondary_links) {
|
||||
$output .= ' <div class="navlinks">';
|
||||
if ($primary_links) {
|
||||
|
|
Loading…
Reference in New Issue