From c62205862130103778018c87d6fccee0ab6ae6d2 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 8 Jan 2011 14:37:46 +0000 Subject: cleanup of the groups plugin views git-svn-id: http://code.elgg.org/elgg/trunk@7863 36083f99-b078-4883-b0ff-0f9b5a30f544 --- .../views/default/object/groupforumtopic.php | 120 ++++++++++----------- 1 file changed, 55 insertions(+), 65 deletions(-) (limited to 'mod/groups/views/default/object/groupforumtopic.php') diff --git a/mod/groups/views/default/object/groupforumtopic.php b/mod/groups/views/default/object/groupforumtopic.php index 551e256db..e569bff77 100644 --- a/mod/groups/views/default/object/groupforumtopic.php +++ b/mod/groups/views/default/object/groupforumtopic.php @@ -1,81 +1,71 @@ title, ENT_QUOTES, 'UTF-8'); -//$description = get_entity($vars['entity']->description); -$topic_owner = get_user($vars['entity']->owner_guid); -$group = get_entity($vars['entity']->container_guid); -$forum_created = elgg_view_friendly_time($vars['entity']->time_created); -$counter = $vars['entity']->countAnnotations("generic_comment"); -$last_post = $vars['entity']->getAnnotations("generic_comment", 1, 0, "desc"); -//get the time and user -if ($last_post) { - foreach($last_post as $last) { - $last_time = $last->time_created; - $last_user = $last->owner_guid; - } +//$full = elgg_get_array_value('full', $vars, FALSE); +$topic = elgg_get_array_value('entity', $vars, FALSE); + +if (!$topic) { + return true; } -$u = get_user($last_user); +$poster = $topic->getOwnerEntity(); +$group = $topic->getContainerEntity(); +$excerpt = elgg_get_excerpt($topic->description); -//select the correct output depending on where you are -if (elgg_get_context() == "search") { - var_export($counter); - if($counter == 1){ - $info = "

" . elgg_echo('groups:forum:created:single', array($forum_created, $counter)) . "
"; - }else{ - $info = "

" . elgg_echo('groups:forum:created', array($forum_created, $counter)) . "
"; - } - if (($last_time) && ($u)) $info.= elgg_echo('groups:lastupdated', array(elgg_view_friendly_time($last_time), " getURL() . "\">" . $u->name . "")); - $info .= '

'; - //get the group avatar - $icon = elgg_view("profile/icon",array('entity' => $u, 'size' => 'tiny')); - //get the group and topic title - $info .= "

" . elgg_echo('groups:topic') . ": guid}&group_guid={$group->guid}\">{$title}

"; - if ($group instanceof ElggGroup) { - $info .= "

" . elgg_echo('group') . ": getURL()}\">".htmlentities($group->name, ENT_QUOTES, 'UTF-8') ."

"; - } +$poster_icon = elgg_view('profile/icon', array('entity' => $poster, 'size' => 'tiny')); +$poster_link = elgg_view('output/url', array( + 'href' => $poster->getURL(), + 'text' => $poster->name, +)); +$poster_text = elgg_echo('groups:started', array($poster->name)); -} else { - if($counter == 1){ - $info = "

" . elgg_echo('groups:forum:created:single', array($forum_created, $counter)) . "

"; - }else{ - $info = "

" . elgg_echo('groups:forum:created', array($forum_created, $counter)) . "

"; - } - $info .= "

" . elgg_echo('groups:started') . " " . $topic_owner->name . ": guid}&group_guid={$group->guid}\">{$title}

"; +$tags = elgg_view('output/tags', array('tags' => $topic->tags)); +$date = elgg_view_friendly_time($topic->time_created); - if (groups_can_edit_discussion($vars['entity'], elgg_get_page_owner()->owner_guid)) { - // display the delete link to those allowed to delete - $info .= "
"; - $info .= '' . elgg_view("output/url", array( - 'href' => "mod/groups/edittopic.php?group={$vars['entity']->container_guid}&topic={$vars['entity']->guid}", - 'text' => elgg_echo('edit'), - )); - $info .= ''; +$comments_link = ''; +$comments_text = ''; +$num_comments = elgg_count_comments($topic); +if ($num_comments != 0) { + $last_comment = $topic->getAnnotations("generic_comment", 1, 0, "desc"); + $commenter = $last_comment[0]->getOwnerEntity(); + $comment_time = elgg_view_friendly_time($last_comment[0]->time_created); + $comments_text = elgg_echo('groups:updated', array($commenter->name, $comment_time)); + + $comments_link = elgg_view('output/url', array( + 'href' => $topic->getURL() . '#topic-comments', + 'text' => elgg_echo("comments") . " ($num_comments)", + )); +} - // display the delete link to those allowed to delete - $info .= '' . elgg_view("output/confirmlink", array( - 'href' => "action/groups/deletetopic?topic=" . $vars['entity']->guid . "&group=" . $vars['entity']->container_guid, - 'text' => elgg_echo('delete'), - 'confirm' => elgg_echo('deleteconfirm'), - )); - $info .= "
"; +$metadata = elgg_view('layout/objects/list/metadata', array( + 'entity' => $topic, + 'handler' => 'forum', +)); -} +$subtitle = "$poster_text $date $comments_link $comments_text"; - if (($last_time) && ($u)) { - $commenter_link = "getURL()}\">$u->name"; - $text = elgg_echo('groups:lastcomment', array(elgg_view_friendly_time($last_time), $commenter_link)); - $info .= "

$text

"; - } - //get the user avatar - $icon = elgg_view("profile/icon",array('entity' => $topic_owner, 'size' => 'tiny')); +// do not show the metadata and controls in widget view +if (elgg_in_context('widgets')) { + $metadata = ''; } -//display -echo elgg_view_listing($icon, $info); \ No newline at end of file +if ($full) { + +} else { + // brief view + + $params = array( + 'entity' => $topic, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'tags' => $tags, + 'content' => $excerpt, + ); + $list_body = elgg_view('layout/objects/list/body', $params); + + echo elgg_view_image_block($poster_icon, $list_body); +} -- cgit v1.2.3