From 21cda6136548a46670ca84fae76a046f57927115 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 2 Jul 2011 19:51:22 -0400 Subject: Fixes #3152 adds wrapping of views with comments --- mod/developers/start.php | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'mod/developers/start.php') diff --git a/mod/developers/start.php b/mod/developers/start.php index b864bca1e..27a14b336 100644 --- a/mod/developers/start.php +++ b/mod/developers/start.php @@ -43,8 +43,12 @@ function developers_process_settings() { if (elgg_get_plugin_setting('show_strings', 'developers') == 1) { // first and last in case a plugin registers a translation in an init method - register_elgg_event_handler('init', 'system', 'developers_clear_strings', 1000); - register_elgg_event_handler('init', 'system', 'developers_clear_strings', 1); + elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1000); + elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1); + } + + if (elgg_get_plugin_setting('wrap_views', 'developers') == 1) { + register_plugin_hook('view', 'all', 'developers_wrap_views'); } } @@ -67,6 +71,40 @@ function developers_clear_strings() { $CONFIG->translations['en'] = array(); } +/** + * Post-process a view to add wrapper comments to it + */ +function developers_wrap_views($hook, $type, $result, $params) { + if (elgg_get_viewtype() != "default") { + return; + } + + $excluded_bases = array('css', 'js', 'input', 'output', 'embed', 'icon',); + + $excluded_views = array( + 'page/default', + 'page/admin', + 'page/elements/head', + ); + + $view = $params['view']; + + $view_hierarchy = explode('/',$view); + if (in_array($view_hierarchy[0], $excluded_bases)) { + return; + } + + if (in_array($view, $excluded_views)) { + return; + } + + if ($result) { + $result = "$result"; + } + + return $result; +} + /** * Serve the theme preview pages * -- cgit v1.2.3