Provides a new way of integrating BUEditor into a site based upon input formats and finer control over which textareas that BUEditor appears on. Works totally via API with no modification to the core BUEditor module needed.

Project: http://drupal.org/sandbox/HollyIT/1289922
GIT: http://git.drupal.org:sandbox/HollyIT/1289922.git
Drupal 7

CommentFileSizeAuthor
#15 drupalcs-result.txt7.74 KBklausi

Comments

patrickd’s picture

Status: Needs review » Needs work

welcome

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Go and review some other project applications, so we can get back to yours sooner.

Jamie Holly’s picture

Status: Needs work » Needs review

Went through and got these items fixed. If you could recheck, I would greatly appreciate it!

sutharsan’s picture

Code review results of bueditor_plus.module file:

      if (isset($settings['BUEPlus'])) {
        drupal_add_js($settings, 'setting');
        _bueditor_plus_add_js();
      }
  • You use drupal_add_js() to add a javascript file. In Drupal 7 the preferred method in a form context or renderable array context is to use #attached.
  • With _bueditor_plus_add_js() you call drupal_add_js() once. Is this to prevent a js file from being added multiple times? No need, drupal_add_js takes care of that.
/**
 * @file
 */
sutharsan’s picture

Status: Needs review » Needs work

Changing state accordingly.

Jamie Holly’s picture

Status: Needs work » Needs review

Got the file comments in.

I dropped the _bueditor_plus_add_js(); and just moved it into the preprocess function.

#attached won't work here. The problem is that this preproccesor function is called after the page array has started rendering and the HTML head already sent to the browser. I originally did try that route and after a couple of hours of pulling my hair out, figured out what was actually going on to prevent it.

sutharsan’s picture

Status: Needs review » Needs work

The HTML is not sent. Otherwise your drupal_add_js() would not work. As for as I know Drupal sends the full HTML only after it finished rendering.

I see no changes in the other documentation. These may seem silly details, but developers care about code style. It makes code better transferable between developers and with that it supports collaboration.

  • Implements hook_* instead of Implements of hook_*
  • Insert empty lines in the function documentation
Jamie Holly’s picture

Status: Needs work » Needs review

OK got those items fixed (eyes still used to look at 6.x LOL). Sorry about that!

On the attached, that does make sense. Probably output buffering dumping out that messed me up. It still doesn't work though. My guess is it has something to do with it preprocessing on a wrapper. I just set up a bunch of traces in the function as well as drupal_render and it looks like the actual wrapper theme never goes through there, meaning #attached is never processed.

I tried adding the JS into child elements, but those have already passed through drupal_render(0 by that time, so they don't get processed either. Looks like the only way to add js in a #theme_wrapper preprocessor is through add_js (same for css).

True this might only apply to text_format_wrapper as there is some weird stuff going on to actually process that wrapper out in filter.module, especially with moving #description and that. Not really sure if that is by design or an actual bug.

The final solution I came up with was dropping the preprocess idea of adding it in and just adding a new #process function to text_format. That is allowing externals to be added through #attached.

sutharsan’s picture

Status: Needs review » Needs work

Well, the purpose of this review is not to make the best possible module, but to make sure it passes the criteria and to help you learn the Drupal API and the Drupal standards. There is always room for improvement.

If you take care of the documentation I will continue with the review of the other files.

sutharsan’s picture

Code review of bueditor_plus.admin.inc:

/**
 * Main administration page. Overrides the default BUEditor admin page
 */

The comment says the BUEditor admin page is overridden, but you ADD a definition to admin/config/content/bueditor in the hook_menu() implementation. Use hook_menu_alter() instead.

  $rows[] = array(
    '',
    l(t('Add new profile'), $path . '/new'),
  );

Use the Local Action UI pattern for the Add new profile link.

  return confirm_form($form, t('Delete profile :profile', array(':profile' => $profile->name)), 'admin/config/content/bueditor', t('This action cannot be undone.'));
  • ':profile' is not an allowed replacement pattern in the t() function. Use %profile instead.
  • t('This action cannot be undone.') is the default description. It can be omitted.
/**
 * Delivers the confirmation to delete $profile
 *

Tip: prefix this comment with 'Menu callback: '. This makes searching and recognizing callbacks easier.

  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Profile Name'),
    '#description' => t('Give your profile a unique name to easily identify it.'),
    '#required' => TRUE,
    '#default_value' => $profile ? $profile->name : '',
  );

Instead of checking the presence of $profile in every form element (e.g. $profile ? $profile->name : '') Check once if $profile is NULL and define a default profile.

    db_query("UPDATE {bueditor_plus_profiles} SET global=0");

db_query() is not meant to be used for update queries. Use db_update() instead.

  if (isset($form['#profile'])) {
    db_update('bueditor_plus_profiles')
    ...
    drupal_set_message(t('Profile has been updated'));
  } 
  else {
    db_insert('bueditor_plus_profiles')
    ...
    drupal_set_message(t('New profile created'));
  }

Use db_merge() to combine db_update() and db_insert().

Jamie Holly’s picture

Status: Needs work » Needs review

I've done all those changes as well as added a bunch more documentation and a bueditor_plus.api.php file.

On the "Add new profile" issue. I went ahead and changed that menu item to a local action, but I left that actual link in the table as well. The reason behind that is that it follows the UX of BUEditor. I did document that reasoning in the code as well.

sutharsan’s picture

I found some security faults:

  • Output of profile names are not sanitized.
  • Output of text formats are not sanitized.
  • Always sanitize the output! Use check_plain() to display as plain text.
Jamie Holly’s picture

Added those in bueditor_plus_admin() and bueditor_plus_profile_form().

sutharsan’s picture

Status: Needs review » Reviewed & tested by the community

If you want to maintain a CHANGELOG.txt make sure you keep it up to date. Personally I can't. So I rely on the issue queue and git log.

Jamie, thanks for your quick reply's and prompt corrections. To me the module is ready, and complies to standards. I hope you feel more comfortable with the Drupal API and are more aware of Drupal's code style and security.

May your hands always be busy, May your code always be used ;)

Jamie Holly’s picture

Thanks a million Sutharsan!

klausi’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new7.74 KB

Review of the 7.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Go and review some other project applications, so we can get back to yours sooner.

manual review:

  • "php = 5.2.x": drupal 7 core already requires PHP 5.2, so remove that line.
  • bueditor_plus_install(): juggling with module weights is ugly and so Drupal 6 style. I assume that you want to make sure to run your hooks before/after bueditor, in that case you can make use of hook_module_implements_alter().
  • bueditor_plus_update_7001(): please break the array up into several lines, we are used to it like in hook_schema().
  • bueditor_plus_menu(): "access argument" is missing on all your menu items.
  • "drupal_set_message(t('The profile :profile has been deleted', array(':profile' => $profile->name)));": The ":" placeholder does not exist, I think you want "@" or "%" here.
  • "'#title' => 'Global profile',": make sure to run all user facing text through t() for translation.
Jamie Holly’s picture

Status: Needs work » Needs review

Got those changes in. Actually there was access checks on the menu items through the common array. I went ahead and dropped that and just added them in each declaration.

Also dropped the module weight. That really isn't needed now at all like it was in Drupal 6. BUEditor can load after this module as far as it's concerned.

Hopefully the coding is alright. I tried using the online checker but it keeps hanging at 33%.

And wow - didn't notice we are now using param types on documentation! That makes things a lot nicer.

Jamie Holly’s picture

OK just pushed more changes in. I ended up getting pareview working on my local server, which makes life a lot easier. Getting no errors or warnings now.

klausi’s picture

Status: Needs review » Reviewed & tested by the community

Sorry, I overlooked the old common array in hook_menu().

Green lights from me.

zzolo’s picture

Status: Reviewed & tested by the community » Fixed

Hey @Jamie Holly, you now have full Git access. Happy hunting.

Thanks to all the reviewers!

Jamie Holly’s picture

Thanks a million zzolo!

Status: Fixed » Closed (fixed)

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