Jump to Main Content
Content > XOOPS > Onair - Weekly Schedule Module for XOOPS
Onair - Weekly Schedule Module for XOOPS

Originally called culex_dj_rotator, the Onair module may be used by any organization wishing to publish a regular, weekly schedule. Designed for Radio, but could be used for TV and/or other weekly schedule uses.

Latest Version: 1.04 (Mirror) | Website
Author: culex


Onair is a module designed for one or more Radio stations, TV stations, or any organization with a regular schedule to publish their weekly schedule along with playlists. It has one block that will display the current program, host/DJ and related information such as playlists. Overall, an excellent but simple module. Currently, I'm still working to get our playlists stuff working so this doesn't focus on that issue, especially since I don't have examples for the formats. We're looking at scraping XML feeds into a database and working with it that way.


  • Fields: Station, Title, Host, Day, Time (start/end), Description, Plugin, Stream
  • Block: Now Playing/Coming Next (jquery/ajax block)


I've only done a fresh installation, although it was updated to 1.04 (from 1.03) early in my start of the usage. So, I did update it per usual module updating, and it worked fine. Installation is done normally.

Errors, Bugs, Defects

One quick comment related to issues I dealt with. Overall, I think this module would do a lot better if it were to measure time based in seconds from 12:00 midnight of the schedule's timezone. I thought that a lot of the time calculations would have been much easier and that my solutions were a bit of a kludge due to it.


The onair_index.html template is never used. The main index actually uses the onair_program.html template and defaults to the current day. I needed a page that showed the entire weekly schedule. So, I wrote a function and used the _index template. I'll note, too, that the onair_program.html template has some problems in the code that could result in badly formed HTML.

Edit Schedule Times Not Kept/Shown

When editing an existing schedule entry, it doesn't display the start/stop times as assigned in the database; it always shows 12:00 midnight (0:00) in both 12- or 24-hour format. I fixed this one. My general recommendation would be for the module to store data on a 24-hour format and then convert to the 12-hour format for display as desired. I think this would simplify a lot of code dealing with the times.

To fix, there were a couple of places. In the end, all I needed to do was this "simplification" edit to /admin/index.php lines 172-193 from:

// determine 12 hour Or 24 hour format time

if (onair_GetModuleOption('timetype')=='0'){

// Uses class to set 24 hour format
$edformstart = new onair_XoopsFormTimeEuro(_AM_ONAIR_START, 'oa_start',20);
$edformstop = new onair_XoopsFormTimeEuro(_AM_ONAIR_STOP, "oa_stop",15);
$oa_start = date('H:i:s', strtotime($oa_start));
$oa_stop = date('H:i:s', strtotime($oa_stop));

// Uses class to set 12 hour format
else if (onair_GetModuleOption('timetype')=='1'){
$edformstart = new onair_XoopsFormTimeUs(_AM_ONAIR_START, 'oa_start',20);
$edformstop = new onair_XoopsFormTimeUs(_AM_ONAIR_STOP, "oa_stop", 15);
$oa_start = date('h:i:s a', strtotime($oa_start));
$oa_stop = date('h:i:s a', strtotime($oa_stop));

changed to:

// Start/Stop Time Display
$timearray = array();
$oa_end = strtotime("23:59:59");
// determine 12 hour Or 24 hour format time
if (onair_GetModuleOption('timetype')=='0') {
    // Uses class to set 24 hour format
    for ( $i=strtotime("00:00:00"); $i < $oa_end;  $i+= 900) {
        $timearray[$i] = date('H:i:s',$i);
} else if (onair_GetModuleOption('timetype')=='1') {
    // Uses class to set 12 hour format
    for ( $i=strtotime("00:00:00"); $i < $oa_end;  $i+= 900) {
        $timearray[$i] = date('h:i:s a',$i);
$edformstart = new XoopsFormSelect(_AM_ONAIR_START, 'oa_start', strtotime($oa_start), 0);
$edformstop = new XoopsFormSelect(_AM_ONAIR_STOP, 'oa_stop', strtotime($oa_stop), 0);

This also allows you to remove the onair_XoopsFormTimeUs and onair_XoopsFormTimeEuro functions in includes/classes.php which puts in an ElementTray layer that really isn't needed (and it wasn't work correctly either, and is 2 of the 3 classes in that file).

Alternatively, this below worked, too, (what I did before using the combined code solution above). In admin/index.php, edit lines 177-179 to be:

$edformstart = new onair_XoopsFormTimeEuro(_AM_ONAIR_START, 'oa_start',0,strtotime($oa_start));
$edformstop = new onair_XoopsFormTimeEuro(_AM_ONAIR_STOP, "oa_stop",0,strtotime($oa_stop));

and lines 187-189 to be:

$edformstart = new onair_XoopsFormTimeUs(_AM_ONAIR_START, 'oa_start',0,strtotime($oa_start));
$edformstop = new onair_XoopsFormTimeUs(_AM_ONAIR_STOP, "oa_stop",0,strtotime($oa_stop));

And for the Add New function to operate correctly, you have to also edit two other locations -- first lines 368-370 to be:

$signformstarteu = new onair_XoopsFormTimeUs(_AM_ONAIR_START, 'oa_start', 0, strtotime($oa_start));
$signformstopeu = new onair_XoopsFormTimeUs(_AM_ONAIR_STOP, "oa_stop", 0, strtotime($oa_stop));

and lines 380-382 to be:

$signformstart = new onair_XoopsFormTimeEuro(_AM_ONAIR_START, 'oa_start', 0, strtotime($oa_start));
$signformstop = new onair_XoopsFormTimeEuro(_AM_ONAIR_STOP, "oa_stop", 0, strtotime($oa_stop));

Another part of the issue was that the XoopsFormSelect call in the includes/classes.php file weren't used correctly. It is defined thusly:

function XoopsFormSelect($caption, $name, $value = null, $size = 1, $multiple = false)

To fix, change lines 53 and 84 to:

$timeselect = new XoopsFormSelect('', $name, $value, $size);

Time Sorting 12-Hour Format

Sorting dates and times doesn't work right using the 12-hour version with am/pm. In the 12-hour preference (as used in the US), the information is written to the database in a text field of HH:MM:SS AP. But when sorting, since it's a text field, 01:00:00 AM comes before 12:00:00 PM, which of course isn't correct. Affects displays both in the user and admin sides. To quickly compensate, I changed the module to use the 24-hour preference and then when modifying the templates (as I always do to every module), changed the display method with Smarty.

Shows to/past Midnight

The module currently doesn't support shows that start before midnight and go beyond midnight. To compensate, enter the show twice, one to midnight (23:59:59) and the other from midnight (0:00) to when it ends.

The module sort of supports shows until midnight, however there is an error. When adding a show, it displays a midnight (00:00:00) end/stop time of 00:00:00. However, then it won't display properly (with the on-air info nor in the now-playing block) in the module because of how the between SQL query operates. So, it really needs an end time of 23:59:59. Fortunately, the edit function takes care of that properly setting the end time of 00:00:00 selected to be 23:59:59. Then it works as advertised.

I thought this would be a simple in admin/post.php, but I didn't find it, so since I have a work-around, it's working fine for me. But it does need to get fixed for the add subroutine.

Program Image Not Remembered

The image selected for a program isn't remembered, so if you edit the program (but not the image) and then save it, you'll lose the image. A few edits in ./admin/index.php onair_EventEdit function takes care of this.

Enhancement Requests

These enhancement requests were tossed back to the author to use as they see fit. I think they were additive, but I also wasn't dealing with more than one station at a time which will complicate things, I think. I also reused the Station and Stream fields to be something else since we only had one of each (at least sorta, but it was nice to use the fields without rebuilding the module further). It would be nice, too, to have a set of extra custom fields, maybe 5 or so.

Admin Menu

The Admin Menu needs to stay at the top of the pages and generally the admin area needs to do a better job of telling you where you are.

Now Playing/Coming Up Block and AJAX

The block using jquery (and ajax) worked, but a couple of comments.

One, it had a system load aspect that wasn't really necessary. It only needs to check once in awhile, not 2 http calls every 20 and 30 seconds (5 times/min/browser really adds up in terms of server loading). It should be max once/minute max or something and should instead only check every minute or so around the next schedule change and using ajax to obtain an XML object including ALL of the info in a single call including the system time, the station time, doing the math and only checking again near/close to the expected change.

Second, the jquery call, while to a current version of jquery, interfered with the call made originally in the theme and broke my other scripts and plugins since it loads on top of them. The script call should be done only if necessary (but I've not investigated just how to do that). I just removed the loading of the script in the template.

Also, because of the data, the block display changes sizes depending on the content moving stuff around on the page (but that can be fixed in CSS and templates); it's just that some users might not be capable of dealing with it.

The templates used in the AJAX calls were the file templates because of the way they were called instead of those in the database (you're using a custom set, right; if not you should as it makes it easier to control between updates). To fix, in onair_ajaxassign.php and onair_ajaxassign2.php change line 25 to call the template from the database like this: $tpl->display('db:onair_div1.html');

Therefore, I created a new setup for this block using AJAX and called it backend. It is actually an RSS feed in XML that can be used by anyone including the new code I created for the now playing block. I also wanted to configure the number of upcoming shows and how that is displayed. Also, if you'd like this data to be able to be used via RSS pulls on another system, then an AJAX call is appropriate. The current solution isn't XML- or RSS-based, but the one I created is.

Weekly Schedule At-a-Glance

We needed a weekly schedule to show at a glance. I created a page for this based on the main index that just pulled and displayed more of the schedule, not too hard, really, but took some time getting it to show well.

Overnight Schedule

The module doesn't appear to handle the ability to have a show that spans midnight. Also, the display block doesn't appear to handle that either. Continuing to investigate and figure that out. I'd also like the ability to deal with on-air/streaming aspects so that I can help users understand whether or not they will only get it on the stream and/or on-air. Nor does it allow the ability to go all the way to midnight (latest stop time choice is 23:45), although you can select 0:00. You can add two entries for this and then it works well, to a degree, but it's not clear on the schedule that it continues without putting more info in.

HTML Out of Functional Layer

This module has at least one place where HTML is embedded in the functional code. When working with things like images and linked images, this should be broken up and passed as object data to a Smarty template to allow template designers better control without having to go into the functional layer. It can be done, but it requires smarty regex usually.

Other Pages
Previous Page XOOPS Menus - Multimenu Profile Module Next Page
Comments are solely the opionion of the author and not to be construed as the opinion of anyone else.



(c) 2006-2007 - Mark Boyden
Privacy - Legal Stuff - Contacts