[kronolith] Alternate views

Elliot Anders elliot at marlboro.edu
Tue Jul 15 11:18:52 UTC 2008


Thanks!
This looks very useful.  I actually figured out what I needed, and  
replied only to myself, but this looks even better.  Here's what I  
discovered.

It is extremely easy to make a new view.

1. Copy all associated files, rename them, and replace appropriate  
instances of the view name with your view name.  I based mine on the  
year view, so
/kronolith/year.php
/kronolith/lib/Views/Year.php
/kronolith/templates/year
2. In /kronolith/lib/Kronolith.php find all instances of WorkWeek,  
workweek, workweek.php  (works better than year in this file because  
year has alternate meanings) and copy them replacing the above three  
items with the appropriate replacements.
3. Adjust /kronolith/lib/Views/YourViewName.php to show your new view.

Thanks Chuck and Jan for making this so easy.

My new question is: is there an easy way to embed kronolith in a non  
horde website?  I feel like I've seen an article on the wiki on using  
instantiating horde outside of horde but I can't seem to find it right  
now. Basically I wan to pull this calendar I just made off our webmail  
installation and into our main website, and have it show up within our  
framework.  Are there instructions for screen-scaping horde somewhere?

Thanks again,
Elliot

On Jul 14, 2008, at 11:19 PM, Chuck Hagenbuch wrote:

> Quoting Elliot Anders <elliot at marlboro.edu>:
>
>> I have need of an alternate view of a kronolith calendar.  I need  
>> an academic year view that lists all event titles, a group of month  
>> views would probably suffice.
>>
>> Is there documentation anywhere for developing new views?
>> Has anyone done this yet?
>> How hard is it to build a new view?
>
> There isn't really documentation, but it's pretty easy. Here's most  
> of the code to do one for generating the event list for a given  
> week. You can just modify the dates passed to  
> Kronolith::listEvents(): (this particular one builds a CSV)
>
>
>
> @define('KRONOLITH_BASE', dirname(__FILE__));
> require_once KRONOLITH_BASE . '/lib/base.php';
> require_once 'Horde/Data.php';
>
> $calendars = array(...); // list the calendar ids you want to include
>
> $month = Util::getFormData('month', date('n'));
> $mday = Util::getFormData('mday', date('j'));
> $year = Util::getFormData('year', date('Y'));
>
> $date = new Horde_Date(array('month' => $month, 'year' => $year,  
> 'mday' => $mday));
> $date->correct();
> $week = $date->weekOfYear();
> if ($date->dayOfWeek() == HORDE_DATE_SUNDAY) {
>    ++$week;
> }
> if ($week == 1 && $month == 12) {
>    ++$year;
> }
>
> $firstDay = Horde_Date::firstDayOfWeek($week, $year) +  
> Date_Calc::dateToDays(1, 1, $year) - 1;
>
> list($sday, $smonth, $syear) = explode('/',  
> Date_Calc::daysToDate($firstDay, '%d/%m/%Y'));
> list($eday, $emonth, $eyear) = explode('/',  
> Date_Calc::daysToDate($firstDay + 7, '%d/%m/%Y'));
>
> $startDate = new Horde_Date(array('year' => $syear, 'month' =>  
> $smonth, 'mday' => $sday));
> $endDate = new Horde_Date(array('year' => $eyear, 'month' =>  
> $emonth, 'mday' => $eday,
>                                'hour' => 23, 'min' => 59, 'sec' =>  
> 59));
> $endDate->correct();
>
> if (Util::getFormData('download')) {
>    $events = Kronolith::listEvents($startDate, $endDate, $calendars);
>
>    $rows = array();
>    $days = array();
>    for ($i = 0; $i <= 7; $i++) {
>        list($mday, $month, $year) = explode('/',  
> Date_Calc::daysToDate($firstDay + $i, '%d/%m/%Y'));
>        $day = new Horde_Date(array('month' => $month, 'year' =>  
> $year, 'mday' => $mday));
>        $rows[] = array(date('l n/j/y', $day->timestamp()), '',  
> 'Category', '', '');
>
>        if (isset($events[$day->timestamp()])) {
>            foreach ($events[$day->timestamp()] as $devent) {
>                $rows[] = array(
>                    date('g:i A', $devent->start->timestamp()),
>                    '',
>                    $devent->category,
>                    '',
>                    $devent->title . ($devent->location ? ' (' .  
> $devent->location . ')' : ''),
>                );
>            }
>        }
>
>        $rows[] = array('', '', '', '', '');
>    }
>
>    array_pop($rows);
>
>    $csv = Horde_Data::factory('csv');
>    $csv->exportFile(_("week.csv"), $rows);
>    exit;
> }
>
>
>
> -chuck
> -- 
> Kronolith mailing list - Join the hunt: http://horde.org/bounties/#kronolith
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: kronolith-unsubscribe at lists.horde.org



More information about the kronolith mailing list