info.pm.inc

  1. 8.0.x commands/pm/info.pm.inc
  2. 6.x commands/pm/info.pm.inc
  3. 7.x commands/pm/info.pm.inc
  4. 5.x commands/pm/info.pm.inc
  5. master commands/pm/info.pm.inc

Functions

Namesort descending Description
drush_pm_info Command callback. Show detailed info for one or more extensions.
_drush_pm_info_extension Return an array with general info of an extension.
_drush_pm_info_module Return an array with info of a module.
_drush_pm_info_theme Return an array with info of a theme.

File

commands/pm/info.pm.inc
View source
  1. <?php
  2. /**
  3. * Command callback. Show detailed info for one or more extensions.
  4. */
  5. function drush_pm_info() {
  6. $args = pm_parse_arguments(func_get_args());
  7. $extension_info = drush_get_extensions(FALSE);
  8. _drush_pm_expand_extensions($args, $extension_info);
  9. // If no extensions are provided, show all.
  10. if (count($args) == 0) {
  11. $args = array_keys($extension_info);
  12. }
  13. foreach ($args as $extension) {
  14. if (isset($extension_info[$extension])) {
  15. $info = $extension_info[$extension];
  16. }
  17. else {
  18. drush_log(dt('!extension was not found.', array('!extension' => $extension)), 'warning');
  19. continue;
  20. }
  21. if ($info->type == 'module') {
  22. $data = _drush_pm_info_module($info);
  23. }
  24. else {
  25. $data = _drush_pm_info_theme($info);
  26. }
  27. drush_print_table(drush_key_value_to_array_table($data));
  28. print "\n";
  29. }
  30. }
  31. /**
  32. * Return an array with general info of an extension.
  33. */
  34. function _drush_pm_info_extension($info) {
  35. $major_version = drush_drupal_major_version();
  36. $data['Extension'] = $info->name;
  37. $data['Project'] = isset($info->info['project'])?$info->info['project']:dt('Unknown');
  38. $data['Type'] = $info->type;
  39. $data['Title'] = $info->info['name'];
  40. $data['Description'] = $info->info['description'];
  41. $data['Version'] = $info->info['version'];
  42. $data['Date'] = format_date($info->info['datestamp'], 'custom', 'Y-m-d');
  43. $data['Package'] = $info->info['package'];
  44. $data['Core'] = $info->info['core'];
  45. $data['PHP'] = $info->info['php'];
  46. $data['Status'] = drush_get_extension_status($info);
  47. $path = (($info->type == 'module')&&($major_version == 7))?$info->uri:$info->filename;
  48. $path = substr($path, 0, strrpos($path, '/'));
  49. $data['Path'] = $path;
  50. return $data;
  51. }
  52. /**
  53. * Return an array with info of a module.
  54. */
  55. function _drush_pm_info_module($info) {
  56. $major_version = drush_drupal_major_version();
  57. $data = _drush_pm_info_extension($info);
  58. if ($info->schema_version > 0) {
  59. $schema_version = $info->schema_version;
  60. }
  61. elseif ($info->schema_version == -1) {
  62. $schema_version = "no schema installed";
  63. }
  64. else {
  65. $schema_version = "module has no schema";
  66. }
  67. $data['Schema version'] = $schema_version;
  68. if ($major_version == 7) {
  69. $data['Files'] = implode(', ', $info->info['files']);
  70. }
  71. if (count($info->info['dependencies']) > 0) {
  72. $requires = implode(', ', $info->info['dependencies']);
  73. }
  74. else {
  75. $requires = "none";
  76. }
  77. $data['Requires'] = $requires;
  78. if ($major_version == 6) {
  79. $requiredby = !empty($info->info['dependents'])?$info->info['dependents']:array("none");
  80. }
  81. else {
  82. $requiredby = !empty($info->required_by)?array_keys($info->required_by):array("none");
  83. }
  84. $data['Required by'] = implode(', ', $requiredby);
  85. return $data;
  86. }
  87. /**
  88. * Return an array with info of a theme.
  89. */
  90. function _drush_pm_info_theme($info) {
  91. $major_version = drush_drupal_major_version();
  92. $data = _drush_pm_info_extension($info);
  93. $data['Core'] = $info->info['core'];
  94. $data['PHP'] = $info->info['php'];
  95. $data['Engine'] = $info->info['engine'];
  96. $data['Base theme'] = isset($info->base_themes) ? implode($info->base_themes, ', ') : '';
  97. $regions = implode(', ', $info->info['regions']);
  98. $data['Regions'] = $regions;
  99. $features = implode(', ', $info->info['features']);
  100. $data['Features'] = $features;
  101. if (count($info->info['stylesheets']) > 0) {
  102. $data['Stylesheets'] = '';
  103. foreach ($info->info['stylesheets'] as $media => $files) {
  104. $files = implode(', ', array_keys($files));
  105. $data['Media '.$media] = $files;
  106. }
  107. }
  108. if (count($info->info['scripts']) > 0) {
  109. $scripts = implode(', ', array_keys($info->info['scripts']));
  110. $data['Scripts'] = $scripts;
  111. }
  112. return $data;
  113. }