aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-12-04 13:17:57 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-12-04 13:17:57 +0000
commit6b1a4978fdc8e5ce4b7722d9e816fc7f95700497 (patch)
treec4651bebd3de706f949ae051e1f8ef486a7516d7 /engine/lib
parent79d887cc9b2d32ba155d6fefcd1a7c40c0a7fc94 (diff)
downloadelgg-6b1a4978fdc8e5ce4b7722d9e816fc7f95700497.tar.gz
elgg-6b1a4978fdc8e5ce4b7722d9e816fc7f95700497.tar.bz2
fixes #1273 - replaced previous hack with call to getType
git-svn-id: http://code.elgg.org/elgg/trunk@3725 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/elgglib.php69
1 files changed, 30 insertions, 39 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index f1a72c06b..30232412a 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -603,52 +603,38 @@ function elgg_view_tree($view_root, $viewtype = "") {
*
* Expects a view to exist called entity-type/subtype, or for the entity to have a parameter
* 'view' which lists a different view to display. In both cases, elgg_view will be called with
- * array('entity' => $entity) as its parameters, and therefore this is what the view should expect
- * to receive.
+ * array('entity' => $entity, 'full' => $full) as its parameters, and therefore this is what
+ * the view should expect to receive.
*
* @param ElggEntity $entity The entity to display
* @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
+ * @return string HTML to display or false
*/
function elgg_view_entity(ElggEntity $entity, $full = false, $bypass = true, $debug = false) {
global $autofeed;
$autofeed = true;
- // No point continuing if entity is null.
+ // No point continuing if entity is null
if (!$entity) {
return '';
}
+
+ if (!($entity instanceof ElggEntity)) {
+ return false;
+ }
+ // if this entity has a view defined, use it
$view = $entity->view;
if (is_string($view)) {
- return elgg_view($view,array('entity' => $entity), $bypass, $debug);
- }
-
- $classes = array(
- 'ElggUser' => 'user',
- 'ElggObject' => 'object',
- 'ElggSite' => 'site',
- 'ElggGroup' => 'group'
- );
-
- $entity_class = get_class($entity);
-
- if (isset($classes[$entity_class])) {
- $entity_type = $classes[$entity_class];
- } else {
- foreach($classes as $class => $type) {
- if ($entity instanceof $class) {
- $entity_type = $type;
- break;
- }
- }
+ return elgg_view($view,
+ array('entity' => $entity, 'full' => $full),
+ $bypass,
+ $debug);
}
- if (!isset($entity_class)) {
- return false;
- }
+ $entity_type = $entity->getType();
$subtype = $entity->getSubtype();
if (empty($subtype)) {
@@ -805,26 +791,31 @@ function elgg_view_annotation_list($annotations, $count, $offset, $limit) {
/**
* Display a selective rendered list of annotations for a given entity.
*
- * The list is produced as the result of the entity:annotate plugin hook and is designed to provide a
- * more generic framework to allow plugins to extend the generic display of entities with their own annotation
+ * The list is produced as the result of the entity:annotate plugin hook
+ * and is designed to provide a more generic framework to allow plugins
+ * to extend the generic display of entities with their own annotation
* renderings.
*
- * This is called automatically by the framework.
+ * This is called automatically by the framework from elgg_view_entity()
*
* @param ElggEntity $entity
* @param bool $full
+ * @return string or false on failure
*/
function elgg_view_entity_annotations(ElggEntity $entity, $full = true) {
- $classes = array(
- 'ElggUser' => 'user',
- 'ElggObject' => 'object',
- 'ElggSite' => 'site',
- 'ElggGroup' => 'group'
- );
- $entity_class = get_class($entity);
+ // No point continuing if entity is null
+ if (!$entity) {
+ return false;
+ }
+
+ if (!($entity instanceof ElggEntity)) {
+ return false;
+ }
+
+ $entity_type = $entity->getType();
- $annotations = trigger_plugin_hook('entity:annotate', $classes[$entity_class],
+ $annotations = trigger_plugin_hook('entity:annotate', $entity_type,
array(
'entity' => $entity,
'full' => $full,