', 'navigate_favorites_load'),
),
);
case 'delete':
navigate_favorites_delete_widget($settings['wid']);
break;
}
}
/**
* Delete a favorites widget
*/
function navigate_favorites_delete_widget($wid) {
db_query("DELETE FROM {navigate_favorites} WHERE wid = '%d'", $wid);
}
/**
* Generate favorites widget
*/
function navigate_favorites_widget($wid) {
$settings = navigate_widget_settings_get($wid);
$inputs['favorite_name'] = navigate_input(array(
'name' => 'favorite_name',
'class' => 'navigate-favorite-name',
'select_all' => TRUE,
'clear' => TRUE,
'callback' => 'navigate_favorites_add',
'help' => 'Type a description for this page and click enter to add it to your favorites.
For advanced users, use the following format to add a group of links: Title One|path/to/page;Title Two|path/to/page',
'wid' => $wid,
));
$inputs['favorite_button'] = navigate_callback_button(array(
'class' => 'navigate-favorites-add',
'callback' => 'navigate_favorites_add',
'content' => '
';
}
return $output;
}
/**
* Remove a favorite
*/
function navigate_favorites_remove() {
global $user;
db_query("DELETE FROM {navigate_favorites} WHERE uid = '%d' AND fav_id = '%d'", $user->uid, $_POST['fav_id']);
$output = navigate_favorites_output($_POST['wid']);
echo $output;
}
/**
* Save the re-sorting of favorites
*/
function navigate_favorites_sort() {
$i = 1;
foreach ($_POST['navigate_favorites_id'] as $fav_id) {
db_query("UPDATE {navigate_favorites} SET weight = '%d' WHERE fav_id = '%d'", $i, $fav_id);
$i++;
}
}
/**
* Implementation of hook_user
*/
function navigate_favorites_user($op, &$edit, &$account, $category='') {
switch ($op) {
case 'delete':
db_query("DELETE * FROM {navigate_favorites} WHERE uid = '%d'", $account->uid);
break;
}
}
/**
* Implementation of hook_navigate_help_page()
*/
function navigate_favorites_navigate_help_page() {
$help['content'] = t('
The Favorites widget allows you to keep a shortlist of your favorite locations on the current Drupal site. Here\'s a quick list of functionality:
To add a favorite, navigate to the page you want to add. Then fill in a title in the Favorites text box and click Add or press enter.
To add a favorite to another site, or a url you can\'t navigate to, use the following format to type the favorite into the text box: Title of favorite|url/of/favorite. Note that that is a pipe character dividing the title and the url. For a url on your site, don\'t include a backslash at the beginning. For a url to another site, use the full url. For example: Example site|http://www.example.com. To add multiple favorites, use a semicolon separator, as in: Link 1|link/1;Link 2|link/2;Link 3...
To re-order favorites, drag the favorite link to the new location and drop it.
To delete a favorite, hover over the link until you see a white \'x\', then click the x.