-
-
Save gl2748/313b19bce1a99e42d94f to your computer and use it in GitHub Desktop.
summarize all views on a drupal site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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