CVS edit link for mossy2100

I have written a module called Classes, which autogenerates PHP class files for Node, User, Term, DateTimeRange, and any content types that the user specifies. This is done in such a way that all core fields of nodes, users and terms, and CCK fields, are accessible in a very straightforward and object-oriented way. No more $node->field_profile_first_name[0]['value']. Now you can just use $node->firstName. Accessing node reference fields returns actual Node objects, user reference fields return User objects, taxonomy term references return Term objects, and dates or datetimes return DateTimeRange objects.

User objects are integrated with any profiles attached to the user. At present, profiles are supported via the content_profile module, but support for the core profile module is planned. Other additions will include classes for File, Image, Vocabulary and Role.

This module is for module developers (like myself) who need to write programs that work with data models built in CCK. It makes the code much easier to write, much more readable, and faster. Lazy-loading is implemented in the base Node class such that the full node is not loaded unless necessary. This can lead to significant performance improvements when working with large numbers of nodes.

To the best of my knowledge this module does not replicate any existing work. It's the first module that I've prepared for contribution, and would like to see it evolve. I am also planning a D7 version.

Comments

mossy2100’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new51.54 KB

Attached is the first uploaded version of the classes module, which autogenerates PHP class files for Node, User, Term, DrupalDateTime, DateTimeRange, and for any or all content types.

avpaderno’s picture

Issue tags: +Module review

Hello, and thank you 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.

mossy2100’s picture

Thanks kiamlaluno, looking forward to hearing the feedback.

Scyther’s picture

Status: Needs review » Needs work

Please read http://drupal.org/coding-standards and the use http://drupal.org/project/coder to check your code and correct it.

mossy2100’s picture

Status: Needs work » Needs review
StatusFileSize
new101.38 KB

Thanks Scyther

This is done now. The only thing I've retained that coder mentions is substr() instead of drupal_substr(), as it seems substr() is preferred (safer/faster) when the offsets are known.

The attached file contains the latest version of the module. Most changes since the previous upload are improvements to the DrupalDateTime class.

Can someone please tell me, is there a way I can be notified by email when anyone comments on this post?

Thanks!
Mossy

mossy2100’s picture

Hi, please tell me what else I have to do to contrib this module so people can start using it?

Thanks,
Shaun

Scyther’s picture

Status: Needs review » Needs work

1. Don't put "< p >" inside t().

$form['instructions'] = array(
    '#type' => 'markup',
    '#value' => t("<p>Select which classes you want to generate for your content types.</p>" .
      "<p>If the base class already exists it will be overwritten. If the derived class does not " .
      "exist then a stub will be created, but if it does exist it will not be overwritten.</p>" .
      "<p>Core classes for nodes, users, terms, dates, etc. will only be generated if they don't " .
      "already exist, or they need to be updated.</p>"),
  );

2. No, no, no, not a good way.

  // CSS:
  $form['css'] = array(
    '#type' => 'markup',
    '#value' => "<link type='text/css' rel='stylesheet' media='all' href='/".
      drupal_get_path('module', 'classes') . "/classes_generate_form.css' />",
  );

Look at this http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad...

3. Remove commented code.

  // If the base class exists, select it for regeneration by default:
  //    if ($base_class_exists) {
  //      $selected[] = $type;
  //    }

4. Put the outputed text into t(), "Yes", "No" and "Generate".

  $form['class_exists'][$type] = array('#value' => $class_exists ? 'Yes' : 'No');

  $form['base_class_exists'][$type] = array('#value' => $base_class_exists ? 'Yes' : 'No');

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Generate',
  );

5. drupal_add_js() instead!

      // Add some JS:
      $form['js'] = array(
        '#type' => 'markup',
        '#value' => "<script type='text/javascript' src='/" . drupal_get_path('module', 'classes') . "/classes-property-name.js'></script>"
      );

6. Missing CVS header in classes.install.

7. You might want to use check_plain on some text you puts out in HTML.

- - - - -

Havn't checked all the code, so there could be more similar errors in more places so please look over all your code and correct them.

mossy2100’s picture

Thanks Scyther - I only just saw this, for some reason I'm not getting notified when a comment is added.

Thanks for the feedback. I will make the necessary changed.

The problem that I've found with using drupal_add_js() when creating a form is that if validation fails and the form is re-displayed, the JS doesn't get included again. I believe this is because the form array is remembered in a session variable, but any added JS or CSS files are not. So I have developed a workaround for this by simply adding type='markup' elements with the necessary

or tags. I will look for a better solution using drupal_add_css() and drupal_add_js(), but if I've missed anything please let me know. Cheers, Shaun
zzolo’s picture

Component: Miscellaneous » miscellaneous
Status: Needs work » Closed (won't fix)

Hi. Please read all the following and the links provided as this is very important information about your CVS Application:

Drupal.org has moved from CVS to Git! This is a very significant change for the Drupal community and for your application. Please read the following documentation on how this affects and benefits you and the application process:
Migrating from CVS Applications to (Git) Full Project Applications

  • The status of this application will be put to "postponed" and by following the instructions in the above link, you will be able to reopen it.
  • Or if your application has been "needs work" for more than 5 weeks, your application will be marked as "closed (won't fix)". You can still reopen it, by reading the instructions above.
mossy2100’s picture

Title: mossy2100 [mossy2100] » CVS account requested - select_province module
Component: miscellaneous » new project application
Status: Closed (won't fix) » Active
StatusFileSize
new1.41 KB

Hi

I am still interested in contributing code to Drupal. The classes module, which I originally applied with, is still in development, so don't worry about that at the moment. However, I have another small module I would like to contribute called "select_province" - attached.

avpaderno’s picture

Title: CVS account requested - select_province module » mossy2100 [mossy2100]
Status: Active » Closed (won't fix)

This queue is not used anymore. Please see Migrating from CVS Applications to (Git) Full Project Applications, and Applying for permission to create full projects to understand how to proceed.