In the ongoing (and Acquia sponsored :) quest to sprinkle Drupal with more and better input format support, this patch moves some custom settings to good old blocks. The observation is the following:

- there is a custom help display mechanism for help texts
- there are two help-like settings which are displayed above the user registration and contact forms

By adding a new "help" region (which instantly works with all themes due to that creating a $help variable in themes, which we don't need to create ourselfs), we can add blocks to the help region. This allows people to

- add custom help to any pages
- sharing the same help text among different pages
- add role dependent / specific help to any page
- have full input format support while authoring these help texts

This is a huge chunk of helptip module right in core by just making the help display a block region and allowing people to put blocks there and also provides format support for two "settings" which are moved to custom blocks on Drupal upgrade.

(I also think that blocks like the site_mission and footer_message should be made blocks, but that's going to be a different patch, let's get this in first).

The upgrade path is not tested, so it needs testing, the functionality itself is click-tested.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

BTW I introduced a non-numeric delta for the default help block in anticipation that this great patch gets in: http://drupal.org/node/216072 sooner or later :)

Ps. discussion of the above approach on the devel list at: http://lists.drupal.org/pipermail/development/2008-February/thread.html#...

keith.smith’s picture

I haven't tested this yet, but from a casual inspection this looks fantastic. +++1

By making help text blocks, in addition to the other positive points noted by Gábor, we also automatically gain, for free:
- the ability to selectively display (or not) help text by role, using the standard role/block ui.
- the ability to set the display of a help block as user configurable, and then allow a user to turn off help using her My Account page.
- the ability to set custom PHP code that controls the display of a help block, like automatically hiding it when the system is running in system_admin_compact_mode() from someone having pressed the "Hide descriptions" link.

floretan’s picture

This patch looks pretty good and works fine. Just a few comments:

The block does not depend on the help module, but the page linked to by the 'more help' link does. Where is the distinction? Shouldn't this help block be handled in help_block() instead of system_block()?

The notification messages set with drupal_set_message() are also help messages (although they are activity dependant rather than location dependant), and are generally displayed at the top of that same "help" region. Could these be turned into a block as well?

keith.smith’s picture

Status: Needs review » Needs work
FileSize
24.4 KB

The patch is great. I tried out most everything I could think of, and really like the new functionality of help-as-block.

A couple of things:

  1. As Gábor noted in his initial post, the upgrade path is not quite right. In particular, if this is a new installation of Drupal, and one has perhaps never installed contact module, then the custom block for contact module never gets created. In my installation, the custom block for user/register information was not created either. Obviously, if this happens, you have no way of editing site-wide contact page information or user/registration headers, until you create the custom blocks manually. I guess the .install routines for system and contact modules should create these custom blocks. I'm unsure what should happen if contact module is later disabled -- the block should also be disabled (and deleted if not modified?) perhaps.
  2. There were a number of instances in the help text that must be modified to conform to this change. In particular, references in the help text to providing additional contact information must be modified. Additionally, we should add some help in both user module and blocks module to explain this new use of custom blocks.
  3. There were one or two comments not ending with a period, not due to this patch, but this patch moves them.

The attached patch, which I am setting to "needs work" since I know that it does, addresses points 2 and 3, but not 1.

Gábor Hojtsy’s picture

flobruit: well, indeed, we might be better off having the help block in help module after all :) Although right now the display of page help is not dependent on help module being turned on, that would be a change, but it might be very much a logical change.

keith.smith: That the blocks are not there does not stop you from setting up anything else in connection to the user registration or contact page. I envision an "Add help block" link in the help region on all pages when you have the permission to add blocks (or an "Add block" link in all block regions), which might be displayed and hidden dynamically (as in panels module). I'd say that helps a lot with adding page dependent help text. The user registration help and contact module help are just two examples, which could still be served by pre-setup blocks, if there is an interest in there.

catch’s picture

Moving help into blocks and regions makes a lot of sense. I'm not convinced about using 'boxes' as a storage method though.

If we stored help text in it's own table, could have a single help block (or two/three) which displays stuff conditionally based on path/module etc. then it ought to be easier to do import and export on it, integrate with localisaton etc.. Otherwise we could be looking at dozens of help blocks in the admin interface and you'd have to set up permissions and rules for them all individually alongside all the other blocks.

If help has it's own storage, could also have a flag for "inline" or "block" for help texts - so you could programmatically add help text to fapi elements etc as well as to whole pages, configure it to be collapsed, popup, etc. etc..

I haven't actually tested the patch though so might be making some false assumptions.

edit: having said that, site missions, footer etc. as 'boxes' sounds great. Just not sure about storing help in there.
edit again: custom data storage would also let us write hook_search and have search/help etc.

Gábor Hojtsy’s picture

catch: Well, as usual, core could provide a simple solution, which might not scale as much (think core's caching, mailing layers). There are just two custom "help blocks" defined by core by default, and there is one dynamic help block which is always the help hook's return value. A contrib module could provide a different storage mechanism for people who would like to add a sizable number of help texts, but for a small number of help texts, as core supported so far, this method is IMHO nice and simple. I'd say it is unlikely that a help editor module would get into core, but making the help spot on the page a region makes it possible for a contrib module to define help for that region and have it weighted/ordered properly.

Ps: site mission and footer message as blocks will be a different issue/patch to keep this one focused. :)

catch’s picture

I don't think I looked at this closely enough. For some reason I thought this was the beginnings of moving hook_help() stuff into boxes, which seemed weird ;) Refactoring hook_help is a whole different issue, but the one dynamic help block displaying output from it is a great first step. As is moving the contact text into a box instead of the variables table, which makes loads of sense.

Just for clarity, I'm not talking about a help editor module in core, just a flexible enough API which would allow for such a module to exist cleanly (i.e. not boxes!). Fortunately that's a completely separate issue, so in general +1 from me and sorry for the confusion!

Gábor Hojtsy’s picture

Thanks catch for your opinion. So we need to look at at least #4/#5 and get more reviews.

Gábor Hojtsy’s picture

Screenshots of how this works to spur up some interest.

keith.smith’s picture

In terms of interest, I think this is a great patch, as I've mentioned before.

It seems we need to address at least:
- installing the contact help and user registration help custom blocks by default on install (or enable of contact module). (I think that the current patch will only create these blocks if text exists for either contact module or user registration help in the variables table, and without the default installation, I'm not certain how the default text gets into the block.)
- determine whether the contact help should go away when contact.module is disabled.
- review the help text added in the patch in #4 to make sure it accurately represents these changes.

gautams’s picture

Version: 7.x-dev » 6.3
Component: block.module » other
Category: task » support

Hi ,

I want to display help text for my site pages is specific help block that may appear in the right side column say.I have a module say 'x' which has 2 different menu router paths.

So,I did the following:
- I merge the above patch.
- In my module write a update hook which adds a block to the blocks table for my theme and a sentence in the 'boxes' table.
- Add a hook_help in which I mention the paths for my module.

I disable,enable and install the new update(which i wrote above).

- The block with the text do appear but the when goto menu paths,the help texts doesnot appear in the block

So,here are the missing links I want to know:
- how the patch links the my hook_help to the custom help block I have generated.The patch doesnot seem to have any info!!??

Gábor Hojtsy’s picture

Version: 6.3 » 7.x-dev
Component: other » block.module
Category: support » task

This patch is an issue is against Drupal 7.x, so please do not hijack it. Moving back to where it was.

gautams’s picture

I'm sorry for mistakenly putting in 6.3 thread.

However,do you have any suggestion for the type of requirement I'm trying to materialize?!?

sun’s picture

+1

However, needs a re-roll. Some issues in the update function are obvious; I can fix those after it has been re-rolled.

sun’s picture

Issue tags: +wysiwyg
Gábor Hojtsy’s picture

Keith et al: is there interest in this given how the help system is being reworked for Drupal 7?

yoroy’s picture

Issue tags: +help system

Subscribing, this still is interesting and relevant to how we can provide useful inline help.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
11.96 KB

Rerolled! Please evaluate and test (again).

Gábor Hojtsy’s picture

FileSize
11.96 KB

Tested myself and it still has all the cool features working as shown on screenshots in comment #10 above. Found one curly brace pair missing in the upgrade path code. Fixed patch attached.

Status: Needs review » Needs work

The last submitted patch failed testing.

JohnAlbin’s picture

Looking at d7's new page.tpl.php, I see that $help comes right before the $content variable. If we made $content a region, having help be a region too seems redundant too me. That, of course, is completely dependent on #428744: Make the main page content a real block actually being committed.

Gábor Hojtsy’s picture

Hm, well, I worked with the assumption that the "help region" has some kind of special styling in core themes even. It was wrapped with a div class="help" before this patch. But by the looks, Drupal core does not seem to have any special styling for this div. Hrm.

Then I guess, for core themes, the argument of semantic separation remains. Is help part of the content that should be put into the main content region? Why Drupal messages are not there then? :)

Having help its own region makes you be able to do things like make font smaller there in all blocks (that is what many themes do). I've also seen themes which hide the help with JS and provide you a click to roll the help text down to read. Not having a container marking these blocks as "help" blocks would not make it possible to style them in a group as such. I don't want us to loose the "this is the help area of the page" functionality.

For the core themes, it looks like it does not matter in terms of looks, only in terms of semantics. For contrib themes, having a help region would be useful. Maybe leaving this in core is also an example for contrib themes of a good possibility. Anyway, I am not completely sure on what exactly should be in core themes, so let's discuss.

dvessel’s picture

This looks good but I have one concern with moving everything into blocks. There will be so many blocks to deal with. It's already a problem with complex sites and this would make it even noisier in the block config page.

This is off-topic but if each block had the ability to tag or classify itself on what type of content it's pushing out, it would allow filtering. Maybe even allow all the block visibility settings for a given type of block. Taxonomy on blocks? Maybe not but you get the idea.

tstoeckler’s picture

dvessel, that's a valid concern, but the flexibility this would allow by far outweighs this, IMO.
Improving the blocks page is something crucial, though.
Jeff Noyes mocked up something a while ago, which goes in the direction Lullabot is heading with the new Buzzr project.
While I wholeheartedly hate the current admin/build/block, what Gabor outlined above really makes my head spin (in a good way).

catch’s picture

If we have a problem with blocks administration being overloaded by too many blocks, which I agree is a problem, then we need to look at ways to make block admin scale better. That's not a reason for core to provide less blocks - the interface is fine when you just have core running.

In terms of moving custom help texts to custom blocks - if the idea is that we essentially remove the feature of custom help texts from those modules and provide this as an upgrade path, then that sounds great to me. And if that's the case, then I think it scores against a specific 'help' region - for system provided help, themes can just as easily style #block-help as a help region, or add their own styled help region themselves. The main question then is where to put the help block in the upgrade path.

Gábor Hojtsy’s picture

@catch: the upgrade path is already in the patch. The problem is that we have (a) module generated help (b) possibly a custom help block for the user registration pages (c) possibly a custom help block for the contact page. This is three blocks. It is not a #block-help, it is a #block-system-help, a #block-custom-5 and a #block-custom-6 (example numbers). Therefore the thinking that we need a region to style and script these consistently, see examples of styling and scripting for help blocks above.

If we'd need to put all the help into one block, then we'd need to make up our own editing interface for it as well as our own visibility for the individual help settings on that custom UI. While obviously all this is done on the blocks level. We just need to let them live as individual blocks and there are all the tools.

catch’s picture

A new Drupal 7 site is going to have neither of these blocks, and the forms in user and contact modules have been removed - so on install you'd get a single help region with a single help block. I don't think the fact that two core modules decided to re-implement the custom blocks system using hook_help() in c.2004 is a sufficient reason to make a separate help region.

There's nothing intrinsic to the contact and and user registration blocks created in the upgrade path that identifies them as help - apart from the fact the content used to be in a variable + hook_help() prior to the patch. I don't think that's a problem, and we could just let them live on as custom blocks on existing sites. Having said that, I'm not opposed to a new region, I just want to examine the reasons for one carefully, and these two blocks doesn't seem like enough.

Should the code to enable the block should also be in help_enable() as well as the core profiles?

Additionally - once this is in, do we want to look at moving node type help to blocks in a followup patch? That's another ugly use of hook_help() which should really go and die, and requires all kinds of ungodly things in i18n module to make it translatable.

Gábor Hojtsy’s picture

Agreed that anything using hook_help() to display dynamic stuff should instead be blocks based.

On the help region, I hate to spend time repeating myself, but looks like this slipped your attention. I've also called out themes, which make **the help blocks** text size smaller, the help area collapsed by default via JS, the help area styled to have a help icon on top, etc. All these require knowledge on the "help area" or "help region" on the site. These all don't make Garland or any other core theme enforced to have a help region (since they don't have any special styling for the help blocks as of now), but it helps to set a standard for contrib themes IMHO.

catch’s picture

Didn't slip my attention, I just don't think core needs to support or suggest this for custom blocks at all - but I'm more interested in the patch getting in than this detail, so will support consensus in either direction.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
13.85 KB

Updated patch fixes tests which were checking for the now removed feature. Should hopefully make all tests pass, so we can proceed with this to the core committers.

Status: Needs review » Needs work

The last submitted patch failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
13.85 KB

Ok, uhm, I should actually run the tests when I modify them, so I can ensure that what I thought would work would actually work. Here is a corrected version.

Status: Needs review » Needs work

The last submitted patch failed testing.

Dries’s picture

Despite the test failing, I think this is a nice clean-up. As far as I'm concerns this can be marked RTBC once the test succeed.

One minor nitpick was the wording of "System generated help for page" -- I felt that "for page" sounded a little bit forced but I'm not native English. It is something we can revise. Like permissions, it would be nice if we had some additional description for each block on the block administration page. But as suggested by catch, that's another issue.

Dries’s picture

Issue tags: +Favorite-of-Dries

Tagging it.

catch’s picture

I'd probably just call it 'system help'.

David_Rothstein’s picture

Nice stuff. I've rerolled the patch (attached) so it now applies to the latest HEAD.

Some comments:

  • These variables used to display with filter_xss_admin(), but in the upgrade code they are switched to the default text format, so for some sites, the formatting will break when they upgrade from D6, right? I've struggled with the exact same issue at #391924: Use Fields to store text variables, especially those that require text format support, so would love to know the right way to deal with it :) Maybe it should just be as simple as printing a note somewhere documenting that fact that the format changed?
  • Is there any reason the update function can't delete the 'contact_form_information and 'user_registration_help' variables once it's done with them?
  • Seems to have been discussed a bit above, but I'm not sure I understand what (if anything) the resolution was: Shouldn't the default install profile (and contact.install in the case of the contact module) insert these blocks upon installation so that people who want them don't have to create them themselves?
  • I agree with @catch that "System help" is best...
Gábor Hojtsy’s picture

@David_Rothstein: You are spot on with the formats issue. Well, it could also happen that it moves from a HTML based format (filter_admin_xss()) to a bbcode or markdown based format, where HTML might even be disallowed. So we should probably print a message on upgrade that this change happened.

Yes, we can remove the variables, no reason not to.

The reason we do not create the contact or user registration help blocks is that they were just special cases. One could argue lots of other places where such a help block would be useful. The fact that previously the user registration and the contact page where special cases does not mean we should keep them as such. That would increase the blocks clutter for people, who don't want these help texts.

Doing the system help block rename, the variable deletion and the message on update. Going to follow up with a patch soon.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
14.63 KB

Attached patch fixes the following:

- renames block to "System help"
- removes variables after migration (even if they were empty)
- adds message to both migrations on the consequences of format change

Gábor Hojtsy’s picture

Updated migration path based on findings from #428744: Make the main page content a real block and #428800: Convert mission statements to a region with blocks. The basic rule is that the blocks should not be added to all themes, but only to themes, which have at least one block stored in the block table. Themes which have no block records there were never enabled, and will copy over all blocks from the default theme, when enabled. If we put in this single block, the copying over of the other blocks will not happen, so we cripple the experience later. Therefore we should check whether there was any block record and only act for themes, were there were.

The other problem with the upgrade path was that the contact and user help block records were always added, even if the boxes (custom help blocks) were not created. This break the data, since we'd reference nonexistent blocks. The intent of the upgrade path is to migrate data, so we should not create blocks if there is no data to create blocks from.

These two issues are hopefully solved in this patch (untested). The final simple change is that the migrated user registration help block will be called "User registration guidelines", just like the predecessor setting. It sounds better then "User registration help". The message text also referred to the guidelines block.

Dries’s picture

Status: Needs review » Reviewed & tested by the community

This patch looks ready to me. Marking it RTBC -- will commit it later today unless someone disagrees.

catch’s picture

I didn't run the update path, looks like Gabor didn't either judging by comments in #41, so I'm assuming Dries did before setting RTBC ;)

One code style nit, otherwise looks great to me too:

+    case 'help':
+      return array(
+        'subject' => NULL, // Don't display a title

Missing a period, not sure what our convention is for comments within arrays. Could be fixed on commit so not changing status.

Dries’s picture

Status: Reviewed & tested by the community » Needs review

I didn't actually test the upgrade path, and I missed Gabor's comment about not having tested it either. I did a code review of it, and that looked good. Setting back to 'needs review' so we can test the upgrade path more thoroughly.

Gábor Hojtsy’s picture

FileSize
17.36 KB
105.53 KB
109.97 KB
60.61 KB

I was called on #428744: Make the main page content a real block to DBTNG-ify the new and changed database related code (ie. upgrade path and install code). Since my three active patches around this area touch the same install code, I am going to attempt the DBTNG-ification here first and get back to rerolling the other two patches once this is committed. Marked #428744: Make the main page content a real block and #428800: Convert mission statements to a region with blocks postponed on this.

Attached patch is a result of several tests and DBTNG related changes.

- Used DBTNG syntax in update function: foreach instead of while/fetch, db_insert() instead of db_query() (although I wish I'd be able to use update_sql(), but the standalone DB escaping functions were removed, so we cannot escape text for update_sql())
- Fixed update bug where $bid_max was a result set, not an actual number value.
- Added links to messages printed out, so users can go to the created blocks directly. Similarly done in other messages in other update functions.
- Fixed update bug with Drupal not recognizing the new help region, since we did not run the theme rebuilding (now we do)
- Fixed catch's nitpick: moved "Don't display title" comment above array and added dot after comment.
- Converted block creation in both install profiles to DBTNG syntax.

I've tested a straight upgrade from a Drupal 6 HEAD installation. All three help blocks migrated great. The two custom help blocks got their path restrictions set right too. (I did notice that Drupal 7 does not enable the Management block on upgrade, so it was considerably harder to manage the upgraded site, but that is a bug totally outside of the scope of this patch). Two pictures from the upgrade:

I also tested fresh Drupal 7 installation. The blocks were created great (only one help block obviously, as intended). The installer reported 5 mysterious notices at the end however.

These are notices with lines in the code, where it says:

      'region' => 'left',
      'pages' => '',
      'cache' => -1

The notice is on the line with 'cache', but from the message, it looks like having some gripe with the empty string on the previous line. I have no idea how it thinks it is a constant with an empty name. I am totally puzzled by that.

Other then these misterious notices, everything seems to work for me (fresh install & upgrade path included).

Status: Needs review » Needs work

The last submitted patch failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
17.35 KB

Ok, turns out that mysterious undefined empty constant bug was a whitespace looking but not-actually-whitespace stuff around the 'cache' key line. Rerolled without those chars and now all works fine even on install. If others find this working, I hope this is RTBC.

Gábor Hojtsy’s picture

Looks like this also solved the new testing errors which were all due to these notices. Superb. Any human reviewers? :)

Dries’s picture

Status: Needs review » Fixed

I reviewed this patch and it looked good. This is very exciting, IMO. Committed to CVS HEAD.

chx’s picture

Status: Fixed » Needs work

There needs to be upgrade information. At least in the theme handbook.

Gábor Hojtsy’s picture

Status: Needs work » Fixed

Basically, $help contains something a bit different. Not sure it warrants documentation, but I'd like keep people in the clear on what is happening, so added this to the D6 -> D7 theme upgrade docs at http://drupal.org/node/254940#help-region

<h3 id="help-region">$help became a region</h3>

In Drupal 6, themes used the $help variable in page.tpl.php to output help text for the page. In Drupal 7, this variable now contains a whole region with help blocks. As with Drupal 6, a page might not have any help. In the same case in Drupal 7 this region will be empty for the page. Administrators will be able  to put any number of help blocks into this region, possibly configuring page visibility to limit their scope.

If you used $help as in the default template in Drupal 6, you probably don't need to do anything.
webchick’s picture

Status: Fixed » Needs work

Let's get a CHANGELOG.txt entry as well.

Gábor Hojtsy’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
708 bytes

Cool, here is one. Since we are about to gain several similar improvements for other things (missions, footer message, content region, etc), I've added a full section right away. I believe this is pretty simple to commit.

Also, upon the call on the content type help from catch, I've opened #448784: Migrate content type help to custom blocks which should be the follow up to that.

Status: Reviewed & tested by the community » Needs work

The last submitted patch failed testing.

catch’s picture

Status: Needs work » Reviewed & tested by the community
sun’s picture

Status: Reviewed & tested by the community » Needs work

Huh? How could this be committed?

function contact_menu() {
  $items['contact'] = array(
    'title' => 'Contact',
...
-    $contact_form_information = $this->randomName(100);
-    $edit['contact_form_information'] = $contact_form_information;
@@ -82,7 +80,7 @@ class ContactSitewideTestCase extends Dr
-    $this->assertText($contact_form_information, t('Contact form is shown when there is one category.'));
+    $this->assertText(t('Contact'), t('Contact form is shown when there is one category.'));

"Contact" is the page title - this does not assert there is a form.

+function system_update_7021() {
...
+    $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('system', 'help', '". $theme->name ."', 1, 0, 'help', '', 1)");
...
+      $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '". ($bid_max + 1) ."', '". $theme ."', 1, 5, 'help', 1, 'contact', -1)");
...
+    drupal_set_message('The contact form information setting was migrated to <a href="'. url('admin/build/block/configure/block/' . ($bid_max + 1)) . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
...
+      $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '". ($bid_max + 2) ."', '". $theme ."', 1, 5, 'help', 1, 'user/register', -1)");
+    }
+    drupal_set_message('The user registration guidelines were migrated to <a href="'. url('admin/build/block/configure/block/' . ($bid_max + 2)) . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');

Wrong string concatenation.

+function system_update_7021() {
...
+  // Rebuild theme data, so the new 'help' region is identified.
+  system_theme_data();

Reminds me of #305653: Themes disabled during update. This will most probably disable all themes.

+  $blocks['help'] = array(
+   'info' => t('System help'),
+   'weight' => '5',
+  );

Wrong indentation.

       return $block;
+    case 'help':
+      return array(
+        // Don't display a title.
+        'subject' => NULL, 
+        'content' => menu_get_active_help(),
+      );
+      break;
     default:

Missing blank lines between switch cases. Also, // Don't display a title. is obvious from the next line; we should document the why's and how's or just omit the comment for the obvious.

   $form = array();
 
-  // Display the registration form.
-  if (!$admin) {
-    $form['user_registration_help'] = array('#markup' => filter_xss_admin(variable_get('user_registration_help', '')));
-  }
-
   // Merge in the default user edit fields.
   $form = array_merge($form, user_edit_form($form_state, NULL, NULL, TRUE));

array_merge() is superfluous now.

 function default_profile_tasks(&$task, $url) {
...
+  // Enable 5 standard blocks.
+  $values = array(
+    array(
+      'module' => 'user',
+      'delta' => 'login',
+      'theme' => 'garland',
+      'status' => 1,
+      'weight' => 0,
+      'region' => 'left',
+      'pages' => '',
+      'cache' => -1
+    ),
+    array(
+      'module' => 'system',
+      'delta' => 'navigation',
+      'theme' => 'garland',
+      'status' => 1,
+      'weight' => 0,
+      'region' => 'left',
+      'pages' => '',
+      'cache' => -1
+    ),
+    array(
+      'module' => 'system',
+      'delta' => 'management',
+      'theme' => 'garland',
+      'status' => 1,
+      'weight' => 1,
+      'region' => 'left',
+      'pages' => '',
+      'cache' => -1
+    ),
+    array(
+      'module' => 'system',
+      'delta' => 'powered-by',
+      'theme' => 'garland',
+      'status' => 1,
+      'weight' => 10,
+      'region' => 'footer',
+      'pages' => '',
+      'cache' => -1
+    ),
+    array(
+      'module' => 'system',
+      'delta' => 'help',
+      'theme' => 'garland',
+      'status' => 1,
+      'weight' => 0,
+      'region' => 'help',
+      'pages' => '',
+      'cache' => -1
+    ),
+  );

Missing trailing comma after last array elements ('cache').

Gábor Hojtsy’s picture

Great, thanks for the core review.

- Test: right, do you have a better suggestion then?
- Strong concatenation: you know, good D6 habits :)
- The system_theme_data() call I stole from D5->D6 update functions (two of them used it). I've looked deeper into the code now and not sure it would disable themes at its current code, but we can go and use _system_theme_data() instead as the linked patch does.
- Right on with the indentation.
- I don't see http://drupal.org/coding-standards requiring blank lines inbetween switch statements. I've just counted 4 functions in the system.module file only which have tight switch statements without blank lines even before this patch. Such as system_help().
- "Don't display a title" removal I can agree with. Again was copied over from the block just right above the one the patch introduced. Same uselessness applies I guess, so both to be removed then.
- array_merge() superfluousness: right!
- commas: right!

sun’s picture

Better suggestion: Any unique string on the contact form page that asserts there is a contact form. For example, t('Your e-mail address').

Coding standard for switch statements is documented as direct example snippet only without further explanation. That snippet uses blank lines between case/default statements, and that's also the style we're trying to foster throughout core.

Gábor Hojtsy’s picture

As soon as the coding standards is updated to require empty lines between switch statements, I am happy to factor that into the patch. Until then, I'm happily following existing code. I've seen huge patches fixing up indentation, line ending spaces, concatenation, etc. so we follow the core example. In this case, I am also following the core example not to include the newlines. If the coding standards is different then that should at least be documented. Every other code example has such details spelled out, so there are no such questions.

Other then that, I am going to work on a follow up patch to fix up the mischiefs here.

chx’s picture

Status: Needs work » Fixed

I edited that quite a bit.

chx’s picture

Status: Fixed » Needs work

opsie i followed up on #51 -- the issue got commented heavily since i was here.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
11.06 KB

Attached patch attempts to solve almost all of the issues mentioned by @sun except the switch/case spacing, which is not in our coding standards:

- Added CHANGELOG entry as requested by webchick.
- Modified tested string to identify displayed form to @sun's suggestion.
- Hopefully fixed all concatenation issues in system_update_7021().
- Call _system_theme_data() instead of system_theme_data() to avoid turning off themes, as the above linked issue explains.
- Fixed whitespace in system_block_list(); also removed a useless comment from existing code which was not spotted by @sun.
- Removed duplicate useless comment from existing and new code in system_block_view(); also reworked the returned array to use the $block[]... format instead of just return array(...). The latter I think is nicer, but existing code uses the other, so better be conformant.
- Eliminated useless array_merge() in user_register().
- Added end of array commas in default_profile_tasks() and expert_profile_tasks().

Reviews are welcome.

sun’s picture

Status: Needs review » Needs work
     case 'powered-by':
       $image_path = 'misc/' . variable_get('drupal_badge_color', 'powered-blue') . '-' . variable_get('drupal_badge_size', '80x15') . '.png';
-      // Don't display a title.
       $block['subject'] = NULL;
       $block['content'] = theme('system_powered_by', $image_path);
       return $block;
+      break;
     case 'help':
-      return array(
-        // Don't display a title.
-        'subject' => NULL, 
-        'content' => menu_get_active_help(),
-      );
+      $block['subject'] = NULL;
+      $block['content'] = menu_get_active_help();
+      return $block;
       break;
     default:

Either return or break to terminate a switch case, but not both. That has nothing to do with coding standards.

The rest looks much better now, RTBC after this remaining fix.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
11.1 KB

I'd say having a "break;" at all times in a "case:" where we do not intentionally avoid it is good practice for later edits, so adding in an if() or something would not let the switch() follow on to the next "case:". There was actually one code flow issue which was just fixed in Drupal 6.11 and appeared in 6.10 due to the same type of modification. This is for the same reason that we put commas at the end of arrays.

Anyway, I am fine with not putting in this safety net here, if that is how it should be. I have more important patches to put my time into.

sun’s picture

Status: Needs review » Reviewed & tested by the community
Dries’s picture

Status: Reviewed & tested by the community » Fixed

Awesome review, sun! Thanks. Committed to CVS HEAD.

JohnAlbin’s picture

In the d7 theme upgrade docs, I added text about needing to define the help region line in the .info file of a theme that overrides the default regions. Otherwise, the $help variable would be undefined in that type of theme’s page.tpl.php template.

Gábor Hojtsy’s picture

@JohnAlbin: thanks.

@catch: Migrating the content type help would require (finally) implementing content type specific visibility for blocks in core. See more at http://drupal.org/node/448784#comment-1550996 and join in there.

Status: Fixed » Closed (fixed)

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

Dave Reid’s picture

Wow...this patch left lots of goodies that no longer exist like "Customize the contact page with additional information (like physical location, mailing address, and telephone number) using the contact form settings page."

:(

Dave Reid’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Needs review
FileSize
4.2 KB

Follow to remove the references to the non-existant contact information setting.

Gábor Hojtsy’s picture

You mean updating the help text :) I'd say we'd rather document people can add tips via a help block. Or maybe it is too general we should not bother documenting it here?

catch’s picture

Status: Needs review » Needs work

No longer applies but this hunk of help text is till in HEAD.

sun.core’s picture

Priority: Critical » Normal

We definitely want the remaining help text correction, but that's not critical.

yoroy’s picture

Version: 7.x-dev » 8.x-dev
benjy’s picture

Issue tags: +Novice

Tagging novice for core mentoring.

axlroach’s picture

Status: Needs work » Fixed
Issue tags: -Novice
FileSize
133.8 KB

This patch no longer applies, and it appears that the help text for the contact module has been completely re-written.

benjy’s picture

Status: Fixed » Closed (works as designed)