CVS edit link for fabian.ruiz

Hello.

I'm working in Strabinarius (www.strabinarius.com), a little spanish company that is engaged in making web projects. For last 3 years, we've been doing several projects with Drupal 5 and 6. Some examples, www.circulodelarte.com, www.viajestejedor.com or www.sefac.org.

In these projects, we've developed some custom modules and we'd like to share it with Drupal community.

We have built a quick & mass import/export module of CCK, Views and Imagecache elements. For next future, we want to adapt it to Drush project. We think this module is very useful for working on a development team environment. All members of the team are always updated with last CCK, Views and Imagcache changes.

As well, we have another module with some little functions that could be useful for other Drupal developers.

I'm and my team are interested in maintaining these both modules. In fact, we're doing it on every project we do.

Thank you and regards.

Fabián Ruiz
STRABINARIUS

CommentFileSizeAuthor
#5 briefcase.zip13.64 KBfabian.ruiz
#1 briefcase.zip13.21 KBfabian.ruiz

Comments

fabian.ruiz’s picture

Assigned: Unassigned » fabian.ruiz
Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +CCK, +export, +views, +drush, +import
StatusFileSize
new13.21 KB

I'm glad to send you the first version of our import/export module: BRIEFCASE.

The main goal of this module is to share quickly all your Drupal elements (Views, CCK, Imagecache, ...) with other members of your project development team.

We've been updating this module for last weeks before sending it to you. Now, it includes following features:

  • Just one click to export all your Views/CCK to separated files into a directory path.
  • Just one click to import any Views or CCK file to your Drupal system.
  • Select the Views or CCK you want to mass import/export.
  • Set export and import path and file extension
  • Integration with Drush. You can export/import any Views/CCK from command line.

TODO features:

  • Improve pages with more filters and information.
  • Add export and import functions to other Drupal modules: Imagecache presets; Menus; Vocabularies and terms; Finder's configurations.
  • Add more Drush commands

We're very excited to create a new Drupal project where we can mantain and improve our module. So, it would be very grateful if you give us a feedback.

Thank you very much.

Fabián Ruiz
STRABINARIUS IT

avpaderno’s picture

Assigned: fabian.ruiz » Unassigned
Issue tags: -CCK, -export, -views, -drush, -import +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

The description of your module made me think to the module Features (http://drupal.org/project/features). May you point out the differences between the modules, and eventually why you didn't open feature requests for the existing module?

fabian.ruiz’s picture

Hi. Thank you for replying so quickly.

Yes, we know Features module and we've checked it before. It's great... I think it is a very potential and ambitious project and, of course, our module (Briefcase) isn't so complicated.

In fact, we've used Features for a project, but it wasn't exactly what we needed (or so fast as we'd like).

  • We want to do all exports/imports as quick as possible. We don't want to create one or more submodules (like Features) to achieve it.
  • For our projects, we use to have any View and CCK element into a separated file. It's useful because using SVN, let us to save all changes for every element (Views, CCK, ..) and track version changes. In Features module, all the exports are saved in same file (not separated). One file for Views, one for CCK, ...
  • We'd like to choose the path where every exported file is saved.

In my opinion, Features module is perfect to combine different Drupal elements in just one module. As well, control dependencies is very great. However, we only want to have these elements updated without having to package them.

Fabián Ruiz
STRABINARIUS

avpaderno’s picture

Status: Needs review » Needs work
  1. See the coding standards to understand how a module should be written. In particular, see how the code should be formatted, and how the constants should be written.
  2. 	$vec_items['admin/settings/briefcase'] = array(
    		'title' 			=> 'Briefcase',
    		'description' 		=> t('Briefcase configuration page'),
    

    Menu titles, and descriptions don't need to be passed through t() as that is already done from Drupal core code.

  3. function _briefcase_goto($page)
    {
    	// Redirect to submodule "briefcase_cck"
    	if ( module_exists('briefcase_cck') )
    	{
    		if ($page == 'settings')
    		{
    			drupal_goto('admin/settings/briefcase/cck');
    		}
    		else if ($page == 'export')
    		{
    			drupal_goto('admin/content/briefcase/export/cck');
    		}
    	}
    	
    	// Redirect to submodule "briefcase_views"
    	if ( module_exists('briefcase_views') )
    	{
    		if ($page == 'settings')
    		{
    			drupal_goto('admin/settings/briefcase/views');
    		}
    		else if ($page == 'export')
    		{
    			drupal_goto('admin/content/briefcase/export/views');
    		}
    	}
    	
    	return '';
    }
    

    There is a much simply way to obtain that, and without write all that code. It's enough to correctly define the menu callbacks.
    Actually, that code is not even necessary, basing on how the sub-modules define their own menu callbacks.

  4. if ( !eregi('^\.', $file_extension) )
    

    The code should use preg_match(), as that function has been deprecated in PHP 5.3.

  5. drupal_set_message( t('Cannot create path: ').$directory, 'error');
    

    Use a placeholder.

  6. function briefcase_cck_menu()
    {
    	$vec_items = array();
    
    	// Briefcase CCK configuration page
    	$vec_items['admin/settings/briefcase/cck'] = array(
    		'title' 			=> 'Briefcase CCK',
    		'description' 		=> t('Briefcase CCK configuration page'),
    		'page callback' 	=> 'drupal_get_form',
    		'page arguments' 	=> array('briefcase_cck_settings'),
        	'access arguments' 	=> array('administer site configuration'),
    		'file' 				=> 'includes/briefcase_cck.admin.inc',
        	'type' 				=> MENU_DEFAULT_LOCAL_TASK,
        	'weight' 			=> -10
    	);
    	
    	// Briefcase CCK export form page
    	$vec_items['admin/content/briefcase/export/cck'] = array(
    		'title' 			=> t('Export CCK'),
    		'page callback' 	=> 'drupal_get_form',
    		'page arguments' 	=> array('briefcase_cck_export_form'),
    		'access arguments' 	=> array('access content'),
    		'file' 				=> 'includes/briefcase_cck.admin.inc',
    		'type' 				=> MENU_LOCAL_TASK,
    		'weight' 			=> -9
    	);
    	
    	// Briefcase CCK import form page
    	$vec_items['admin/content/briefcase/import/cck'] = array(
    		'title' 			=> t('Import CCK'),
    		'page callback' 	=> 'drupal_get_form',
    		'page arguments' 	=> array('briefcase_cck_import_form'),
    		'access arguments' 	=> array('access content'),
    		'file' 				=> 'includes/briefcase_cck.admin.inc',
    		'type' 				=> MENU_LOCAL_TASK,
    		'weight' 			=> -8
    	);
    
    	return $vec_items;
    }
    

    The menu definition is not correct; there is a MENU_LOCAL_TASK without a MENU_DEFAULT_LOCAL_TASK.

  7. function briefcase_views_menu()
    {
    	$vec_items = array();
    
    	// Briefcase Views configuration page
    	$vec_items['admin/settings/briefcase/views'] = array(
    		'title' 			=> 'Briefcase Views',
    		'description' 		=> t('Briefcase Views configuration page'),
    		'page callback' 	=> 'drupal_get_form',
    		'page arguments' 	=> array('briefcase_views_settings'),
        	'access arguments' 	=> array('administer site configuration'),
    		'file' 				=> 'includes/briefcase_views.admin.inc',
        	'type'				=> MENU_LOCAL_TASK
    	);
    	
    	// Briefcase Views export form page
    	$vec_items['admin/content/briefcase/export/views'] = array(
    		'title' 			=> t('Export Views'),
    		'page callback' 	=> 'drupal_get_form',
    		'page arguments' 	=> array('briefcase_views_export_form'),
    		'access arguments' 	=> array('access content'),
    		'file' 				=> 'includes/briefcase_views.admin.inc',
    		'type' 				=> MENU_LOCAL_TASK,
    		'weight' 			=> -9
    	);
    	
    	// Briefcase Views import form page
    	$vec_items['admin/content/briefcase/import/views'] = array(
    		'title' 			=> t('Import Views'),
    		'page callback' 	=> 'drupal_get_form',
    		'page arguments' 	=> array('briefcase_views_import_form'),
    		'access arguments' 	=> array('access content'),
    		'file' 				=> 'includes/briefcase_views.admin.inc',
    		'type' 				=> MENU_LOCAL_TASK,
    		'weight' 			=> -8
    	);
    
    	return $vec_items;
    }
    

    The menu definition is not correct, for the same reason I reported before. Then, what would happen if the user enables one sub-module, but not the other? There would be again one MENU_LOCAL_TASK without a MENU_DEFAULT_LOCAL_TASK.
    I would rather use a single module, and define the menu in that module.

  8. 		'#title' 			=> t('CCK - Export Path'),
    

    Strings used in the user interface as title of items should be in sentence case.

fabian.ruiz’s picture

Status: Needs work » Needs review
StatusFileSize
new13.64 KB

Wow. What a great review!! Thanks.

I've checked all 8 steps and updated my Briefcase module with corresponding corrections:

  1. Changed all syntax code following coding standards.
  2. I've also used Coder module to achieve a better code.
  3. Regarding to points 3, 6 and 7. I've removed _briefcase_goto() function of my code and then I've reestructured hook menu function. Now, I think I'm using MENU_DEFAULT_LOCAL_TASK and MENU_LOCAL_TASK in a correct way.
  4. About last comment of point 7. I've been thinking about it... and finally I've decided to use a single module to define all menu path alias, as you suggested. I think code is cleaner, specially hook menu function. Besides, it didn't make sense to install Briefcase module without any submodule. It means, you couldn't export or import nothing.
  5. Other points have been fixed.

I attach here new Briefcase module version. It's important you know that it has some changes from last version. I've been working last week and I could finish Drush integration. It means that new Briefcase version (attached here) has new Drush commands for export and import CCK and Views.

Thanks again for your time.

Fabián

avpaderno’s picture

Status: Needs review » Fixed

Thank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)
Issue tags: -Module review

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

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes