Archive

Archive for June, 2008

More on Short Codes

June 25th, 2008 No comments

I had posted a question on Short Codes to the wp-hackers mailing list and got a pointed to an article on the Codex which explained the process of coding up a short code.  I expected it to be more involved than it was and I was pleasantly surprised to find it was really straight forward.  I have already implemented one short code for the wp-SwimTeam plugin and expect I’ll have half a dozen more done by the end of the week.

What I implemented for Flickr was pretty simple – it allows the insertion of a Flickr slideshow in a post or page using the Flickr UserId value (which is different than the username) and the Set Id.  Here is the snippet of code:

/**
 * wpst_flickr_slideshow shortcode handler
 *
 * Build a short code handler to display a Flickr slide show.
 *
 * [wpst_flickr_slideshow userid="id" slideshowid="id"
 *     frameborder="pixels" *     width="pixels" height="pixels"
 *     scrolling="yes|no" align="left|center|right" view="yes|y"]
 *
 * To show this Flickr slide show:
 *
 * http://www.flickr.com/photos/27604893@N04/sets/72157605764227907/show
 *
 * Use this shortcode:
 *
 * [wpst_flickr_slideshow userid="27604893@N04" slideshowid="72157605764227907"]
 *
 * This is the resulting IFRAME tag which is returned to the caller.
 *
 * <iframe align=center src=http://www.flickr.com/slideShow/index.gne?
 *     user_id=27604893@N04&set_id=72157605761943480 frameBorder=0
 *     width=500 scrolling=no height=500></iframe>
 *
 * If the 'view="yes"' or 'view="y"' attribute is include, a linl to the
 * Flickr slideshow will be placed under the IFRAME.
 *    
 * @param array - shortcode attributes
 * @return string -  HTML code
 */
function wpst_flickr_slideshow_sc_handler($atts)
{
    $c = container() ;
    //  Parse the shortcode
 
    extract(shortcode_atts(array(
        'userid' => '',
        'slideshowid' => '',
        'frameborder' => 'default 0',
        'width' => '500',
        'height' => '500',
        'scrolling' => 'no',
        'align' => 'center',
        'view' => 'no',
    ), $atts)) ;
    //  If either the userid or slideshowid are missing then
    //  we have a problem and can't do anything meaningful.
    if (empty($userid) || empty($slideshowid))
    {
        $c->add(html_br(),
            html_b("wpst_flickr_slideshow::Invalid Shortcode Syntax"),
            html_br(2)) ;
        return $c->render() ;
    }
    $if_src = "http://www.flickr.com/slideShow/index.gne?" .
        sprintf("user_id=%s&set_id=%s frameBorder=%s align=%s",
            $userid, $slideshowid, $frameborder, $align) ;
    $c->add(html_iframe($if_src, $width, $height, $scrolling)) ;
    if (($view == 'yes') || ($view == 'y'))
    {
        $link = "http://www.flickr.com/slideShow/index.gne?" .
        sprintf("user_id=%s&set_id=%s", $userid, $slideshowid) ;
        $c->add(html_br(2), html_a($link, "View this slideshow on Flickr."), html_br(2)) ;
    }
 return $c->render() ;
}

The code above makes use of the phpHtmlLib to generate HTML code but the general intent should be pretty obvious.

 

Categories: Development, WordPress Tags:

wp-SwimTeam shortcodes

June 24th, 2008 No comments

Today I implemented the first of what I suspect will be quite a few shotcodes.  Prior to today I haven’t played with shortcodes but they are really powerful and simple to use and implement.  The one I did today displays a Flickr slideshow on a post or a page.

Categories: Development, Progress Tags:

Opt-in vs. Opt-out?

June 22nd, 2008 No comments

It has been pretty quiet on the development front.  Now that swim team season is in full gear, I am spending a bunch of time actually using what I have developed to date.  So far, everything is working pretty well although I definitely have some things to do.

Next on the agenda is an online scratch sheet which I will likely implement as a an opt-in or opt-out feature on a meet.  Some meets make more sense to opt out of where as others make more sense to opt in. For example, our regular season meets will be opt-out meets.  All swimmers are assumed to be participating unless they opt out.  On the other hand, our local city meet which we only have 25-30 swimmers entered in, will be an opt-in meet.  All swimmers will assumed to be not participating unless they opt in.  I believe supporting both makes the most sense and will ultimately make the system work better.  Forunately this should be a pretty simple extension to the meet functionality I implemented a few weeks ago.

Categories: Development, Progress Tags:

Fixed Assign Label Bug

June 11th, 2008 No comments

I just committed a pretty important fix to address a bug in the Assign Label function.  If a label is manually assigned, the swimmer would be marked as Inactive on the master swimmer list which is incorrect.  This was a leftover artifact from reusing the Unregister code.  It has been fixed and now swimmers are  propertly labeled AND if Swimmer Label field is properly initialized with an existing value if there one (which wasn’t happening either).

The other thing I ran into as a result of running our Time Trials last night is the need for a confirmation on the “Assign Labels” functionality as it will re-assign all the swimmer labels which may not be the desired state as it was in my case last night.  Fortunately only 2-3 new swimmers had been added to the database since I had assigned labels so manually fixing them wasn’t too much work but I’d rather not have done it at all.

Categories: Bugs, Development Tags:

Swim Meets and Swim Club Profiles

June 9th, 2008 No comments

Over the last couple of days, actually since I flew home from Paris on Friday, I have added functionality to set up a swim season schedule.  To do this, I added swim club profiles and swim meets.  The swim meet functionality also includes a summary which is added to the overview page.  The summary reports the schedule for the current season, results. and lcation of the meets.

Adding swim meets is base functionality which is necessary to support online scratch sheets (need to know which meet a swimmer is scratching from) and ultimately results.  The online scratch will probably be the next thing I implement, results are a bit trickly because loading, parsing, and connecting results to swim meets and swimmers will be a fairly extensive problem.  I suspect I won’t have this working until after our season completes but you never know!

I also want to go back and visit the Team Profile functionality.  I am storing the Team Profile in the WordPress options table but now that I have Swim Club Profiles, there isn’t any reason to store the Team Profile any differently than any other Swim Club.  It isn’t urgent so I may defer that as well.

Lastly, I need to make changes to many of the classes to allow some of the methods to be called without needing a class variable first (the class::method() format).  For example – I should be able to call SwimTeamSwimmer::getAllSwimmerIds() and return an array of SwimmerIds without declaring a class variable first but right now I can’t due to the way I constructed the base level database query class.  There are a number of places where this would be really handy.

Categories: Development, Progress Tags:

Swimmer Numbers? Swimmer Labels?

June 5th, 2008 No comments

I have spent a fair amount of time this week implementing what I am now calling Swimmer Labels.  I may go back to Swimmer Numbers but I am not sure.  I’d like to call them Swimmer Ids but I have used that terminology all through the plugin for the unique MySQL record id field that changing it would be a pretty sizable task.

On the good news front, I have auto-assigment of Swimmer Labels working under several different scenarios.  I am particularly pleased with the auto-assignment of labels within an age group with a prefix – it is pretty slick if I do say so myself.  Since the MacDolphins use this format, it was particularly important to me!

Categories: Development, Progress Tags:

Enhancement List!

June 3rd, 2008 No comments

My wife gave me a list of all of the things she’d like to be able to do the other day.  None were a real surprise and I hope to get some of them implemented this week.  Probably the hardest one will be to do an online scratch list because I need to finish the Meet Module first since scratching is dependent on having a swim meet to scratch from.

Categories: Development Tags:

High on WinSwim, low on MeetManager

June 3rd, 2008 No comments

I have posted on this subject before but after spending a bunch of time with WinSwim this weekend I want to talk about it again.  I really like WinSwim.  Gary Wood (the author) provides top notch support.  I have run into a few bugs and his turn-around time to fix them is phenominal, usually within a day or so.

The last one was a wierd one though.  I was unable to run any of WinSwim’s reports.  I installed it on my wife’s computer and they ran fine.  WFT?!?  I provided a slew of data to WinSwim Support and got an e-mail back from Gary explaining that in his opinion, what was happening was I likely had Hytek’s Meet Manager installed (I do) as it uses an old version of Crystal Reports, the same Report Module which WinSwim uses.  Because WinSwim expects the newer version, they won’t work.  Bleh, what a mess.  I am still trying to figure out how to rectify this situation.  I can’t imagine what I’d do without Gary’s support.

Categories: Rants, Software Tags: