Permalink
Browse files

feature(developers): add view_vars hook to views inspector

  • Loading branch information...
mrclay committed Apr 19, 2016
1 parent f22dc7d commit 41e9e1ef9462dedae00b49079ec5b3b4619cfb75
@@ -98,25 +98,28 @@ public function getViews($viewtype = 'default') {
// view handlers
$handlers = _elgg_services()->hooks->getAllHandlers();
+ $input_filtered_views = array();
+ if (!empty($handlers['view_vars'])) {
+ $input_filtered_views = array_keys($handlers['view_vars']);
+ }
+
$filtered_views = array();
if (!empty($handlers['view'])) {
$filtered_views = array_keys($handlers['view']);
}
$global_hooks = array();
- if (!empty($handlers['view']['all'])) {
- $global_hooks[] = 'view,all';
+ if (!empty($handlers['view_vars']['all'])) {
+ $global_hooks[] = 'view_vars, all';
}
- if (!empty($handlers['display']['view'])) {
- $global_hooks[] = 'display,view';
- }
- if (!empty($handlers['display']['all'])) {
- $global_hooks[] = 'display,all';
+ if (!empty($handlers['view']['all'])) {
+ $global_hooks[] = 'view, all';
}
return array(
'views' => $views,
'global_hooks' => $global_hooks,
+ 'input_filtered_views' => $input_filtered_views,
'filtered_views' => $filtered_views,
);
}
@@ -49,7 +49,8 @@
'developers:inspect:priority' => 'Priority',
'developers:inspect:simplecache' => 'Simple Cache',
'developers:inspect:views' => 'Views',
- 'developers:inspect:views:all_filtered' => "<b>Note!</b> All view output is filtered through these Plugin Hooks:",
+ 'developers:inspect:views:all_filtered' => "<b>Note!</b> All view input/output is filtered through these Plugin Hooks:",
+ 'developers:inspect:views:input_filtered' => "(input filtered by plugin hook: %s)",
'developers:inspect:views:filtered' => "(filtered by plugin hook: %s)",
'developers:inspect:widgets' => 'Widgets',
'developers:inspect:webservices' => 'Webservices',
@@ -5,9 +5,10 @@
return;
}
-$views = $data['views'];
-$global_hooks = $data['global_hooks'];
-$filtered_views = $data['filtered_views'];
+$views = elgg_extract('views', $data);
+$global_hooks = elgg_extract('global_hooks', $data);
+$filtered_views = elgg_extract('filtered_views', $data);
+$input_filtered_views = (array)elgg_extract('input_filtered_views', $data);
$root = elgg_get_root_path();
$strip = function ($file) use ($root) {
@@ -62,15 +63,24 @@
$rowspan = count($components);
+ $extra_rows = '';
+
+ if (in_array($view, $input_filtered_views)) {
+ $rowspan += 1;
+ $id = "z" . md5("view_vars, $view");
+ $link = "<a href='?inspect_type=Plugin%20Hooks#$id'>view_vars, $view</a>";
+ $col2 = elgg_echo('developers:inspect:views:input_filtered', array($link));
+
+ $extra_rows .= "<tr><td>&nbsp;</td><td>$col2</td></tr>";
+ }
+
if (in_array($view, $filtered_views)) {
$rowspan += 1;
- $id = "z" . md5("view,$view");
- $link = "<a href='?inspect_type=Plugin%20Hooks#$id'>view,$view</a>";
+ $id = "z" . md5("view, $view");
+ $link = "<a href='?inspect_type=Plugin%20Hooks#$id'>view, $view</a>";
$col2 = elgg_echo('developers:inspect:views:filtered', array($link));
- $extra_row = "<tr><td>&nbsp;</td><td>$col2</td></tr>";
- } else {
- $extra_row = "";
+ $extra_rows .= "<tr><td>&nbsp;</td><td>$col2</td></tr>";
}
foreach ($components as $priority => $component) {
@@ -100,7 +110,7 @@
echo "</tr>";
}
- echo $extra_row;
+ echo $extra_rows;
}
echo "</table>";

0 comments on commit 41e9e1e

Please sign in to comment.