From 29422fa55379aa61a61019b832c83dab6d450264 Mon Sep 17 00:00:00 2001 From: cweiske Date: Sat, 3 Oct 2009 14:00:33 +0000 Subject: move files to new locations git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@386 b3834d28-1941-0410-a4f8-b48e95affb8f --- www/bookmarks.php | 292 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 www/bookmarks.php (limited to 'www/bookmarks.php') diff --git a/www/bookmarks.php b/www/bookmarks.php new file mode 100644 index 0000000..91d0999 --- /dev/null +++ b/www/bookmarks.php @@ -0,0 +1,292 @@ +isLoggedOn()) { + $loginqry = str_replace("'", '%27', stripslashes($_SERVER['QUERY_STRING'])); + header('Location: '. createURL('login', '?'. $loginqry)); + exit(); +} + +if ($userservice->isLoggedOn()) { + $currentUser = $userservice->getCurrentObjectUser(); + $currentUserID = $currentUser->getId(); + $currentUsername = $currentUser->getUsername(); +} + + +@list($url, $user, $cat) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL; + + +$endcache = false; +if ($usecache) { + // Generate hash for caching on + $hash = md5($_SERVER['REQUEST_URI'] . $user); + + // Don't cache if its users' own bookmarks + if ($userservice->isLoggedOn()) { + if ($currentUsername != $user) { + // Cache for 5 minutes + $cacheservice->Start($hash); + $endcache = true; + } + } else { + // Cache for 30 minutes + $cacheservice->Start($hash, 1800); + $endcache = true; + } +} + +$pagetitle = $rssCat = $catTitle = ''; +if ($user) { + if (is_int($user)) { + $userid = intval($user); + } else { + if (!($userinfo = $userservice->getUserByUsername($user))) { + $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user); + $templateservice->loadTemplate('error.404.tpl', $tplVars); + exit(); + } else { + $userid =& $userinfo['uId']; + } + } + $pagetitle .= ': '. $user; +} +if ($cat) { + $catTitle = ': '. str_replace('+', ' + ', $cat); + + $catTitleWithUrls = ': '; + $titleTags = explode('+', filter($cat)); + for($i = 0; $i* + '; + } + $catTitleWithUrls = substr($catTitleWithUrls, 0, strlen($catTitleWithUrls) - strlen(' + ')); + + $pagetitle .= $catTitleWithUrls; +} +else +{ + $catTitleWithUrls = ''; +} +$pagetitle = substr($pagetitle, 2); + +// Header variables +$tplVars['loadjs'] = true; + +// ADD A BOOKMARK +$saved = false; +$templatename = 'bookmarks.tpl'; +if ($userservice->isLoggedOn() && POST_SUBMITTED != '') { + if (!POST_TITLE || !POST_ADDRESS) { + $tplVars['error'] = T_('Your bookmark must have a title and an address'); + $templatename = 'editbookmark.tpl'; + } else { + $address = trim(POST_ADDRESS); + // If the bookmark exists already, edit the original + if ($bookmarkservice->bookmarkExists($address, $currentUserID)) { + $bookmark =& $bookmarkservice->getBookmarkByAddress($address); + header('Location: '. createURL('edit', $bookmark['bId'])); + exit(); + // If it's new, save it + } else { + $title = trim(POST_TITLE); + $description = trim(POST_DESCRIPTION); + $privateNote = trim(POST_PRIVATENOTE); + $status = intval(POST_STATUS); + $categories = trim(POST_TAGS); + $saved = true; + if ($bookmarkservice->addBookmark($address, $title, $description, $privateNote, $status, $categories)) { + if (POST_POPUP != '') { + $tplVars['msg'] = ''; + } else { + $tplVars['msg'] = T_('Bookmark saved') . ' '.T_('(Come back to previous page.)').''; + // Redirection option + if ($GLOBALS['useredir']) { + $address = $GLOBALS['url_redir'] . $address; + } + } + } else { + $tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.'); + $templatename = 'editbookmark.tpl'; + $saved = false; + } + } + } +} + +if (GET_ACTION == "add") { + // If the bookmark exists already, edit the original + if ($bookmarkservice->bookmarkExists(stripslashes(GET_ADDRESS), $currentUserID)) { + $bookmark =& $bookmarkservice->getBookmarks(0, NULL, $currentUserID, NULL, NULL, NULL, NULL, NULL, NULL, md5($bookmarkservice->normalize(stripslashes(GET_ADDRESS)))); + $popup = (GET_POPUP!='') ? '?popup=1' : ''; + header('Location: '. createURL('edit', $bookmark['bookmarks'][0]['bId'] . $popup)); + exit(); + } + $templatename = 'editbookmark.tpl'; +} + +if ($templatename == 'editbookmark.tpl') { + if ($userservice->isLoggedOn()) { + $tplVars['formaction'] = createURL('bookmarks', $currentUsername); + if (POST_SUBMITTED != '') { + $tplVars['row'] = array( + 'bTitle' => stripslashes(POST_TITLE), + 'bAddress' => stripslashes(POST_ADDRESS), + 'bDescription' => stripslashes(POST_DESCRIPTION), + 'bPrivateNote' => stripslashes(POST_PRIVATENOTE), + 'tags' => (POST_TAGS ? explode(',', stripslashes(POST_TAGS)) : array()), + 'bStatus' => 0, + ); + $tplVars['tags'] = POST_TAGS; + } else { + if(GET_COPYOF != '') { //copy from bookmarks page + $tplVars['row'] = $bookmarkservice->getBookmark(GET_COPYOF, true); + if(!$currentUser->isAdmin()) { + $tplVars['row']['bPrivateNote'] = ''; //only admin can copy private note + } + }else { //copy from pop-up bookmarklet + $tplVars['row'] = array( + 'bTitle' => stripslashes(GET_TITLE), + 'bAddress' => stripslashes(GET_ADDRESS), + 'bDescription' => stripslashes(GET_DESCRIPTION), + 'bPrivateNote' => stripslashes(GET_PRIVATENOTE), + 'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()), + 'bStatus' => 0 + ); + } + + } + $title = T_('Add a Bookmark'); + $tplVars['referrer'] = '';; + if (isset($_SERVER['HTTP_REFERER'])) { + $tplVars['referrer'] = $_SERVER['HTTP_REFERER']; + } + $tplVars['pagetitle'] = $title; + $tplVars['subtitle'] = $title; + $tplVars['btnsubmit'] = T_('Add Bookmark'); + $tplVars['popup'] = (GET_POPUP!='') ? GET_POPUP : null; + } else { + $tplVars['error'] = T_('You must be logged in before you can add bookmarks.'); + } +} else if ($user && GET_POPUP == '') { + + $tplVars['sidebar_blocks'] = array('watchstatus'); + + if (!$cat) { //user page without tags + $cat = NULL; + $tplVars['currenttag'] = NULL; + //$tplVars['sidebar_blocks'][] = 'menu2'; + $tplVars['sidebar_blocks'][] = 'linked'; + $tplVars['sidebar_blocks'][] = 'popular'; + } else { //pages with tags + $rssCat = '/'. filter($cat, 'url'); + $tplVars['currenttag'] = $cat; + $tplVars['sidebar_blocks'][] = 'tagactions'; + //$tplVars['sidebar_blocks'][] = 'menu2'; + $tplVars['sidebar_blocks'][] = 'linked'; + $tplVars['sidebar_blocks'][] = 'related'; + /*$tplVars['sidebar_blocks'][] = 'menu';*/ + } + $tplVars['sidebar_blocks'][] = 'menu2'; + $tplVars['popCount'] = 30; + //$tplVars['sidebar_blocks'][] = 'popular'; + + $tplVars['userid'] = $userid; + $tplVars['userinfo'] =& $userinfo; + $tplVars['user'] = $user; + $tplVars['range'] = 'user'; + + // Pagination + $perpage = getPerPageCount($currentUser); + if (intval(GET_PAGE) > 1) { + $page = GET_PAGE; + $start = ($page - 1) * $perpage; + } else { + $page = 0; + $start = 0; + } + + // Set template vars + $tplVars['rsschannels'] = array( + array(filter($sitename .': '. $pagetitle), createURL('rss', filter($user, 'url') . $rssCat.'?sort='.getSortOrder())) + ); + + $tplVars['page'] = $page; + $tplVars['start'] = $start; + $tplVars['bookmarkCount'] = $start + 1; + + $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, null, getSortOrder()); + $tplVars['total'] = $bookmarks['total']; + $tplVars['bookmarks'] =& $bookmarks['bookmarks']; + $tplVars['cat_url'] = createURL('bookmarks', '%s/%s'); + $tplVars['nav_url'] = createURL('bookmarks', '%s/%s%s'); + if ($userservice->isLoggedOn() && $user == $currentUsername) { + $tplVars['pagetitle'] = T_('My Bookmarks') . $catTitle; + $tplVars['subtitle'] = T_('My Bookmarks') . $catTitleWithUrls; + } else { + $tplVars['pagetitle'] = $user.': '.$cat; + $tplVars['subtitle'] = $pagetitle; + } +} + +$tplVars['summarizeLinkedTags'] = true; +$tplVars['pageName'] = PAGE_BOOKMARKS; + + +$templateservice->loadTemplate($templatename, $tplVars); + +if ($usecache && $endcache) { + // Cache output if existing copy has expired + $cacheservice->End($hash); +} +?> -- cgit v1.2.3