2 rcs_id('$Id: CalendarList.php,v 1.2 2004-02-17 12:11:36 rurban Exp $');
4 if (!defined('SECONDS_PER_DAY'))
5 define('SECONDS_PER_DAY', 24 * 3600);
8 * This is a list of calendar appoinments.
9 * Same arguments as Calendar, so no one is confused
10 * Uses <dl><dd>DATE<dt>page contents...
11 * Derived from Calendar.php by Martin Norbäck <martin@safelogic.se>
13 * Insert this plugin into your Calendar page, for example in:
15 * Add the line: <?plugin CalendarList ?>
18 class WikiPlugin_CalendarList
22 return _("CalendarList");
25 function getDescription () {
26 return _("CalendarList");
29 function getDefaultArguments() {
30 return array('prefix' => '[pagename]',
31 'date_format' => '%Y-%m-%d',
36 'month_format' => '%B, %Y',
37 'wday_format' => '%a',
41 function __date($dbi, $time) {
43 $date_string = strftime($args['date_format'], $time);
45 $page_for_date = $args['prefix'] . SUBPAGE_SEPARATOR . $date_string;
46 $t = localtime($time, 1);
48 $td = HTML::td(array('align' => 'center'));
50 if ($dbi->isWikiPage($page_for_date)) {
51 // Extract the page contents for this date
52 $p = $dbi->getPage($page_for_date);
53 $r = $p->getCurrentRevision();
54 $c = $r->getContent();
55 include_once('lib/BlockParser.php');
56 $content = TransformText(implode("\n", $c), $r->get('markup'));
57 $link = HTML::a(array('class' => 'cal-hide',
58 'href' => WikiURL($page_for_date,
59 array('action' => 'edit')),
60 'title' => sprintf(_("Edit %s"), $page_for_date)),
62 $a = array(HTML::dt($link), HTML::dd($content));
69 function run($dbi, $argstr, &$request, $basepage) {
70 $this->args = $this->getArgs($argstr, $request);
73 $now = localtime(time() + 3600 * $request->getPref('timeOffset'), 1);
74 foreach ( array('month' => $now['tm_mon'] + 1,
75 'year' => $now['tm_year'] + 1900)
76 as $param => $dflt ) {
78 if (!($args[$param] = intval($args[$param])))
79 $args[$param] = $dflt;
82 $time = mktime(12, 0, 0, // hh, mm, ss,
83 $args['month'] + $args['month_offset'], // month (1-12)
87 $t = localtime($time, 1);
89 if ($now['tm_year'] == $t['tm_year'] && $now['tm_mon'] == $t['tm_mon'])
90 $this->_today = $now['tm_mday'];
92 $this->_today = false;
99 $cal->pushContent($this->__date($dbi, $time));
101 $time += SECONDS_PER_DAY;
102 $t = localtime($time, 1);
103 $done = $t['tm_mday'] == 1;
111 // $Log: not supported by cvs2svn $
112 // Revision 1.1 2003/11/18 19:06:03 carstenklapp
113 // New plugin to be used in conjunction with the Calendar plugin.
114 // Upgraded to use SUBPAGE_SEPARATOR for subpages. SF patch tracker
115 // submission 565369.
124 // c-hanging-comment-ender-p: nil
125 // indent-tabs-mode: nil