]> projects.mako.cc - scuttle/blob - templates/bookmarks.tpl.php
initial patch to cause scuttle to work with PHP 8.2
[scuttle] / templates / bookmarks.tpl.php
1 <?php
2 $sf = new ServiceFactory();
3 $userservice     =& $sf->getServiceInstance('UserService');
4 $bookmarkservice =& $sf->getServiceInstance('BookmarkService');
5
6 $logged_on_userid = $userservice->getCurrentUserId();
7 $this->includeTemplate($GLOBALS['top_include']);
8
9 # define variables
10 if (!isset($currenttag)) {
11     $currenttag = NULL;
12 }
13 if (!isset($user)) {
14     $user = NULL;
15 }
16 if (!isset($userid)) {
17     $userid = NULL;
18 }
19
20 include 'search.inc.php';
21 if (count($bookmarks) > 0) {
22 ?>
23
24 <p id="sort">
25   <?php echo T_("Sort by:"); ?>
26   <a href="?sort=date_desc"><?php echo T_("Date"); ?></a><span> / </span>
27   <a href="?sort=title_asc"><?php echo T_("Title"); ?></a><span> / </span>
28   <?php if (!isset($hash)): ?>
29     <a href="?sort=url_asc"><?php echo T_("URL"); ?></a>
30   <?php endif; ?>
31 </p>
32 <ol<?php echo ($start > 0 ? ' start="'. ++$start .'"' : ''); ?> id="bookmarks">
33
34     <?php
35     foreach(array_keys($bookmarks) as $key) {
36         $row =& $bookmarks[$key];
37         switch ($row['bStatus']) {
38             case 0:
39                 $access = '';
40                 break;
41             case 1:
42                 $access = ' shared';
43                 break;
44             case 2:
45                 $access = ' private';
46                 break;
47         }
48
49         $cats = '';
50         $tags = $row['tags'];
51         foreach(array_keys($tags) as $key) {
52             $tag =& $tags[$key];
53             $cats .= '<a href="'. sprintf($cat_url, filter($user, 'url'), filter($tag, 'url')) .'" rel="tag">'. filter($tag) .'</a>, ';
54         }
55         $cats = substr($cats, 0, -2);
56         if ($cats != '') {
57             $cats = ' to '. $cats;
58         }
59
60         // Edit and delete links
61         $edit = '';
62         if ($bookmarkservice->editAllowed($row['bId'])) {
63             $edit = ' - <a href="'. createURL('edit', $row['bId']) .'">'. T_('Edit') .'</a><script type="text/javascript">document.write(" - <a href=\"#\" onclick=\"deleteBookmark(this, '. $row['bId'] .'); return false;\">'. T_('Delete') .'<\/a>");</script>';
64         }
65
66         // User attribution
67         $copy = '';
68         if (!isset($user) || isset($watched)) {
69             $copy = ' '. T_('by') .' <a href="'. createURL('bookmarks', $row['username']) .'">'. $row['username'] .'</a>';
70         }
71
72         // Udders!
73         if (!isset($hash)) {
74             $others = $bookmarkservice->countOthers($row['bAddress']);
75             $ostart = '<a href="'. createURL('history', $row['bHash']) .'">';
76             $oend = '</a>';
77             switch ($others) {
78                 case 0:
79                     break;
80                 case 1:
81                     $copy .= sprintf(T_(' and %s1 other%s'), $ostart, $oend);
82                     break;
83                 default:
84                     $copy .= sprintf(T_(' and %2$s%1$s others%3$s'), $others, $ostart, $oend);
85             }
86         }
87
88         // Copy link
89         if ($userservice->isLoggedOn() && ($logged_on_userid != $row['uId'])) {
90             // Get the username of the current user
91             $currentUser = $userservice->getCurrentUser();
92             $currentUsername = $currentUser[$userservice->getFieldName('username')];
93             $copy .= ' - <a href="'. createURL('bookmarks', $currentUsername .'?action=add&amp;address='. urlencode($row['bAddress']) .'&amp;title='. urlencode($row['bTitle'])) .'">'. T_('Copy') .'</a>';   
94         }
95
96         // Nofollow option
97         $rel = '';
98         if ($GLOBALS['nofollow']) {
99             $rel = ' rel="nofollow"';
100         }
101
102         $address = filter($row['bAddress']);
103         
104         // Internet Archive WayBack Links
105         $archive_link = '';
106         if ($GLOBALS["archive_links"]) { 
107             $archive_link = ' - <a href="' . $GLOBALS['archive_base_url'] . "/" . date("YmdHis", strtotime($row['bDatetime'])) . "/" . $address . '">' . T_('Archived Link') . '</a>';
108         }
109         
110         // Redirection option
111         if ($GLOBALS['useredir']) {
112             $address = $GLOBALS['url_redir'] . $address;
113         }
114         
115         // Output
116         echo '<li class="xfolkentry'. $access .'">'."\n";
117         echo '<div class="link"><a href="'. $address .'"'. $rel .' class="taggedlink">'. filter($row['bTitle']) ."</a></div>\n";
118         if ($row['bDescription'] != '') {
119             echo '<div class="description">'. filter($row['bDescription']) ."</div>\n";
120         }
121         if ($row['bDatetime'] == $row['bModified']) {
122             echo '<div class="meta">'. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . $cats . $copy . $edit . $archive_link ."</div>\n";
123         } else {
124             echo '<div class="meta"><span id="date-updated">updated: '. date($GLOBALS['shortdate'], strtotime($row['bModified'])) . '</span>, <span id="date-original">original: '. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . "</span>" . $cats . $copy . $edit . $archive_link ."</div>\n";
125         }
126         echo "</li>\n";
127     }
128     ?>
129
130 </ol>
131
132     <?php
133     // PAGINATION
134     
135     // Ordering
136     $sortOrder = '';
137     if (isset($_GET['sort'])) {
138         $sortOrder = 'sort='. $_GET['sort'];
139     }
140     
141     $sortAmp = (($sortOrder) ? '&amp;'. $sortOrder : '');
142     $sortQue = (($sortOrder) ? '?'. $sortOrder : '');
143     
144     // Previous
145     $perpage = getPerPageCount();
146     if (!$page || $page < 2) {
147         $page = 1;
148         $start = 0;
149         $bfirst = '<span class="disable">'. T_('First') .'</span>';
150         $bprev = '<span class="disable">'. T_('Previous') .'</span>';
151     } else {
152         $prev = $page - 1;
153         $prev = 'page='. $prev;
154         $start = ($page - 1) * $perpage;
155         $bfirst= '<a href="'. sprintf($nav_url, $user, $currenttag, '') . $sortQue .'">'. T_('First') .'</a>';
156         $bprev = '<a href="'. sprintf($nav_url, $user, $currenttag, '?') . $prev . $sortAmp .'">'. T_('Previous') .'</a>';
157     }
158     
159     // Next
160     $next = $page + 1;
161     $totalpages = ceil($total / $perpage);
162     if (count($bookmarks) < $perpage || $perpage * $page == $total) {
163         $bnext = '<span class="disable">'. T_('Next') .'</span>';
164         $blast = '<span class="disable">'. T_('Last') .'</span>';
165     } else {
166         $bnext = '<a href="'. sprintf($nav_url, $user, $currenttag, '?page=') . $next . $sortAmp .'">'. T_('Next') .'</a>';
167         $blast = '<a href="'. sprintf($nav_url, $user, $currenttag, '?page=') . $totalpages . $sortAmp .'">'. T_('Last') .'</a>';
168     }
169     echo '<p class="paging">'. $bfirst .'<span> / </span>'. $bprev .'<span> / </span>'. $bnext .'<span> / </span>'. $blast .'<span> / </span>'. sprintf(T_('Page %d of %d'), $page, $totalpages) .'</p>';
170 } else {
171 ?>
172
173     <p class="error"><?php echo T_('No bookmarks available'); ?>.</p>
174
175 <?php
176 }
177 $this->includeTemplate('sidebar.tpl');
178 $this->includeTemplate($GLOBALS['bottom_include']);
179 ?>

Benjamin Mako Hill || Want to submit a patch?