summaryrefslogtreecommitdiffstats
path: root/system/libraries/Calendar.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-20 14:03:43 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-20 14:03:43 +0100
commitea801ab4ab80042638ffddc6056483a1ec43fa80 (patch)
treef75f30c0df6a8f861ca7df22af09fa3240b0bbd6 /system/libraries/Calendar.php
parent1c08d557a21ecb0f79cd1a1de4e06817a26e0537 (diff)
parent4d0571666d03511ac5b4a1f2a6882ccb1509a209 (diff)
Merge branch 'develop' into feature/user-guide-cleanup
Diffstat (limited to 'system/libraries/Calendar.php')
-rw-r--r--system/libraries/Calendar.php46
1 files changed, 41 insertions, 5 deletions
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 9c68c94c1..fc6599931 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -96,6 +96,13 @@ class CI_Calendar {
public $next_prev_url = '';
/**
+ * Show days of other months
+ *
+ * @var bool
+ */
+ public $show_other_days = FALSE;
+
+ /**
* Class constructor
*
* Loads the calendar language file and sets the default time reference.
@@ -143,6 +150,12 @@ class CI_Calendar {
$this->$key = $val;
}
}
+
+ // Set the next_prev_url to the controller if required but not defined
+ if ($this->show_next_prev === TRUE && empty($this->next_prev_url))
+ {
+ $this->next_prev_url = $this->CI->config->site_url($this->CI->router->class.'/'.$this->CI->router->method);
+ }
}
// --------------------------------------------------------------------
@@ -261,10 +274,10 @@ class CI_Calendar {
for ($i = 0; $i < 7; $i++)
{
- $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
-
if ($day > 0 && $day <= $total_days)
{
+ $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
+
if (isset($data[$day]))
{
// Cells with content
@@ -279,14 +292,34 @@ class CI_Calendar {
$this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
$out .= str_replace('{day}', $day, $temp);
}
+
+ $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
+ }
+ elseif ($this->show_other_days === TRUE)
+ {
+ $out .= $this->temp['cal_cell_start_other'];
+
+ if ($day <= 0)
+ {
+ // Day of previous month
+ $prev_month = $this->adjust_date($month - 1, $year);
+ $prev_month_days = $this->get_total_days($prev_month['month'], $prev_month['year']);
+ $out .= str_replace('{day}', $prev_month_days + $day, $this->temp['cal_cell_other']);
+ }
+ else
+ {
+ // Day of next month
+ $out .= str_replace('{day}', $day - $total_days, $this->temp['cal_cell_other']);
+ }
+
+ $out .= $this->temp['cal_cell_end_other'];
}
else
{
// Blank cells
- $out .= $this->temp['cal_cell_blank'];
+ $out .= $this->temp['cal_cell_start'].$this->temp['cal_cell_blank'].$this->temp['cal_cell_end'];
}
- $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
$day++;
}
@@ -457,13 +490,16 @@ class CI_Calendar {
'cal_row_start' => '<tr>',
'cal_cell_start' => '<td>',
'cal_cell_start_today' => '<td>',
+ 'cal_cell_start_other' => '<td style="color: #666;">',
'cal_cell_content' => '<a href="{content}">{day}</a>',
'cal_cell_content_today' => '<a href="{content}"><strong>{day}</strong></a>',
'cal_cell_no_content' => '{day}',
'cal_cell_no_content_today' => '<strong>{day}</strong>',
'cal_cell_blank' => '&nbsp;',
+ 'cal_cell_other' => '{day}',
'cal_cell_end' => '</td>',
'cal_cell_end_today' => '</td>',
+ 'cal_cell_end_other' => '</td>',
'cal_row_end' => '</tr>',
'table_close' => '</table>'
);
@@ -490,7 +526,7 @@ class CI_Calendar {
$today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today');
- 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)
+ 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', 'cal_cell_start_other', 'cal_cell_other', 'cal_cell_end_other') as $val)
{
if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match))
{