bookmarks.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <?php
  2. if (basename ($_SERVER['SCRIPT_NAME']) == basename (__FILE__)) {
  3. die ("no direct access allowed");
  4. }
  5. 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, $user = false) {
  6. global $folderid,
  7. $expand,
  8. $settings,
  9. $column_width_folder,
  10. $bookmark_image,
  11. $edit_image,
  12. $move_image,
  13. $delete_image,
  14. $folder_opened,
  15. $folder_opened_public,
  16. $date_formats,
  17. $order;
  18. # print the bookmark header if enabled.
  19. # Yes, it's ugly PHP code, but beautiful HTML code.
  20. if ($show_header) {
  21. if ($order[0] == 'titleasc') {
  22. $sort_t = 'titledesc';
  23. $img_t = '<img src="./images/ascending.gif" alt="">';
  24. }
  25. else if ($order[0] == 'titledesc') {
  26. $sort_t = 'titleasc';
  27. $img_t = '<img src="./images/descending.gif" alt="">';
  28. }
  29. else {
  30. $sort_t = 'titleasc';
  31. $img_t = '<img src="./images/descending.gif" alt="" class="invisible">';
  32. }
  33. if ($order[0] == 'dateasc') {
  34. $sort_d = 'datedesc';
  35. $img_d = '<img src="./images/ascending.gif" alt="">';
  36. }
  37. else if ($order[0] == 'datedesc') {
  38. $sort_d = 'dateasc';
  39. $img_d = '<img src="./images/descending.gif" alt="">';
  40. }
  41. else {
  42. $sort_d = 'dateasc';
  43. $img_d = '<img src="./images/descending.gif" alt="" class="invisible">';
  44. }
  45. echo '<div class="bookmarkcaption">' . "\n";
  46. if ($show_folder) {
  47. echo "\t" . '<div style="width:' . $column_width_folder . '; float: left;">&nbsp;</div>' . "\n";
  48. }
  49. if ($show_checkbox) {
  50. echo "\t\t" . '<div class="bmleft">' . "\n";
  51. echo "\t\t\t" . '<input type="checkbox" name="CheckAll" onClick="selectthem(\'checkall\', this.checked)">' . "\n";
  52. echo "\t\t" . '</div>' . "\n";
  53. }
  54. if ($show_date) {
  55. $query_data = array (
  56. 'folderid' => $folderid,
  57. 'expand' => implode (",", $expand),
  58. 'order' => $sort_d,
  59. );
  60. if ($user) {
  61. $query_data['user'] = $user;
  62. }
  63. $query_string = assemble_query_string ($query_data);
  64. echo "\t\t" . '<div class="bmright">' . "\n";
  65. echo "\t\t\t" . '<span class="date">' . "\n";
  66. echo "\t\t\t\t" . '<a href="' . $_SERVER['SCRIPT_NAME'] . '?' . $query_string . '" class="f">Date ' . $img_d . '</a>' . "\n";
  67. echo "\t\t\t" . '</span>' . "\n";
  68. if ($show_edit) {
  69. echo "\t\t\t" . '<img src="./images/edit.gif" alt="" class="invisible">' . "\n";
  70. }
  71. if ($show_move) {
  72. echo "\t\t\t" . '<img src="./images/move.gif" alt="" class="invisible">' . "\n";
  73. }
  74. if ($show_delete) {
  75. echo "\t\t\t" . '<img src="./images/delete.gif" alt="" class="invisible">' . "\n";
  76. }
  77. echo "\t\t" . '</div>' . "\n";
  78. }
  79. echo "\t\t" . '<div class="link">' . "\n";
  80. if ($show_icon) {
  81. echo "\t\t\t" . '<img src="./images/bookmark_image.gif" alt="" class="invisible">' . "\n";
  82. }
  83. $query_data ['order'] = $sort_t;
  84. $query_string = assemble_query_string ($query_data);
  85. echo "\t\t\t" . '<a href="' . $_SERVER['SCRIPT_NAME'] . '?' . $query_string . '" class="f">Title ' . $img_t . '</a>' . "\n";
  86. echo "\t\t" . '</div>' . "\n";
  87. echo "\t" . '</div>' . "\n\n";
  88. }
  89. if ($show_folder) {
  90. require_once (ABSOLUTE_PATH . "folders.php");
  91. $tree = new folder;
  92. }
  93. echo '<form name="bookmarks" action="" class="nav">' . "\n";
  94. foreach ($bookmarks as $value) {
  95. echo '<div class="bookmark">' . "\n";
  96. # the folders, only needed when searching for bookmarks
  97. if ($show_folder) {
  98. if ($value['fid'] == null) {
  99. $value['name'] = $settings['root_folder_name'];
  100. $value['fid'] = 0;
  101. }
  102. if ($value['fpublic']) {
  103. $folder_image = $folder_opened_public;
  104. }
  105. else {
  106. $folder_image = $folder_opened;
  107. }
  108. $expand = $tree->get_path_to_root ($value['fid']);
  109. echo "\t" . '<div style="width:' . $column_width_folder . '; float: left;">';
  110. echo '<a class="f" href="./index.php?expand=' . implode (",", $expand) . '&folderid='. $value['fid'] .'#' . $value['fid'] . '">';
  111. echo $folder_image . " " . $value['name'] . "</a>";
  112. echo "</div>\n";
  113. }
  114. # the checkbox and favicon section
  115. echo "\t" . '<div class="bmleft">' . "\n";
  116. # the checkbox
  117. if ($show_checkbox){
  118. echo "\t\t" . '<input type="checkbox" name="' . $value['id'] . '">' . "\n";
  119. }
  120. echo "\n\t</div>\n";
  121. # the share, date and edit/move/delete icon section
  122. echo "\t" . '<div class="bmright">' . "\n";
  123. if ($show_share) {
  124. $share = $value['public'] ? 'public' : 'private';
  125. echo "\t\t" . '<span class="' . $share . '">' . $share . "</span>\n";
  126. }
  127. if ($show_date) {
  128. echo "\t\t" . '<span class="date">';
  129. echo date ($date_formats[$settings['date_format']], $value['timestamp']);
  130. echo "\t</span>\n";
  131. }
  132. # the edit column
  133. if ($show_edit) {
  134. echo "\t\t" . '<a href="javascript:bookmarkedit(\'' . $value['id'] . '\')">';
  135. echo sprintf ($edit_image, "Edit");
  136. echo "</a>\n";
  137. }
  138. # the move column
  139. if ($show_move) {
  140. echo "\t\t" . '<a href="javascript:bookmarkmove(\'' . $value['id'] . '\', \'' . 'expand=' . implode (",", $expand) . '&amp;folderid=' . $folderid . '\')">';
  141. echo sprintf ($move_image, "Move");
  142. echo "</a>\n";
  143. }
  144. # the delete column
  145. if ($show_delete) {
  146. echo "\t\t" . '<a href="javascript:bookmarkdelete(\'' . $value['id'] . '\')">';
  147. echo sprintf ($delete_image, "Delete");
  148. echo "</a>\n";
  149. }
  150. echo "\t</div>\n";
  151. # the favicon
  152. echo "\t" . '<div class="link">' . "\n";
  153. echo "\t\t";
  154. if ($show_icon){
  155. if ($value['favicon'] && is_file ($value['favicon'])) {
  156. echo '<img src="' . $value['favicon'] . '" width="16" height="16" alt="">' . "\n";
  157. }
  158. else {
  159. echo $bookmark_image . "\n";
  160. }
  161. }
  162. # the link
  163. if ($settings['open_new_window']) {
  164. $target = ' target="_blank"';
  165. }
  166. else {
  167. $target = null;
  168. }
  169. if ($show_link){
  170. $link = '<a href="' . $value['url'] . '" title="' . $value['url'] . '"' . $target . '>' . $value['title'] . "</a>";
  171. }
  172. else {
  173. $link = $value['title'];
  174. }
  175. echo "\t\t$link\n";
  176. echo "\t</div>\n";
  177. # the description and if not empty
  178. if ($show_desc && $value['description'] != "") {
  179. if ($show_folder) {
  180. $css_extension = ' style="margin-left: ' . $column_width_folder . ';"';
  181. }
  182. else {
  183. $css_extension = "";
  184. }
  185. echo "\t" . '<div class="description"' . $css_extension . '>' . $value['description'] . "</div>\n";
  186. }
  187. echo "</div>\n\n";
  188. }
  189. echo "</form>\n";
  190. }
  191. ?>