Calendar

My first attempt to the calendar widget has failed. I have tried to override Ext.DatePicker to allow it to be loaded by an array of dates. To be more exact: in order to have something like on the picture below I wanted to load DatePicked with the following array: ['2007-08-01','2007-08-03', '2007-08-07'].

I still like the idea, but I have realized that it would take to much time to do. Apart from overriding DatePicked (loading with array would not be enough) I would need to write a php code that generates the array make it synchronized somehow with the rest of theme and so on. Thus I decided to use a “shortcut”. I have rewritten original Wordpress calendar widget and skinned it with Ext DatePicker styles. On “widget_calendar.php” you will find two functions widget_extjslike_calendar() calls get_extjslike_calendar(), the last one do the job. Then I created new Wordpress template file as follows (the file is called “content_widget_calendar.php”):

<?php
if(!function_exists(‘get_option’))
  require_once(‘../../../wp-config.php’);
 
require_once(‘widget_calendar.php’);
get_extjslike_calendar();
?>

Then I have written simple javascript stuff that allows to switch between months. Perhaps this fadeIn and fadeOut trick is to fancy, but in a mean time I decided to leave it as it is:

<script>
. . .
loadCalendar: function(url) {
    var c = Ext.get(‘calendar_wrap’);
    c.fadeOut({
        callback : loadCalendarCallback
    });
    function loadCalendarCallback() {
        c.load(url, {backgroundCalendar:true}, function(e) {
            e.fadeIn();
        });
    }
}
. . .
</script>

Then, at the end, I have put into theme’s functions.php two things: new calendar widget registration (that displays calendar during page load), and Wordpress’ hierarchy break (that makes possible reloding calendar with previous/next months):

. . .
// calendar widget registration
require_once(‘widget_calendar.php’);
if ( function_exists(‘register_sidebar_widget’) ) {
    register_sidebar_widget(__(‘Calendar’), ‘widget_extjslike_calendar’);
}
// new template handling
if (isset($_POST[‘backgroundCalendar’])) {
    add_action(‘template_redirect’, ‘content_widget_calendar’);
}
function content_widget_calendar() {
    include(TEMPLATEPATH . ‘/content_widget_calendar.php’);
    exit;
}
. . .