Commit 4119b5dc authored by tim.plunkett's avatar tim.plunkett Committed by tim.plunkett

Issue #1686798 by tim.plunkett: Added a list of which plugins are from which...

Issue #1686798 by tim.plunkett: Added a list of which plugins are from which modules and used in which views.
parent 3aa13be9
...@@ -5411,3 +5411,26 @@ function views_ui_field_list() { ...@@ -5411,3 +5411,26 @@ function views_ui_field_list() {
return $output; return $output;
} }
/**
* Lists all plugins and what enabled Views use them.
*/
function views_ui_plugin_list() {
$rows = views_plugin_list();
foreach ($rows as &$row) {
// Link each view name to the view itself.
foreach ($row['views'] as $row_name => $view) {
$row['views'][$row_name] = l($view, "admin/structure/views/view/$view");
}
$row['views'] = implode(', ', $row['views']);
}
// Sort rows by field name.
ksort($rows);
return array(
'#theme' => 'table',
'#header' => array(t('Type'), t('Name'), t('Provided by'), t('Used in')),
'#rows' => $rows,
'#empty' => t('There are no enabled views.'),
);
}
...@@ -269,6 +269,57 @@ function _views_find_module_templates($cache, $path) { ...@@ -269,6 +269,57 @@ function _views_find_module_templates($cache, $path) {
return $templates; return $templates;
} }
/**
* Returns a list of plugins and metadata about them.
*
* @return array
* An array keyed by PLUGIN_TYPE:PLUGIN_NAME, like 'display:page' or
* 'pager:full', containing an array with the following keys:
* - title: The plugin's title.
* - type: The plugin type.
* - module: The module providing the plugin.
* - views: An array of enabled Views that are currently using this plugin,
* keyed by machine name.
*/
function views_plugin_list() {
$plugin_data = views_fetch_plugin_data();
$plugins = array();
foreach (views_get_enabled_views() as $view) {
foreach ($view->display as $display_id => $display) {
foreach ($plugin_data as $type => $info) {
if ($type == 'display' && isset($display->display_plugin)) {
$name = $display->display_plugin;
}
elseif (isset($display->display_options["{$type}_plugin"])) {
$name = $display->display_options["{$type}_plugin"];
}
elseif (isset($display->display_options[$type]['type'])) {
$name = $display->display_options[$type]['type'];
}
else {
continue;
}
// Key first by the plugin type, then the name.
$key = $type . ':' . $name;
// Add info for this plugin.
if (!isset($plugins[$key])) {
$plugins[$key] = array(
'type' => $type,
'title' => check_plain($info[$name]['title']),
'module' => check_plain($info[$name]['module']),
'views' => array(),
);
}
// Add this view to the list for this plugin.
$plugins[$key]['views'][$view->name] = $view->name;
}
}
}
return $plugins;
}
/** /**
* A theme preprocess function to automatically allow view-based node * A theme preprocess function to automatically allow view-based node
* templates if called from a view. * templates if called from a view.
......
...@@ -152,6 +152,13 @@ function views_ui_menu() { ...@@ -152,6 +152,13 @@ function views_ui_menu() {
'page callback' => 'views_ui_field_list', 'page callback' => 'views_ui_field_list',
) + $base; ) + $base;
// A page in the Reports section to show usage of plugins in all views.
$items['admin/reports/views-plugins'] = array(
'title' => 'Views plugins',
'description' => 'Overview of plugins used in all views.',
'page callback' => 'views_ui_plugin_list',
) + $base;
return $items; return $items;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment