Bringing `theme-info` from #530780: drush commands to administer themes into drush `pm-info` and extending it to handle modules.

To obtain the type of the project I do SELECT type FROM {system} WHERE name = :name. is it safe? is there a better way?

possible additions:
themes:
1. all versions: show current global and specific settings: mission, logo, zen_wireframes, etc
2. for d7: parse regions to show: overlay, hidden and overlay_supplemental regions

modules:
3. data available in some versions but not printed by pm-info: weight(7), throtle (5,6), old_filename (5,6) datestamp (5,6,7)
4. some of this data can be obtained by querying the system table.
5. still figuring out how to obtain dependencies / dependants for d7

Any feedback welcome. Particularly on display ordering or a more elegant way to do select queries for d5-6,7.

pd. This patch also fixes drupal_get_themes() that is broken for d5 and d7 by replacing `_system_theme_data()` with `list_themes()`

=> _system_theme_data() is only for drupal 6. It is not available for d5 and d7.
=> list_themes() is available for all versions, use the database if possible and includes theme status (_system_theme_data() doesn't).

Comments

moshe weitzman’s picture

querying system table seems fine to me. i think we should show info from a couple more columns, especially schema_version.

i think you'd want to simply show the whole .info file for a module and theme. it is very common with themes in particular to add custom properties which are meaningful. see http://drupal.org/project/skinr.

Listing the dependencies from .info might be enough for modules. If we want to show the full dependency chain, call _module_build_dependencies() in D7.

jonhattan’s picture

StatusFileSize
new6 KB

schema_version was already there.

I see a problem with showing .info files for themes: it can include default settings that are to be override via UI, ej: settings[zen_block_editing] = 1.
skinr info is available in the theme object we gather info from ($info->skinr). Perhaps it's a task for a skinr drush integration implementing `drush_skinr_post_pm_info()`.

More:
* Querying the system table is not realiable as recently downloaded projects are not still there is project's data has not been rebuild. Attached patch rely on `drush_get_modules()` and `drush_get_themes()`.
* we show module dependencies (as in .info) for all versions and also dependants for D6, as it is included in $info. I can put full dependency chain for D6,7 if you see it of interest. It is not hard but perhaps time consuming.

moshe weitzman’s picture

Status: Active » Needs work

Some feedback on this output from D7:

~/htd/prfr$ drush pm-info devel
Project: devel
Type: module
Status: disabled
Title: Devel
Description: Various blocks, pages, and functions for developers.
Version: 7.x-1.x-dev
Path: sites/all/modules/devel/devel.module
Package: 1
Schema version: -1
Core: 7.x
Files: 
  - devel.module
  - devel.install
Requires: 
  menu
  1. Lets align all the colons like we do for core-status command.
  2. What do we mean by Path here? I expected to see one level higher, and not the .module file. This is project info, not module info.
  3. WHats up with Package=1
  4. Schema version - lets use a more friendly text if possible
  5. Files should probably be on one line
  6. Requires on one line
jonhattan’s picture

StatusFileSize
new6.7 KB

This is how it looks now in d7 for for devel and garland:

$ drush pm-info devel garland 
  Project           : devel
  Type              : module
  Title             : Devel
  Description       : Various blocks, pages, and functions for developers.
  Version           : 7.x-1.x-dev
  Core              : 7.x
  Status            : enabled
  Path              : sites/all/modules/devel
  Package           : Development
  Schema version    : 7001
  Files             : devel.module, devel.install
  Requires          : menu

  Project           : garland
  Type              : module
  Title             : Garland
  Description       : A multi-column theme which can be configured to modify colors and switch between fixed and fluid width layouts.
  Version           : 7.x-dev
  Core              : 7.x
  Status            : enabled
  Path              : themes/garland
  Core              : 7.x
  PHP               : 5.2.0
  Engine            : phptemplate
  Regions           : Left sidebar, Right sidebar, Content, Header, Footer, Highlighted content, Help, Page top, Page bottom, Dashboard main, Dashboard sidebar
  Features          : comment_user_picture, comment_user_verification, favicon, logo, name, node_user_picture, slogan, main_menu, secondary_menu
  Stylesheets       :
      media all     : style.css
      media print   : print.css

I've split the code into three new functions. Now they are:

function _drush_pm_info_project($info) {}

Known Issues:

1. d5 themes:
`[description] => themes/engines/phptemplate/phptemplate.engine` is printed as: `Engine : themes/engines/phptemplate/phptemplate.engine`
2. when no direct or reverse dependencies: ` Requires : none`. It can be changed to empty or the line completely removed.
3. which expresion should we use when schema_version = -1 ?

moshe weitzman’s picture

that ouput is nicer ... have you considered output using tables. the wrapping would be better for something like Garland's Region line.

2. requires: none looks good to me

3. See constants at top of includes/install.inc

jonhattan’s picture

is a pain to move this to an array for drush_table. I prefer to emulate it by indenting the 2nd column.

jonhattan’s picture

StatusFileSize
new9.48 KB

Changes:

* messages for possible schema_version values:

 > 0 : print $schema_version
== -1: "no schema installed"
== 0: "module has no schema"

* new function drush_sprint() in includes/drush.inc. This one return the string of each line in the form "key:value" ready to be printed. With custom wordwrap.
If you like it I can reroll this patch or open other issue using drush_sprint() for `status` command.

  Project           : zen
  Type              : theme
  Title             : Zen
  Description       : Zen sub-themes are the ultimate starting themes for
                      Drupal 6. Read the <a
                      href="http://drupal.org/node/226507">online docs</a> or
                      the included README.txt on how to create a sub-theme.
  Version           : 6.x-1.1
  Core              : 6.x
  PHP               : 4.3.5
  Status            : enabled
  Path              : sites/adepsi/themes/zen/zen
  Core              : 6.x
  PHP               : 4.3.5
  Engine            : phptemplate
  Regions           : left sidebar, right sidebar, navigation bar, content top,
                      content bottom, header, footer, closure
  Features          : logo, name, slogan, mission, node_user_picture,
                      comment_user_picture, search, favicon, primary_links,
                      secondary_links
  Stylesheets       :
      media all     : html-elements.css, tabs.css, messages.css,
                      block-editing.css, wireframes.css, zen.css
      media print   : print.css
  Scripts           : script.js

note: php's wordwrap() doesn't wrap html code

jonhattan’s picture

Status: Needs work » Needs review
jonhattan’s picture

StatusFileSize
new9.57 KB

Patch updated to latest HEAD.

A example of `drush_sprint`:

drush eval "print drush_sprint('lorem ipsum', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eleifend tempus neque, eu interdum turpis fringilla sit amet. Nulla vitae leo sed orci ornare viverra vitae quis augue. Nam fringilla purus eu risus varius nec pharetra orci tincidunt. Phasellus tempus viverra ante, sed placerat erat ullamcorper vel. In libero velit, lobortis in pulvinar semper, viverra vitae ligula. Aenean rutrum scelerisque pellentesque. Nunc consectetur nibh a ante condimentum vitae aliquet felis sodales. In hac habitasse platea dictumst. Suspendisse potenti. Phasellus sit amet tempus nisl. Suspendisse et dolor non nisi pharetra pharetra et non tortor. Cras ac metus faucibus urna semper malesuada. Donec consequat feugiat lectus eu egestas. Mauris auctor hendrerit dui, vitae suscipit nisi adipiscing vitae. Maecenas aliquam est vel mauris iaculis quis bibendum est ultrices. Etiam quis orci nec felis iaculis rhoncus consectetur ac leo. ');"
  lorem ipsum       : Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas eleifend tempus
                      neque, eu interdum turpis fringilla sit amet. Nulla vitae leo sed orci ornare
                      viverra vitae quis augue. Nam fringilla purus eu risus varius nec pharetra orci
                      tincidunt. Phasellus tempus viverra ante, sed placerat erat ullamcorper vel. In
                      libero velit, lobortis in pulvinar semper, viverra vitae ligula. Aenean rutrum
                      scelerisque pellentesque. Nunc consectetur nibh a ante condimentum vitae aliquet
                      felis sodales. In hac habitasse platea dictumst. Suspendisse potenti. Phasellus sit
                      amet tempus nisl. Suspendisse et dolor non nisi pharetra pharetra et non tortor.
                      Cras ac metus faucibus urna semper malesuada. Donec consequat feugiat lectus eu
                      egestas. Mauris auctor hendrerit dui, vitae suscipit nisi adipiscing vitae.
                      Maecenas aliquam est vel mauris iaculis quis bibendum est ultrices. Etiam quis orci
                      nec felis iaculis rhoncus consectetur ac leo. 
greg.1.anderson’s picture

I think I prefer Moshe's suggestion in #683942: provide an API to detect the drush version. If you convert pm-info from $output _str.= stuff($key, $value); to $output_array[$key] = $value; and then operate on the array (like drush status does in the issue above), then it is easier to process the info list in other ways -- support different output formats, pass it to other code that might fiddle with it, etc.

moshe weitzman’s picture

Thanks for the example, jonhattan. That does work.

I also prefer the table approach as well. Just like pm-status, do: drush_print_table(drush_key_value_to_array_table($output_array));

jonhattan’s picture

StatusFileSize
new7.05 KB

patch updated to HEAD and changed to tables.

output for D5:

$ drush pm-info garland path
 Project   :  garland                                       
 Type      :  theme                                         
 Status    :  enabled                                       
 Path      :  themes/garland                                
 Engine    :  themes/engines/phptemplate/phptemplate.engine 

 Project          :  path                         
 Type             :  module                       
 Title            :  Path                         
 Description      :  Allows users to rename URLs. 
 Version          :  5.x-dev                      
 Status           :  disabled                     
 Path             :  modules/path                 
 Package          :  Core - optional              
 Schema version   :  no schema installed          
 Requires         :  none  

for D6:

$ drush pm-info garland devel
 Project       :  garland                                                                                               
 Type          :  theme                                                                                                 
 Title         :  Garland                                                                                               
 Description   :  Tableless, recolorable, multi-column, fluid width theme (default).                                    
 Version       :  6.15                                                                                                  
 Core          :  6.x                                                                                                   
 PHP           :  4.3.5                                                                                                 
 Status        :  disabled                                                                                              
 Path          :  themes/garland                                                                                        
 Engine        :  phptemplate                                                                                           
 Regions       :  Left sidebar, Right sidebar, Content, Header, Footer                                                  
 Features      :  comment_user_picture, favicon, mission, logo, name, node_user_picture, search, slogan, primary_links, 
                  secondary_links                                                                                       
 Stylesheets   :                                                                                                        
 media all     :  style.css                                                                                             
 media print   :  print.css                                                                                             
 Scripts       :  script.js                                                                                             

 Project          :  devel                                                
 Type             :  module                                               
 Title            :  Devel                                                
 Description      :  Various blocks, pages, and functions for developers. 
 Version          :  6.x-1.18                                             
 Core             :  6.x                                                  
 PHP              :  4.3.5                                                
 Status           :  enabled                                              
 Path             :  sites/adepsi/modules/devel                           
 Package          :  Development                                          
 Schema version   :  6002                                                 
 Requires         :  menu                                                 
 Required by      :  devel_themer       

D7:

 Project       :  garland                                                                                                     
 Type          :  theme                                                                                                       
 Title         :  Garland                                                                                                     
 Description   :  A multi-column theme which can be configured to modify colors and switch between fixed and fluid width      
                  layouts.                                                                                                    
 Version       :  7.x-dev                                                                                                     
 Core          :  7.x                                                                                                         
 Status        :  enabled                                                                                                     
 Path          :  themes/garland                                                                                              
 PHP           :  5.2.0                                                                                                       
 Engine        :  phptemplate                                                                                                 
 Regions       :  Left sidebar, Right sidebar, Content, Header, Footer, Highlighted content, Help, Page top, Page bottom,     
                  Dashboard main, Dashboard sidebar                                                                           
 Features      :  comment_user_picture, comment_user_verification, favicon, logo, name, node_user_picture, slogan, main_menu, 
                  secondary_menu                                                                                              
 Stylesheets   :                                                                                                              
 media all     :  style.css                                                                                                   
 media print   :  print.css                                                                                                   

 Project          :  devel                                                
 Type             :  module                                               
 Title            :  Devel                                                
 Description      :  Various blocks, pages, and functions for developers. 
 Version          :  7.x-1.x-dev                                          
 Core             :  7.x                                                  
 Status           :  enabled                                              
 Path             :  sites/all/modules/devel                              
 Package          :  Development                                          
 Schema version   :  7001                                                 
 Files            :  devel.module, devel.install                          
 Requires         :  menu      
moshe weitzman’s picture

Status: Needs review » Fixed

Committed. Thanks. Good stuff.

Status: Fixed » Closed (fixed)

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