blob: 299cb50472756086a763059e64dd81101fc856fa [file] [log] [blame]
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +02001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +02008 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05009 * Licensed under the Open Software License version 3.0
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +020010 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -050011 * This source file is subject to the Open Software License (OSL 3.0) that is
12 * bundled with this package in the files license.txt / license.rst. It is
13 * also available through the world wide web at this URL:
14 * http://opensource.org/licenses/OSL-3.0
15 * If you did not receive a copy of the license and are unable to obtain it
16 * through the world wide web, please send an email to
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Derek Allard2067d1a2008-11-13 22:59:24 +000019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
21 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
22 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
24 * @since Version 1.0
25 * @filesource
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * CodeIgniter Calendar Class
32 *
33 * This class enables the creation of calendars
34 *
35 * @package CodeIgniter
36 * @subpackage Libraries
37 * @category Libraries
Derek Jonesf4a4bd82011-10-20 12:18:42 -050038 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000039 * @link http://codeigniter.com/user_guide/libraries/calendar.html
40 */
41class CI_Calendar {
42
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +020043 private $CI;
44 public $lang;
45 public $local_time;
46 public $template = '';
47 public $start_day = 'sunday';
48 public $month_type = 'long';
49 public $day_type = 'abr';
50 public $show_next_prev = FALSE;
51 public $next_prev_url = '';
Derek Allard2067d1a2008-11-13 22:59:24 +000052
53 /**
54 * Constructor
55 *
56 * Loads the calendar language file and sets the default time reference
Derek Allard2067d1a2008-11-13 22:59:24 +000057 */
Greg Akera9263282010-11-10 15:26:43 -060058 public function __construct($config = array())
Barry Mienydd671972010-10-04 16:33:58 +020059 {
Derek Allard2067d1a2008-11-13 22:59:24 +000060 $this->CI =& get_instance();
Barry Mienydd671972010-10-04 16:33:58 +020061
Greg Aker3a746652011-04-19 10:59:47 -050062 if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE))
Derek Allard2067d1a2008-11-13 22:59:24 +000063 {
64 $this->CI->lang->load('calendar');
65 }
66
67 $this->local_time = time();
Barry Mienydd671972010-10-04 16:33:58 +020068
Derek Allard2067d1a2008-11-13 22:59:24 +000069 if (count($config) > 0)
70 {
71 $this->initialize($config);
72 }
Barry Mienydd671972010-10-04 16:33:58 +020073
Derek Allard2067d1a2008-11-13 22:59:24 +000074 log_message('debug', "Calendar Class Initialized");
75 }
Barry Mienydd671972010-10-04 16:33:58 +020076
Derek Allard2067d1a2008-11-13 22:59:24 +000077 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +020078
Derek Allard2067d1a2008-11-13 22:59:24 +000079 /**
80 * Initialize the user preferences
81 *
82 * Accepts an associative array as input, containing display preferences
83 *
84 * @access public
85 * @param array config preferences
86 * @return void
Barry Mienydd671972010-10-04 16:33:58 +020087 */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +020088 public function initialize($config = array())
Derek Allard2067d1a2008-11-13 22:59:24 +000089 {
90 foreach ($config as $key => $val)
91 {
92 if (isset($this->$key))
93 {
94 $this->$key = $val;
95 }
96 }
97 }
Barry Mienydd671972010-10-04 16:33:58 +020098
Derek Allard2067d1a2008-11-13 22:59:24 +000099 // --------------------------------------------------------------------
100
101 /**
102 * Generate the calendar
103 *
104 * @access public
105 * @param integer the year
106 * @param integer the month
107 * @param array the data to be shown in the calendar cells
108 * @return string
109 */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200110 public function generate($year = '', $month = '', $data = array())
Derek Allard2067d1a2008-11-13 22:59:24 +0000111 {
112 // Set and validate the supplied month/year
113 if ($year == '')
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200114 $year = date('Y', $this->local_time);
115 elseif (strlen($year) === 1)
Derek Allard2067d1a2008-11-13 22:59:24 +0000116 $year = '200'.$year;
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200117 elseif (strlen($year) === 2)
Derek Allard2067d1a2008-11-13 22:59:24 +0000118 $year = '20'.$year;
119
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200120 if ($month == '')
121 $month = date('m', $this->local_time);
122 elseif (strlen($month) === 1)
Derek Allard2067d1a2008-11-13 22:59:24 +0000123 $month = '0'.$month;
Barry Mienydd671972010-10-04 16:33:58 +0200124
Derek Allard2067d1a2008-11-13 22:59:24 +0000125 $adjusted_date = $this->adjust_date($month, $year);
Barry Mienydd671972010-10-04 16:33:58 +0200126
Derek Allard2067d1a2008-11-13 22:59:24 +0000127 $month = $adjusted_date['month'];
128 $year = $adjusted_date['year'];
Barry Mienydd671972010-10-04 16:33:58 +0200129
Derek Allard2067d1a2008-11-13 22:59:24 +0000130 // Determine the total days in the month
131 $total_days = $this->get_total_days($month, $year);
Barry Mienydd671972010-10-04 16:33:58 +0200132
Derek Allard2067d1a2008-11-13 22:59:24 +0000133 // Set the starting day of the week
134 $start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
135 $start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day];
Barry Mienydd671972010-10-04 16:33:58 +0200136
Derek Allard2067d1a2008-11-13 22:59:24 +0000137 // Set the starting day number
138 $local_date = mktime(12, 0, 0, $month, 1, $year);
139 $date = getdate($local_date);
Derek Jones37f4b9c2011-07-01 17:56:50 -0500140 $day = $start_day + 1 - $date["wday"];
Barry Mienydd671972010-10-04 16:33:58 +0200141
Derek Allard2067d1a2008-11-13 22:59:24 +0000142 while ($day > 1)
143 {
144 $day -= 7;
145 }
Barry Mienydd671972010-10-04 16:33:58 +0200146
Derek Allard2067d1a2008-11-13 22:59:24 +0000147 // Set the current month/year/day
148 // We use this to determine the "today" date
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200149 $cur_year = date('Y', $this->local_time);
150 $cur_month = date('m', $this->local_time);
151 $cur_day = date('j', $this->local_time);
Barry Mienydd671972010-10-04 16:33:58 +0200152
Derek Allard2067d1a2008-11-13 22:59:24 +0000153 $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
Barry Mienydd671972010-10-04 16:33:58 +0200154
Derek Allard2067d1a2008-11-13 22:59:24 +0000155 // Generate the template data array
156 $this->parse_template();
Derek Allard2067d1a2008-11-13 22:59:24 +0000157
Barry Mienydd671972010-10-04 16:33:58 +0200158 // Begin building the calendar output
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200159 $out = $this->temp['table_open'] . "\n\n" . $this->temp['heading_row_start'] . "\n";
Barry Mienydd671972010-10-04 16:33:58 +0200160
Derek Allard2067d1a2008-11-13 22:59:24 +0000161 // "previous" month link
162 if ($this->show_next_prev == TRUE)
163 {
Derek Jones37f4b9c2011-07-01 17:56:50 -0500164 // Add a trailing slash to the URL if needed
165 $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
Barry Mienydd671972010-10-04 16:33:58 +0200166
Derek Allard2067d1a2008-11-13 22:59:24 +0000167 $adjusted_date = $this->adjust_date($month - 1, $year);
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200168 $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000169 }
170
171 // Heading containing the month/year
172 $colspan = ($this->show_next_prev == TRUE) ? 5 : 7;
Barry Mienydd671972010-10-04 16:33:58 +0200173
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200174 $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan,
175 str_replace('{heading}', $this->get_month_name($month).'&nbsp;'.$year, $this->temp['heading_title_cell']));
Barry Mienydd671972010-10-04 16:33:58 +0200176
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200177 $out .= $this->temp['heading_title_cell'] . "\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000178
179 // "next" month link
180 if ($this->show_next_prev == TRUE)
Barry Mienydd671972010-10-04 16:33:58 +0200181 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000182 $adjusted_date = $this->adjust_date($month + 1, $year);
183 $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']);
184 }
185
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200186 $out .= "\n" . $this->temp['heading_row_end'] . "\n\n"
187 // Write the cells containing the days of the week
188 . $this->temp['week_row_start'] . "\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000189
190 $day_names = $this->get_day_names();
191
192 for ($i = 0; $i < 7; $i ++)
193 {
194 $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']);
195 }
196
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200197 $out .= "\n" . $this->temp['week_row_end'] . "\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000198
199 // Build the main body of the calendar
200 while ($day <= $total_days)
201 {
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200202 $out .= "\n" . $this->temp['cal_row_start'] . "\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000203
204 for ($i = 0; $i < 7; $i++)
205 {
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200206 $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
Barry Mienydd671972010-10-04 16:33:58 +0200207
Derek Allard2067d1a2008-11-13 22:59:24 +0000208 if ($day > 0 AND $day <= $total_days)
Barry Mienydd671972010-10-04 16:33:58 +0200209 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000210 if (isset($data[$day]))
Barry Mienydd671972010-10-04 16:33:58 +0200211 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000212 // Cells with content
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200213 $temp = ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
214 $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp);
Derek Allard2067d1a2008-11-13 22:59:24 +0000215 }
216 else
217 {
218 // Cells with no content
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200219 $temp = ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
Derek Allard2067d1a2008-11-13 22:59:24 +0000220 $out .= str_replace('{day}', $day, $temp);
221 }
222 }
223 else
224 {
225 // Blank cells
226 $out .= $this->temp['cal_cell_blank'];
227 }
Barry Mienydd671972010-10-04 16:33:58 +0200228
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200229 $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
Derek Allard2067d1a2008-11-13 22:59:24 +0000230 $day++;
231 }
Barry Mienydd671972010-10-04 16:33:58 +0200232
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200233 $out .= "\n" . $this->temp['cal_row_end'] . "\n";
Derek Allard2067d1a2008-11-13 22:59:24 +0000234 }
235
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200236 $out .= "\n" . $this->temp['table_close'];
Derek Allard2067d1a2008-11-13 22:59:24 +0000237
238 return $out;
239 }
Barry Mienydd671972010-10-04 16:33:58 +0200240
Derek Allard2067d1a2008-11-13 22:59:24 +0000241 // --------------------------------------------------------------------
242
243 /**
244 * Get Month Name
245 *
246 * Generates a textual month name based on the numeric
247 * month provided.
248 *
249 * @access public
250 * @param integer the month
251 * @return string
252 */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200253 public function get_month_name($month)
Derek Allard2067d1a2008-11-13 22:59:24 +0000254 {
255 if ($this->month_type == 'short')
256 {
257 $month_names = array('01' => 'cal_jan', '02' => 'cal_feb', '03' => 'cal_mar', '04' => 'cal_apr', '05' => 'cal_may', '06' => 'cal_jun', '07' => 'cal_jul', '08' => 'cal_aug', '09' => 'cal_sep', '10' => 'cal_oct', '11' => 'cal_nov', '12' => 'cal_dec');
258 }
259 else
260 {
Derek Allarddefaa172009-08-17 17:24:31 +0000261 $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
Derek Allard2067d1a2008-11-13 22:59:24 +0000262 }
Barry Mienydd671972010-10-04 16:33:58 +0200263
Derek Allard2067d1a2008-11-13 22:59:24 +0000264 $month = $month_names[$month];
Barry Mienydd671972010-10-04 16:33:58 +0200265
Derek Allard2067d1a2008-11-13 22:59:24 +0000266 if ($this->CI->lang->line($month) === FALSE)
267 {
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200268 return ucfirst(substr($month, 4));
Derek Allard2067d1a2008-11-13 22:59:24 +0000269 }
270
271 return $this->CI->lang->line($month);
272 }
Barry Mienydd671972010-10-04 16:33:58 +0200273
Derek Allard2067d1a2008-11-13 22:59:24 +0000274 // --------------------------------------------------------------------
275
276 /**
277 * Get Day Names
278 *
279 * Returns an array of day names (Sunday, Monday, etc.) based
Derek Jones37f4b9c2011-07-01 17:56:50 -0500280 * on the type. Options: long, short, abrev
Derek Allard2067d1a2008-11-13 22:59:24 +0000281 *
282 * @access public
283 * @param string
284 * @return array
285 */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200286 public function get_day_names($day_type = '')
Derek Allard2067d1a2008-11-13 22:59:24 +0000287 {
288 if ($day_type != '')
289 $this->day_type = $day_type;
Barry Mienydd671972010-10-04 16:33:58 +0200290
Derek Allard2067d1a2008-11-13 22:59:24 +0000291 if ($this->day_type == 'long')
292 {
293 $day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
294 }
295 elseif ($this->day_type == 'short')
296 {
297 $day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
298 }
299 else
300 {
301 $day_names = array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa');
302 }
Barry Mienydd671972010-10-04 16:33:58 +0200303
Derek Allard2067d1a2008-11-13 22:59:24 +0000304 $days = array();
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200305 for ($i = 0, $c = count($day_names); $i < $c; $i++)
Barry Mienydd671972010-10-04 16:33:58 +0200306 {
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200307 $days[] = ($this->CI->lang->line('cal_'.$day_names[$i]) === FALSE) ? ucfirst($day_names[$i]) : $this->CI->lang->line('cal_'.$day_names[$i]);
Derek Allard2067d1a2008-11-13 22:59:24 +0000308 }
Barry Mienydd671972010-10-04 16:33:58 +0200309
Derek Allard2067d1a2008-11-13 22:59:24 +0000310 return $days;
311 }
Barry Mienydd671972010-10-04 16:33:58 +0200312
Derek Allard2067d1a2008-11-13 22:59:24 +0000313 // --------------------------------------------------------------------
314
315 /**
316 * Adjust Date
317 *
318 * This function makes sure that we have a valid month/year.
319 * For example, if you submit 13 as the month, the year will
320 * increment and the month will become January.
321 *
322 * @access public
323 * @param integer the month
324 * @param integer the year
325 * @return array
326 */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200327 public function adjust_date($month, $year)
Derek Allard2067d1a2008-11-13 22:59:24 +0000328 {
329 $date = array();
330
331 $date['month'] = $month;
332 $date['year'] = $year;
333
334 while ($date['month'] > 12)
335 {
336 $date['month'] -= 12;
337 $date['year']++;
338 }
339
340 while ($date['month'] <= 0)
341 {
342 $date['month'] += 12;
343 $date['year']--;
344 }
345
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200346 if (strlen($date['month']) === 1)
Derek Allard2067d1a2008-11-13 22:59:24 +0000347 {
348 $date['month'] = '0'.$date['month'];
349 }
350
351 return $date;
352 }
Barry Mienydd671972010-10-04 16:33:58 +0200353
Derek Allard2067d1a2008-11-13 22:59:24 +0000354 // --------------------------------------------------------------------
355
356 /**
357 * Total days in a given month
358 *
359 * @access public
360 * @param integer the month
361 * @param integer the year
362 * @return integer
363 */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200364 public function get_total_days($month, $year)
Derek Allard2067d1a2008-11-13 22:59:24 +0000365 {
366 $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
367
368 if ($month < 1 OR $month > 12)
369 {
370 return 0;
371 }
372
373 // Is the year a leap year?
374 if ($month == 2)
375 {
376 if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
377 {
378 return 29;
379 }
380 }
381
382 return $days_in_month[$month - 1];
383 }
Barry Mienydd671972010-10-04 16:33:58 +0200384
Derek Allard2067d1a2008-11-13 22:59:24 +0000385 // --------------------------------------------------------------------
386
387 /**
388 * Set Default Template Data
389 *
390 * This is used in the event that the user has not created their own template
391 *
392 * @access public
393 * @return array
394 */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200395 public function default_template()
Derek Allard2067d1a2008-11-13 22:59:24 +0000396 {
Derek Jones37f4b9c2011-07-01 17:56:50 -0500397 return array (
Barry Mienydd671972010-10-04 16:33:58 +0200398 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
399 'heading_row_start' => '<tr>',
Derek Allard2067d1a2008-11-13 22:59:24 +0000400 'heading_previous_cell' => '<th><a href="{previous_url}">&lt;&lt;</a></th>',
Barry Mienydd671972010-10-04 16:33:58 +0200401 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>',
402 'heading_next_cell' => '<th><a href="{next_url}">&gt;&gt;</a></th>',
403 'heading_row_end' => '</tr>',
404 'week_row_start' => '<tr>',
405 'week_day_cell' => '<td>{week_day}</td>',
406 'week_row_end' => '</tr>',
407 'cal_row_start' => '<tr>',
408 'cal_cell_start' => '<td>',
Derek Allard2067d1a2008-11-13 22:59:24 +0000409 'cal_cell_start_today' => '<td>',
410 'cal_cell_content' => '<a href="{content}">{day}</a>',
411 'cal_cell_content_today' => '<a href="{content}"><strong>{day}</strong></a>',
412 'cal_cell_no_content' => '{day}',
413 'cal_cell_no_content_today' => '<strong>{day}</strong>',
414 'cal_cell_blank' => '&nbsp;',
415 'cal_cell_end' => '</td>',
416 'cal_cell_end_today' => '</td>',
417 'cal_row_end' => '</tr>',
418 'table_close' => '</table>'
Barry Mienydd671972010-10-04 16:33:58 +0200419 );
Derek Allard2067d1a2008-11-13 22:59:24 +0000420 }
Barry Mienydd671972010-10-04 16:33:58 +0200421
Derek Allard2067d1a2008-11-13 22:59:24 +0000422 // --------------------------------------------------------------------
423
424 /**
425 * Parse Template
426 *
427 * Harvests the data within the template {pseudo-variables}
428 * used to display the calendar
429 *
430 * @access public
431 * @return void
432 */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200433 public function parse_template()
Barry Mienydd671972010-10-04 16:33:58 +0200434 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000435 $this->temp = $this->default_template();
Barry Mienydd671972010-10-04 16:33:58 +0200436
437 if ($this->template == '')
438 {
439 return;
440 }
441
Derek Allard2067d1a2008-11-13 22:59:24 +0000442 $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today');
Barry Mienydd671972010-10-04 16:33:58 +0200443
Derek Jones37f4b9c2011-07-01 17:56:50 -0500444 foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
Derek Allard2067d1a2008-11-13 22:59:24 +0000445 {
446 if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
447 {
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200448 $this->temp[$val] = $match[1];
Derek Allard2067d1a2008-11-13 22:59:24 +0000449 }
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200450 elseif (in_array($val, $today, TRUE))
Derek Allard2067d1a2008-11-13 22:59:24 +0000451 {
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200452 $this->temp[$val] = $this->temp[substr($val, 0, -6)];
Derek Allard2067d1a2008-11-13 22:59:24 +0000453 }
Barry Mienydd671972010-10-04 16:33:58 +0200454 }
455 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000456
457}
458
459// END CI_Calendar class
460
461/* End of file Calendar.php */
Andrey Andreeve8dfc1b2011-12-24 01:22:19 +0200462/* Location: ./system/libraries/Calendar.php */