CIMSU OTS Technical Blog

Tuesday, April 17, 2007

Tutor Time Errors, DST, and Profile Updates

Dealing with users is timezones over 12 hours apart has caused all sorts of interesting errors. Most recently, we noticed that adding new availability tended to be 12 hours off. Turns out there was a series of errors that lead to times being added wrong&em;apparently when I fixed it I didn't fix it everywhere.

So now, theoretically, that's fixed so that all times really are stored in the servers timezone and then converted for each user.

I also found an easy way to automatically adjust for Daylight Saving Time. Unfortunately, due to PHP's slight bias, it only works with US DST, not with European Summer Time. So, sorry Europeans, but you'll have to go through and adjust your timezone yourself.

Finally, I added what I always intended to have, but forgot about: immediate profile updates. If you change something on your profile, the update will automatically appear in both the database and the session, so the changes appear everywhere on the site simultaneously.

Labels: ,

Thursday, April 12, 2007

Bugs

A while ago we created our own small bug reporting script to handle, well, bug reporting. That script (http://msuconfuciusinstitute.org/scheduler/bugs/) is the first live test of FrameWorks 2. It seems to be running well so far.

Labels:

IE Fix

Because Internet Explorer does not support the display: table-cell; value in CSS (or any of its related values), apparently all the calendars were appearing as vertical columns in IE. Apparently "We don't support Internet Explorer" wasn't a valid response, so I had to alter the Calendar object a bit to output tables instead of divs.

Just to make it harder, though, the system wasn't using a new version of Calendar, it was using something along the lines of v0.9. When I altered the file directly, very weird stuff happened. So I tried to upgrade to 1.2 which uses Parser and some templates, but of course I ended up with several conflicting class names and it was more work than it was worth. So I downgraded to Calender 1.1, and modified the output code.

This all involved breaking the site for maybe half an hour, which is pretty good.

I haven't had the chance to work on this project lately, but now the plethora other small projects seem to be vanishing so I can really start work on version 2 again.

Labels:

Thursday, March 8, 2007

Parser 1.4.1 , Pages, Request & Ajax

Parser 1.4.1

Major updates on the Parser object. Version 1.3 included Parser Extensions. Version 1.4.1 includes Parser Extensions and Link formatting, in 3.5 different flavors.

First, two FrameWorks-style tags were added, "link" and "url". They do about what you'd expect, ie: "link" generates an internal link and "url" generates an internal URL. Here's the syntax:
{link:page}
{link:page|Link Text}
{url:page}

These work with the new global $fgLinkStyle. Those familiar with MediaWiki will recognize this, it's essentially the same thing, just a string with $1 in it somewhere that tells the parser how to format links.

There's also two pseudo-WikiMarkup additions: [[link]] and [http://link], which work exactly as they do in MediaWiki, including the | deliminator.

Pages

The way we'll handle pages has finally been worked out. This is fairly intricate, but also entirely encapsulated and modular, so I think it's a fair deal. New pages are stored in their own files (though you could, of course, store multiple pages in the same file). This file calls a function, ffAddPage, which takes 2-4 parameters. First is the "label" for the page, ie: some kind of text name that will appear in the URL or querystring. Second is a unique callback function (I've been starting callbacks with "fc") that actually does the processing for the page. More on this in a minute. The third and fourth parameters are booleans, setting the #3 to true will make this page the default, setting #4 true will make it the error page. This is pretty unnecessary, as there's a built-in error page you can use.

The callback functions need to take four parameters, preferably by reference—at least for the first three. Here's the format:
fcPageCallback( &$Parser, &$User, &$Request, $Subpage = false ) {...}

The $Parser parameter is the global fgParser object. The $User parameter is the global fgUser, and the $Request parameter is the global fgRequest object. The subpage is any part of the parameter after the first '/' character.

So, calling
index.php?page=page/subpage
will result in the following: if "page" exists, and the callback is defined, say fcPage, fcPage will be called with the parameters above, including the $Subpage = "subpage". It's the responsibility of the callback fcPage to output material to the browser. This lets pages generate RSS feeds using RSSFeed.

Request & Ajax

Request is a new object that handles getting variables from the HTTP request for you, including escaping quotes if magic_quotes is off. Use the method $fgRequest->getVar('varname'); to get either any request var. Note that POST vars take precedence over GET vars, and that, even if you use the POST method, if there are no POST vars, it will interpret this as essentially GET.

Ajax is almost identical to the AjaxDispatcher object in MediaWiki, that is, if $fgUseAjax is set to true, and you pass a request var called "action" set to "ajax", it will call the Ajax object and use a user-defined callback function. (Note you actually need to set "action=ajax", "rs=callback", and "rsargs=functionarguments" in your request. Though, of course, you could always global in the $fgRequest object and access anything that way.) User-defined callback functions have to be added using the void ffAddAjaxFunction( string Callback ) function.

The Ajax callback has to do two things: 1) accept a string or array as the only parameter, and 2) if necessary, it needs to handle any output to the browser.

Labels: ,

Tuesday, March 6, 2007

Bug Reports

There is a new method of bug reporting in town. Basically, I got sick of people e-mailing me directly with problems. Now the OTS uses something called the Bug Reporting and Tracking Service to handle bug reports. I always intended to get around to coding this, but didn't get to it until this week.

It's fairly straightforward. Instead of bothering with logins I just created a password protected directory to allow "admin" access. And each user can create a "bug password," which is stored in plaintext, to limit who can respond to the bug.

The real point of this new Service is to test some of the FrameWorks components. It uses DB2, Parser1.2, and RSSFeed1.1 to generate RSS feeds tracking the progress of each bug or to see the latest bugs—which I'm using to keep track of people submitting them. So far, the new components seem to be performing admirably.

Labels:

Lots of Small Changes

In the past week, there have been several small changes made throughout the FrameWorks system. Let me 'splain. No, there is too much. Let me sum up:

Parser 1.2.2: Parser got a little upgrade, to have a little more in common with Smarty and to simplify the code in pages that use it. The "addVariable" method was shortened to "set" (with an alias left for backwards compatibility) and the "setTemplate" method was made private (this may cause scripts to crash) and template selection was limited to the output function, as in Smarty. So now, code should look something like:

$parser = new Parser;
$parser->set('name', 'value');
echo $parser->output('default.htm');

It also now gets the default template directory from LocalSettings.php, which means you must first include LocalSettings.php, which means you must first define the security constant.

Calendar 1.2.1: Calendar just got updates to follow the new Parser code formats.

RSSFeed 1.1: RSSFeed got similar updates to Calendar 1.1. It now uses Parser to generate code, instead of encoding raw XML. The "addItem" method was also shortened to "add" (with an alias for backwards compatibility).

User 2.0.1 and Userdata 1.0.1: To streamline the process of accessing user information, the Rights array and associated functions were moved to the Userdata object. The User method "hasRight" is now a reference to the mUserdata object's "getRight" method.

The only major update planned for any of these at this time is the addition of ParserExtensions to the Parser object. These would use callback functions to allow custom extensions, as in the MediaWiki parser. I am currently undecided about the format for such tags or how data will be passed to the callback.

Labels:

Tuesday, February 13, 2007

Calendar 1.2

The next major revision of Calendar is done. Calendar 1.2 simplifies Calendar 1.1, reducing the CSS requirements and overall shortening the code by over 100 lines. It also abstracts the process of generating HTML, which used to be done in the Calendar object itself but now relies on templates with loops—a feature of Parser 1.2.

Currently Calendar 1.2 needs three templates. This is due to the inability to nest loops. This does give pretty specific control over how each section will look, though. The only lost functionality is the ability to use completely different CSS for "big days," used to display seven days or less, and "small days," used for two-week and month displays. Practically, the only difference was a height factor, which could easily be changed on a page-by-page basis, or left to float, with a min-height attribute.

With these major revisions of Parser and Calendar I am now going back to work on User 2.0. If anyone has advice on the best way to do session-based user login, let me know. Version 1.0 serialized the itself and stored the data in the session. Any new User object would check for the session data, and, if found, copy the data into itself. I can't decide if I want to do something like this again, or store the whole object in the session.

Labels: