]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
welcome to the new media view - it is being used in the new latest comments module
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 4 Dec 2010 21:05:54 +0000 (21:05 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 4 Dec 2010 21:05:54 +0000 (21:05 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7530 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/views.php
mod/blog/views/default/blog/sidebar_menu.php
mod/file/friends.php
mod/file/index.php
mod/file/world.php
views/default/annotation/generic_comment.php
views/default/annotation/latest_comments.php [deleted file]
views/default/comments/latest.php [new file with mode: 0644]
views/default/css/screen.php
views/default/layout_elements/media.php [new file with mode: 0644]
views/default/layout_elements/module.php

index 09653e11db2599e7c398c701db8fbdddf0563c44..789348567f5e0b588fcfde6c557cc19637f80a5e 100644 (file)
@@ -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);
        }
 }
 
index d6bd3e08676496896a71eb24451c9bfab3c5f0dc..10798d7a488a0719069bf5a7f2b28c1cd2a6b03a 100644 (file)
@@ -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.
index e7a17adab18137a85d71510a20ad8773d2d22185..44532dfba75de05fe5eeadcfd79b81ada9f4a512 100644 (file)
@@ -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 = "<div class='files'>".$area1.$area2."</div>";
        $params = array(
index 06a5979d1e12fb658fdf562ad29f30802e58f37e..ae2353724f4cfe5b57839c4d7ccdef224ddf56d1 100644 (file)
@@ -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 = "<div class='files'>".$area1.$area2."</div>";
 
index bd6c2b859e0ee21b0c73f479eac2d519bae0b4e5..6ac4ba38a1d2a50ce78dbc49bcecf569f3db76ee 100644 (file)
@@ -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 = "<div class='files'>".$area1.$area2."</div>";
        $params = array(
index 26fd468b755c1b51f0d595b9de009c498c4b3022..ac603e9785d96b85b731e933feffdf2724c5e7cd 100644 (file)
@@ -1,8 +1,60 @@
 <?php
 /**
- * Elgg generic comment
+ * Elgg generic comment view
+ *
+ * @uses $vars['annotation']  ElggAnnotation object
+ * @uses $vars['full_view']   Display fill view or brief view
  */
 
+if (!isset($vars['annotation'])) {
+       return true;
+}
+
+$full_view = elgg_get_array_value('full_view', $vars, true);
+
+$comment = $vars['annotation'];
+
+$entity = get_entity($comment->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 = "<a href=\"{$commenter->getURL()}\">$commenter->name</a>";
+
+$entity_title = $entity->title ? $entity->title : elgg_echo('untitled');
+$entity_link = "<a href=\"{$entity->getURL()}\">$entity_title</a>";
+
+if ($full_view) {
+
+} else {
+       // brief view
+
+       //@todo need link to actual comment!
+       
+       $on = elgg_echo('on');
+
+       $body = <<<HTML
+<span class="entity-subtext">$commenter_link $on <span class='entity-title'>$entity_link</span> ($friendlytime)</span>
+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 (file)
index d603a38..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Display latest comments on objects
- */
-        
-if ($vars['comments']){
-       global $CONFIG;
-       //echo "<h3>" . elgg_echo('generic_comments:latest') . "</h3>";
-       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 = "<a href=\"{$url}\">{$objecttitle}</a>";
-               }else{
-                       $url_display = $objecttitle;
-               }
-       
-               echo "<div class='generic-comment latest clearfix'><span class='generic-comment-icon'>" . elgg_view("profile/icon",array('entity' => $comment_owner, 'size' => 'tiny')) . "</span>";
-               echo "<div class='generic-comment-details'><span class='entity-subtext'><a href=\"".elgg_get_site_url()."pg/profile/{$comment_owner->username}\">{$comment_owner->name}</a> " . elgg_echo('on') . " <span class='entity-title'>{$url_display}</span> ({$friendlytime})</span></div>";
-               echo "</div>";
-       
-       }
-}
\ No newline at end of file
diff --git a/views/default/comments/latest.php b/views/default/comments/latest.php
new file mode 100644 (file)
index 0000000..f8e1af1
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Latest comments on an entity
+ *
+ * @uses $vars['comments']  Array of comment objects
+ */
+
+if (isset($vars['comments'])) {
+       echo '<ul class="elgg-latest-comments">';
+       foreach ($vars['comments'] as $comment) {
+               $html = elgg_view_annotation($comment, false);
+               if ($html) {
+                       echo "<li>$html</li>";
+               }
+       }
+       echo '</ul>';
+}
\ No newline at end of file
index 61d7fe2de0485abc75b48cdeef587426dd9f3881..6450f541ce4fe929a97f7e5f4c49931459fb2aaf 100644 (file)
@@ -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 (file)
index 0000000..8599d6c
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Elgg media element
+ *
+ * ---------------------------------------------------
+ * |          |                                      |
+ * |  image   |               body                   |
+ * |  block   |               block                  |
+ * |          |                                      |
+ * ---------------------------------------------------
+ *
+ * @uses $vars['body']        HTML content of the body block
+ * @uses $vars['img']         HTML content of the image block
+ * @uses $vars['class']       Optional additional class for media element
+ * @uses $vars['body_class']  Optional additional class for body block
+ * @uses $vars['img_class']   Optional additional class for image block
+ */
+
+$body = elgg_get_array_value('body', $vars, '');
+$image_block = elgg_get_array_value('img', $vars, '');
+
+$class = 'elgg-media';
+$additional_class = elgg_get_array_value('class', $vars, '');
+if ($additional_class) {
+       $class = "$class $additional_class";
+}
+
+$body_class = 'elgg-body';
+$additional_class = elgg_get_array_value('body_class', $vars, '');
+if ($additional_class) {
+       $body_class = "$body_class $additional_class";
+}
+$body = "<div class=\"$body_class\">$body</div>";
+
+$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 = "<div class=\"$img_class\">$image_block</div>";
+}
+
+echo <<<HTML
+<div class="$class clearfix">
+       $image_block$body
+</div>
+HTML;
index 46ddcfbfdb3757909297d1372ab632fa87af2bfd..b0ac82f8ed7ce0b3aff5f1b41dd163511cce3bd6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Elgg module
+ * Elgg module element
  *
  * @uses $vars['title']        Title text
  * @uses $vars['header']       HTML content of the header