Ok, first try. All settings are now per content type, and the global settings page is removed. We can ad it back if we need it again.
I changed $node to $node_type in _advpoll_get_mode() to be able to call it easier from advpoll_form_alter, and as I see it the full node object is not needed. That function is a bit hackish. I once added a check to _advpoll_list_modes() to see if the mode was listed, but I removed it again for performance reasons.
Removed "default" from variable names and constants since the variables are renamed anyway, and "default" redundant. It would be nice with an upgrade path for the previous default settings, or we should at least delete the old variables. Chris, could you help me with that?
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | advpoll_default_2.patch | 12.92 KB | anders.fajerson |
| #8 | advpoll_default_1.patch | 12.89 KB | ChrisKennedy |
| #2 | advpoll_default_0.patch | 11.96 KB | anders.fajerson |
| advpoll_default.patch | 11.87 KB | anders.fajerson |
Comments
Comment #1
ChrisKennedy commentedThis is awesome!
A few small things:
* The algorithm description needs to be translated (as does the original, apparently).
* For me, the new settings show after the "save content type", "reset to defaults" buttons, and aren't collapsible. Is a cache clear required or something?
* Need to uppercase that "false".
And yeah, I'll help with the settings upgrade path.
Comment #2
anders.fajerson commented1. Fixed
2. I can't see this. Would be great if you could do some digging.
3. Coder module once told me that "false" was faster than "FALSE". But a search in HEAD reveals that FALSE is the one used. Fixed. (some other places still exists, but that's for a code style patch).
Comment #3
ChrisKennedy commentedOkay I found out that the collapsible part is due to a javascript error or something unrelated.
The ordering problem continues to exist though. The code does seem to be the issue here - advpoll_form_alter() is inserting $form['advpoll'] after $form['submit'] and $form['reset'] have already been created in node/content_types.inc. I don't see how you wouldn't also be experiencing this, hopefully I'm not crazy.
For me this code fixes the ordering by moving $form['submit'] & $form['reset'] after $form['advpoll'].
Or maybe you could use weighting.
Comment #4
anders.fajerson commentedThat should not be needed. Are you sure you are using a clean checkout of Drupal-5? If you print the form:
You see that submit has a weight of 40 and reset a weight of 50:
Comment #5
ChrisKennedy commentedAhhh ok I figured it out - I'm only partially crazy. I was accidentally running DRUPAL-5-1 rather than DRUPAL-5, and the buttons didn't get weights added until after 5.1 was released: http://drupal.org/node/111537
So the weights have only existed in a released version of Drupal since 5.2 came out two weeks ago.
Comment #6
anders.fajerson commentedThat's a petty. But the fix is in Drupal 5.2 (I looked it up), wich is good. Can I commit this?
Comment #7
anders.fajerson commentedMissed your link - early morning.
Comment #8
ChrisKennedy commentedI implemented the settings migration - check it out and see if it looks okay. What was your reasoning behind moving the "reset vote" button out of a fieldset?
Comment #9
anders.fajerson commented1. I missed to rename "advpoll_default_electoral_list" to "advpoll_electoral_list" in a few places. Fixed that and updated the migration code to handle the renaming. It might have been cleaner/less code to rename it directly in the database but this works. Also fixed
$type->namein the migration code, it should be$type->type.2. Changed
if (strpos($node_type, 'advpoll_') !== FALSE)toif ($form['module']['#value'] == 'advpoll'). I didn't know the module name was in there.3. The reset button most have been some left-over from testing. Fixed that.
Comment #10
ChrisKennedy commentedLooks good, thanks. I don't think direct db changes would be cleaner though - it's better to use the drupal API (although Drupal could add a variable_rename() command).
Comment #11
anders.fajerson commentedCommitted with updated documentation: http://drupal.org/cvs?commit=77113. Great job!
Comment #12
(not verified) commented