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',
));
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs work
+      'handler' => 'views_handler_argument',

Shouldn't all this fields be a views_handler_argument_string?

+/**
+ * Implementation of hook_views_default_views()
+ */
+function system_views_default_views() {
+  $views = array();
 
+  $files = file_scan_directory(drupal_get_path('module', 'views') .'/modules/system/views', '.view$');
+  foreach ($files as $absolute => $file) {
+    require $absolute;
+    if (isset($view)) {
+      $views[$file->name] = $view;
+    }
+  }
+
+  return $views;
+}
+

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.

benoit.borrel’s picture

Status: Needs work » Needs review
FileSize
3.1 KB

So, 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.

dawehner’s picture

Status: Needs review » Needs work

Can you please create a patch? It's much easier to apply.

  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

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 :(

benoit.borrel’s picture

Status: Needs work » Needs review
FileSize
10.42 KB

Sorry... 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.

merlinofchaos’s picture

Status: Needs review » Needs work

While 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.

dawehner’s picture

Status: Needs work » Needs review
FileSize
5.07 KB

Here is a rerole based on #5

merlinofchaos’s picture

Version: 6.x-2.11 » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

Applied to 6.x-3.x -- not sure I want to just commit it to 7.x without some testing there.

dawehner’s picture

Status: Patch (to be ported) » Fixed

Ported to d7. The handler had to be changed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.