Navigate is the bar of widgets you see to your left. Or, if Navigate is minimized, you will see the Navigate icon peeking out of the upper left corner of the screen. When you click this icon, you will see the full Navigate widget set. Depending on the modules installed, Navigate will automatically add a Search widget and a Favorites widget for new users.
Navigate uses a cache to save each user\'s Navigate bar whenever it is changed. This means that it requires few system resources when navigating from page to page.
The basic tools
Additional widgets can be added to your bar by clicking the add / remove widgets button, which looks like a cog wheel in the upper right hand corner of Navigate. Each user has their own Navigate bar, so you can customize yours to fit your needs.
For help on how to use a widget, you can often hover over the part in question until a tooltip displays.
To hide / show the Navigate bar, click the steering wheel icon in the upper left corner of the Navigate bar, or if it is hidden, on the part of the icon that displays in the upper left hand corner of the screen.
To add or remove widgets, click the cog wheel icon in the upper right corner of the Navigate bar. A small (x) icon will appear next to your widget title, which you can click to remove the widget.
To re-order your widgets, drag them by their title to the desired location and then let go.
To change the title of a widget, double-click the title, enter your new text and press enter.
To access the advanced settings of a widget, if advanced settings are available, a small cog wheel icon will be visible in the upper right hand corner of the widget. Click this to expand the advanced settings pane.
To shrink the Navigate bar, double-click on the Navigate bar title (which says "navigate"). This will hide areas widgets have marked as superfluous. To get them to show again, double click the title once more.
Press CTL+SHIFT+N to toggle Navigate visibility. Click the "KEY" button at the bottom of Navigate to disable keyboard shortcuts.
'. $content;
return $output;
}
}
/**
* Implementation of hook_perm().
*/
function navigate_perm() {
return array("navigate view", "navigate customize", "navigate administer");
}
/**
* Defines admin settings form
*/
function navigate_admin_settings() {
$form['navigate_help_text'] = array(
'#title' => 'Help Text',
'#description' => 'This is the help text the displays when the help link is clicked. You can use PHP tags, and if you leave it blank it will show the default text.',
'#type' => 'textarea',
'#rows' => '7',
'#default_value' => variable_get('navigate_help_text', navigate_HELP_TEXT),
);
return $settings;
}
/**
* Implementation of hook_footer().
*/
function navigate_footer() {
$output = '';
if (user_access('navigate view')) {
// Build navigate
$output = navigate_build();
// Theme navigate
$output = theme('navigate_outer', $output);
$output .= '
';
}
return $output;
}
/**
* Load a widget set
*/
function navigate_defaults_load() {
global $user;
// Save current set
if (navigate_variable_get('saved_set_for_loading', 0) == '') {
$settings = array(
'name' => 'saved_set_for_loading',
'value' => serialize(navigate_export($user->uid)),
'wid' => 0,
);
navigate_variable_set($settings);
}
// Replace out current
if (isset($_POST['rid'])) {
$export = variable_get('navigate_defaults_'. check_plain($_POST['rid']), '');
navigate_import($export, $user->uid);
}
if (isset($_POST['username'])) {
if ($uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $_POST['username']))) {
$export = navigate_export($uid);
navigate_import($export, $user->uid);
navigate_variable_set(array('value' => check_plain($_POST['username']), 'name' => 'username_search'));
}
}
echo navigate_build_defaults_admin();
die();
}
/**
* Return to saved widget set
*/
function navigate_defaults_switch_back() {
global $user;
$export = unserialize(navigate_variable_get('saved_set_for_loading', 0));
navigate_import($export, $user->uid);
navigate_variable_delete('saved_set_for_loading');
echo navigate_build_defaults_admin();
die();
}
/**
* Change the default widget set for all users of a certain role
*/
function navigate_defaults_set_all() {
global $user;
$export = navigate_export($user->uid);
if (isset($_POST['rid']) && $_POST['rid'] != 2) {
if ($rid = db_result(db_query("SELECT rid FROM {role} WHERE rid = '%d'", $_POST['rid']))) {
variable_set('navigate_defaults_'. $rid, navigate_export($user->uid));
$result = db_query("SELECT uid FROM {users_roles} WHERE rid = '%d'", $_POST['rid']);
while ($row = db_fetch_array($result)) {
if (db_fetch_array(db_query("SELECT uid FROM {navigate_widgets} WHERE uid = '%d'", $row['uid']))) {
navigate_import($export, $row['uid']);
}
}
}
}
elseif (isset($_POST['rid']) && $_POST['rid'] == 2) {
$result = db_query("SELECT DISTINCT(u.uid), ur.rid FROM {users} u
LEFT JOIN {users_roles} ur ON u.uid = ur.uid
WHERE u.uid != 0
AND ur.rid IS NULL
GROUP BY u.uid");
while ($row = db_fetch_array($result)) {
if (db_fetch_array(db_query("SELECT uid FROM {navigate_widgets} WHERE uid = '%d'", $row['uid']))) {
navigate_import($export, $row['uid']);
}
}
}
elseif (isset($_POST['username'])) {
if ($uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $_POST['username']))) {
navigate_import(navigate_export($user->uid), $uid);
navigate_variable_set(array('value' => check_plain($_POST['username']), 'name' => 'username_search'));
}
}
echo navigate_build_defaults_admin();
die();
}
/**
* Theme the outer portion of navigate
*/
function theme_navigate_outer($output) {
$admin_menu_class = '';
if (module_exists('admin_menu') && user_access('access administration menu')) {
$admin_menu_class = ' navigate-admin-menu ';
}
$output = '
'. $output .'
' . navigate_tooltip('navigate-switch-outer', '
For help or more information on Navigate, visit /admin/help/navigate.
'. t('Welcome to Navigate') .'
'. t('Click this switch to show and hide Navigate. If something happens and Navigate is not displaying properly, visit /navigate/clear to clear Navigate\'s cache.') .'
') .'
';
return $output;
}
/**
* Run all ajax queries through navigate/process, which maps to this function
*/
function navigate_process() {
switch ($_POST['action']) {
case 'variable_save':
navigate_variable_set();
break;
case 'widget_list':
navigate_widget_list();
break;
case 'add_widget':
navigate_widget_add();
break;
case 'widget_sort':
navigate_widget_sort();
break;
case 'widget_delete':
navigate_widget_delete();
break;
case 'save_defaults':
navigate_save_defaults();
break;
case 'defaults_unset':
navigate_unset_defaults();
break;
case 'widgets_reload':
navigate_reload_widgets();
break;
case 'defaults_load':
navigate_defaults_load();
break;
case 'defaults_switch_back':
navigate_defaults_switch_back();
break;
case 'defaults_set_all':
navigate_defaults_set_all();
break;
case 'export_widget_set':
navigate_export_widget_set();
break;
case 'import_widget_set':
navigate_import_widget_set();
break;
default:
if (module_exists($_POST['module'])) {
$function = $_POST['module'] .'_navigate_widget_process';
$function($_POST['wid'], $_POST['action']);
}
}
}
/**
* Load a widget set associated with a user
*/
function navigate_user_load_set() {
global $user;
if (!user_access('navigate administer')) {
return;
}
}
/**
* Reload the navigate widgets
*/
function navigate_reload_widgets() {
global $user;
$output = navigate_build_all_widgets($user->uid);
echo $output;
die();
}
/**
* Save default widget set
*/
function navigate_save_defaults() {
global $user;
if (!user_access('navigate administer')) {
return;
}
if (isset($_POST['rid'])) {
if ($rid = db_result(db_query("SELECT rid FROM {role} WHERE rid = '%d'", $_POST['rid']))) {
variable_set('navigate_defaults_'. $rid, navigate_export($user->uid));
}
if ($_POST['rid'] == 0) {
variable_set('navigate_defaults_0', navigate_export($user->uid));
}
}
if (isset($_POST['uid'])) {
if ($uid = db_result(db_query("SELECT uid FROM {users} WHERE uid = '%d'", $_POST['uid']))) {
navigate_import(navigate_export($user->uid), $uid);
}
}
echo navigate_build_defaults_admin();
die();
}
/**
* Unset default widget set
*/
function navigate_unset_defaults() {
global $user;
if (!user_access('navigate administer')) {
return;
}
variable_del('navigate_defaults_'. $_POST['rid']);
echo navigate_build_defaults_admin();
die();
}
/**
* Deletes a widget
*/
function navigate_widget_delete($wid='', $uid = '') {
global $user;
if (!user_access('navigate administer') && $uid != $user->uid) {
return FALSE;
}
if ($uid == '') {
$uid = $user->uid;
}
$wid = ($wid == '') ? $_POST['wid'] : $wid;
// Call widget delete operation
$row = db_fetch_array(db_query("SELECT * FROM {navigate_widgets} WHERE wid = '%d' AND uid = '%d'", $wid, $uid));
$function = $row['module'] .'_navigate_widgets';
if (function_exists($function)) {
$function('delete', array('wid' => $row['wid'], 'type' => $row['type']));
}
db_query("DELETE FROM {navigate_widgets} WHERE uid = '%d' AND wid = '%d'", $uid, $wid);
db_query("DELETE FROM {navigate_user_settings} WHERE uid = '%d' AND wid = '%d'", $uid, $wid);
}
/**
* Save the new sort order for the widgets
*/
function navigate_widget_sort() {
global $user;
foreach ($_POST['navigate-widget-outer'] as $key => $wid) {
db_query("UPDATE {navigate_widgets} SET weight = '%d' WHERE uid = '%d' AND wid = '%d'", $key, $user->uid, $wid);
}
}
/**
* Add a new widget
*/
function navigate_widget_add($output=TRUE, $type='', $module='') {
global $user;
if ($type == '') {
$type = $_POST['type'];
}
if ($module == '') {
$module = $_POST['module'];
}
if (!module_exists($module)) {
return FALSE;
}
// Get next weight
$weight = db_result(db_query_range("SELECT weight FROM {navigate_widgets} WHERE uid = '%d' ORDER BY weight DESC", $user->uid, 0, 1));
$weight++;
db_query("INSERT INTO {navigate_widgets} (uid, type, module, weight) VALUES (%d, '%s', '%s', %d)", $user->uid, $type, $module, $weight);
$wid = db_last_insert_id('navigate_widgets', 'wid');
if ($output) {
$row = db_fetch_array(db_query("SELECT * FROM {navigate_widgets} WHERE wid = '%d'", $wid));
echo navigate_output_widget($row, 1);
}
}
/**
* Generate a list of available widgets
*/
function navigate_widget_list() {
$hook = 'navigate_widgets';
$array = array();
$output = '';
foreach (module_implements($hook) as $module) {
$function = $module .'_'. $hook;
$array = array_merge($array, $function('list'));
}
foreach ($array as $widget) {
$output .= theme('navigate_widget_list_item', $widget);
}
$output = '
'. t('Add widgets') .'
'. $output .'
';
return $output;
}
/**
* Theme a widget list item
*/
function theme_navigate_widget_list_item($widget) {
$single = isset($widget['single']) ? '' : '';
return '
'. $widget['content'] . $single .'
';
}
/**
* Save a user variable
*/
function navigate_variable_set($settings=FALSE) {
global $user;
if (!$settings) {
$value = $_POST['value'];
$name = $_POST['name'];
$wid = $_POST['wid'];
}
else {
if (!isset($settings['wid'])) {
$settings['wid'] = 0;
}
$value = $settings['value'];
$name = $settings['name'];
$wid = $settings['wid'];
}
if (db_result(db_query("SELECT COUNT(*) FROM {navigate_user_settings} WHERE uid = '%d' AND name = '%s' AND wid = '%d'", $user->uid, $name, $wid)) > 0) {
db_query("UPDATE {navigate_user_settings} SET value = '%s' WHERE uid = '%d' AND name = '%s' AND wid = '%d'", $value, $user->uid, $name, $wid);
}
else {
db_query("INSERT INTO {navigate_user_settings} (uid, value, name, wid) VALUES (%d, '%s', '%s', %d)", $user->uid, $value, $name, $wid);
}
}
/**
* Get a user variable
*/
function navigate_variable_get($name, $wid=0) {
global $user;
return db_result(db_query("SELECT value FROM {navigate_user_settings} WHERE uid = '%d' AND name = '%s' AND wid = '%d'", $user->uid, $name, $wid));
}
/**
* Delete a user variable
*/
function navigate_variable_delete($name, $wid=0) {
global $user;
db_query("DELETE FROM {navigate_user_settings} WHERE name = '%s' AND wid = '%d' AND uid = '%d'", $name, $wid, $user->uid);
}
/**
* Build the Navigate bar
*/
function navigate_build() {
global $user;
$output = '';
// Build default widget set, if there are no widgets
$count = db_result(db_query("SELECT COUNT(wid) FROM {navigate_widgets} WHERE uid = '%d'", $user->uid));
if ($count < 1) {
navigate_add_default_widgets();
}
// Build widgets
$output .= navigate_build_all_widgets($user->uid);
$output = theme('navigate_all_widgets', $output);
$content['navigate'] = $output;
// Keyboard shortcut enable button
$key_disabled = navigate_variable_get('key_disabled');
$disabled_class = '';
if ($key_disabled == 1) {
$disabled_class = ' key-disabled ';
}
$content['key_button'] = '
';
}
$default = variable_get('navigate_defaults_0', '');
$load = ''. t('Load') .'';
$unset = ''. t('Unset') .'';
if ($default != '') {
$load = ''. t('Load') .'';
$unset = ''. t('Unset') .'';
}
// User search row
$username_value = navigate_variable_get('username_search');
$username_class = '';
$load = ''. t('Load') .'';
$set_user = ''. t('Set user') .'';
if ($username_value == '') {
$username_value = t('Search name / UID');
$username_class = ' navigate-username-empty ';
}
else {
$load = ''. t('Load') .'';
$set_user = ''. t('Set user') .'';
}
// Import / export
$inputs['export'] = navigate_textarea(array(
'name' => 'set-export',
'class' => 'navigate-favorites-export',
'filters' => 'true',
'submit' => 'Export widget set',
'hide_filters' => 1,
'callback' => 'navigate_set_export',
'help' => 'Click the export button and it will load the content in this box.',
'wid' => '',
));
$inputs['import'] = navigate_textarea(array(
'name' => 'set-import',
'class' => 'navigate-favorites-import',
'filters' => 'true',
'submit' => 'Import widget set',
'hide_filters' => 1,
'callback' => 'navigate_set_import',
'help' => 'Click the import button to import widget set. Note that this will replace your current set.',
'wid' => '',
));
$import_export = '
'. $inputs['export'] . $inputs['import'] .'
';
// Combine output
$output = '
'. t('Defaults') .'
'. $alert .'
'. $output .'
'. $load .'
'. $set_user .'
'. t('Widget set import / export') .'
'. $import_export .'
';
return $output;
}
/**
* Build default set of widgets
*/
function navigate_add_default_widgets() {
global $user;
$export = '';
// Get default widget set for user role
foreach ($user->roles as $rid => $role) {
$export = variable_get('navigate_defaults_'. $rid, '');
}
// If no default role sets exist, then use 'unassigned roles' one
if ($export == '') {
$export = variable_get('navigate_defaults_0', '');
}
// Run import
if ($export != '') {
navigate_import($export, $user->uid);
return;
}
// If there is default set, add a search and favorites widget
if ($export != '') {
navigate_import($export, $user->uid);
return;
}
navigate_widget_add(FALSE, 'navigate_search', 'navigate_search');
navigate_widget_add(FALSE, 'favorites', 'navigate_favorites');
}
/**
* Builds a widget for output
*/
function navigate_output_widget($row, $show_close_button=0) {
$function = $row['module'] .'_navigate_widgets';
$settings = array(
'type' => $row['type'],
'wid' => $row['wid']
);
if (isset($row['order'])) {
$settings['order'] = $row['order'];
}
$op = 'output';
$content = '';
if (function_exists($function)) {
$content = $function($op, $settings);
}
if (!is_array($content)) {
$content['widget'] = $content;
}
if (isset($content['settings'])) {
$content['settings'] = theme('navigate_widget_settings', $content['settings'], $row['wid']);
$content['settings_button'] = theme('navigate_widget_settings_button', $row['wid']);
}
$title = navigate_variable_get('widget_title', $row['wid']);
if ($title != '') {
$content['title'] = $title;
}
$close_button_style = ($show_close_button == 0) ? 'display:none' : '';
$output = theme('navigate_widget', $content, $row['wid'], $close_button_style, $row['type']);
return $output;
}
/**
* Themes the outside of all widgets
*/
function theme_navigate_all_widgets($output) {
$sortable = '';
if (user_access('navigate customize')) {
$sortable = ' navigate-all-widgets-sortable ';
}
$output = '
'. $output .'
';
return $output;
}
/**
* Create a link for the 'add widgets' list.
*
* $content can be anything, $callback is a js function that will be run after the new widget is loaded
*/
function navigate_add_widget_link($content, $callback='') {
$output = $content .'';
return $output;
}
/**
* Theme the navigate bar
*/
function theme_navigate($content) {
$launch_settings = '';
if (user_access('navigate customize')) {
$launch_settings = '