unset_config('debug', $site->getGUID());
}
-$simple_settings = array('display_errors', 'screen_log', 'show_strings');
+$simple_settings = array('display_errors', 'screen_log', 'show_strings', 'wrap_views');
foreach ($simple_settings as $setting) {
elgg_set_plugin_setting($setting, get_input($setting), 'developers');
}
'developers:help:screen_log' => "This displays elgg_log() and elgg_dump() output on the web page.",
'developers:label:show_strings' => "Show raw translation strings",
'developers:help:show_strings' => "This displays the translation strings used by elgg_echo().",
+ 'developers:label:wrap_views' => "Wrap views",
+ 'developers:help:wrap_views' => "This wraps almost every view with HTML comments. Useful for finding the view creating particular HTML.",
'developers:debug:off' => 'Off',
'developers:debug:error' => 'Error',
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');
}
}
$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 = "<!-- developers:begin $view -->$result<!-- developers:end $view -->";
+ }
+
+ return $result;
+}
+
/**
* Serve the theme preview pages
*