From d4e4268d11612408e4989a5c57f69fcb2febe8aa Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 3 Feb 2011 03:25:25 +0000 Subject: Refs #2680: First pass at porting the 1.7 bookmarks to 1.8. Functional, but code is still messy. git-svn-id: http://code.elgg.org/elgg/trunk@7998 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/bookmarks/views/default/object/bookmarks.php | 173 +++++++++++++---------- 1 file changed, 95 insertions(+), 78 deletions(-) (limited to 'mod/bookmarks/views/default/object/bookmarks.php') diff --git a/mod/bookmarks/views/default/object/bookmarks.php b/mod/bookmarks/views/default/object/bookmarks.php index f90a2f355..ccb02457c 100644 --- a/mod/bookmarks/views/default/object/bookmarks.php +++ b/mod/bookmarks/views/default/object/bookmarks.php @@ -5,91 +5,108 @@ * @package ElggBookmarks */ -$owner = $vars['entity']->getOwnerEntity(); -$friendlytime = elgg_view_friendly_time($vars['entity']->time_created); -$address = $vars['entity']->address; - -// you used to be able to add without titles, which created unclickable bookmarks -// putting a fake title in so you can click on it. -if (!$title = $vars['entity']->title) { - $title = elgg_echo('bookmarks:no_title'); -} +$full = elgg_get_array_value('full', $vars, FALSE); +$bookmark = elgg_get_array_value('entity', $vars, FALSE); -$a_tag_visit = filter_tags("" . elgg_echo('bookmarks:visit') . ""); -$a_tag_title = filter_tags("$title"); - - -$parsed_url = parse_url($address); -$faviconurl = $parsed_url['scheme'] . "://" . $parsed_url['host'] . "/favicon.ico"; - -//sort out the access level for display -$object_acl = get_readable_access_level($vars['entity']->access_id); -//files with these access level don't need an icon -$general_access = array('Public', 'Logged in users', 'Friends'); -//set the right class for access level display - need it to set on groups and shared access only -$is_group = get_entity($vars['entity']->container_guid); -if($is_group instanceof ElggGroup){ - //get the membership type open/closed - $membership = $is_group->membership; - //we decided to show that the item is in a group, rather than its actual access level - $object_acl = "Group: " . $is_group->name; - if($membership == 2) - $access_level = "class='access_level group_open'"; - else - $access_level = "class='access_level group_closed'"; -}elseif($object_acl == 'Private'){ - $access_level = "class='access_level private'"; -}else{ - if(!in_array($object_acl, $general_access)) - $access_level = "class='access_level shared_collection'"; - else - $access_level = "class='access_level entity_access'"; +if (!$bookmark) { + return; } -if($vars['entity']->description != '') - $view_notes = "note"; -else - $view_notes = ''; -if (@file_exists($faviconurl)) { - $icon = ""; +$owner = $bookmark->getOwnerEntity(); +$container = $bookmark->getContainerEntity(); +$categories = elgg_view('categories/view', $vars); + +$link = filter_tags(elgg_view('output/url', array('href' => $bookmark->address))); +$description = elgg_view('output/longtext', array('value' => $bookmark->description, 'class' => 'pbl')); + +$owner_link = elgg_view('output/url', array( + 'href' => "pg/file/owner/$owner->username", + 'text' => $owner->name, +)); +$author_text = elgg_echo('blog:author_by_line', array($owner_link)); + +$tags = elgg_view('output/tags', array('tags' => $bookmark->tags)); +$date = elgg_view_friendly_time($bookmark->time_created); + +$comments_count = elgg_count_comments($bookmark); +//only display if there are commments +if ($comments_count != 0) { + $text = elgg_echo("comments") . " ($comments_count)"; + $comments_link = elgg_view('output/url', array( + 'href' => $bookmark->getURL() . '#comments', + 'text' => $text, + )); } else { - $icon = elgg_view("profile/icon", array('entity' => $owner,'size' => 'tiny',)); -} - - -//delete -if($vars['entity']->canEdit()){ - $delete .= "" . elgg_view('output/confirmlink',array( - 'href' => "action/bookmarks/delete?bookmark_guid=" . $vars['entity']->guid, - 'text' => elgg_echo("delete"), - 'confirm' => elgg_echo("bookmarks:delete:confirm"), - )) . ""; -} - -$info = "
{$object_acl}"; - -// include a view for plugins to extend -$info .= elgg_view("bookmarks/options",array('entity' => $vars['entity'])); -$info .= elgg_view_likes($vars['entity']); // include likes - -//include edit and delete options -if($vars['entity']->canEdit()){ - $info .= "username}/edit/{$vars['entity']->getGUID()}\">" . elgg_echo('edit') . ""; - $info .= $delete; + $comments_link = ''; } - $info .= "
"; +$metadata = elgg_view('layout/objects/list/metadata', array( + 'entity' => $bookmark, + 'handler' => 'bookmarks', +)); -$info .= "

$a_tag_title

"; -$info .= "

Bookmarked by username}\">{$owner->name} {$friendlytime} {$view_notes}

"; +$subtitle = "$author_text $date $categories $comments_link"; -$tags = elgg_view('output/tags', array('tags' => $vars['entity']->tags)); -if (!empty($tags)) { - $info .= '

' . $tags . '

'; -} -if($view_notes != ''){ - $info .= ""; +// do not show the metadata and controls in widget view +if (elgg_in_context('widgets')) { + $metadata = ''; } -//display -echo elgg_view_listing($icon, $info); +if ($full && !elgg_in_context('gallery')) { + $header = elgg_view_title($bookmark->title); + + $params = array( + 'entity' => $bookmark, + 'title' => false, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + ); + $bookmark_info = elgg_view('layout/objects/list/body', $params); + + echo << +

$link

+ $description + +HTML; + +} elseif (elgg_in_context('gallery')) { + echo ''; +} else { + // brief view + $url = $bookmark->address; + $display_text = $url; + $excerpt = elgg_get_excerpt($bookmark->description); + + if (strlen($url) > 25) { + $bits = parse_url($url); + if (isset($bits['host'])) { + $display_text = $bits['host']; + } else { + $display_text = elgg_get_excerpt($url, 100); + } + } + + $link = filter_tags(elgg_view('output/url', array( + 'href' => $bookmark->address, + 'text' => $display_text + ))); + + $content = "$link - $excerpt"; + + $params = array( + 'entity' => $bookmark, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + 'content' => $content, + ); + + echo elgg_view('layout/objects/list/body', $params); +} \ No newline at end of file -- cgit v1.2.3