From 7724caf7ff55fc6bfc552d596ea5d4463e26cba4 Mon Sep 17 00:00:00 2001 From: Stefan Frech Date: Sat, 28 Jun 2008 09:32:21 +0000 Subject: [PATCH] Added the possibility to sort bookmarks either by name or by date. --- bookmark_delete.php | 1 + bookmark_edit.php | 3 ++- bookmarks.php | 57 +++++++++++++++++++++++++++++++++++++++++++-- index.php | 10 ++++---- lib/lib.php | 44 +++++----------------------------- shared.php | 6 +++-- 6 files changed, 73 insertions(+), 48 deletions(-) diff --git a/bookmark_delete.php b/bookmark_delete.php index 9e91b6b..26ddc74 100644 --- a/bookmark_delete.php +++ b/bookmark_delete.php @@ -48,6 +48,7 @@ else { false, false, false, + false, false); ?> diff --git a/bookmark_edit.php b/bookmark_edit.php index 0f41f9e..2bb406d 100644 --- a/bookmark_edit.php +++ b/bookmark_edit.php @@ -42,7 +42,8 @@ if (count ($bmlist) > 1) { false, false, false, - true); + true, + false); ?> diff --git a/bookmarks.php b/bookmarks.php index fbb21cc..e4334cf 100644 --- a/bookmarks.php +++ b/bookmarks.php @@ -3,7 +3,7 @@ if (basename ($_SERVER['SCRIPT_NAME']) == basename (__FILE__)) { die ("no direct access allowed"); } -function list_bookmarks ($bookmarks, $show_checkbox, $show_folder, $show_icon, $show_link, $show_desc, $show_date, $show_edit, $show_move, $show_delete, $show_share) { +function list_bookmarks ($bookmarks, $show_checkbox, $show_folder, $show_icon, $show_link, $show_desc, $show_date, $show_edit, $show_move, $show_delete, $show_share, $show_header) { global $folderid, $expand, $settings, @@ -14,7 +14,60 @@ function list_bookmarks ($bookmarks, $show_checkbox, $show_folder, $show_icon, $ $delete_image, $folder_opened, $folder_opened_public, - $date_formats; + $date_formats, + $order; + + # print the bookmark header if enabled. + # Yes, it's ugly PHP code, but beautiful HTML code. + if ($show_header) { + $order[0] == 'titleasc' ? $sort_t = 'titledesc' : $sort_t = 'titledasc'; + $order[0] == 'dateasc' ? $sort_d = 'datedesc' : $sort_d = 'dateasc'; + + echo '
' . "\n"; + if ($show_folder) { + echo "\t" . '
 
' . "\n"; + } + if ($show_checkbox) { + echo "\t\t" . '
' . "\n"; + echo "\t\t\t" . '' . "\n"; + echo "\t\t" . '
' . "\n"; + } + if ($show_date) { + $query_data = array ( + 'folderid' => $folderid, + 'expand' => implode (",", $expand), + 'order' => $sort_d, + ); + if (isset ($GLOBALS['user']) && $GLOBALS['user'] != '') { + $query_data ['user'] = $GLOBALS['user']; + } + $query_string = assemble_query_string ($query_data); + echo "\t\t" . '
' . "\n"; + echo "\t\t\t" . '' . "\n"; + echo "\t\t\t\t" . 'Date ' . "\n"; + echo "\t\t\t" . '' . "\n"; + if ($show_edit) { + echo "\t\t\t" . '' . "\n"; + } + if ($show_move) { + echo "\t\t\t" . '' . "\n"; + } + if ($show_delete) { + echo "\t\t\t" . '' . "\n"; + } + echo "\t\t" . '
' . "\n"; + } + echo "\t\t" . '' . "\n"; + echo "\t" . '
' . "\n\n"; + } + if ($show_folder) { require_once (ABSOLUTE_PATH . "folders.php"); diff --git a/index.php b/index.php index ec59f15..c72ce5f 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,6 @@ require_once ("./header.php"); logged_in_only (); $search = set_get_string_var ('search'); -$order = set_get_order (); if ($search != '') { $search_mode = true; } @@ -11,6 +10,7 @@ else { $search_mode = false; } +$order = set_get_order (); ?> @@ -100,7 +100,8 @@ else { $settings['show_column_edit'], $settings['show_column_move'], $settings['show_column_delete'], - $settings['show_public']); + $settings['show_public'], + true); } else { echo '
No Bookmarks found matching ' . $search . '.
'; @@ -135,8 +136,6 @@ else { error); diff --git a/lib/lib.php b/lib/lib.php index 7a5b6f6..c248841 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -462,44 +462,12 @@ function object_count () { echo $return; } -function display_bookmark_header () { - global $expand, $folderid, $order, $settings; - - if ($order[0] == 'titleasc') { - $sort_t = 'titledesc'; +function assemble_query_string ($data) { + $return = array (); + foreach ($data as $key => $value) { + array_push ($return, $key . "=" . $value); } - else { - $sort_t = 'titleasc'; - } - if ($order[0] == 'dateasc') { - $sort_d = 'datedesc'; - } - else { - $sort_d = 'dateasc'; - } - - ?> -
-
- -
- - - - -
- \ No newline at end of file +?> diff --git a/shared.php b/shared.php index 8c6d773..08f528c 100644 --- a/shared.php +++ b/shared.php @@ -74,6 +74,7 @@ if (isset ($_GET['user']) && check_username ($user)) {
escape ($user), $mysql->escape ($folderid)); @@ -101,7 +102,8 @@ if (isset ($_GET['user']) && check_username ($user)) { false, false, false, - false); + false, + true); } else { message ($mysql->error);