1
0

Added the possibility to sort bookmarks either by name or by date.

This commit is contained in:
Stefan Frech
2008-06-28 09:32:21 +00:00
committed by Jonas Kattendick
parent 5b8f25c80f
commit 7724caf7ff
6 changed files with 73 additions and 48 deletions

View File

@@ -48,6 +48,7 @@ else {
false, false,
false, false,
false, false,
false,
false); false);
?> ?>

View File

@@ -42,7 +42,8 @@ if (count ($bmlist) > 1) {
false, false,
false, false,
false, false,
true); true,
false);
?> ?>
</div> </div>

View File

@@ -3,7 +3,7 @@ if (basename ($_SERVER['SCRIPT_NAME']) == basename (__FILE__)) {
die ("no direct access allowed"); 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, global $folderid,
$expand, $expand,
$settings, $settings,
@@ -14,7 +14,60 @@ function list_bookmarks ($bookmarks, $show_checkbox, $show_folder, $show_icon, $
$delete_image, $delete_image,
$folder_opened, $folder_opened,
$folder_opened_public, $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 '<div class="bookmarkcaption">' . "\n";
if ($show_folder) {
echo "\t" . '<div style="width:' . $column_width_folder . '; float: left;">&nbsp;</div>' . "\n";
}
if ($show_checkbox) {
echo "\t\t" . '<div class="bmleft">' . "\n";
echo "\t\t\t" . '<input type="checkbox" name="CheckAll" onClick="selectthem(\'checkall\', this.checked)">' . "\n";
echo "\t\t" . '</div>' . "\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" . '<div class="bmright">' . "\n";
echo "\t\t\t" . '<span class="date">' . "\n";
echo "\t\t\t\t" . '<a href="' . $_SERVER['SCRIPT_NAME'] . '?' . $query_string . '" class="f">Date <img src="./images/ascending.gif" alt=""></a>' . "\n";
echo "\t\t\t" . '</span>' . "\n";
if ($show_edit) {
echo "\t\t\t" . '<img src="./images/edit.gif" alt="" class="invisible">' . "\n";
}
if ($show_move) {
echo "\t\t\t" . '<img src="./images/move.gif" alt="" class="invisible">' . "\n";
}
if ($show_delete) {
echo "\t\t\t" . '<img src="./images/delete.gif" alt="" class="invisible">' . "\n";
}
echo "\t\t" . '</div>' . "\n";
}
echo "\t\t" . '<div class="link">' . "\n";
if ($show_icon) {
echo "\t\t\t" . '<img src="./images/bookmark_image.gif" alt="" class="invisible">' . "\n";
}
$query_data ['order'] = $sort_t;
$query_string = assemble_query_string ($query_data);
echo "\t\t\t" . '<a href="' . $_SERVER['SCRIPT_NAME'] . '?' . $query_string . '" class="f">Title <img src="./images/ascending.gif" alt=""></a>' . "\n";
echo "\t\t" . '</div>' . "\n";
echo "\t" . '</div>' . "\n\n";
}
if ($show_folder) { if ($show_folder) {
require_once (ABSOLUTE_PATH . "folders.php"); require_once (ABSOLUTE_PATH . "folders.php");

View File

@@ -3,7 +3,6 @@ require_once ("./header.php");
logged_in_only (); logged_in_only ();
$search = set_get_string_var ('search'); $search = set_get_string_var ('search');
$order = set_get_order ();
if ($search != '') { if ($search != '') {
$search_mode = true; $search_mode = true;
} }
@@ -11,6 +10,7 @@ else {
$search_mode = false; $search_mode = false;
} }
$order = set_get_order ();
?> ?>
@@ -100,7 +100,8 @@ else {
$settings['show_column_edit'], $settings['show_column_edit'],
$settings['show_column_move'], $settings['show_column_move'],
$settings['show_column_delete'], $settings['show_column_delete'],
$settings['show_public']); $settings['show_public'],
true);
} }
else { else {
echo '<div id="content"> No Bookmarks found matching <b>' . $search . '</b>.</div>'; echo '<div id="content"> No Bookmarks found matching <b>' . $search . '</b>.</div>';
@@ -135,8 +136,6 @@ else {
<?php <?php
display_bookmark_header ();
require_once (ABSOLUTE_PATH . "bookmarks.php"); require_once (ABSOLUTE_PATH . "bookmarks.php");
$query = sprintf ("SELECT title, url, description, UNIX_TIMESTAMP(date) AS timestamp, id, favicon, public $query = sprintf ("SELECT title, url, description, UNIX_TIMESTAMP(date) AS timestamp, id, favicon, public
FROM bookmark FROM bookmark
@@ -162,7 +161,8 @@ else {
$settings['show_column_edit'], $settings['show_column_edit'],
$settings['show_column_move'], $settings['show_column_move'],
$settings['show_column_delete'], $settings['show_column_delete'],
$settings['show_public']); $settings['show_public'],
true);
} }
else { else {
message ($mysql->error); message ($mysql->error);

View File

@@ -462,44 +462,12 @@ function object_count () {
echo $return; echo $return;
} }
function display_bookmark_header () { function assemble_query_string ($data) {
global $expand, $folderid, $order, $settings; $return = array ();
foreach ($data as $key => $value) {
if ($order[0] == 'titleasc') { array_push ($return, $key . "=" . $value);
$sort_t = 'titledesc';
} }
else { return implode ($return, "&");
$sort_t = 'titleasc';
}
if ($order[0] == 'dateasc') {
$sort_d = 'datedesc';
}
else {
$sort_d = 'dateasc';
}
?>
<div class="bookmarkcaption">
<div class="bmleft">
<input type="checkbox" name="CheckAll" onClick="selectthem('checkall', this.checked)">
</div>
<?php if ($settings['show_column_date']) : ?>
<div class="bmright">
<span class="date">
<a href="./index.php?expand=<?php echo implode(",", $expand); ?>&folderid=<?php echo $folderid; ?>&order=<?php echo $sort_d; ?>" class="f">Date <img src="./images/ascending.gif" alt="">
</span>
<img src="./images/edit.gif" alt="" class="invisible">
<img src="./images/move.gif" alt="" class="invisible">
<img src="./images/delete.gif" alt="" class="invisible">
</div>
<?php endif; ?>
<div class="link">
<img src="./images/bookmark_image.gif" alt="" class="invisible">
<a href="./index.php?expand=<?php echo implode(",", $expand); ?>&folderid=<?php echo $folderid; ?>&order=<?php echo $sort_t; ?>" class="f">Title <img src="./images/ascending.gif" alt=""></a>
</div>
</div>
<?php
} }
?> ?>

View File

@@ -74,6 +74,7 @@ if (isset ($_GET['user']) && check_username ($user)) {
<div class="bookmarks" style="height: <?php echo $table_height; ?>;"> <div class="bookmarks" style="height: <?php echo $table_height; ?>;">
<?php <?php
$order = set_get_order ();
require_once (ABSOLUTE_PATH . "bookmarks.php"); require_once (ABSOLUTE_PATH . "bookmarks.php");
$query = sprintf ("SELECT title, url, description, UNIX_TIMESTAMP(date) AS timestamp, id, favicon $query = sprintf ("SELECT title, url, description, UNIX_TIMESTAMP(date) AS timestamp, id, favicon
@@ -82,7 +83,7 @@ if (isset ($_GET['user']) && check_username ($user)) {
AND childof='%d' AND childof='%d'
AND deleted!='1' AND deleted!='1'
AND public='1' AND public='1'
ORDER BY title", ORDER BY $order[1]",
$mysql->escape ($user), $mysql->escape ($user),
$mysql->escape ($folderid)); $mysql->escape ($folderid));
@@ -101,7 +102,8 @@ if (isset ($_GET['user']) && check_username ($user)) {
false, false,
false, false,
false, false,
false); false,
true);
} }
else { else {
message ($mysql->error); message ($mysql->error);