CVS edit link for Artman

On my pre-Drupal site, I had a scrolling Florida lottery block and could not find one already written for Drupal, so I wrote my own. I thought that I should contribute back to the community that I've gotten so much from already and decided to contribute a Lottery Block module that uses free RSS feeds from US-Lotteries (www.us-lotteries.com) to display recent lottery results from one of 44 US States that have lotteries.

I am sure that I will be writing other modules as I add more to my sites (and get more and more familiar with Drupal itself).

CommentFileSizeAuthor
#2 lottery_block.zip7.95 KBArtman
#1 lottery_block.zip13.71 KBArtman

Comments

Artman’s picture

Assigned: Unassigned » Artman
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new13.71 KB

Lottery Block adds a block with scrolling lottery results from one of 44 US states (including District of Columbia) that have lotteries.
It uses the Pausing up-down Scroller script from Dynamic Drive (www.dynamicdrive.com) to show your state's lottery results for the week. It utilizes the free RSS feeds from
US-Lotteries (www.us-lotteries.com) for the data.

EDIT: Note that I accidentally left in a LICENSE.txt file that shouldn't be there. Sorry. ;)

Artman’s picture

StatusFileSize
new7.95 KB

Well, I guess the reason LICENSE.txt was included in that first package I uploaded was because I uploaded it from the wrong directory as I just noticed that in IE a styling problem wasn't fixed and the included CSS file wasn't set for Garland theme colors.

So, after double and triple checking to make sure I've got the right module packed up, here is the correct file for review. (Please ignore/delete/feed-to-the-dog/whatever with the first one) ;)

You can see it in action in the right side column here: www.darrelltown.com

avpaderno’s picture

Assigned: Artman » Unassigned
Status: Needs review » Needs work
Issue tags: +Module review

Hello, and thanks for applying for a CVS account.

  1. See http://drupal.org/coding-standards to understand how a module should be written.
  2. function lottery_block_install() {
    
      // Set up our default variables
      $data = array(
                    'state' => 'FL',
                    'pause_delay' => '3000',
    		'show_header' => TRUE,
    		'two_line_header' => TRUE,
    		'footer_text' => 'Mouseover To Pause',
    		'show_analysis_link' => TRUE,
                  );
      
      variable_set('lottery_block_settings', $data);
    
      drupal_set_message(t('Lottery Block Module Installed! Go to Administer->Site Building->Blocks->Lottery Block to configure your parameters.'));
    }
    

    Drupal variables are not initialized during installation.

  3.     // Load our block settings
        $data = variable_get('lottery_block_settings', FALSE);
        
        // Open our XML feed file from us-lotteries.com
        $source = 'http://www.us-lotteries.com/rss/'.$data['state'].'Rss.xml';
        $RSSfeed = fopen($source, "r");
    
        // Let's parse the information
        $LotteryData = array();
        $i = 0;
    
        while($line = fgets($RSSfeed)) {
        
            if (strstr($line, '<item>')) {
    	    
    	    while($line = fgets($RSSfeed)) {
    	        if (strstr($line, '</item>')) {
    		    break;
    		}
    

    The code would not work, if fopen() is not allowed to read remote files. Why isn't the code using the function that Drupal has to get content from an external site?

  4. Files available from third-party sites should not committed in Drupal.org. The comment that is present at the beginning of the file makes me think the file is not released under GPL license.
  5. The function _lottery_block_content() is outputting too much HTML; you should be using a theme function.

  6.       $output = '<p>'.  t("Displays state lottery results in a styleable block.") . '<br />';
          $output .= t("Works with RSS feeds from www.us-lotteries.com and will display lottery results for any one of 44 lottery states (including the District of Columbia). ");
          $output .= t("For more lottery widgets and/or analysis and other data, visit: ") . '<a href="http://www.us-lotteries.com" target="_blank">'.t('US-Lotteries').'</a></p>';
    

    Is the link of any relevance for who has a Drupal site?

Artman’s picture

1. I have read the coding standards, but never saw anything about not initializing default values in variables during install. As a side note - I was using several other modules as educational examples as I was writing this one and there's a lot of them that do the same thing I did in my install hook. And it just made more sense to initialize them with as an array with one call to variable_set() than use 6 calls to variable_get() and supplying default arguments for each of them in several places in lottery_block.module (and thus more queries). Less bloat, IMO.

2. What function would that be? There's a function that will read in a remote file as a file stream? I found drupal_http_request, and may rewrite it to support that, but it looks like overkill for just custom parsing a small file.

3. ???

4. I assume you're talking about the pausescroller.js, right? It's free to use on any site, but to make sure we're complying correctly, it wouldn't be a big deal to include a link to Dynamic Drive's page for that so anybody can download it themselves. That could be removed from the package and mentioned in module description, installation instructions and documentation with no problem.

5. Outputting too much HTML? Don't go look at the hook_help() from gallery_assist, image_gallery or the image modules, lol. I guess I should have wrapped it in l() or something, but when you think about it, it's still only outputting a br and a link.

And, yes, anybody using this module would be using the service from us-lotteries.com, so not only is it informative as to where the module pulls its information from, it's a courtesy to US-Lotteries to at least credit them within the help system of the module.

I'll give a go at rewriting the fopen() section of code to use drupal_http_request(), reformat the hook_help() output and remove the js file from the package and include directions to the file in the README.txt file for that and re-upload and let ya check it again. ;)

Thanks,

avpaderno’s picture

See comment #3; there was a missing tag that did mess all the comment.

The link to a third-party site seems more like a spam link.
The link text is For more lottery widgets and/or analysis and other data, visit: , which leads users to think they will find widgets they can use for their Drupal site; the correct link text should probably say Feed content obtained from: .

The function I reported to output too much HTML without to use theme functions is not an implementation of hook_help(); if it would have been, then I would not have reported what I reported.

avpaderno’s picture

Status: Needs work » Closed (won't fix)
avpaderno’s picture

Component: Miscellaneous » new project application
Issue summary: View changes

Please read the following links as this is very important information about CVS applications.

Drupal.org has moved from CVS to Git! This is a very significant change for the Drupal community and for these applications. Please read Migrating from CVS Applications to (Git) Full Project Applications and Applying for permission to opt into security advisory coverage on how this affects and benefits you and the application process. In short, every user has now the permissions necessary to create new projects, but they need to apply for opt into security advisory coverage. Without applying, the projects will have a warning on projects that says:

This project is not covered by Drupal’s security advisory policy.