Skip to content

Instantly share code, notes, and snippets.

@gl2748
Forked from bnchdrff/summarize-views.php
Last active December 16, 2015 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gl2748/313b19bce1a99e42d94f to your computer and use it in GitHub Desktop.
Save gl2748/313b19bce1a99e42d94f to your computer and use it in GitHub Desktop.
summarize all views on a drupal site
<?php
$views = [
[
'view machine name',
'view name',
'view desc',
'base table',
'display machine name',
'display title',
'display plugin',
'page url if exists',
'has php',
'has php in fields',
'has php in header',
'has php in footer',
]
];
foreach (views_get_all_views() as $view) {
foreach ($view->display as $display => $data) {
$page_url_if_exists = FALSE;
$has_php_anywhere = FALSE;
$has_php_in_fields = FALSE;
$has_php_in_header = FALSE;
$has_php_in_footer = FALSE;
if ($data->display_plugin==='page') {
$page_url_if_exists = $data->display_options['path'];
}
if (isset($data->display_options['fields']['php']['php_value'])) {
$has_php_in_fields = "TRUE";
$has_php_anywhere = "TRUE";
}
if (isset($data->display_options['fields']['php']['php_output'])) {
$has_php_in_fields = "TRUE";
$has_php_anywhere = "TRUE";
}
if (isset($data->display_options['fields']['php_1']['php_output'])) {
$has_php_in_fields = "TRUE";
$has_php_anywhere = "TRUE";
}
if (isset($data->display_options['header']['php']['php_output'])) {
$has_php_in_header = "TRUE";
$has_php_anywhere = "TRUE";
}
if (isset($data->display_options['footer']['php']['php_output'])) {
$has_php_in_footer = "TRUE";
$has_php_anywhere = "TRUE";
}
$views[] = [
// 'view machine name'
$view->name,
// 'view name'
$view->human_name,
// 'view desc'
$view->description,
// 'base table'
$view->base_table,
// 'display machine name'
$display,
// 'display title'
$data->display_title,
// 'display plugin'
$data->display_plugin,
// page url exists?
$page_url_if_exists,
// has php
$has_php_anywhere,
// has php in field
$has_php_in_fields,
// has php in header
$has_php_in_header,
// has php in footer
$has_php_in_footer,
];
}
}
$fp = fopen('views-summary.csv', 'w');
foreach ($views as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment