Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi,
Here is a patch which expose table system to Views, allowing to display modules, themes and theme engines information. I am using similar code in a custom module, but it would be great to have it integrated into Views module.
Below the export of a view which list modules and their schema version (as a page display) to demonstrate the usage. You could either import it into the database or save it into sites/all/modules/contrib/views/modules/system/views/modules.view.
Thanks
<?php
$view = new view;
$view->name = 'modules';
$view->description = 'List modules';
$view->tag = 'system';
$view->view_php = '';
$view->base_table = 'system';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'name' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'name',
'table' => 'system',
'field' => 'name',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'schema_version' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'exclude' => 0,
'id' => 'schema_version',
'table' => 'system',
'field' => 'schema_version',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'name' => array(
'order' => 'ASC',
'id' => 'name',
'table' => 'system',
'field' => 'name',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'status' => array(
'id' => 'status',
'table' => 'system',
'field' => 'status',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'system',
'field' => 'status',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('items_per_page', 100);
$handler->override_option('style_plugin', 'grid');
$handler->override_option('style_options', array(
'grouping' => '',
'columns' => '5',
'alignment' => 'horizontal',
'fill_single_line' => 1,
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('access', array(
'type' => 'perm',
'perm' => 'administer site configuration',
));
$handler->override_option('path', 'admin/reports/modules');
$handler->override_option('menu', array(
'type' => 'none',
'title' => 'Modules',
'description' => '',
'weight' => '0',
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
Comment | File | Size | Author |
---|---|---|---|
#6 | 935176-system_table-views_data.patch | 5.07 KB | dawehner |
#4 | views_modules_system-with-system-table.patch | 10.42 KB | benoit.borrel |
#2 | modules_system-with-system-table.tgz | 3.1 KB | benoit.borrel |
system.views_.inc-with-system-table.patch | 4.33 KB | benoit.borrel | |
Comments
Comment #1
dawehnerShouldn't all this fields be a views_handler_argument_string?
it would be cool to use modules/system/system.views_default.inc here. Views uses this everywhere so don't make a difference for this isuse.
I like the feature.
Comment #2
benoit.borrel CreditAttribution: benoit.borrel commentedSo, if you like it, here it is with the required fixes:
- fixed all fields (but status which is a boolean) argument handlers to views_handler_argument_string in patch (system.views.inc-with-system-table_v2.patch) for modules/system/system.views.inc
- created modules/system/system.views_default.inc to define the view
And also, improved system type filter now extending filter 'in_operator' :
- created modules/system/views_handler_filter_system_type.inc
All files are in attached archive.
Comment #3
dawehnerCan you please create a patch? It's much easier to apply.
Please disable the view by default. I'm not sure whether there should be a view for the system by default.
There might not be a lot of people which uses this feature.
I don't know what you did with your patch file but it's totally corrupted here. Sorry :(
Comment #4
benoit.borrel CreditAttribution: benoit.borrel commentedSorry... I've been caught not testing my patch... 8-\
So, here it is again:
- tested,
- with the requested fix (default view initially disabled),
- and this time rooted in contrib modules directory.
Thanks to review it.
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedWhile I have no problem creating views for the system table, I think we don't need the default view at all. It will confuse people, I think, because it's something so few people need. If we demonstrated everything possible as default views we would have a great deal of them.
Comment #6
dawehnerHere is a rerole based on #5
Comment #7
merlinofchaos CreditAttribution: merlinofchaos commentedApplied to 6.x-3.x -- not sure I want to just commit it to 7.x without some testing there.
Comment #8
dawehnerPorted to d7. The handler had to be changed