From 9aafe7551eb5a73739709e72465031db7a1531b4 Mon Sep 17 00:00:00 2001
From: mensonge
Date: Fri, 21 Nov 2008 18:45:18 +0000
Subject: Minor refactoring: introduce user as an object.
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@172 b3834d28-1941-0410-a4f8-b48e95affb8f
---
templates/bookmarks.tpl.php | 428 ++++++++++++++++++++++----------------------
1 file changed, 210 insertions(+), 218 deletions(-)
(limited to 'templates')
diff --git a/templates/bookmarks.tpl.php b/templates/bookmarks.tpl.php
index e95f787..475436b 100644
--- a/templates/bookmarks.tpl.php
+++ b/templates/bookmarks.tpl.php
@@ -8,9 +8,13 @@ $cdservice =& ServiceFactory::getServiceInstance('CommonDescriptionService');
-$logged_on_userid = $userservice->getCurrentUserId();
-$currentUser = $userservice->getCurrentUser();
-$currentUsername = $currentUser[$userservice->getFieldName('username')];
+//$logged_on_userid = $userservice->getCurrentUserId();
+//$currentUser = $userservice->getCurrentUser();
+//$currentUsername = $currentUser[$userservice->getFieldName('username')];
+
+// Momentary useful to go to object code
+$currentObjectUser = $userservice->getCurrentObjectUser();
+
$pageName = isset($pageName)?$pageName:"";
$this->includeTemplate($GLOBALS['top_include']);
@@ -23,50 +27,45 @@ include('search.inc.php');
-
-
-
+
getLastTagDescription($currenttag)) {
- $description = $cdservice->getLastTagDescription($currenttag);
- echo nl2br(filter($description['cdDescription']));
+ $description = $cdservice->getLastTagDescription($currenttag);
+ echo nl2br(filter($description['cdDescription']));
} elseif(isset($hash) && $cdservice->getLastBookmarkDescription($hash)) {
- $description = $cdservice->getLastBookmarkDescription($hash);
- echo nl2br(filter($description['cdTitle'])). "
";
- echo nl2br(filter($description['cdDescription'])). "
";
+ $description = $cdservice->getLastBookmarkDescription($hash);
+ echo nl2br(filter($description['cdTitle'])). "
";
+ echo nl2br(filter($description['cdDescription'])). "
";
}
-if($logged_on_userid>0) {
- if(isset($currenttag)) {
- echo ' (';
- echo T_('edit common description').')';
- } elseif(isset($hash)) {
- echo ' (';
- echo T_('edit common description').')';
- }
+if($userservice->isLoggedOn()) {
+ if(isset($currenttag)) {
+ echo ' (';
+ echo T_('edit common description').')';
+ } elseif(isset($hash)) {
+ echo ' (';
+ echo T_('edit common description').')';
+ }
}
-?>
-
+?>
getUserByUsername($user);
- if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>
+ $userObject = $userservice->getUserByUsername($user);
+ if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>
-
-getDescription($currenttag, $userObject['uId']);
- echo nl2br(filter($description['tDescription']));
-?>
-
+getDescription($currenttag, $userObject['uId']);
+echo nl2br(filter($description['tDescription']));
+?>
-
@@ -75,202 +74,195 @@ if(isset($currenttag) && isset($user)) {
window.onload = playerLoad;
-
- -
-
-
- /
- /
-
-
-
-
- -
+
+/
+/
+ ';
- echo T_('Bookmarks from other users for this tag').'';
- //echo T_(' for these tags');
- } else if($logged_on_userid>0){
- echo ' - ';
- echo '';
- echo T_('Only your bookmarks for this tag').'';
- //echo T_(' for these tags');
+ echo ' - ';
+ echo '';
+ echo T_('Bookmarks from other users for this tag').'';
+ //echo T_(' for these tags');
+ } else if($userservice->isLoggedOn()){
+ echo ' - ';
+ echo '';
+ echo T_('Only your bookmarks for this tag').'';
+ //echo T_(' for these tags');
+ }
+}
+?>
+
+
+
+ 0 ? ' start="'. ++$start .'"' : ''); ?>
+ id="bookmarks">
+
+ '. filter($tag) .', ';
+ $tagsForCopy.= $tag.',';
+ }
+ $cats = substr($cats, 0, -2);
+ if ($cats != '') {
+ $cats = ' '.T_('in').' '. $cats;
+ }
+
+ // Edit and delete links
+ $edit = '';
+ if ($bookmarkservice->editAllowed($row['bId'])) {
+ $edit = ' - '. T_('Edit') .'';
+ }
+
+ // User attribution
+ $copy = '';
+ if (!isset($user) || isset($watched)) {
+ $copy = ' '. T_('by') .' '. $row['username'] .'';
+ }
+
+ // Udders!
+ if (!isset($hash)) {
+ $others = $bookmarkservice->countOthers($row['bAddress']);
+ $ostart = '';
+ $oend = '';
+ 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()
+ && ($currentObjectUser->getId() != $row['uId'])
+ && !$bookmarkservice->bookmarkExists($row['bAddress'], $currentObjectUser->getId())) {
+ $copy .= ' - '. T_('Copy') .'';
+ }
+
+ // 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 '- '."\n";
+ if ($GLOBALS['enableWebsiteThumbnails']) {
+ $thumbnailHash = md5($address.$GLOBALS['thumbnailsUserId'].$GLOBALS['thumbnailsKey']);
+ echo '
';
+ }
+ echo '';
+
+ echo '
\n";
+ if ($row['bDescription'] == '') {
+ $row['bDescription'] = '-';
+ }
+ echo '
'. filter($row['bDescription']) ."
\n";
+ if(!isset($hash)) {
+ echo '
'.shortenString($address).'
';
+ }
+
+ echo '
'. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . $cats . $copy . $edit ."
\n";
+
+ echo '
';
+
+ echo " \n";
+ }
+ ?>
+
+
+
+
-
-
-
-
- 0 ? ' start="'. ++$start .'"' : ''); ?> id="bookmarks">
-
- '. filter($tag) .', ';
- $tagsForCopy.= $tag.',';
- }
- $cats = substr($cats, 0, -2);
- if ($cats != '') {
- $cats = ' '.T_('in').' '. $cats;
- }
-
- // Edit and delete links
- $edit = '';
- if ($bookmarkservice->editAllowed($row['bId'])) {
- $edit = ' - '. T_('Edit') .'';
- }
-
- // User attribution
- $copy = '';
- if (!isset($user) || isset($watched)) {
- $copy = ' '. T_('by') .' '. $row['username'] .'';
- }
-
- // Udders!
- if (!isset($hash)) {
- $others = $bookmarkservice->countOthers($row['bAddress']);
- $ostart = '';
- $oend = '';
- 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() && ($logged_on_userid != $row['uId']) && !$bookmarkservice->bookmarkExists($row['bAddress'], $logged_on_userid)) {
- // Get the username of the current user
- $currentUser = $userservice->getCurrentUser();
- $currentUsername = $currentUser[$userservice->getFieldName('username')];
- $copy .= ' - '. T_('Copy') .'';
- }
-
- // 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 '- '."\n";
- if ($GLOBALS['enableWebsiteThumbnails']) {
- $thumbnailHash = md5($address.$GLOBALS['thumbnailsUserId'].$GLOBALS['thumbnailsKey']);
- echo '
';
+
+ $sortAmp = (($sortOrder) ? '&'. $sortOrder : '');
+ $sortQue = (($sortOrder) ? '?'. $sortOrder : '');
+
+ // Previous
+ $perpage = getPerPageCount();
+ if (!$page || $page < 2) {
+ $page = 1;
+ $start = 0;
+ $bfirst = ''. T_('First') .'';
+ $bprev = ''. T_('Previous') .'';
+ } else {
+ $prev = $page - 1;
+ $prev = 'page='. $prev;
+ $start = ($page - 1) * $perpage;
+ $bfirst= ''. T_('First') .'';
+ $bprev = ''. T_('Previous') .'';
}
- echo '';
-
- echo '
\n";
- if ($row['bDescription'] == '') {
- $row['bDescription'] = '-';
- }
- echo '
'. filter($row['bDescription']) ."
\n";
- if(!isset($hash)) {
- echo '
'.shortenString($address).'
';
+
+ // Next
+ $next = $page + 1;
+ $totalpages = ceil($total / $perpage);
+ if (count($bookmarks) < $perpage || $perpage * $page == $total) {
+ $bnext = '
'. T_('Next') .'';
+ $blast = '
'. T_('Last') ."\n";
+ } else {
+ $bnext = '
'. T_('Next') .'';
+ $blast = '
'. T_('Last') ."\n";
}
- echo '
'. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . $cats . $copy . $edit ."
\n";
+ // RSS
+ $brss = '';
+ $size = count($rsschannels);
+ for ($i = 0; $i < $size; $i++) {
+ $brss = '
!['. $rsschannels[$i][0] .']('. ROOT .'images/rss.gif)
';
+ }
- echo '
';
+ echo ''. $bfirst .' / '. $bprev .' / '. $bnext .' / '. $blast .' / '. sprintf(T_('Page %d of %d'), $page, $totalpages) ." ". $brss ."
\n";
- echo " \n";
- }
- ?>
-
- '. T_('First') .'';
- $bprev = ''. T_('Previous') .'';
- } else {
- $prev = $page - 1;
- $prev = 'page='. $prev;
- $start = ($page - 1) * $perpage;
- $bfirst= ''. T_('First') .'';
- $bprev = ''. T_('Previous') .'';
- }
-
- // Next
- $next = $page + 1;
- $totalpages = ceil($total / $perpage);
- if (count($bookmarks) < $perpage || $perpage * $page == $total) {
- $bnext = ''. T_('Next') .'';
- $blast = ''. T_('Last') ."\n";
- } else {
- $bnext = ''. T_('Next') .'';
- $blast = ''. T_('Last') ."\n";
- }
-
- // RSS
- $brss = '';
- $size = count($rsschannels);
- for ($i = 0; $i < $size; $i++) {
- $brss = '
';
- }
-
- echo ''. $bfirst .' / '. $bprev .' / '. $bnext .' / '. $blast .' / '. sprintf(T_('Page %d of %d'), $page, $totalpages) ." ". $brss ."
\n";
-
-
-
} else {
- echo ''.T_('No bookmarks available').'
';
+ echo ''.T_('No bookmarks available').'
';
}
$this->includeTemplate('sidebar.tpl');
$this->includeTemplate($GLOBALS['bottom_include']);
--
cgit v1.2.3