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

Benjamin Mako Hill || Want to submit a patch?