Skip to content

Instantly share code, notes, and snippets.

@gl2748
Created December 16, 2015 17:36
Show Gist options
  • Save gl2748/055d856141f94d3ea5f2 to your computer and use it in GitHub Desktop.
Save gl2748/055d856141f94d3ea5f2 to your computer and use it in GitHub Desktop.
output spreadsheet of views
<?php
$views = [
[
'view machine name',
'view name',
'view desc',
'base table',
'display machine name',
'display title',
'display plugin',
'page url if exists',
'has php in fields',
]
];
foreach (views_get_all_views() as $view) {
foreach ($view->display as $display => $data) {
$page_url_if_exists = FALSE;
$has_php_in_fields = 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 = $data->display_options['fields']['php_value']
$has_php_in_fields = 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 in field
$has_php_in_fields,
];
}
}
$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