aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-22 21:28:30 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-22 21:28:30 +0000
commit11512c0b3ef34ebf5b66e98c9c11cbbad074c037 (patch)
treeab2947cc6a8c38e421b759fb4a6d47579d551ade /engine/lib/elgglib.php
parentb4ac8dcaf7676152f0430023145c3a54334a57ec (diff)
downloadelgg-11512c0b3ef34ebf5b66e98c9c11cbbad074c037.tar.gz
elgg-11512c0b3ef34ebf5b66e98c9c11cbbad074c037.tar.bz2
Introducing elgg_view_annotation
git-svn-id: https://code.elgg.org/elgg/trunk@1046 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php46
1 files changed, 44 insertions, 2 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index cc7fbf209..f1ddb2472 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -241,7 +241,7 @@
* @param ElggEntity $entity The entity to display
* @param string $viewtype Optionally, the type of view that we're using (most commonly 'default')
* @param boolean $full Determines whether or not to display the full version of an object, or a smaller version for use in aggregators etc
- * @param boolean $debug If set to true, elgg_view will bypass any specified alternative template handler; by default, it will hand off to this if requested (see set_template_handler)
+ * @param boolean $bypass If set to true, elgg_view will bypass any specified alternative template handler; by default, it will hand off to this if requested (see set_template_handler)
* @param boolean $debug If set to true, the viewer will complain if it can't find a view
* @return string HTML (etc) to display
*/
@@ -290,7 +290,49 @@
), $viewtype, $bypass, $debug);
}
}
-
+
+ /**
+ * When given an annotation, views it intelligently.
+ *
+ * This function expects annotation views to be of the form annotation/name, where name
+ * is the type of annotation.
+ *
+ * @param ElggAnnotation $annotation The annotation to display
+ * @param string $viewtype Optionally, the type of view that we're using (most commonly 'default')
+ * @param boolean $full Determines whether or not to display the full version of an object, or a smaller version for use in aggregators etc
+ * @param boolean $bypass If set to true, elgg_view will bypass any specified alternative template handler; by default, it will hand off to this if requested (see set_template_handler)
+ * @param boolean $debug If set to true, the viewer will complain if it can't find a view
+ * @return string HTML (etc) to display
+ */
+ function elgg_view_annotation(ElggAnnotation $annotation, $viewtype = "", $bypass = true, $debug = false) {
+
+ global $autofeed;
+ $autofeed = true;
+
+ $view = $annotation->view;
+ if (is_string($view)) {
+ return elgg_view($view,array('annotation' => $annotation), $viewtype, $bypass, $debug);
+ }
+
+ $name = $annotation->name;
+ $intname = (int) $name;
+ if ("{$intname}" == "{$name}") {
+ $name = get_metastring($intname);
+ }
+ if (empty($name)) { return ""; }
+
+ if (elgg_view_exists("annotation/{$name}")) {
+ return elgg_view("annotation/{$name}",array(
+ 'annotation' => $annotation,
+ ), $viewtype, $bypass, $debug);
+ } else {
+ return elgg_view("annotation/default",array(
+ 'annotation' => $annotation,
+ ), $viewtype, $bypass, $debug);
+ }
+ }
+
+
/**
* Returns a view of a list of entities, plus navigation. It is intended that this function
* be called from other wrapper functions.