I have built a module that fetches various statistics of a site(Such as Google pr, Alexa rank, Backlinks, Pages Indexed in different search engine and domain age). The module was developed at Drupal Code Sprint at Pune (Oct 09) and I want to publish it on drupal.org.
The Code Sprint Website: http://drupalindia2009.plug.org.in/
My module is available at http://linuxers.org/sitestats.tar.gz
If there's any issues with the code or module functionality as such, I'm ready to improve it, since this code is all about single day's work so far. I had also applied for CVS access earlier, however, due to time restrictions and studies, I couldn't follow up with the disapproval reasons. I'll be glad to have the ability to publish my module and also learn further with the experience of the same.
Thanks!
Regards,
Tushar Mahajan
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | sitestats.tar_.gz | 73.61 KB | chia |
| #19 | sitestats.tar_.gz | 73.83 KB | chia |
| #16 | sitestats.tar_.gz | 73.87 KB | chia |
| #13 | sitestats.tar_.gz | 75.12 KB | chia |
| #12 | sitestats.tar_.gz | 75.12 KB | chia |
Comments
Comment #1
chia commentedComment #2
avpadernoRemember to change status, when you upload new code.
Comment #3
chia commentedComment #4
avpadernoPlease change only the status, when you upload new code.
Comment #5
avpadernoSee the Drupal coding standards to understand how a module code should be written.
In particular, see the part about the namespace respect, and the use of Drupal Unicode functions (which is then valid for all the functions Drupal makes available to third-party modules).
Comment #6
avpadernoAlso, I think that the ereg functions are not anymore present in PHP 5.3; the code should use the preg functions.
Comment #7
chia commentedThanks for the update.
Yes, ereg family of functions is deprecated in PHP 5.3 and will be removed completely in PHP6. Replaced ereg function.
Please review this new code.
Thanks
Comment #8
chia commentedComment #9
avpadernoThe first argument of
t()needs to be a literal string, not a variable; differently the script to extract the strings to translate will not find the string to translate.The code should use a placeholder.
Every strings that are used in the user interface should be translatable.
A submission function doesn't use
drupal_goto().The statement require_once is looking for a file that is in the root directory of Drupal; the code should use
module_load_include().Also, rather than using
array_filter($urls, 'strlen'), the code could usearray_filter($urls).This error has been already reported.
The string is not translatable.
IF-statements should use the curly brachets, as reported in the coding standards.
Why isn't the code using
truncate_utf8()?It would be better to use placeholders.
Normally, the installation code just calls the function without to check the value returned.
See the Drupal coding standards to understand how a module code should be written.
The coding standars also suggest to use Drupal Unicode functions, which handle better the multi-byte strings.
Strings used like that should have the first word written in capital case, and the others written in lower case (with the exception of proper nouns, or acronyms).
It should be .
It would be better to use the form field .
The code is not formatted as the coding standards suggest.
Comment #10
chia commentedThanks KiamLaLuno for reviewing the module. I have made those changes, please review this new code.
Comment #11
chia commentedremoved sitestats.admin.inc and added that code to sitestats.module, because of single function in that file.
Comment #12
chia commentedFixed couple of more coding Standards Issues
Comment #13
chia commentedFixed couple of more coding Standards Issues
Comment #14
avpadernoSee the Drupal coding standards to understand how a module code should be written.
Comment #15
avpadernoWhat is wrong with the following code?
Comment #16
chia commentedThanks KiamLaLuno for the update.
I have fixed those coding standard issues.
Comment #17
avpadernoThe first argument of
t()is a literal string, not a dynamic value; differently, the script to extract the strings to translate will not extract the string.db_result()is used when the query is selecting a single field of the table, not the full row; the code should use a different function.The title should say ; differently, users will probably understand that that is the length of the URL, not the maximum number of URLs they can insert.
Are you sure that the placeholder %max is the one you want to use?
The coding standards also report to use Drupal Unicode functions; although, in this case it's enough to write
array_filter($urls).Concatenating string to obtain a string that is then passed to
t()is normally not a good idea (watchdog()passes the string tot());$r['mail'], and$r['url']needs to be sanitized, before to be output (t()does that, if it gets the right placeholders).str_replace()accepts arrays as parameters; there isn't the need to call the function three times.Every strings used in the user interface should be translated.
In the options for the checkbox(ex) form field, the question mark is never used at the end of the string.
Strings used in user interface should have the first word in capital case, and the other words in lower case (with the exception of proper nouns, adjectives derived from proper nouns, and acronyms).
That option is not used by Drupal core code; is it used by a third-party module?
Why isn't the code using Drupal behaviors?
Comment #18
avpadernoComment #19
chia commentedThanks KiamLaLuno once again for the update.
Removed t() function
2.
3.
used single column hashelement instead of entire row
4.
changed the name of the placeholder from %max to @max_url
5.
changed to $urls = array_filter($urls);
6.
Concatenating string to obtain a string that is then passed to t() is normally not a good idea (watchdog() passes the string to t()); $r['mail'], and $r['url'] needs to be sanitized, before to be output (t() does that, if it gets the right placeholders).
$msg = '!mail is now registered to the pagerank update on !url';
$vars = array('!mail' => $r['mail'], '!url' => $r['url']);
watchdog('sitestats', $msg, $vars, WATCHDOG_INFO);
echo t($msg, $vars);
}
7.
Thanks for pointing it out changed to
$url = str_replace(array('www.', 'http://', 'https://'), '', $url);
8.
Every strings used in the user interface should be translated.
In the options for the checkbox(ex) form field, the question mark is never used at the end of the string.
Strings used in user interface should have the first word in capital case, and the other words in lower case (with the exception of proper nouns, adjectives derived from proper nouns, and acronyms).
Done!
9.
That option is not used by Drupal core code; is it used by a third-party module?
One of the module uses this code
http://drupal.org/project/multicolumncheckboxesradios
I have commented this line since i dont have this as a dependency for my module.
10.
Changed to
Drupal.behaviors.sitestats = function () {
$("input[@name=submit]").click(sitestats_handler);
$('#loading1').hide();
};
Comment #20
chia commentedComment #21
avpadernoThe code is using some PHP functions when there are equivalent Drupal functions, which should be preferred.
Comment #22
chia commentedThanks again kiamlaluno for the reply
I have replaced curl functions which drupal_http_request, i could find this, but not sure if there are any other out there :).
Comment #23
chia commentedforgot to change the status
Comment #24
avpadernourlencode()should be replaced bydrupal_urlencode(), which fixes some Apache problems.Comment #25
avpadernoComment #26
chia commentedThanks a lot Kiamlaluno.
I will make that change and again thanks for all your time
Comment #29
avpaderno