aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/developers/actions/developers/settings.php2
-rw-r--r--mod/developers/languages/en.php2
-rw-r--r--mod/developers/start.php42
-rw-r--r--mod/developers/views/default/admin/developers/settings.php6
4 files changed, 49 insertions, 3 deletions
diff --git a/mod/developers/actions/developers/settings.php b/mod/developers/actions/developers/settings.php
index 5a7f97cd3..f7caf859d 100644
--- a/mod/developers/actions/developers/settings.php
+++ b/mod/developers/actions/developers/settings.php
@@ -24,7 +24,7 @@ if ($debug) {
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');
}
diff --git a/mod/developers/languages/en.php b/mod/developers/languages/en.php
index 827eb6ba3..a20241eff 100644
--- a/mod/developers/languages/en.php
+++ b/mod/developers/languages/en.php
@@ -25,6 +25,8 @@ $english = array(
'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',
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
diff --git a/mod/developers/views/default/admin/developers/settings.php b/mod/developers/views/default/admin/developers/settings.php
index a1ae6c186..d463955b6 100644
--- a/mod/developers/views/default/admin/developers/settings.php
+++ b/mod/developers/views/default/admin/developers/settings.php
@@ -44,6 +44,12 @@ $data = array(
'value' => 1,
'checked' => elgg_get_plugin_setting('show_strings', 'developers') == 1,
),
+
+ 'wrap_views' => array(
+ 'type' => 'checkbox',
+ 'value' => 1,
+ 'checked' => elgg_get_plugin_setting('wrap_views', 'developers') == 1,
+ ),
);
$form_vars = array('id' => 'developer-settings-form');