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

pm-info command implementation.

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_format_table_data Output format formatter-filter callback.
_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. * @file
  4. * pm-info command implementation.
  5. */
  6. /**
  7. * Command callback. Show detailed info for one or more extensions.
  8. */
  9. function drush_pm_info() {
  10. $result = array();
  11. $args = pm_parse_arguments(func_get_args());
  12. $extension_info = drush_get_extensions(FALSE);
  13. _drush_pm_expand_extensions($args, $extension_info);
  14. // If no extensions are provided, show all.
  15. if (count($args) == 0) {
  16. $args = array_keys($extension_info);
  17. }
  18. foreach ($args as $extension) {
  19. if (isset($extension_info[$extension])) {
  20. $info = $extension_info[$extension];
  21. }
  22. else {
  23. drush_log(dt('!extension was not found.', array('!extension' => $extension)), 'warning');
  24. continue;
  25. }
  26. if ($info->type == 'module') {
  27. $data = _drush_pm_info_module($info);
  28. }
  29. else {
  30. $data = _drush_pm_info_theme($info);
  31. }
  32. $result[$extension] = $data;
  33. }
  34. return $result;
  35. }
  36. /**
  37. * Output format formatter-filter callback.
  38. *
  39. * @see drush_parse_command()
  40. * @see drush_outputformat
  41. */
  42. function _drush_pm_info_format_table_data($data) {
  43. $result = array();
  44. foreach ($data as $extension => $info) {
  45. foreach($info as $key => $value) {
  46. if (is_array($value)) {
  47. if (empty($value)) {
  48. $value = 'none';
  49. }
  50. else {
  51. $value = implode(', ', $value);
  52. }
  53. }
  54. $result[$extension][$key] = $value;
  55. }
  56. }
  57. return $result;
  58. }
  59. /**
  60. * Return an array with general info of an extension.
  61. */
  62. function _drush_pm_info_extension($info) {
  63. $major_version = drush_drupal_major_version();
  64. $data['extension'] = $info->name;
  65. $data['project'] = isset($info->info['project'])?$info->info['project']:dt('Unknown');
  66. $data['type'] = $info->type;
  67. $data['title'] = $info->info['name'];
  68. $data['config'] = isset($info->info['configure']) ? $info->info['configure'] : dt('None');
  69. $data['description'] = $info->info['description'];
  70. $data['version'] = $info->info['version'];
  71. $data['date'] = format_date($info->info['datestamp'], 'custom', 'Y-m-d');
  72. $data['package'] = $info->info['package'];
  73. $data['core'] = $info->info['core'];
  74. $data['php'] = $info->info['php'];
  75. $data['status'] = drush_get_extension_status($info);
  76. $path = (($info->type == 'module')&&($major_version == 7))?$info->uri:$info->filename;
  77. $path = substr($path, 0, strrpos($path, '/'));
  78. $data['path'] = $path;
  79. return $data;
  80. }
  81. /**
  82. * Return an array with info of a module.
  83. */
  84. function _drush_pm_info_module($info) {
  85. $major_version = drush_drupal_major_version();
  86. $data = _drush_pm_info_extension($info);
  87. if ($info->schema_version > 0) {
  88. $schema_version = $info->schema_version;
  89. }
  90. elseif ($info->schema_version == -1) {
  91. $schema_version = "no schema installed";
  92. }
  93. else {
  94. $schema_version = "module has no schema";
  95. }
  96. $data['schema_version'] = $schema_version;
  97. if ($major_version == 7) {
  98. $data['files'] = $info->info['files'];
  99. }
  100. $data['requires'] = $info->info['dependencies'];
  101. if ($major_version == 6) {
  102. $requiredby = $info->info['dependents'];
  103. }
  104. else {
  105. $requiredby = array_keys($info->required_by);
  106. }
  107. $data['required_by'] = $requiredby;
  108. if ($info->status == 1) {
  109. $role = drush_role_get_class();
  110. $data['permissions'] = $role->getModulePerms($info->name);
  111. }
  112. return $data;
  113. }
  114. /**
  115. * Return an array with info of a theme.
  116. */
  117. function _drush_pm_info_theme($info) {
  118. $major_version = drush_drupal_major_version();
  119. $data = _drush_pm_info_extension($info);
  120. $data['core'] = $info->info['core'];
  121. $data['php'] = $info->info['php'];
  122. $data['engine'] = $info->info['engine'];
  123. $data['base_theme'] = isset($info->base_themes) ? implode($info->base_themes, ', ') : '';
  124. $regions = $info->info['regions'];
  125. $data['regions'] = $regions;
  126. $features = $info->info['features'];
  127. $data['features'] = $features;
  128. if (count($info->info['stylesheets']) > 0) {
  129. $data['stylesheets'] = '';
  130. foreach ($info->info['stylesheets'] as $media => $files) {
  131. $files = array_keys($files);
  132. $data['media '.$media] = $files;
  133. }
  134. }
  135. if (count($info->info['scripts']) > 0) {
  136. $scripts = array_keys($info->info['scripts']);
  137. $data['scripts'] = $scripts;
  138. }
  139. return $data;
  140. }