diff options
author | cash <cash.costello@gmail.com> | 2011-07-02 19:51:22 -0400 |
---|---|---|
committer | cash <cash.costello@gmail.com> | 2011-07-02 19:51:22 -0400 |
commit | 21cda6136548a46670ca84fae76a046f57927115 (patch) | |
tree | 0eb4951feb773ff6df4fc781697bc99bfc4a5b1c /mod/developers/start.php | |
parent | c7e9b59e95b34c0d850e0b53c90a7b9f04ed4d2b (diff) | |
download | elgg-21cda6136548a46670ca84fae76a046f57927115.tar.gz elgg-21cda6136548a46670ca84fae76a046f57927115.tar.bz2 |
Fixes #3152 adds wrapping of views with comments
Diffstat (limited to 'mod/developers/start.php')
-rw-r--r-- | mod/developers/start.php | 42 |
1 files changed, 40 insertions, 2 deletions
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'); } } @@ -68,6 +72,40 @@ function developers_clear_strings() { } /** + * 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 = "<!-- developers:begin $view -->$result<!-- developers:end $view -->"; + } + + return $result; +} + +/** * Serve the theme preview pages * * @param array $page |