From 10e5db3119afca7060a680517393518be3aa54ab Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 27 Jun 2008 15:20:33 +0000 Subject: Brought generic comments into Elgg core git-svn-id: https://code.elgg.org/elgg/trunk@1185 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 3b8e444d7..d4feabf53 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -321,7 +321,7 @@ $name = get_metastring($intname); } if (empty($name)) { return ""; } - + if (elgg_view_exists("annotation/{$name}")) { return elgg_view("annotation/{$name}",array( 'annotation' => $annotation, @@ -413,7 +413,7 @@ )); $html .= $nav; - + if (is_array($annotations) && sizeof($annotations) > 0) { foreach($annotations as $annotation) { $html .= elgg_view_annotation($annotation, "", false); @@ -422,7 +422,7 @@ if ($count) $html .= $nav; - + return $html; } @@ -463,6 +463,25 @@ } + /** + * Automatically views comments and a comment form relating to the given entity + * + * @param ElggEntity $entity The entity to comment on + * @return string|false The HTML (etc) for the comments, or false on failure + */ + function elgg_view_comments($entity){ + + if (!($entity instanceof ElggEntity)) return false; + + $comments = list_annotations($entity->getGUID(),'generic_comment'); + + //display the comment form + $comments .= elgg_view('comments/forms/edit',array('entity' => $entity)); + + return $comments; + + } + /** * Wrapper function to display search listings. * @@ -1491,7 +1510,13 @@ $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI']; } - - + + function elgg_init() { + // Important actions + register_action('comments/add'); + register_action('comments/delete'); + } + + register_elgg_event_handler('init','system','elgg_init'); ?> \ No newline at end of file -- cgit v1.2.3