CVS edit link for protyze

Hi,
My name's Jan Azzati. I'm a Drupal Developer at Previon AG. A Swiss enterprise specialized on Content Management and Web portals. We are Drupal fanatic since 2 years now. We realized a lot of web sites using Drupal and I was able to improve my Drupal development skills form project to project.

The Drupal community is outstanding and I’ve been able to solve most of the problems using the fantastic modules that have already been contributed by others. But of course the complexity of our projects always requires some own development.
Now, my motivation behind my request for the cvs account is mainly that I want to participate on the community and would like to share my developments with others who might have a similar problem to solve. This is just one step in my overall plan to be more active in the community (helping in irc or in forums, write a blog, etc…).

In one of our last projects I developed a module called “xml2node” (more details later) which was very useful for us. And I think this module could be useful to others and it also is a good module for my first contribution (I’m excited ;-).
The basic functionality of xml2node is importing data from XML-Files into Drupal. This can be used for a one-time import (for example a content migration) OR for a continuous import on cron (from hot folders).

Now there are some other already contributed modules that can import data. But most of them are optimized for “one-time imports” (Node Import; Migrate; Power Import), most of them only support import from CSV Files or MySQL Dumps. My module is not focused on content migration (although it is very easily possible and also done by us before) but more on providing an interface to import any kind of data either by user interaction or by crawling through hot folders and import the content automatically. So, 3rd party systems could deliver XML files periodically into the hot folders.

Another concept that makes my module different to others is the mapping between the XML-Data and the Content-Type fields. There is no mapping required. In most of the other modules like “Table Wizard” you map the incoming content dynamically to the destination content type. I’m not saying that this is not a cool feature (it really is), but my modules just follows another concept.

The XML Structure must follow a specific structure which is very similar to the structure of the destination node. So the module can get the required content mapping out of the xml structure.

I’ve made a short introduction screencast to present the concept and the features of the modules:
http://www.youtube.com/watch?v=tfU5z6TFmZA

Also you can find a screencast with a demo here:
http://www.youtube.com/watch?v=tfU5z6TFmZA

You can find the sample XML files from the videos here:
http://www.tyze.ch/files/xml2node_sample_xml.tar

And here you can find the module:
http://www.tyze.ch/files/xml2node.tar

Now that you know about the basic principles of the functionality, I’d like to provide some information about the code:
- Import via User Interface is based on the Drupal Batch API
- Import via cron is based on the Drupal Queue module (backport from Drupal 7 Queue functionality)
- A hook is provided
- I followed the Drupal Coding Standards and tested this with the coder module
- I used Drupal Standards, such as hook_menu, the Form API, hook_cron, the t()-Function, etc…
- Whenever possible I used Drupal functions to do basic operations that are also done by standard PHP Functions. (e.g. file_check_directory()).
- The core Logic of the module is implemented using OOP concepts.
- I always tried to code “the Drupal way”. Please correct me if I missed something.

I hope these information give you a basic overview on my contribution. The module is used in a productive system right now, but there are still some improvements I’d like to do in the next couple of weeks (better error-handling, more comfortable CRUD Operations, etc..). I also will add a full documentation on how to use the module as soon as the module is contributed.

Feel free to ask any question about my module or about me.

Thanks in Advance and best regards
Jan “protyze” Azzati

CommentFileSizeAuthor
#6 xml2node.zip12.77 KBAnonymous (not verified)
#1 xml2node_sample_xml.zip1.41 KBAnonymous (not verified)
#1 xml2node.zip12.31 KBAnonymous (not verified)

Comments

Anonymous’s picture

StatusFileSize
new12.31 KB
new1.41 KB
Anonymous’s picture

Status: Postponed (maintainer needs more info) » Needs review
Anonymous’s picture

The link to the demo video is actually the following:
http://www.youtube.com/watch?v=K1XCk6u87gM

avpaderno’s picture

Issue tags: +Module review

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

avpaderno’s picture

Status: Needs review » Needs work
  • The points reported in this review are not in order or importance / relevance.
  • Most of the times I report the code that present an issue. In such cases, the same error can be present in other parts of the code; the fact I don't report the same issue more than once doesn't mean the same issue is not present in different places.
  • Not all the reported points are application blockers; some of the points I report are simple suggestions to who applies for a CVS account. For a list of what is considered a blocker for the application approval, see CVS applications review, what to expect. Keep in mind the list is still under construction, and can be changed to adapt it to what has been found out during code review, or to make the list clearer to who applies for a CVS account.
  1. The version line needs to be removed from the .info file.
  2.     else {
          drupal_set_message(t('Die XML-Datei konnte nicht geladen werden! Überprüfen Sie den Dateipfad.'), 'error');
        }
    
    

    Strings passed to t() must be in English.

  3. The module doesn't implement hook_uninstall().
  4.   // if there are hotfolders defined, crawl them
      foreach ((array) $hotfolders as $hotfolder) {
        $hotfolder = trim($hotfolder);
        if (file_check_directory($hotfolder)) {
          if ($handle = opendir($hotfolder)) {
            while (false !== ($file = readdir($handle))) {
              if (pathinfo($file, PATHINFO_EXTENSION) == 'xml') {
                // add the xml file to array
                $files[] = $hotfolder . '/' . $file;
              }
            }
            closedir($handle);
          }
        }
      }
    
    

    Why isn't the code calling file_scan_directory()?

  5.   if ($success) {
        $message = t('@count Nodes imported!', array('@count' => count($results)));
      }
    
    

    Why isn't the code using format_plural()

  6.   $form['xml2node_filepath'] = array(
        '#type' => 'textfield',
        '#title' => t('XML File'),
        '#default_value' => 'sites/default/files/',
        '#size' => 60,
        '#maxlength' => 250,
        '#description' => t('The path to the XML File you would like to import.'),
      );
    
    

    The default value should be the value used the last time the same form has been used. If users need to use a different value, they would need to enter the value they want to use all the times they use the form.

  7. /**
     * Implementation of hook_form_submit().
     *
     * @param unknown_type $form
     * @param unknown_type $form_state
     */
    
    

    Hook implementation comments should be like the following one:

    /**
     * Implements hook_menu().
     */
    

    The comment doesn't report the parameters used by the hook, as they are already known, and don't change for each implementation of the hook.

  8.   $form['xml2node_hotfolders'] = array(
        '#type' => 'textarea',
        '#title' => t('Hotfolders'),
        '#default_value' => variable_get('xml2node_hotfolders', ''),
        '#rows' => 4,
        '#description' => t('Add Hotfolders to be crawled on crun (each line, one path relative to the base path)'),
      );
    
    

    Crun?

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new12.77 KB

hi kiamlaluno,

first I want to thank you very much for reviewing my module and giving me feedback. i made some other improvements (performance, etc...) together with your points so it took me a little bit longer.

Thoughts to your reported points:

1: done
2: all english now
3: the module cleans now up
4: thanks for that hint. using it now at several points! also in other projects.
5: corrected on multiple code sections
6: corrected
7: corrected
8: typo. corrected :-)

find attached the corrected version of the module.

Thanks in advance for reviewing it again.

best regards.

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Needs review » Fixed

Thank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
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
Issue summary: View changes
avpaderno’s picture

Status: Closed (fixed) » Fixed

I am giving credits to the users who participated in this issue.

Status: Fixed » Closed (fixed)

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