From: cash Date: Mon, 6 Dec 2010 01:48:53 +0000 (+0000) Subject: comments use the media view now X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=eb306be905c9fd78600841070d0796bd99ae7f73;p=lorea%2Felgg.git comments use the media view now git-svn-id: http://code.elgg.org/elgg/trunk@7544 36083f99-b078-4883-b0ff-0f9b5a30f544 --- diff --git a/engine/lib/views.php b/engine/lib/views.php index 3885babf1..d2e63d1a5 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -836,34 +836,14 @@ $list_type_toggle = true, $pagination = true) { * @access private */ function elgg_view_annotation_list($annotations, $count, $offset, $limit) { - $count = (int) $count; - $offset = (int) $offset; - $limit = (int) $limit; - - $html = ""; - - $nav = elgg_view('navigation/pagination', array( - 'baseurl' => $_SERVER['REQUEST_URI'], - 'offset' => $offset, - 'count' => $count, - 'limit' => $limit, - 'word' => 'annoff', - 'nonefound' => false, - )); - - $html .= $nav; - - if (is_array($annotations) && sizeof($annotations) > 0) { - foreach ($annotations as $annotation) { - $html .= elgg_view_annotation($annotation, true); - } - } - - if ($count) { - $html .= $nav; - } + $params = array( + 'annotations' => $annotations, + 'count' => (int) $count, + 'offset' => (int) $offset, + 'limit' => (int) $limit, + ); - return $html; + return elgg_view('annotation/list', $params); } /** @@ -959,13 +939,19 @@ function elgg_view_comments($entity, $add_comment = true) { if ($comemnts) { return $comments; } else { + $params = array( + 'entity' => $entity, + 'show_add_form' => $add_comment, + ); + $comments = elgg_view('comments/list', $params); + /* $comments = list_annotations($entity->getGUID(), 'generic_comment'); //display the new comment form if required if ($add_comment) { $comments .= elgg_view('comments/forms/edit', array('entity' => $entity)); } - +*/ return $comments; } } diff --git a/languages/en.php b/languages/en.php index cad8a93c3..e4e17d9b9 100644 --- a/languages/en.php +++ b/languages/en.php @@ -923,7 +923,7 @@ If you requested this click on the link below, otherwise ignore this email. 'generic_comments:text' => "Comment", 'generic_comments:latest' => "Latest comments", 'generic_comment:posted' => "Your comment was successfully posted.", - 'generic_comment:deleted' => "Your comment was successfully deleted.", + 'generic_comment:deleted' => "The comment was successfully deleted.", 'generic_comment:blank' => "Sorry, you need to actually put something in your comment before we can save it.", 'generic_comment:notfound' => "Sorry, we could not find the specified item.", 'generic_comment:notdeleted' => "Sorry, we could not delete this comment.", diff --git a/views/default/annotation/generic_comment.php b/views/default/annotation/generic_comment.php index bb0127bfe..63633d3b5 100644 --- a/views/default/annotation/generic_comment.php +++ b/views/default/annotation/generic_comment.php @@ -20,7 +20,6 @@ if (!$entity || !$commenter) { return true; } - $friendlytime = elgg_view_friendly_time($comment->time_created); $commenter_icon = elgg_view("profile/icon", array('entity' => $commenter, 'size' => 'tiny')); @@ -31,6 +30,31 @@ $entity_link = "getURL()}\">$entity_title"; if ($full_view) { + $delete_button = ''; + if ($comment->canEdit()) { + $delete_button = elgg_view("output/confirmlink",array( + 'href' => "action/comments/delete?annotation_id={$comment->id}", + 'text' => elgg_echo('delete'), + 'confirm' => elgg_echo('deleteconfirm') + )); + $delete_button = "$delete_button"; + } + + $comment_text = elgg_view("output/longtext", array("value" => $comment->value)); + + $body = << + $delete_button + $commenter_link + + $friendlytime + + $comment_text +

+HTML; + + echo elgg_view_media($commenter_icon, $body, array('id' => "comment-$comment->id")); + } else { // brief view @@ -39,57 +63,10 @@ if ($full_view) { $on = elgg_echo('on'); $body = <<$commenter_link $on $entity_link ($friendlytime) + + $commenter_link $on $entity_link ($friendlytime) + HTML; echo elgg_view_media($commenter_icon, $body); - - // @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); - -?> - -
-
- $owner, - 'size' => 'tiny' - )); - ?> -
- -
- canEdit()) { - ?> - - "action/comments/delete?annotation_id=" . $vars['annotation']->id, - 'text' => elgg_echo('delete'), - 'confirm' => elgg_echo('deleteconfirm') - )); - ?> - - -

- name; ?> - - time_created); ?> - -

- -
- $vars['annotation']->value)); ?> -
-
-
\ No newline at end of file diff --git a/views/default/annotation/list.php b/views/default/annotation/list.php new file mode 100644 index 000000000..f432ad640 --- /dev/null +++ b/views/default/annotation/list.php @@ -0,0 +1,46 @@ + $_SERVER['REQUEST_URI'], + 'offset' => $offset, + 'count' => $count, + 'limit' => $limit, + 'word' => 'annoff', + 'nonefound' => false, + )); +} + +if (is_array($annotations) && count($annotations) > 0) { + $html .= ''; +} + +if ($count) { + $html .= $nav; +} + +echo $html; diff --git a/views/default/comments/forms/edit.php b/views/default/comments/forms/edit.php deleted file mode 100644 index 3c26bf7cc..000000000 --- a/views/default/comments/forms/edit.php +++ /dev/null @@ -1,20 +0,0 @@ -

" . elgg_view('input/longtext',array('internalname' => 'generic_comment')) . "

"; - $form_body .= elgg_view('input/hidden', array('internalname' => 'entity_guid', 'value' => $vars['entity']->getGUID())); - $form_body .= elgg_view('input/submit', array('value' => elgg_echo("generic_comments:post"))) . ""; - - echo elgg_view('input/form', array('body' => $form_body, 'action' => "action/comments/add")); - - } - -?> \ No newline at end of file diff --git a/views/default/forms/comments/add.php b/views/default/forms/comments/add.php new file mode 100644 index 000000000..74ee5ba4b --- /dev/null +++ b/views/default/forms/comments/add.php @@ -0,0 +1,23 @@ + +

+ + 'generic_comment')); ?> +

+ 'entity_guid', + 'value' => $vars['entity']->getGUID() + )); + echo elgg_view('input/submit', array('value' => elgg_echo("generic_comments:post"))); +} diff --git a/views/default/layout_elements/media.php b/views/default/layout_elements/media.php index 5f4e51d57..fcf0fba77 100644 --- a/views/default/layout_elements/media.php +++ b/views/default/layout_elements/media.php @@ -12,8 +12,9 @@ * @uses $vars['body'] HTML content of the body block * @uses $vars['icon'] HTML content of the icon block * @uses $vars['class'] Optional additional class for media element + * @uses $vars['id'] Optional id for the media element * @uses $vars['body_class'] Optional additional class for body block - * @uses $vars['icon_class'] Optional additional class for icon block + * @uses $vars['icon_class'] Optional additional class for icon block */ $body = elgg_get_array_value('body', $vars, ''); @@ -25,6 +26,11 @@ if ($additional_class) { $class = "$class $additional_class"; } +$id = ''; +if (isset($vars['id'])) { + $id = "id=\"{$vars['id']}\""; +} + $body_class = 'elgg-body'; $additional_class = elgg_get_array_value('body_class', $vars, ''); if ($additional_class) { @@ -42,7 +48,7 @@ if ($icon_block) { } echo << +
$icon_block$body
HTML;