aboutsummaryrefslogtreecommitdiff
path: root/templates/bookmarks.tpl.php
blob: 4a9c1b261d5f34fecf31d6517a7f380af6ecd0bd (plain)
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
<?php

/* Service creation: only useful services are created */
$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
$tagservice =& ServiceFactory::getServiceInstance('TagService');
$cdservice =& ServiceFactory::getServiceInstance('CommonDescriptionService');


$pageName = isset($pageName)?$pageName:"";
$user = isset($user)?$user:"";

$this->includeTemplate($GLOBALS['top_include']);

include('search.inc.php');
?>

<?php if($pageName == PAGE_INDEX):?>
<p id="welcome"><?php echo $GLOBALS['welcomeMessage'];?></p>
<?php endif?>


<?php
// common tag description
if((isset($currenttag) && $currenttag!= '' && $GLOBALS['enableCommonTagDescription'])
|| (isset($hash) && $GLOBALS['enableCommonBookmarkDescription'])):?>


<p class="commondescription"><?php
if(isset($currenttag) && $currenttag!= '' && $cdservice->getLastTagDescription($currenttag)) {
	$description = $cdservice->getLastTagDescription($currenttag);
	echo nl2br(filter($description['cdDescription']));
} elseif(isset($hash) && $cdservice->getLastBookmarkDescription($hash)) {
	$description = $cdservice->getLastBookmarkDescription($hash);
	echo nl2br(filter($description['cdTitle'])). "<br/>";
	echo nl2br(filter($description['cdDescription'])). "<br/>";
}

//common tag description edit
if($userservice->isLoggedOn()) {
	if(isset($currenttag) && $currenttag!= '') {
		echo ' (<a href="'. createURL('tagcommondescriptionedit', $currenttag).'">';
		echo T_('edit common description').'</a>)';
	} elseif(isset($hash)) {
		echo ' (<a href="'.createURL('bookmarkcommondescriptionedit', $hash).'">';
		echo T_('edit common description').'</a>)';
	}
}
?></p>
<?php endif ?>


<?php
/* Private tag description */
if(isset($currenttag) && $currenttag!= '' && isset($user)) {
	$userObject = $userservice->getUserByUsername($user);
	if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>

<p class="commondescription"><?php
$description = $tagservice->getDescription($currenttag, $userObject['uId']);
echo nl2br(filter($description['tDescription']));
?></p>

<?php
	}
}
?>

<?php if (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
$dateSort = (getSortOrder()=='date_desc')? 'date_asc':'date_desc';
$titleSort = (getSortOrder()=='title_asc')? 'title_desc':'title_asc';
$urlSort = (getSortOrder()=='url_asc')? 'url_desc':'url_asc';
?> <a href="?sort=<?php echo $dateSort ?>"><?php echo T_("Date"); ?></a><span>
/ </span> <a href="?sort=<?php echo $titleSort ?>"><?php echo T_("Title"); ?></a><span>
/ </span> <?php
if (!isset($hash)) {
	?> <a href="?sort=<?php echo $urlSort ?>"><?php echo T_("URL"); ?></a>
	<?php
}
?> <?php
if(isset($currenttag) && $currenttag!= '') {
	if(isset($user) && $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>



<ol <?php echo ($start > 0 ? ' start="'. ++$start .'"' : ''); ?>
	id="bookmarks">

	<?php
	foreach(array_keys($bookmarks) as $key) {
		$row =& $bookmarks[$key];
		switch ($row['bStatus']) {
			case 0:
				$access = '';
				break;
			case 1:
				$access = ' shared';
				break;
			case 2:
				$access = ' private';
				break;
		}

		$cats = '';
		$tagsForCopy = '';
		$tags = $row['tags'];
		foreach(array_keys($tags) as $key) {

			$tag =& $tags[$key];
			$cats .= '<a href="'. sprintf($cat_url, filter($row['username'], 'url'), filter($tag, 'url')) .'" rel="tag">'. filter($tag) .'</a>, ';
			$tagsForCopy.= $tag.',';
		}
		$cats = substr($cats, 0, -2);
		if ($cats != '') {
			$cats = ' '.T_('in').' '. $cats;
		}

		// Edit and delete links
		$edit = '';
		if ($bookmarkservice->editAllowed($row['bId'])) {
			$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>';
		}

		// User attribution
		$copy = '';
		if ($user == '' || isset($watched)) {
			$copy = ' '. T_('by') .' <a href="'. createURL('bookmarks', $row['username']) .'">'. $row['username'] .'</a>';
		}

		// Udders!
		if (!isset($hash)) {
			$others = $bookmarkservice->countOthers($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);
			}
		}

		// Copy link
		if ($userservice->isLoggedOn()
		&& ($currentUser->getId() != $row['uId'])
		&& !$bookmarkservice->bookmarkExists($row['bAddress'], $currentUser->getId())) {
			$copy .= ' - <a href="'. createURL('bookmarks', $currentUser->getUsername() .'?action=add&amp;address='. urlencode($row['bAddress']) .'&amp;title='. urlencode($row['bTitle'])). '&amp;description='.urlencode($row['bDescription']). '&amp;tags='.$tagsForCopy  .'">'. T_('Copy') .'</a>';
		}

		// Nofollow option
		$rel = '';
		if ($GLOBALS['nofollow']) {
			$rel = ' rel="nofollow"';
		}

		$address = filter($row['bAddress']);

		// Redirection option
		if ($GLOBALS['useredir']) {
			$address = $GLOBALS['url_redir'] . $address;
		}

		// Output
		echo '<li class="xfolkentry'. $access .'">'."\n";
		if ($GLOBALS['enableWebsiteThumbnails']) {
			$thumbnailHash = md5($address.$GLOBALS['thumbnailsUserId'].$GLOBALS['thumbnailsKey']);
			echo '<a href="'. $address .'"'. $rel .' ><img class="thumbnail" src="http://www.artviper.net/screenshots/screener.php?url='.$address.'&w=120&sdx=1280&userID='.$GLOBALS['thumbnailsUserId'].'&hash='.$thumbnailHash.'" />  ';
		}
		echo '<div>';

		echo '<div class="link"><a href="'. $address .'"'. $rel .' class="taggedlink">'. filter($row['bTitle']) ."</a></div>\n";
		if ($row['bDescription'] == '') {
			$bkDescription = '-';
		} else {
			$bkDescription = preg_replace('|\[\/.*?\]|', '', filter($row['bDescription'])); // remove final anchor
			$bkDescription = preg_replace('|\[(.*?)\]|', ' <br/><b>$1 : </b>', $bkDescription); // remove final anchor
		}
		echo '<div class="description">'. $bkDescription ."</div>\n";
		//if(!isset($hash)) {
			echo '<div class="address">'.shortenString($address).'</div>';
		//}

		echo '<div class="meta">'. date($GLOBALS['shortdate'], strtotime($row['bModified'])) . $cats . $copy . $edit ."</div>\n";

		echo '</div>';

		echo "</li>\n";
	}
	?>

</ol>

	<?php
	// PAGINATION

	// Ordering
	$sortOrder = '';
	if (GET_SORT != '') {
		$sortOrder = 'sort='. GET_SORT;
	}

	$sortAmp = (($sortOrder) ? '&amp;'. $sortOrder : '');
	$sortQue = (($sortOrder) ? '?'. $sortOrder : '');

	// Previous
	$perpage = getPerPageCount();
	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="'. $rsschannels[$i][1] .'" title="'. $rsschannels[$i][0] .'"><img src="'. ROOT .'images/rss.gif" width="16" height="16" alt="'. $rsschannels[$i][0] .'" /></a>';
	}

	echo '<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";




} else {
	echo '<p class="error">'.T_('No bookmarks available').'</p>';
}
$this->includeTemplate('sidebar.tpl');
$this->includeTemplate($GLOBALS['bottom_include']);
?>