diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-01-25 02:49:20 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-01-25 02:49:20 +0000 |
commit | 68213505bda10f90094f54a948a08d65d4d7a37c (patch) | |
tree | 268650b0a249417a6236cdc0a2b2c999411340b0 | |
parent | 14eba5b07da9b008634e05d1e9e4abfd06714dad (diff) | |
download | elgg-68213505bda10f90094f54a948a08d65d4d7a37c.tar.gz elgg-68213505bda10f90094f54a948a08d65d4d7a37c.tar.bz2 |
added support for $vars to elgg_view_entity() - need to clean up documentation and deprecate old usage
git-svn-id: http://code.elgg.org/elgg/trunk@7927 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/views.php | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/engine/lib/views.php b/engine/lib/views.php index ef1fe984d..aafec07f3 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -722,6 +722,7 @@ function elgg_view_menu($menu_name, array $vars = array()) { * * @param ElggEntity $entity The entity to display * @param boolean $full Passed to entity view to decide how much information to show. + * Beginning with Elgg 1.8, $full can be an array of vars for elgg_view() * @param boolean $bypass If false, will not pass to a custom template handler. * {@see set_template_handler()} * @param boolean $debug Complain if views are missing @@ -732,25 +733,35 @@ function elgg_view_menu($menu_name, array $vars = array()) { * @todo The annotation hook might be better as a generic plugin hook to append content. */ function elgg_view_entity(ElggEntity $entity, $full = false, $bypass = true, $debug = false) { - global $autofeed; - $autofeed = true; // No point continuing if entity is null - if (!$entity) { - return ''; + if (!$entity || !($entity instanceof ElggEntity)) { + return false; } - if (!($entity instanceof ElggEntity)) { - return false; + global $autofeed; + $autofeed = true; + + $defaults = array( + 'full' => false, + ); + + if (is_array($full)) { + $vars = $full; + $vars = array_merge($defaults, $vars); + } else { + $vars = array( + 'full' => $full, + ); } + $vars['entity'] = $entity; + + // if this entity has a view defined, use it $view = $entity->view; if (is_string($view)) { - return elgg_view($view, - array('entity' => $entity, 'full' => $full), - $bypass, - $debug); + return elgg_view($view, $vars, $bypass, $debug); } $entity_type = $entity->getType(); @@ -761,18 +772,13 @@ function elgg_view_entity(ElggEntity $entity, $full = false, $bypass = true, $de } $contents = ''; - if (elgg_view_exists("{$entity_type}/{$subtype}")) { - $contents = elgg_view("{$entity_type}/{$subtype}", array( - 'entity' => $entity, - 'full' => $full - ), $bypass, $debug); + if (elgg_view_exists("$entity_type/$subtype")) { + $contents = elgg_view("$entity_type/$subtype", $vars, $bypass, $debug); } if (empty($contents)) { - $contents = elgg_view("{$entity_type}/default", array( - 'entity' => $entity, - 'full' => $full - ), $bypass, $debug); + $contents = elgg_view("$entity_type/default", $vars, $bypass, $debug); } + // Marcus Povey 20090616 : Speculative and low impact approach for fixing #964 if ($full) { $annotations = elgg_view_entity_annotations($entity, $full); |