This module adds a temperature field to Drupal 7; it uses the Field API. It has settings (via the temperature_ui module) that let users choose their preferred temperature unit and then it allows them to view the value of this field in their preferred value, if field settings allow such localization. It supports fahrenheit, celsius and kelvin. It also provides useful functions to format and convert temperature values. At this time is has a select list widget. I may add other widgets in the future if needed, such as a simple textfield.
I'm applying for Full project access.
Here is a link to the sandbox project; please review the 7.x-1.x branch as this is where commits are being made.
http://drupal.org/sandbox/aklump/1188184
Comment | File | Size | Author |
---|---|---|---|
#9 | branch-shell-log.txt | 898 bytes | stfwi |
#8 | degree.png | 22.28 KB | aklump |
#5 | marginal-changes.patch | 2.01 KB | stfwi |
Comments
Comment #1
jordojuice CreditAttribution: jordojuice commentedHello, thank you for your contribution!
Please remove LICENSE.txt from your module, that will be added by git.
Please ensure that your module has been run through Coder module (http://drupal.org/project/coder) on minor (most). Ignore
// $Id$
and similar tags as those are no longer used with git. They can be removed.Comment #2
aklump CreditAttribution: aklump commentedHello, Thank you for reviewing my module; I've done as you asked. There is one error on coder module but I've reviewed it for the exception and I believe all is well based on how I'm using the eval()
Please let me know what's next. Thanks in advance,
Aaron
Comment #3
joachim CreditAttribution: joachim commentedJust a quick eyeball review...
This belongs in your install file. Though there's no need for logging this anyway. If there were, it would be system.module's job.
ORLY? I think you'll find the default international unit is c... ;)
> temperature_field_schema
This looks a bit odd... What is $columns?
I don't think the description is needed here. Also, check how core does it but I suspect it'll be sentence case not title case.
One last point, some of your files are missing a newline at the end.
Comment #4
aklump CreditAttribution: aklump commentedThank you joachim for your review! I didn't know that about eof \n chars.
I've updated the code per your suggestions... (with the exceptions below).
Regarding the enable disable watchdog calls... I'm guessing that's not a deal breaker; I picked that up somewhere along the lines and it's actually been handy a few times in troubleshooting which user did what, so I usually add that to all my modules. I'll assume it's a matter of my verbose commenting taste, unless you correct me otherwise. Thanks.
Here are the answers to your questions...
This looks a bit odd... What is $columns?
The schema definition is a bit different between hook_schema and hook_field_schema...
http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...
I don't think the description is needed here.
I pulled from the api which shows it...
http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...
Am I correct to have also changed the status of this thread back to 'needs review' ?
Comment #5
stfwi CreditAttribution: stfwi commentedHi Aaron,
I installed the module and checked the code. I have a patch file with some marginal change proposals:
1) It's degrees celsius, so added the º (I know, we bloody Europeans with their units :-) )
2) Moved enable/disable the sub module in temperature_ui.install.
The code doc, readability, text and link escaping, logs and error handling looks all quite good in my
opinion. Notice: I did not check the UI yet by using it, only code review.
Cheers
Stefan
Comment #6
joachim CreditAttribution: joachim commented> Regarding the enable disable watchdog calls... I'm guessing that's not a deal breaker; I picked that up somewhere along the lines and it's actually been handy a few times in troubleshooting which user did what, so I usually add that to all my modules
It really is totally superfluous. If you want that kind of logging, add it as a patch to something like devel or util module. It's absolutely not up to modules to do this.
Comment #7
stfwi CreditAttribution: stfwi commentedYes, it doesn't make any real difference, it's just a structural review proposal.
Comment #8
aklump CreditAttribution: aklump commentedHi stfwi,
I've been working and updating the 7.x-1.x version not the master (I've just been ignoring the master, so I must be confused as to workflow. I'm an svn guy, new to git, and new to the module contribution process). That said I had previously moved the enable/disables to .install on that version, not master. Also the master has not been updated since the original branch off to 7.x-1.x.
Regarding the degree symbol; I desperately want it too! But I couldn't figure that out during initial dev on this, how to get it to work; see the attached because the ui isn't allowing the entity to get through, somewhere in the chain. Maybe it's a flag I need to add to the field definition or something, like 'allow html' or html = TRUE. I'm stumped though. It's like a check_plain() or something somewhere.
I'm going to go ahead an remove the enable/disable for this module as it does seem a bit much in this case, per joachim's comment.
So:
1) Do I need to do something to keep master in sync with 7.x-1.x? Why is there a master if I'm going to dev for 7x and 6x?
2) Any idea how to make the degree symbol work?
3) What else should I do at this point to keep the process going?
Thanks for your time,
Aaron
Comment #9
stfwi CreditAttribution: stfwi commentedHi,
[1] My note referred to the temperature_ui/temperature_ui.module file, there are the enable/disable hook with watchdog as well.
It's ok to work on the 7.x-1.x branch. The master branch is just the default branch starting up a GIT project, there is nothing really special about it. Depending on the GIT project, people use it as a guide branch (to see "how far they are away from master"), but technically GIT doesn's care - one of the GIT/mercurial advantages. Probably the first answer in http://superuser.com/questions/80379/git-branches-how-exactly-do-they-wo... can give you some more information how some people deal with the master branch. For downloadable DP releases, the tags are important.
[2] According to the degrees (sorry about not checking the select box again, was quite late, as programmers always say when they commit non-fix :-) ), let me check this again. I'm not sure if you can rely on using utf-8 instead. I will browse a bit the core and doc (because I wanna know now as well how to handle this properly). A first idea was to split the html and utf-8 for the corresponding representations in the assoc unit declaration array, but this would probably not work for the select-field if the encoding is not declared as utf-8 in the http-header/html-header and the browser does not assume it neither. So, ... let's check a way around this, I am sure it will be trivial in the very end, as DP covers a lot :-), but to find it ...
[3] According to getting the project release process - I think the DP experts will be able to say this, I feel to new in the community to make a reviewed statement (as reviewing is also a learning process for me).
Comment #10
stfwi CreditAttribution: stfwi commentedHi again,
Although issues in modules or themes are reported here and there, the core (common.inc) declares content type utf-8 in the header, and there are actually a lot of drupal_**** string functions treating utf-8 strings. So probably the function drupal_convert_to_utf8() it the one you want to use to convert an ISO-8859-1 string in the source code into utf-8. A php native function is (http://www.php.net/manual/en/function.html-entity-decode.php). If I would have to do it without DP, this would have been my approach to ensure that the character is still correct even if someone changes the source code char encoding.
Here the common.inc code FYI:
Hope it helps, cheers.
Comment #11
aklump CreditAttribution: aklump commentedThanks stfwi,
I'm just now getting back to this module and used the snippet you send in this last comment; it seemed to work just fine in my testing. I've pasted an example of the diff below. I would not have figured this out as quickly without your help. Thanks immensily!
Comment #12
klausi* lines in README.txt should not exceed 80 characters
* info file: only list files there that contain classes or interfaces
* info file: do not include "version", this is added by drupal.org packaging automatically
* Remove old CVS $Id tags from all files, not needed anymore
* "Implementation of hook_help()" should be "Implements hook_help()"
* "//if the node id is not yet set, then we haven't stored anything and so we're" there should be a space after '//'. Also comments should start capitalized.
Comment #13
aklump CreditAttribution: aklump commentedHello klausi,
Are these comments based on the master branch, by chance?
Please review based on the 7.x-1.x branch; as I understand it that is where I should have been making my commits; the master branch has not been updated at all from the initial import. All the updates I've made have been on the 7.x-1.x branch.
Please let me know...
Thanks,
Aaron
Comment #14
klausiThen delete everything in the master branch if you don't use it, e.g. like here: http://drupalcode.org/project/rules.git/blob/refs/heads/master:/README.txt
No, most of my comments still apply in 7.x-1.x.
Comment #15
joachim CreditAttribution: joachim commentedDocblocks that just read back the parameters are no help at all. Each param needs at least a few words to say what it is.
Comment #16
aklump CreditAttribution: aklump commentedThank you klausi and joachim; I believe I have made the requested changes:
The master has been cleaned up as well as comments in the 7.x-1.x branch.
I also made the changes per #12 as well.
Please let me know what is next, I'm excited to get this finished up.
Thanks,
aklump
Comment #17
aklump CreditAttribution: aklump commentedComment #18
sreynen CreditAttribution: sreynen commentedHi aklump,
Please fix the following issues, then move this back to "needs review":
version = VERSION
can be removed from temperature.info. Version info will be added automatically by the Drupal.org packaging script.$value = eval('return ' . $formula . ';');
eval should be avoided where possible, since it's both slow and a security hole. It's not necessary here. You have 6 formulas that aren't changing, so there's no need to put this code into strings. Either put them in functions and reference the function names in the strings, e.g.$function = $unit_data[$current_unit]['formulas'][$desired_unit]; $value = $function($current_unit);
, or simply reference the units and define the math where you're actually doing it, e.g.if ($current_unit == 'c' && $desired_unit == 'k') { $value = (float) $value + 273; } elseif (...)
Comment #19
aklump CreditAttribution: aklump commentedHi sreynen,
I went the route of function names, which kept the definition array cleaner and added drupal_alter, to allow for complete extension by other modules. Granted F to K will always be the same formula, but as a design model, I felt more comfortable defining functions which in theory could be alterable, rather than hard-coding in the calculations to temperature_convert(). The other changes I made as well. Thanks for you points!
- Aaron
Comment #20
sreynen CreditAttribution: sreynen commentedLooks good to me.
Comment #21
gregglesPlease take a moment to make your project page follow tips for a great project page.
Thanks for your contribution, aklump! Welcome to the community of project contributors on drupal.org.
I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.
Thanks, 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.
As you continue to work on your module, keep in minde: Commit messages - providing history and credit and Release naming conventions.
Comment #22
gregglesBetter status....
Comment #23.0
(not verified) CreditAttribution: commentedspecified that the 7.x-1.x branch is for review, not master