From 7433b07dac28a87a8d22bd0dd5fa78effe333255 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 4 Dec 2010 21:05:54 +0000 Subject: welcome to the new media view - it is being used in the new latest comments module git-svn-id: http://code.elgg.org/elgg/trunk@7530 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/views.php | 18 ++++++---- mod/blog/views/default/blog/sidebar_menu.php | 2 +- mod/file/friends.php | 2 +- mod/file/index.php | 2 +- mod/file/world.php | 2 +- views/default/annotation/generic_comment.php | 54 +++++++++++++++++++++++++++- views/default/annotation/latest_comments.php | 36 ------------------- views/default/comments/latest.php | 17 +++++++++ views/default/css/screen.php | 17 +++++++++ views/default/layout_elements/media.php | 48 +++++++++++++++++++++++++ views/default/layout_elements/module.php | 2 +- 11 files changed, 152 insertions(+), 48 deletions(-) delete mode 100644 views/default/annotation/latest_comments.php create mode 100644 views/default/comments/latest.php create mode 100644 views/default/layout_elements/media.php diff --git a/engine/lib/views.php b/engine/lib/views.php index 09653e11d..789348567 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -787,19 +787,25 @@ function elgg_view_entity(ElggEntity $entity, $full = false, $bypass = true, $de * - ElggEntity 'annotation' The annotation being viewed. * * @param ElggAnnotation $annotation The annotation to display - * @param boolean $bypass If false, will not pass to a custom + * @param bool $full Display the full view + * @param bool $bypass If false, will not pass to a custom * template handler. {@see set_template_handler()} - * @param boolean $debug Complain if views are missing + * @param bool $debug Complain if views are missing * * @return string HTML (etc) to display */ -function elgg_view_annotation(ElggAnnotation $annotation, $bypass = true, $debug = false) { +function elgg_view_annotation(ElggAnnotation $annotation, $full = true, $bypass = true, $debug = false) { global $autofeed; $autofeed = true; + $params = array( + 'annotation' => $annotation, + 'full_view' => $full, + ); + $view = $annotation->view; if (is_string($view)) { - return elgg_view($view, array('annotation' => $annotation), $bypass, $debug); + return elgg_view($view, $params, $bypass, $debug); } $name = $annotation->name; @@ -812,9 +818,9 @@ function elgg_view_annotation(ElggAnnotation $annotation, $bypass = true, $debug } if (elgg_view_exists("annotation/{$name}")) { - return elgg_view("annotation/{$name}", array('annotation' => $annotation), $bypass, $debug); + return elgg_view("annotation/{$name}", $params, $bypass, $debug); } else { - return elgg_view("annotation/default", array('annotation' => $annotation), $bypass, $debug); + return elgg_view("annotation/default", $params, $bypass, $debug); } } diff --git a/mod/blog/views/default/blog/sidebar_menu.php b/mod/blog/views/default/blog/sidebar_menu.php index d6bd3e086..10798d7a4 100644 --- a/mod/blog/views/default/blog/sidebar_menu.php +++ b/mod/blog/views/default/blog/sidebar_menu.php @@ -30,7 +30,7 @@ echo elgg_view("blogs/sidebar", array("object_type" => 'blog')); // fetch & display latest comments on all blog posts $comments = get_annotations(0, "object", "blog", "generic_comment", "", 0, 4, 0, "desc"); $title = elgg_echo('generic_comments:latest'); -$body = elgg_view('annotation/latest_comments', array('comments' => $comments)); +$body = elgg_view('comments/latest', array('comments' => $comments)); echo elgg_view('layout_elements/module', array('title' => $title, 'body' => $body)); // only show archives for users or groups. diff --git a/mod/file/friends.php b/mod/file/friends.php index e7a17adab..44532dfba 100644 --- a/mod/file/friends.php +++ b/mod/file/friends.php @@ -31,7 +31,7 @@ //get the latest comments on all files $comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc"); - $area3 = elgg_view('annotation/latest_comments', array('comments' => $comments)); + $area3 = elgg_view('comments/latest', array('comments' => $comments)); $content = "
".$area1.$area2."
"; $params = array( diff --git a/mod/file/index.php b/mod/file/index.php index 06a5979d1..ae2353724 100644 --- a/mod/file/index.php +++ b/mod/file/index.php @@ -37,7 +37,7 @@ //get the latest comments on the current users files $comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc",0,0,elgg_get_page_owner_guid()); - $area3 = elgg_view('annotation/latest_comments', array('comments' => $comments)); + $area3 = elgg_view('comments/latest', array('comments' => $comments)); $content = "
".$area1.$area2."
"; diff --git a/mod/file/world.php b/mod/file/world.php index bd6c2b859..6ac4ba38a 100644 --- a/mod/file/world.php +++ b/mod/file/world.php @@ -28,7 +28,7 @@ //get the latest comments on all files $comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc"); - $area3 = elgg_view('annotation/latest_comments', array('comments' => $comments)); + $area3 = elgg_view('comments/latest', array('comments' => $comments)); $content = "
".$area1.$area2."
"; $params = array( diff --git a/views/default/annotation/generic_comment.php b/views/default/annotation/generic_comment.php index 26fd468b7..ac603e978 100644 --- a/views/default/annotation/generic_comment.php +++ b/views/default/annotation/generic_comment.php @@ -1,8 +1,60 @@ entity_guid); +$commenter = get_user($comment->owner_guid); +if (!$entity || !$commenter) { + return true; +} + + +$friendlytime = elgg_view_friendly_time($comment->time_created); + +$commenter_icon = elgg_view("profile/icon", array('entity' => $commenter, 'size' => 'tiny')); +$commenter_link = "getURL()}\">$commenter->name"; + +$entity_title = $entity->title ? $entity->title : elgg_echo('untitled'); +$entity_link = "getURL()}\">$entity_title"; + +if ($full_view) { + +} else { + // brief view + + //@todo need link to actual comment! + + $on = elgg_echo('on'); + + $body = <<$commenter_link $on $entity_link ($friendlytime) +HTML; + + $params = array( + 'img' => $commenter_icon, + 'body' => $body, + ); + echo elgg_view('layout_elements/media', $params); + + // @todo remove this once the full view has been rewritten + return true; +} + + +// @todo - below needs to be rewritten like the brief view + $owner = get_user($vars['annotation']->owner_guid); ?> diff --git a/views/default/annotation/latest_comments.php b/views/default/annotation/latest_comments.php deleted file mode 100644 index d603a3830..000000000 --- a/views/default/annotation/latest_comments.php +++ /dev/null @@ -1,36 +0,0 @@ -" . elgg_echo('generic_comments:latest') . ""; - foreach ($vars['comments'] as $comment) { - //grab the entity the comment is on - $entity = get_entity($comment->entity_guid); - //comment owner - $comment_owner = get_user($comment->owner_guid); - $friendlytime = elgg_view_friendly_time($comment->time_created); // get timestamp for comment - - //set the title - if($entity->title){ - $objecttitle = $entity->title; - }else{ - $objecttitle = elgg_echo('untitled'); - } - - //if the entity has been deleted, don't link to it - if($entity){ - $url = $entity->getURL(); // get url to file for comment link - $url_display = "{$objecttitle}"; - }else{ - $url_display = $objecttitle; - } - - echo "
" . elgg_view("profile/icon",array('entity' => $comment_owner, 'size' => 'tiny')) . ""; - echo "
username}\">{$comment_owner->name} " . elgg_echo('on') . " {$url_display} ({$friendlytime})
"; - echo "
"; - - } -} \ No newline at end of file diff --git a/views/default/comments/latest.php b/views/default/comments/latest.php new file mode 100644 index 000000000..f8e1af10f --- /dev/null +++ b/views/default/comments/latest.php @@ -0,0 +1,17 @@ +'; + foreach ($vars['comments'] as $comment) { + $html = elgg_view_annotation($comment, false); + if ($html) { + echo "
  • $html
  • "; + } + } + echo ''; +} \ No newline at end of file diff --git a/views/default/css/screen.php b/views/default/css/screen.php index 61d7fe2de..6450f541c 100644 --- a/views/default/css/screen.php +++ b/views/default/css/screen.php @@ -339,6 +339,16 @@ h2 { .elgg-footer { } +.elgg-media { + padding: 3px 0; +} + +.elgg-media .elgg-img { + float: left; + margin-right: 5px; +} + + .elgg-main-header { border-bottom: 1px solid #CCCCCC; padding-bottom: 3px; @@ -350,6 +360,13 @@ h2 { margin-right: 10px; } +.elgg-latest-comments li { + border-bottom: 1px dotted #CCCCCC; +} + +.elgg-latest-comments:first-child { + border-top: 1px dotted #CCCCCC; +} .elgg-center { margin: 0 auto; diff --git a/views/default/layout_elements/media.php b/views/default/layout_elements/media.php new file mode 100644 index 000000000..8599d6c8a --- /dev/null +++ b/views/default/layout_elements/media.php @@ -0,0 +1,48 @@ +$body"; + +$img_class = 'elgg-img'; +$additional_class = elgg_get_array_value('img_class', $vars, ''); +if ($additional_class) { + $img_class = "$img_class $additional_class"; +} +if ($image_block) { + $image_block = "
    $image_block
    "; +} + +echo << + $image_block$body + +HTML; diff --git a/views/default/layout_elements/module.php b/views/default/layout_elements/module.php index 46ddcfbfd..b0ac82f8e 100644 --- a/views/default/layout_elements/module.php +++ b/views/default/layout_elements/module.php @@ -1,6 +1,6 @@