steffen: server/kolab-horde-fbview/kolab-horde-fbview/fbview/kronolith/lib/Block month.php, NONE, 1.1 monthlist.php, NONE, 1.1 prevmonthlist.php, NONE, 1.1 summary.php, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Mon Oct 31 12:43:20 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-fbview/kolab-horde-fbview/fbview/kronolith/lib/Block
In directory doto:/tmp/cvs-serv18388/kolab-horde-fbview/kolab-horde-fbview/fbview/kronolith/lib/Block

Added Files:
	month.php monthlist.php prevmonthlist.php summary.php 
Log Message:
Fbview in separate package

--- NEW FILE: month.php ---
<?php
/**
 * Horde_Block_Kronolith_month:: Implementation of the Horde_Block API
 * to display a mini month view of calendar items.
 *
 * $Horde: kronolith/lib/Block/month.php,v 1.8 2004/04/26 16:55:54 chuck Exp $
 *
 * @package Horde_Block
 */
class Horde_Block_Kronolith_month extends Horde_Block {

    var $_app = 'kronolith';

    function getParams()
    {
        @define('KRONOLITH_BASE', dirname(__FILE__) . '/..');
        require_once KRONOLITH_BASE . '/lib/base.php';

        $params = array('calendar' => array('name' => _("Calendar"),
                                            'type' => 'enum',
                                            'default' => '__all'));
        $params['calendar']['values']['__all'] = _("All Visible");
        foreach (Kronolith::listCalendars() as $id => $cal) {
            $params['calendar']['values'][$id] = $cal->get('name');
        }

        $GLOBALS['registry']->popApp();
        return $params;
    }

    /**
     * The title to go in this block.
     *
     * @return string   The title text.
     */
    function _title()
    {
        global $registry;

        $title = strftime('%B, %G');
        $html  = Horde::link(Horde::url($registry->getInitialPage(), true), $title, 'header') . $title . '</a> :: ';
        $html .= Horde::link(Horde::applicationUrl('addevent.php', true), _("New Event"), 'smallheader') . Horde::img('new.gif', _("New Event"), 'align="middle"', Horde::url($registry->getParam('graphics'), true, -1)) . ' ' . _("New Event") . '</a>';

        return $html;
    }

    /**
     * The content to go in this block.
     *
     * @return string   The content
     */
    function _content()
    {
        global $prefs;
        require_once dirname(__FILE__) . '/../base.php';
        require_once KRONOLITH_BASE . '/lib/Day.php';

        Horde::addScriptFile('tooltip.js', 'horde');

        $year = date('Y');
        $month = date('m');
        $today = mktime(0, 0, 0, date('n'), date('j'), date('Y'));

        $startday = Kronolith::dayOfWeek($prefs->getValue('week_start_monday') ? 1 : 2, $month, $year);
        $daysInMonth = Date_Calc::weeksInMonth($month, $year) * 7;

        $startStamp = mktime(0, 0, 0, $month, 1 - $startday, $year);
        $startDate = Kronolith::timestampToObject($startStamp);
        $endStamp = mktime(23, 59, 59, $month, (1 - $startday) + $daysInMonth, $year);
        $endDate = Kronolith::timestampToObject($endStamp);

        /* Table start. and current month indicator. */
        $html = '<table border="0" cellpadding="1" cellspacing="1" class="monthgrid" width="100%">';

        /* Set up the weekdays. */
        $weekdays = array(_("Mo"), _("Tu"), _("We"), _("Th"), _("Fr"), _("Sa"));
        if (!$prefs->getValue('week_start_monday')) {
            array_unshift($weekdays, _("Su"));
        } else {
            array_push($weekdays, _("Su"));
        }
        foreach ($weekdays as $weekday) {
            $html .= '<th class="item">' . $weekday . '</th>';
        }

        if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
            $all_events = Kronolith::listEvents($startDate, $endDate, array($this->_params['calendar']));
        } else {
            $all_events = Kronolith::listEvents($startDate, $endDate, $GLOBALS['display_calendars']);
        }

        $weeks = array();
        $weekday = 0;
        $week = -1;
        for ($day = (1 - $startday); $day < (1 - $startday) + $daysInMonth; $day++) {
            $dayStamp = mktime(0, 0, 0, $month, $day, $year);

            if ($weekday == 7) {
                $weekday = 0;
            }
            if ($weekday == 0) {
                $week++;
                $html .= '</tr><tr>';
            }

            if (mktime(0, 0, 0) == $dayStamp) {
                $td_class = 'today';
            } elseif (date('n', $dayStamp) != $month) {
                $td_class = 'othermonth';
            } elseif (date('w', $dayStamp) == 0 || date('w', $dayStamp) == 6) {
                $td_class = 'weekend';
            } else {
                $td_class = 'text';
            }
            $html .= '<td align="center" class="' . $td_class . '">';

            /* Set up the link to the day view. */
            $url = Horde::applicationUrl('day.php', true);
            $url = Util::addParameter($url, array('timestamp' => $dayStamp));

            if (!empty($all_events[$dayStamp])) {
                /* There are events; create a cell with tooltip to
                 * list them. */
                $day_events = '';
                foreach ($all_events[$dayStamp] as $event) {
                    $day_events .= date($prefs->getValue('twentyFour') ? 'G:i' : 'g:ia', $event->getStartTimestamp()) . ' - ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:ia', $event->getEndTimestamp());
                    $day_events .= ($event->getLocation()) ? ' (' . $event->getLocation() . ')' : '';
                    $day_events .= ' ' . $event->getTitle() . "\n";
                }
                $cell = Horde::linkTooltip($url, _("View Day"), '', '', '', $day_events) . date('j', $dayStamp) . '</a>';
            } else {
                /* No events, plain link to the day. */
                $cell = Horde::linkTooltip($url, _("View Day")) . date('j', $dayStamp) . '</a>';
            }

            /* Bold the cell if there are events. */
            if (!empty($all_events[$dayStamp])) {
                $cell = '<b>' . $cell . '</b>';
            }

            $html .= $cell . '</td>';
            $weekday++;
        }

        $html .= '</tr><tr><td colspan="7" class="control" align="center">';
        $url = Horde::applicationUrl('day.php', true);
        $url = Util::addParameter($url, array('timestamp' => time()));
        $today_link = strftime($prefs->getValue('date_format'), time());
        $today_link = Horde::link($url) . $today_link . '</a>';

        $html .= sprintf(_("Today is %s"), $today_link);
        $html .= '</td></tr></table>';

        return $html;
    }

}

--- NEW FILE: monthlist.php ---
<?php
/**
 * Horde_Block_Kronolith_monthlist:: Implementation of the Horde_Block API
 * to display a list of calendar items grouped by month.
 *
 * $Horde: kronolith/lib/Block/monthlist.php,v 1.12 2004/05/27 17:51:54 chuck Exp $
 *
 * @package Horde_Block
 */
class Horde_Block_Kronolith_monthlist extends Horde_Block {

    var $_app = 'kronolith';

    function getParams()
    {
        @define('KRONOLITH_BASE', dirname(__FILE__) . '/..');
        require_once KRONOLITH_BASE . '/lib/base.php';

        $params = array('calendar' => array('name' => _("Calendar"),
                                            'type' => 'enum',
                                            'default' => '__all'),
                        'months'   => array('name' => _("Months Ahead"),
                                            'type' => 'int',
                                            'default' => '2'));
        $params['calendar']['values']['__all'] = _("All Visible");
        foreach (Kronolith::listCalendars() as $id => $cal) {
            $params['calendar']['values'][$id] = $cal->get('name');
        }

        $GLOBALS['registry']->popApp();
        return $params;
    }

    /**
     * The title to go in this block.
     *
     * @return string   The title text.
     */
    function _title()
    {
        global $registry;

        $html  = Horde::link(Horde::url($registry->getInitialPage(), true), _("Monthly Events List"), 'header') . _("Monthly Events List") . '</a> :: ';
        $html .= Horde::link(Horde::applicationUrl('addevent.php', true), _("New Event"), 'smallheader') . Horde::img('new.gif', _("New Event"), 'align="middle"', Horde::url($registry->getParam('graphics'), true, -1)) . ' ' . _("New Event") . '</a>';

        return $html;
    }

    /**
     * The content to go in this block.
     *
     * @return string   The content
     */
    function _content()
    {
        global $registry, $prefs, $cManager;
        require_once dirname(__FILE__) . '/../base.php';
        require_once KRONOLITH_BASE . '/lib/Day.php';

        Horde::addScriptFile('tooltip.js', 'horde');

        $now = time();
        $today = date('j');
        $current_month = '';
        $colors = $cManager->colors();

        /* Get timestamps. */
        $startDate = mktime(0, 0, 0, date('n'), 1);
        $endDate = mktime(0, 0, 0, date('n') + $this->_params['months'], $today);

        /* Get Kronolith objects from timestamps. */
        $startDate_object = Kronolith::timestampToObject($startDate);
        $endDate_object = Kronolith::timestampToObject($endDate);

        if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
            $allevents = Kronolith::listEvents($startDate_object, $endDate_object, array($this->_params['calendar']));
        } else {
            $allevents = Kronolith::listEvents($startDate_object, $endDate_object, $GLOBALS['display_calendars']);
        }

        $html = '<table border="0" cellpadding="0" cellspacing="0" width="100%">';

        /* How many days do we need to check. */
        $iMax = ($endDate - $startDate) / 86400;

        /* Loop through the days. */
        for ($i = $today; $i < $iMax; $i++) {
            $day = &new Kronolith_Day(date('n'), $i);
            $today_stamp = $day->getStamp();
            if (empty($allevents[$today_stamp])) {
                continue;
            }

            $events = &$allevents[$today_stamp];
            $firstevent = true;
            $htmldays = array();

            /* Output month header. */
            if ($current_month != $day->month) {
                $current_month = strftime('%m', $today_stamp);
                $html .= '<tr><td colspan="4" class="control"><b>' . strftime('%B', $today_stamp) . '</b></td></tr>';
            }

            $today12am = mktime(0, 0, 0, $day->month, $day->mday, $day->year);
            $tomorrow12am = mktime(0, 0, 0, $day->month, $day->mday + 1, $day->year);
            foreach ($events as $event) {
                if (!$event->hasRecurType(KRONOLITH_RECUR_NONE)) {
                    $event->startTimestamp = mktime($event->start->hour, $event->start->min, $event->start->sec, $day->month, $day->mday, $day->year);
                    $event->endTimestamp = $event->startTimestamp + $event->durMin * 60;
                } else {
                    if ($event->startTimestamp < $today12am) {
                        $event->startTimestamp = $today12am;
                    }
                    if ($event->endTimestamp >= $tomorrow12am) {
                        $event->endTimestamp = $tomorrow12am;
                    }
                }
                if ($event->endTimestamp < $now) continue;
                if ($prefs->getValue('summary_alarms') && !$event->alarm) continue;
                if ($firstevent) {
                    $html .= '<tr><td class="text" valign="top" align="right"><b>';
                    if ($day->isToday()) {
                        $html .= _("Today");
                    } elseif ($day->isTomorrow()) {
                        $html .= _("Tomorrow");
                    } else {
                        $html .= strftime('%e', $today_stamp);
                    }
                    $html .= '</b> </td>';
                    $htmlday = '';
                    $firstevent = false;
                } else {
                    $htmlday = '<tr><td class="text"> </td>';
                }

                $htmlday .= '<td class="text" nowrap="nowrap" valign="top">';
                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '<b>';
                }

                /* The following check to make sure the start time is
                 * not 12AM was changed to use the getStartDate
                 * function to get the startTimestamp hour and min
                 * instead of using start->hour and start->min. When
                 * using the SQL driver this change properly lists a
                 * multiday event as 'All day' if it spans the entire
                 * day. It shouldn't affect the MCAL driver since in
                 * the case of the MCAL driver the startTimestamp hour
                 * and min are the same as start->hour and
                 * start->min. */
                if ($event->getStartDate('G') != 0 ||
                    $event->getStartDate('i') != 0 ||
                    (($event->endTimestamp - $event->startTimestamp) % (24 * 60 * 60)) != 0) {
                    if ($prefs->getValue('twentyFour')) {
                        $time  = date('G:i', $event->startTimestamp) . '-';
                        $time .= date('G:i', $event->endTimestamp);
                    } else {
                        $time  = date('g:i A', $event->startTimestamp) . '-';
                        $time .= date('g:i A', $event->endTimestamp);
                    }
                } else {
                    $time = _("All day event");
                }

                $text = $event->getTitle();
                if ($location = $event->getLocation()) {
                    $htmlday .= $location;
                }

                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '</b>';
                }

                $categoryColor = isset($colors[$event->getCategory()]) ? $colors[$event->getCategory()] : $colors['_default_'];
                $htmlday .= '</td><td class="text">   </td>';
                $htmlday .= '<td class="block-eventbox" style="background-color: ' . $categoryColor . '; ';
                $htmlday .= 'border-color: ' . Kronolith::borderColor($categoryColor) . '" ';
                $htmlday .= 'onmouseover="javascript:style.backgroundColor=\'' . Kronolith::highlightColor($categoryColor) . '\'" ';
                $htmlday .= 'onmouseout="javascript:style.backgroundColor=\'' . $categoryColor . '\'" ';
                $htmlday .= 'valign="top">';

                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '<b>';
                }
                if (isset($event->eventID)) {
                    $htmlday .= $event->getLink(null, true);
                } elseif (isset($event->taskID)) {
                    $htmlday .= Horde::link(Horde::url($registry->link('tasks/show', array('task' => $event->taskID,
                                                                                           'tasklist' => $event->tasklistID)),
                                                       true), $event->title) . $text . '</a>';
                } else {
                    $htmlday .= $text;
                }
                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $html .= '</b>';
                }
                $htmlday .= '</td></tr>';
                while (isset($htmldays[$event->startTimestamp])) {
                    $event->startTimestamp++;
                }
                $htmldays[$event->startTimestamp] = $htmlday;
            }
            ksort($htmldays);
            $html .= implode("\n", $htmldays);

        }

        if (empty($htmldays)) {
            $html .= sprintf('<i>%s</i>', _("No events to display"));
        }
        return $html . '</table>';
    }

}

--- NEW FILE: prevmonthlist.php ---
<?php
/**
 * Horde_Block_Kronolith_monthlist:: Implementation of the Horde_Block
 * API to display a list of previous calendar items grouped by month.
 *
 * $Horde: kronolith/lib/Block/prevmonthlist.php,v 1.3 2004/05/27 17:51:54 chuck Exp $
 *
 * @package Horde_Block
 */
class Horde_Block_Kronolith_prevmonthlist extends Horde_Block {

    var $_app = 'kronolith';

    function getParams()
    {
        @define('KRONOLITH_BASE', dirname(__FILE__) . '/..');
        require_once KRONOLITH_BASE . '/lib/base.php';

        $params = array('calendar' => array('name' => _("Calendar"),
                                            'type' => 'enum',
                                            'default' => '__all'),
                        'months'   => array('name' => _("Months Before"),
                                            'type' => 'int',
                                            'default' => '2'));
        $params['calendar']['values']['__all'] = _("All Visible");
        foreach (Kronolith::listCalendars() as $id => $cal) {
            $params['calendar']['values'][$id] = $cal->get('name');
        }

        $GLOBALS['registry']->popApp();
        return $params;
    }

    /**
     * The title to go in this block.
     *
     * @return string   The title text.
     */
    function _title()
    {
        global $registry;

        return Horde::link(Horde::url($registry->getInitialPage(), true), _("Missed Events List"), 'header') . _("Missed Events List") . '</a>';
    }

    /**
     * The content to go in this block.
     *
     * @return string   The content
     */
    function _content()
    {
        global $registry, $prefs, $cManager;
        require_once dirname(__FILE__) . '/../base.php';
        require_once KRONOLITH_BASE . '/lib/Day.php';

        Horde::addScriptFile('tooltip.js', 'horde');

        $now = mktime(0, 0, 0, date('n') - 2);
        $today = date('j');
        $current_month = '';
        $colors = $cManager->colors();

        /* Get timestamps. */
        $startDate = mktime(0, 0, 0, date('n') - 2, 1);
        $endDate = time();

        /* Get Kronolith objects from timestamps. */
        $startDate_object = Kronolith::timestampToObject($startDate);
        $endDate_object = Kronolith::timestampToObject($endDate);

        if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
            $allevents = Kronolith::listEvents($startDate_object, $endDate_object, array($this->_params['calendar']));
        } else {
            $allevents = Kronolith::listEvents($startDate_object, $endDate_object, $GLOBALS['display_calendars']);
        }

        $html = '<table border="0" cellpadding="0" cellspacing="0" width="100%">';

        /* How many days do we need to check. */
        $iMax = ($endDate - $startDate) / 86400;

        /* Loop through the days. */
        for ($i = $today; $i < $iMax; $i++) {
            $day = &new Kronolith_Day(date('n') - 2, $i);
            $today_stamp = $day->getStamp();
            if (empty($allevents[$today_stamp])) {
                continue;
            }

            $events = &$allevents[$today_stamp];
            $firstevent = true;
            $htmldays = array();

            /* Output month header. */
            if ($current_month != $day->month) {
                $current_month = strftime('%m', $today_stamp);
                $html .= '<tr><td colspan="4" class="control"><b>' . strftime('%B', $today_stamp) . '</b></td></tr>';
            }

            $today12am = mktime(0, 0, 0, $day->month, $day->mday, $day->year);
            $tomorrow12am = mktime(0, 0, 0, $day->month, $day->mday + 1, $day->year);
            foreach ($events as $event) {
                if (!$event->hasRecurType(KRONOLITH_RECUR_NONE)) {
                    $event->startTimestamp = mktime($event->start->hour, $event->start->min, $event->start->sec, $day->month, $day->mday, $day->year);
                    $event->endTimestamp = $event->startTimestamp + $event->durMin * 60;
                } else {
                    if ($event->startTimestamp < $today12am) {
                        $event->startTimestamp = $today12am;
                    }
                    if ($event->endTimestamp >= $tomorrow12am) {
                        $event->endTimestamp = $tomorrow12am;
                    }
                }
                if ($event->endTimestamp < $now) continue;
                if ($prefs->getValue('summary_alarms') && !$event->alarm) continue;
                if ($firstevent) {
                    $html .= '<tr><td class="text" valign="top" align="right"><b>';
                    if ($day->isToday()) {
                        $html .= _("Today");
                    } elseif ($day->isTomorrow()) {
                        $html .= _("Tomorrow");
                    } else {
                        $html .= strftime('%e', $today_stamp);
                    }
                    $html .= '</b> </td>';
                    $htmlday = '';
                    $firstevent = false;
                } else {
                    $htmlday = '<tr><td class="text"> </td>';
                }

                $htmlday .= '<td class="text" nowrap="nowrap" valign="top">';
                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '<b>';
                }

                /* The following check to make sure the start time is
                 * not 12AM was changed to use the getStartDate
                 * function to get the startTimestamp hour and min
                 * instead of using start->hour and start->min. When
                 * using the SQL driver this change properly lists a
                 * multiday event as 'All day' if it spans the entire
                 * day. It shouldn't affect the MCAL driver since in
                 * the case of the MCAL driver the startTimestamp hour
                 * and min are the same as start->hour and
                 * start->min. */
                if ($event->getStartDate('G') != 0 ||
                    $event->getStartDate('i') != 0 ||
                    (($event->endTimestamp - $event->startTimestamp) % (24 * 60 * 60)) != 0) {
                    if ($prefs->getValue('twentyFour')) {
                        $time  = date('G:i', $event->startTimestamp) . '-';
                        $time .= date('G:i', $event->endTimestamp);
                    } else {
                        $time  = date('g:i A', $event->startTimestamp) . '-';
                        $time .= date('g:i A', $event->endTimestamp);
                    }
                } else {
                    $time = _("All day event");
                }

                $text = $event->getTitle();
                if ($location = $event->getLocation()) {
                    $htmlday .= $location;
                }

                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '</b>';
                }

                $categoryColor = isset($colors[$event->getCategory()]) ? $colors[$event->getCategory()] : $colors['_default_'];
                $htmlday .= '</td><td class="text">   </td>';
                $htmlday .= '<td class="block-eventbox" style="background-color: ' . $categoryColor . '; ';
                $htmlday .= 'border-color: ' . Kronolith::borderColor($categoryColor) . '" ';
                $htmlday .= 'onmouseover="javascript:style.backgroundColor=\'' . Kronolith::highlightColor($categoryColor) . '\'" ';
                $htmlday .= 'onmouseout="javascript:style.backgroundColor=\'' . $categoryColor . '\'" ';
                $htmlday .= 'valign="top">';

                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '<b>';
                }
                if (isset($event->eventID)) {
                    $htmlday .= $event->getLink(null, true);
                } elseif (isset($event->taskID)) {
                    $htmlday .= Horde::link(Horde::url($registry->link('tasks/show', array('task' => $event->taskID,
                                                                                           'tasklist' => $event->tasklistID)),
                                                       true), $event->title) . $text . '</a>';
                } else {
                    $htmlday .= $text;
                }
                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $html .= '</b>';
                }
                $htmlday .= '</td></tr>';
                while (isset($htmldays[$event->startTimestamp])) {
                    $event->startTimestamp++;
                }
                $htmldays[$event->startTimestamp] = $htmlday;
            }
            ksort($htmldays);
            $html .= implode("\n", $htmldays);

        }

        if (empty($htmldays)) {
            $html .= sprintf('<i>%s</i>', _("No events to display"));
        }
        return $html . '</table>';
    }

}

--- NEW FILE: summary.php ---
<?php
/**
 * Horde_Block_Kronolith_summary:: Implementation of the Horde_Block API
 * to display a summary of calendar items.
 *
 * $Horde: kronolith/lib/Block/summary.php,v 1.27 2004/05/27 17:51:54 chuck Exp $
 *
 * @package Horde_Block
 */
class Horde_Block_Kronolith_summary extends Horde_Block {

    var $_app = 'kronolith';

    function getParams()
    {
        @define('KRONOLITH_BASE', dirname(__FILE__) . '/..');
        require_once KRONOLITH_BASE . '/lib/base.php';

        $params = array('calendar' => array('name' => _("Calendar"),
                                            'type' => 'enum',
                                            'default' => '__all'));
        $params['calendar']['values']['__all'] = _("All Visible");
        foreach (Kronolith::listCalendars() as $id => $cal) {
            $params['calendar']['values'][$id] = $cal->get('name');
        }

        $GLOBALS['registry']->popApp();
        return $params;
    }

    /**
     * The title to go in this block.
     *
     * @return string   The title text.
     */
    function _title()
    {
        global $registry;

        $html  = Horde::link(Horde::url($registry->getInitialPage(), true), $registry->getParam('name'), 'header') . $registry->getParam('name') . '</a> :: ';
        $html .= Horde::link(Horde::applicationUrl('addevent.php', true), _("New Event"), 'smallheader') . Horde::img('new.gif', _("New Event"), 'align="middle"', Horde::url($registry->getParam('graphics'), true, -1)) . ' ' . _("New Event") . '</a>';

        return $html;
    }

    /**
     * The content to go in this block.
     *
     * @return string   The content
     */
    function _content()
    {
        global $registry, $prefs, $cManager;
        require_once dirname(__FILE__) . '/../base.php';
        require_once KRONOLITH_BASE . '/lib/Day.php';

        Horde::addScriptFile('tooltip.js', 'horde');

        $now = time();
        $today = date('j');
        $colors = $cManager->colors();
        $startDate = Kronolith::timestampToObject(mktime(0, 0, 0));
        $endDate = Kronolith::timestampToObject(mktime(0, 0, 0, date('n'), $today + $prefs->getValue('summary_days')));

        if (isset($this->_params['calendar']) && $this->_params['calendar'] != '__all') {
            $allevents = Kronolith::listEvents($startDate, $endDate, array($this->_params['calendar']));
        } else {
            $allevents = Kronolith::listEvents($startDate, $endDate, $GLOBALS['display_calendars']);
        }

        $html = '<table border="0" cellpadding="0" cellspacing="0" width="100%">';
        $iMax = $today + $prefs->getValue('summary_days');
        $firstday = true;
        for ($i = $today; $i < $today + $iMax; $i++) {
            $day = &new Kronolith_Day(date('n'), $i);
            if (empty($allevents[$day->getStamp()])) {
                continue;
            }

            $events = &$allevents[$day->getStamp()];
            $firstevent = true;
            $htmldays = array();

            $today12am = mktime(0, 0, 0, $day->month, $day->mday, $day->year);
            $tomorrow12am = mktime(0, 0, 0, $day->month, $day->mday + 1, $day->year);
            foreach ($events as $event) {
                if (!$event->hasRecurType(KRONOLITH_RECUR_NONE)) {
                    $event->startTimestamp = mktime($event->start->hour, $event->start->min, $event->start->sec, $day->month, $day->mday, $day->year);
                    $event->endTimestamp = $event->startTimestamp + $event->durMin * 60;
                } else {
                    if ($event->startTimestamp < $today12am) {
                        $event->startTimestamp = $today12am;
                    }
                    if ($event->endTimestamp >= $tomorrow12am) {
                        $event->endTimestamp = $tomorrow12am;
                    }
                }
                if ($event->endTimestamp < $now) continue;
                if ($prefs->getValue('summary_alarms') && !$event->alarm) continue;
                if ($firstevent) {
                    if (!$firstday) {
                        $html .= '<tr><td colspan="3" style="font-size:2px;"> </td></tr>';
                    }
                    $html .= '<tr><td colspan="3" class="control"><b>';
                    if ($day->isToday()) {
                        $dayname = _("Today");
                    } elseif ($day->isTomorrow()) {
                        $dayname = _("Tomorrow");
                    } else {
                        $dayname = strftime($prefs->getValue('date_format'), $day->getStamp());
                    }
                    $daylink = Horde::applicationUrl('day.php');
                    $daylink = Util::addParameter($daylink, 'timestamp', $day->getStamp());
                    $html .= Horde::link($daylink, sprintf(_("Goto %s"), $dayname));
                    $html .= $dayname . '</a></b></td></tr>';
                    $firstevent = false;
                    $firstday = false;
                }
                $htmlday = '<tr><td class="text" nowrap="nowrap" valign="top">';
                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '<b>';
                }

                /* The following check to make sure the start time is
                 * not 12AM was changed to use the getStartDate
                 * function to get the startTimestamp hour and min
                 * instead of using start->hour and start->min. When
                 * using the SQL driver this change properly lists a
                 * multiday event as 'All day' if it spans the entire
                 * day. It shouldn't affect the MCAL driver since in
                 * the case of the MCAL driver the startTimestamp hour
                 * and min are the same as start->hour and
                 * start->min. */
                if ($event->getStartDate('G') != 0 ||
                    $event->getStartDate('i') != 0 ||
                    (($event->endTimestamp - $event->startTimestamp) % (24 * 60 * 60)) != 0) {
                    if ($prefs->getValue('twentyFour')) {
                        $time  = date('G:i', $event->startTimestamp) . '-';
                        $time .= date('G:i', $event->endTimestamp);
                    } else {
                        $time  = date('g:i A', $event->startTimestamp) . '-';
                        $time .= date('g:i A', $event->endTimestamp);
                    }
                } else {
                    $time = _("All day event");
                }

                $text = $event->getTitle();
                if ($location = $event->getLocation()) {
                    $text .= ' (' . $location . ')';
                }
                if (isset($event->taskID)) {
                    $htmlday .= Horde::link(Horde::url($registry->link('tasks/show',
                                                                       array('task' => $event->taskID,
                                                                             'tasklist' => $event->tasklistID)),
                                                       $event->title)) . $time . '</a>';
                } else {
                    $htmlday .= $time;
                }
                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '</b>';
                }

                $categoryColor = isset($colors[$event->getCategory()]) ? $colors[$event->getCategory()] : $colors['_default_'];
                $htmlday .= '</td><td class="text">   </td>';
                $htmlday .= '<td class="block-eventbox" style="background-color: ' . $categoryColor . '; ';
                $htmlday .= 'border-color: ' . Kronolith::borderColor($categoryColor) . '" ';
                $htmlday .= 'onmouseover="javascript:style.backgroundColor=\'' . Kronolith::highlightColor($categoryColor) . '\'" ';
                $htmlday .= 'onmouseout="javascript:style.backgroundColor=\'' . $categoryColor . '\'" ';
                $htmlday .= 'valign="top">';

                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $htmlday .= '<b>';
                }
                if (isset($event->eventID)) {
                    $htmlday .= $event->getLink(null, true);
                } elseif (isset($event->taskID)) {
                    $htmlday .= Horde::link(Horde::url($registry->link('tasks/show', array('task' => $event->taskID,
                                                                                           'tasklist' => $event->tasklistID)),
                                                       true), $event->title) . $text . '</a>';
                } else {
                    $htmlday .= $text;
                }
                if ($event->startTimestamp < $now && $event->endTimestamp > $now) {
                    $html .= '</b>';
                }
                $htmlday .= '</td></tr>';
                while (isset($htmldays[$event->startTimestamp])) {
                    $event->startTimestamp++;
                }
                $htmldays[$event->startTimestamp] = $htmlday;
            }
            ksort($htmldays);
            $html .= implode("\n", $htmldays);

        }

        if (empty($htmldays)) {
            $html .= '<i>' . _("No events to display") . '</i>';
        }
        return $html . '</table>';
    }

}





More information about the commits mailing list