1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
|
<?php
/**
* Show a list of bookmarks.
*
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @subcategory Templates
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
* @author Christian Weiske <cweiske@cweiske.de>
* @author Eric Dane <ericdane@users.sourceforge.net>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
/* Service creation: only useful services are created */
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
$tagservice = SemanticScuttle_Service_Factory::get('Tag');
$cdservice = SemanticScuttle_Service_Factory::get('CommonDescription');
$pageName = isset($pageName) ? $pageName : '';
$user = isset($user) ? $user : '';
$currenttag = isset($currenttag) ? $currenttag : '';
$this->includeTemplate($GLOBALS['top_include']);
include('search.menu.php');
?>
<?php if($pageName == PAGE_INDEX && $GLOBALS['welcomeMessage']):?>
<p id="welcome"><?php echo $GLOBALS['welcomeMessage'];?></p>
<?php endif?>
<?php if($GLOBALS['enableAdminColors']!=false && isset($userid) && $userservice->isAdmin($userid) && $pageName != PAGE_WATCHLIST) : ?>
<div style="width:70%;text-align:center;">
<img src="<?php echo $theme->resource('images/logo_24.gif'); ?>" width="12px"/>
<?php echo T_('Bookmarks on this page are managed by an admin user.'); ?>
<img src="<?php echo $theme->resource('images/logo_24.gif'); ?>" width="12px"/>
</div>
<?php endif?>
<?php
// common tag description
if(($currenttag!= '' && $GLOBALS['enableCommonTagDescription'])
|| (isset($hash) && $GLOBALS['enableCommonBookmarkDescription'])):?>
<p class="commondescription"><?php
$cDescription = '';
if($currenttag!= '' && $cdservice->getLastTagDescription($currenttag)) {
$cDescription = $cdservice->getLastTagDescription($currenttag);
echo nl2br(filter($cDescription['cdDescription']));
} elseif(isset($hash) && $cdservice->getLastBookmarkDescription($hash)) {
$cDescription = $cdservice->getLastBookmarkDescription($hash);
echo nl2br(filter($cDescription['cdTitle'])). "<br/>";
echo nl2br(filter($cDescription['cdDescription'])). "<br/>";
}
//common tag description edit
if ($userservice->isLoggedOn()) {
if ($currenttag != ''
&& ($GLOBALS['enableCommonTagDescriptionEditedByAll']
|| $currentUser->isAdmin()
)
) {
echo ' <a href="'. createURL('tagcommondescriptionedit', $currenttag).'" title="'.T_('Edit the common description of this tag').'">';
echo !is_array($cDescription) || strlen($cDescription['cdDescription'])==0?T_('Edit the common description of this tag'):'';
echo ' <img src="' . $theme->resource('images/b_edit.png') . '" /></a>';
} else if (isset($hash)) {
echo ' (<a href="'.createURL('bookmarkcommondescriptionedit', $hash).'" title="'.T_('Edit the common description of this bookmark').'">';
echo T_('Edit the common description of this bookmark').'</a>)';
}
}
?></p>
<?php endif ?>
<?php
/* personal tag description */
if($currenttag!= '' && $user!='') {
$userObject = $userservice->getUserByUsername($user);
if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>
<p class="commondescription"><?php
$pDescription = $tagservice->getDescription($currenttag, $userObject['uId']);
echo nl2br(filter($pDescription['tDescription']));
//personal tag description edit
if($userservice->isLoggedOn()) {
if($currenttag!= '') {
echo ' <a href="'. createURL('tagedit', $currenttag).'" title="'.T_('Edit your personal description of this tag').'" >';
echo strlen($pDescription['tDescription'])==0?T_('Edit your personal description of this tag'):'';
echo ' <img src="' . $theme->resource('images/b_edit.png') . '" /></a>';
}
}
?></p>
<?php
}
}
?>
<?php if (isset($bookmarks) && count($bookmarks) > 0) { ?>
<script type="text/javascript">
window.onload = playerLoad;
</script>
<p id="sort"><?php echo $total.' '.T_("bookmark(s)"); ?> - <?php echo T_("Sort by:"); ?>
<?php
$titleArrow = '';
$dateArrow = '';
$votingArrow = '';
$dateSort = 'date_desc';
$titleSort = 'title_asc';
$votingSort = 'voting_desc';
switch(getSortOrder()) {
case 'date_asc':
$dateArrow = ' ↑';
$dateSort = 'date_desc';
break;
case 'title_asc':
$titleArrow = ' ↑';
$titleSort = 'title_desc';
break;
case 'title_desc':
$titleArrow = ' ↓';
$titleSort = 'title_asc';
break;
case 'voting_asc':
$votingArrow = ' ↑';
$votingSort = 'voting_desc';
break;
case 'voting_desc':
$votingArrow = ' ↓';
$votingSort = 'voting_asc';
break;
case 'date_desc':
default:
$dateArrow = ' ↓';
$dateSort = 'date_asc';
break;
}
?>
<a href="?sort=<?php echo $dateSort ?>"><?php echo T_("Date").$dateArrow; ?></a>
<span>/</span>
<a href="?sort=<?php echo $titleSort ?>"><?php echo T_("Title").$titleArrow; ?></a>
<span>/</span>
<?php if ($GLOBALS['enableVoting']) { ?>
<a href="?sort=<?php echo $votingSort ?>"><?php echo T_("Voting").$votingArrow; ?></a>
<span>/</span>
<?php } ?>
<?php
if ($currenttag!= '') {
if ($user!= '') {
echo ' - ';
echo '<a href="'. createURL('tags', $currenttag) .'">';
echo T_('Bookmarks from other users for this tag').'</a>';
//echo T_(' for these tags');
} else if ($userservice->isLoggedOn()){
echo ' - ';
echo '<a href="'. createURL('bookmarks', $currentUser->getUsername().'/'.$currenttag) .'">';
echo T_('Only your bookmarks for this tag').'</a>';
//echo T_(' for these tags');
}
}
?></p>
<?php
// PAGINATION
// Ordering
$sortOrder = '';
if (GET_SORT != '') {
$sortOrder = 'sort=' . getSortOrder();
}
$sortAmp = (($sortOrder) ? '&'. $sortOrder : '');
$sortQue = (($sortOrder) ? '?'. $sortOrder : '');
// Previous
$perpage = getPerPageCount($currentUser);
if (!$page || $page < 2) {
$page = 1;
$start = 0;
$bfirst = '<span class="disable">'. T_('First') .'</span>';
$bprev = '<span class="disable">'. T_('Previous') .'</span>';
} else {
$prev = $page - 1;
$prev = 'page='. $prev;
$start = ($page - 1) * $perpage;
$bfirst= '<a href="'. sprintf($nav_url, $user, $currenttag, '') . $sortQue .'">'. T_('First') .'</a>';
$bprev = '<a href="'. sprintf($nav_url, $user, $currenttag, '?') . $prev . $sortAmp .'">'. T_('Previous') .'</a>';
}
// Next
$next = $page + 1;
$totalpages = ceil($total / $perpage);
if (count($bookmarks) < $perpage || $perpage * $page == $total) {
$bnext = '<span class="disable">'. T_('Next') .'</span>';
$blast = '<span class="disable">'. T_('Last') ."</span>\n";
} else {
$bnext = '<a href="'. sprintf($nav_url, $user, $currenttag, '?page=') . $next . $sortAmp .'">'. T_('Next') .'</a>';
$blast = '<a href="'. sprintf($nav_url, $user, $currenttag, '?page=') . $totalpages . $sortAmp .'">'. T_('Last') ."</a>\n";
}
// RSS
$brss = '';
$size = count($rsschannels);
for ($i = 0; $i < $size; $i++) {
$brss = '<a style="background:#FFFFFF"'
. ' href="'. htmlspecialchars($rsschannels[$i][1]) . '"'
. ' title="' . htmlspecialchars($rsschannels[$i][0]) . '">'
. '<img src="' . $theme->resource('images/rss.gif') . '"'
. ' width="16" height="16"'
. ' alt="' . htmlspecialchars($rsschannels[$i][0]) .'"/>'
. '</a>';
}
$pagesBanner = '<p class="paging">'. $bfirst .'<span> / </span>'. $bprev .'<span> / </span>'. $bnext .'<span> / </span>'. $blast .'<span> / </span>'. sprintf(T_('Page %d of %d'), $page, $totalpages) ." ". $brss ." </p>\n";
if (getPerPageCount($currentUser) > 10) {
echo $pagesBanner; // display a page banner if too many bookmarks to manage
}
?>
<ol<?php echo ($start > 0 ? ' start="'. ++$start .'"' : ''); ?> id="bookmarks">
<?php
$addresses = array();
foreach ($bookmarks as $key => &$row) {
$addresses[$row['bId']] = $row['bAddress'];
}
$otherCounts = $bookmarkservice->countOthers($addresses);
if ($userservice->isLoggedOn()) {
$existence = $bookmarkservice->bookmarksExist(
$addresses, $currentUser->getId()
);
}
if ($userservice->isLoggedOn()) {
$watchedNames = $userservice->getWatchNames(
$currentUser->getId(), true
);
} else {
$watchedNames = null;
}
foreach ($bookmarks as $key => &$row) {
switch ($row['bStatus']) {
case 0:
$access = '';
break;
case 1:
$access = ' shared';
break;
case 2:
$access = ' private';
break;
}
$cats = '';
$tagsForCopy = '';
$tags = $row['tags'];
foreach ($tags as $tkey => &$tag) {
$tagcaturl = sprintf(
$cat_url,
filter($row['username'], 'url'),
filter($tag, 'url')
);
$cats .= sprintf(
'<a href="%s" rel="tag">%s</a>, ',
$tagcaturl, filter($tag)
);
$tagsForCopy .= $tag . ',';
}
$cats = substr($cats, 0, -2);
if ($cats != '') {
$cats = T_('Tags:') . ' ' . $cats;
}
// Edit and delete links
$edit = '';
if ($bookmarkservice->editAllowed($row)) {
$edit = ' - <a href="' . createURL('edit', $row['bId']) . '">'
. T_('Edit')
. '</a>'
. ' <a href="#" onclick="deleteBookmark(this, '. $row['bId'] .'); return false;">'
. T_('Delete')
.'</a>';
}
// Last update
$update = ' <small title="'. T_('Last update') .'">('. date($GLOBALS['shortdate'], strtotime($row['bModified'])). ') </small>';
// User attribution
$copy = ' ' . T_('by') . ' ';
if ($userservice->isLoggedOn()
&& $currentUser->getUsername() == $row['username']
) {
$copy .= T_('you');
} else {
$copy .= '<a href="' . createURL('bookmarks', $row['username']) . '">'
. SemanticScuttle_Model_UserArray::getName($row)
. '</a>';
}
// others
if (!isset($hash)) {
$others = $otherCounts[$row['bAddress']];
$ostart = '<a href="' . createURL('history', $row['bHash']) . '">';
$oend = '</a>';
switch ($others) {
case 0:
break;
case 1:
$copy .= sprintf(T_(' and %s1 other%s'), $ostart, $oend);
break;
default:
$copy .= sprintf(T_(' and %2$s%1$s others%3$s'), $others, $ostart, $oend);
}
}
// Local cache
$cacheInfo = $GLOBALS['dir_cache'] .'/urls';
$cacheLink = null;
if ($GLOBALS['cacheUrl'] != null) {
// Hashing discussion at http://linuxprocess.free.fr/MHonArc/Oct-2005/msg00016.html
$assetHash = sha1($row['bAddress'] . "\n");
$assetHash = substr($assetHash, 0, 2) . '/' . substr($assetHash, 2, 2) . '/' . $assetHash;
$assetBase = $GLOBALS['cacheUrl'] . '/' . $assetHash;
$assetLink = $assetBase;
$assetPdf = $assetBase.'/screenshot.pdf';
$assetPng = $assetBase .'/screenshot.png';
// Handle PDF links
$assetFile = basename(parse_url($row['bAddress'])['path']);
$assetExt = strtolower(pathinfo($assetFile, PATHINFO_EXTENSION));
if ($assetExt == 'pdf') {
$assetLink = $GLOBALS['cacheUrl'] . '/' . $assetHash . '/' . $assetFile;
}
// Check if the link exists
if (file_exists($cacheInfo .'/'. $assetHash .'/hascache')) {
$cacheLink = "| <a href=\"$assetLink\">Cache</a>";
if (file_exists($cacheInfo .'/'. $assetHash .'/haspdf')) {
$cacheLink .= " | <a href=\"$assetPdf\">PDF</a>";
}
if (file_exists($cacheInfo .'/'. $assetHash .'/haspng')) {
$cacheLink .= " | <a href=\"$assetPng\">PNG</a>";
}
}
else if ($fp = curl_init($assetBase)) {
curl_setopt($fp, CURLOPT_NOBODY, true);
curl_exec($fp);
$retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE);
if ($retcode != 404) {
if (!file_exists($cacheInfo .'/'. $assetHash)) {
mkdir($cacheInfo .'/'. $assetHash, 0755, true);
}
touch($cacheInfo .'/'. $assetHash .'/hascache');
$cacheLink = "| <a href=\"$assetLink\">Cache</a>";
// Check if PDF is available
if ($fp = curl_init($assetPdf)) {
curl_setopt($fp, CURLOPT_NOBODY, true);
curl_exec($fp);
$retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE);
if ($retcode != 404) {
touch($cacheInfo .'/'. $assetHash .'/haspdf');
$cacheLink .= " | <a href=\"$assetPdf\">PDF</a>";
}
curl_close($fp);
}
// Check if PNG is available
if ($fp = curl_init($assetPng)) {
curl_setopt($fp, CURLOPT_NOBODY, true);
curl_exec($fp);
$retcode = curl_getinfo($fp, CURLINFO_HTTP_CODE);
if ($retcode != 404) {
touch($cacheInfo .'/'. $assetHash .'/haspng');
$cacheLink .= " | <a href=\"$assetPng\">PNG</a>";
}
curl_close($fp);
}
}
curl_close($fp);
}
}
// Copy link
if ($userservice->isLoggedOn()
&& ($currentUser->getId() != $row['uId'])
&& !$existence[$row['bAddress']]
) {
$copy .= ' - <a href="'
. createURL(
'bookmarks',
$currentUser->getUsername()
. '?action=add&copyOf=' . $row['bId'])
. '" title="'.T_('Copy this bookmark to YOUR bookmarks.').'">'
. T_('Copy')
. '</a>';
}
// Nofollow option
$rel = '';
if ($GLOBALS['nofollow']) {
$rel = ' rel="nofollow"';
}
$address = $row['bAddress'];
$oaddress = $address;
// Redirection option
if ($GLOBALS['useredir']) {
$address = $GLOBALS['url_redir'] . $address;
}
// Admin specific design
if ($userservice->isAdmin($row['username'])
&& $GLOBALS['enableAdminColors']
) {
$adminBgClass = ' class="adminBackground"';
$adminStar = ' <img'
. ' src="' . $theme->resource('images/logo_24.gif') . '"'
. ' width="12px"'
. ' title="' . T_('This bookmark is certified by an admin user.') . '"'
. '/>';
} else {
$adminBgClass = '';
$adminStar = '';
}
// Private Note (just visible by the owner and his/her contacts)
if ($watchedNames !== null
&& ($currentUser->getId() == $row['uId']
|| in_array($row['username'], $watchedNames)
)
) {
$privateNoteField = $row['bPrivateNote'];
} else {
$privateNoteField = '';
}
if ($GLOBALS['enableVoting'] && $GLOBALS['hideBelowVoting'] !== null
&& $row['bVoting'] < $GLOBALS['hideBelowVoting']
) {
$access .= ' below-threshold';
}
// Output
echo ' <li class="xfolkentry'. $access .'">'."\n";
include 'bookmarks-thumbnail.inc.tpl.php';
include 'bookmarks-vote.inc.tpl.php';
echo ' <div' . $adminBgClass . '>' . "\n";
echo ' <div class="link">'
. '<a href="'. htmlspecialchars($address) .'"'. $rel .' class="taggedlink">'
. filter($row['bTitle'])
. '</a>' . $adminStar . "</div>\n";
if ($row['bDescription'] == '') {
$bkDescription = $GLOBALS['blankDescription'];
} else {
// Improve description display (anchors, links, ...)
$bkDescription = preg_replace('|\[\/.*?\]|', '', filter($row['bDescription'])); // remove final anchor
$bkDescription = preg_replace('|\[(.*?)\]|', ' <span class="anchorBookmark">$1</span> » ', $bkDescription); // highlight starting anchor
$bkDescription = preg_replace('@((http|https|ftp)://.*?)( |\r|$)@', '<a href="$1" rel="nofollow">$1</a>$3', $bkDescription); // make url clickable
}
echo ' <div class="description">'. nl2br($bkDescription) ."</div>\n";
echo ' <div class="address">' . htmlspecialchars(shortenString($oaddress)) . "</div>\n";
echo ' <div class="meta">'
. $cats . "\n"
. $copy . "\n"
. $edit . "\n"
. $update . "\n"
. $cacheLink ."\n"
. " </div>\n";
echo $privateNoteField != ''
? ' <div class="privateNote" title="'. T_('Private Note on this bookmark') .'">'.$privateNoteField."</div>\n"
: '';
echo ' ';
include 'bookmarks-vote-horizontal.inc.tpl.php';
echo " </div>\n";
echo " </li>\n";
}
?>
</ol>
<?php
if(getPerPageCount($currentUser)>7) {
echo '<p class="backToTop"><a href="#header" title="'.T_('Come back to the top of this page.').'">'.T_('Top of the page').'</a></p>';
}
echo $pagesBanner; // display previous and next links pages + RSS link
} else {
echo '<p class="error">'.T_('No bookmarks available').'</p>';
}
$this->includeTemplate('sidebar.tpl');
$this->includeTemplate($GLOBALS['bottom_include']);
?>
|