From f4a4bd8fac188ebc9cda822ffc811c218fd92b45 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Thu, 20 Oct 2011 12:18:42 -0500 Subject: adding new license file (OSL 3.0) and updating readme to ReST added notice of license to all source files. OSL to all except the few files we ship inside of the application folder, those are AFL. Updated license in user guide. incrementing next dev version to 3.0 due to licensing change --- system/libraries/Calendar.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index df0fd6eeb..f5ef4d576 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -4,10 +4,22 @@ * * An open source application development framework for PHP 5.1.6 or newer * + * NOTICE OF LICENSE + * + * Licensed under the Open Software License version 3.0 + * + * This source file is subject to the Open Software License (OSL 3.0) that is + * bundled with this package in the files license.txt / license.rst. It is + * also available through the world wide web at this URL: + * http://opensource.org/licenses/OSL-3.0 + * If you did not receive a copy of the license and are unable to obtain it + * through the world wide web, please send an email to + * licensing@ellislab.com so we can send you a copy immediately. + * * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html + * @author EllisLab Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 * @filesource @@ -23,7 +35,7 @@ * @package CodeIgniter * @subpackage Libraries * @category Libraries - * @author ExpressionEngine Dev Team + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/calendar.html */ class CI_Calendar { -- cgit v1.2.3-24-g4f1b From e8dfc1b34ce71e5c47c6da3f553ecae52ad935d8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Dec 2011 01:22:19 +0200 Subject: Improve the Calendar library --- system/libraries/Calendar.php | 133 +++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 79 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index f5ef4d576..299cb5047 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -1,13 +1,13 @@ - $val) { @@ -107,22 +107,19 @@ class CI_Calendar { * @param array the data to be shown in the calendar cells * @return string */ - function generate($year = '', $month = '', $data = array()) + public function generate($year = '', $month = '', $data = array()) { // Set and validate the supplied month/year if ($year == '') - $year = date("Y", $this->local_time); - - if ($month == '') - $month = date("m", $this->local_time); - - if (strlen($year) == 1) + $year = date('Y', $this->local_time); + elseif (strlen($year) === 1) $year = '200'.$year; - - if (strlen($year) == 2) + elseif (strlen($year) === 2) $year = '20'.$year; - if (strlen($month) == 1) + if ($month == '') + $month = date('m', $this->local_time); + elseif (strlen($month) === 1) $month = '0'.$month; $adjusted_date = $this->adjust_date($month, $year); @@ -149,9 +146,9 @@ class CI_Calendar { // Set the current month/year/day // We use this to determine the "today" date - $cur_year = date("Y", $this->local_time); - $cur_month = date("m", $this->local_time); - $cur_day = date("j", $this->local_time); + $cur_year = date('Y', $this->local_time); + $cur_month = date('m', $this->local_time); + $cur_day = date('j', $this->local_time); $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE; @@ -159,12 +156,7 @@ class CI_Calendar { $this->parse_template(); // Begin building the calendar output - $out = $this->temp['table_open']; - $out .= "\n"; - - $out .= "\n"; - $out .= $this->temp['heading_row_start']; - $out .= "\n"; + $out = $this->temp['table_open'] . "\n\n" . $this->temp['heading_row_start'] . "\n"; // "previous" month link if ($this->show_next_prev == TRUE) @@ -173,18 +165,16 @@ class CI_Calendar { $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url); $adjusted_date = $this->adjust_date($month - 1, $year); - $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']); - $out .= "\n"; + $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n"; } // Heading containing the month/year $colspan = ($this->show_next_prev == TRUE) ? 5 : 7; - $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']); - $this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)." ".$year, $this->temp['heading_title_cell']); + $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, + str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->temp['heading_title_cell'])); - $out .= $this->temp['heading_title_cell']; - $out .= "\n"; + $out .= $this->temp['heading_title_cell'] . "\n"; // "next" month link if ($this->show_next_prev == TRUE) @@ -193,14 +183,9 @@ class CI_Calendar { $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']); } - $out .= "\n"; - $out .= $this->temp['heading_row_end']; - $out .= "\n"; - - // Write the cells containing the days of the week - $out .= "\n"; - $out .= $this->temp['week_row_start']; - $out .= "\n"; + $out .= "\n" . $this->temp['heading_row_end'] . "\n\n" + // Write the cells containing the days of the week + . $this->temp['week_row_start'] . "\n"; $day_names = $this->get_day_names(); @@ -209,33 +194,29 @@ class CI_Calendar { $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']); } - $out .= "\n"; - $out .= $this->temp['week_row_end']; - $out .= "\n"; + $out .= "\n" . $this->temp['week_row_end'] . "\n"; // Build the main body of the calendar while ($day <= $total_days) { - $out .= "\n"; - $out .= $this->temp['cal_row_start']; - $out .= "\n"; + $out .= "\n" . $this->temp['cal_row_start'] . "\n"; for ($i = 0; $i < 7; $i++) { - $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; + $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; if ($day > 0 AND $day <= $total_days) { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; - $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp)); + $temp = ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; + $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; + $temp = ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } } @@ -245,17 +226,14 @@ class CI_Calendar { $out .= $this->temp['cal_cell_blank']; } - $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; + $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; $day++; } - $out .= "\n"; - $out .= $this->temp['cal_row_end']; - $out .= "\n"; + $out .= "\n" . $this->temp['cal_row_end'] . "\n"; } - $out .= "\n"; - $out .= $this->temp['table_close']; + $out .= "\n" . $this->temp['table_close']; return $out; } @@ -272,7 +250,7 @@ class CI_Calendar { * @param integer the month * @return string */ - function get_month_name($month) + public function get_month_name($month) { if ($this->month_type == 'short') { @@ -287,7 +265,7 @@ class CI_Calendar { if ($this->CI->lang->line($month) === FALSE) { - return ucfirst(str_replace('cal_', '', $month)); + return ucfirst(substr($month, 4)); } return $this->CI->lang->line($month); @@ -305,7 +283,7 @@ class CI_Calendar { * @param string * @return array */ - function get_day_names($day_type = '') + public function get_day_names($day_type = '') { if ($day_type != '') $this->day_type = $day_type; @@ -324,9 +302,9 @@ class CI_Calendar { } $days = array(); - foreach ($day_names as $val) + for ($i = 0, $c = count($day_names); $i < $c; $i++) { - $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val); + $days[] = ($this->CI->lang->line('cal_'.$day_names[$i]) === FALSE) ? ucfirst($day_names[$i]) : $this->CI->lang->line('cal_'.$day_names[$i]); } return $days; @@ -346,7 +324,7 @@ class CI_Calendar { * @param integer the year * @return array */ - function adjust_date($month, $year) + public function adjust_date($month, $year) { $date = array(); @@ -365,7 +343,7 @@ class CI_Calendar { $date['year']--; } - if (strlen($date['month']) == 1) + if (strlen($date['month']) === 1) { $date['month'] = '0'.$date['month']; } @@ -383,7 +361,7 @@ class CI_Calendar { * @param integer the year * @return integer */ - function get_total_days($month, $year) + public function get_total_days($month, $year) { $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); @@ -414,7 +392,7 @@ class CI_Calendar { * @access public * @return array */ - function default_template() + public function default_template() { return array ( 'table_open' => '', @@ -452,7 +430,7 @@ class CI_Calendar { * @access public * @return void */ - function parse_template() + public function parse_template() { $this->temp = $this->default_template(); @@ -467,14 +445,11 @@ class CI_Calendar { { if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match)) { - $this->temp[$val] = $match['1']; + $this->temp[$val] = $match[1]; } - else + elseif (in_array($val, $today, TRUE)) { - if (in_array($val, $today, TRUE)) - { - $this->temp[$val] = $this->temp[str_replace('_today', '', $val)]; - } + $this->temp[$val] = $this->temp[substr($val, 0, -6)]; } } } @@ -484,4 +459,4 @@ class CI_Calendar { // END CI_Calendar class /* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file +/* Location: ./system/libraries/Calendar.php */ -- cgit v1.2.3-24-g4f1b From c7dc07eb40a3e8e6cc6a81af454ec96785152660 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Dec 2011 16:48:50 +0200 Subject: Some braces & spaces added/removed to comply with the coding standarts --- system/libraries/Calendar.php | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 299cb5047..605765bf6 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -111,16 +111,26 @@ class CI_Calendar { { // Set and validate the supplied month/year if ($year == '') + { $year = date('Y', $this->local_time); + } elseif (strlen($year) === 1) + { $year = '200'.$year; + } elseif (strlen($year) === 2) + { $year = '20'.$year; + } if ($month == '') + { $month = date('m', $this->local_time); + } elseif (strlen($month) === 1) + { $month = '0'.$month; + } $adjusted_date = $this->adjust_date($month, $year); @@ -156,7 +166,7 @@ class CI_Calendar { $this->parse_template(); // Begin building the calendar output - $out = $this->temp['table_open'] . "\n\n" . $this->temp['heading_row_start'] . "\n"; + $out = $this->temp['table_open']."\n\n".$this->temp['heading_row_start']."\n"; // "previous" month link if ($this->show_next_prev == TRUE) @@ -174,7 +184,7 @@ class CI_Calendar { $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->temp['heading_title_cell'])); - $out .= $this->temp['heading_title_cell'] . "\n"; + $out .= $this->temp['heading_title_cell']."\n"; // "next" month link if ($this->show_next_prev == TRUE) @@ -183,9 +193,9 @@ class CI_Calendar { $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']); } - $out .= "\n" . $this->temp['heading_row_end'] . "\n\n" + $out .= "\n".$this->temp['heading_row_end']."\n\n" // Write the cells containing the days of the week - . $this->temp['week_row_start'] . "\n"; + .$this->temp['week_row_start']."\n"; $day_names = $this->get_day_names(); @@ -194,12 +204,12 @@ class CI_Calendar { $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']); } - $out .= "\n" . $this->temp['week_row_end'] . "\n"; + $out .= "\n".$this->temp['week_row_end']."\n"; // Build the main body of the calendar while ($day <= $total_days) { - $out .= "\n" . $this->temp['cal_row_start'] . "\n"; + $out .= "\n".$this->temp['cal_row_start']."\n"; for ($i = 0; $i < 7; $i++) { @@ -210,13 +220,15 @@ class CI_Calendar { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; + $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; + $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } } @@ -230,10 +242,10 @@ class CI_Calendar { $day++; } - $out .= "\n" . $this->temp['cal_row_end'] . "\n"; + $out .= "\n".$this->temp['cal_row_end']."\n"; } - $out .= "\n" . $this->temp['table_close']; + $out .= "\n".$this->temp['table_close']; return $out; } @@ -286,7 +298,9 @@ class CI_Calendar { public function get_day_names($day_type = '') { if ($day_type != '') + { $this->day_type = $day_type; + } if ($this->day_type == 'long') { -- cgit v1.2.3-24-g4f1b From 0defe5d33ee2633f377a109519ca818becc60f64 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 1 Jan 2012 18:46:41 -0600 Subject: Updating copyright date to 2012 --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 605765bf6..a05a7babf 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index a05a7babf..6c04de8a2 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 6dbabb565e1411a2c62fa86d46b0b2bbb98ab9b0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:41:48 +0300 Subject: Switch a private property to protected and cleanup the Calendar library --- system/libraries/Calendar.php | 61 ++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 6c04de8a2..b6f145d95 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Calendar Class * @@ -40,7 +38,7 @@ */ class CI_Calendar { - private $CI; + protected $CI; public $lang; public $local_time; public $template = ''; @@ -54,6 +52,9 @@ class CI_Calendar { * Constructor * * Loads the calendar language file and sets the default time reference + * + * @param array + * @return void */ public function __construct($config = array()) { @@ -71,7 +72,7 @@ class CI_Calendar { $this->initialize($config); } - log_message('debug', "Calendar Class Initialized"); + log_message('debug', 'Calendar Class Initialized'); } // -------------------------------------------------------------------- @@ -81,7 +82,6 @@ class CI_Calendar { * * Accepts an associative array as input, containing display preferences * - * @access public * @param array config preferences * @return void */ @@ -101,9 +101,8 @@ class CI_Calendar { /** * Generate the calendar * - * @access public - * @param integer the year - * @param integer the month + * @param int the year + * @param int the month * @param array the data to be shown in the calendar cells * @return string */ @@ -147,7 +146,7 @@ class CI_Calendar { // Set the starting day number $local_date = mktime(12, 0, 0, $month, 1, $year); $date = getdate($local_date); - $day = $start_day + 1 - $date["wday"]; + $day = $start_day + 1 - $date['wday']; while ($day > 1) { @@ -160,7 +159,7 @@ class CI_Calendar { $cur_month = date('m', $this->local_time); $cur_day = date('j', $this->local_time); - $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE; + $is_current_month = ($cur_year == $year && $cur_month == $month); // Generate the template data array $this->parse_template(); @@ -172,7 +171,7 @@ class CI_Calendar { if ($this->show_next_prev == TRUE) { // Add a trailing slash to the URL if needed - $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url); + $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); $adjusted_date = $this->adjust_date($month - 1, $year); $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n"; @@ -213,21 +212,21 @@ class CI_Calendar { for ($i = 0; $i < 7; $i++) { - $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; - if ($day > 0 AND $day <= $total_days) + if ($day > 0 && $day <= $total_days) { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $temp = ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $temp = ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } @@ -238,7 +237,7 @@ class CI_Calendar { $out .= $this->temp['cal_cell_blank']; } - $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $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++; } @@ -258,8 +257,7 @@ class CI_Calendar { * Generates a textual month name based on the numeric * month provided. * - * @access public - * @param integer the month + * @param int the month * @return string */ public function get_month_name($month) @@ -289,9 +287,8 @@ class CI_Calendar { * Get Day Names * * Returns an array of day names (Sunday, Monday, etc.) based - * on the type. Options: long, short, abrev + * on the type. Options: long, short, abrev * - * @access public * @param string * @return array */ @@ -333,9 +330,8 @@ class CI_Calendar { * For example, if you submit 13 as the month, the year will * increment and the month will become January. * - * @access public - * @param integer the month - * @param integer the year + * @param int the month + * @param int the year * @return array */ public function adjust_date($month, $year) @@ -370,10 +366,9 @@ class CI_Calendar { /** * Total days in a given month * - * @access public - * @param integer the month - * @param integer the year - * @return integer + * @param int the month + * @param int the year + * @return int */ public function get_total_days($month, $year) { @@ -387,7 +382,7 @@ class CI_Calendar { // Is the year a leap year? if ($month == 2) { - if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0)) + if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0)) { return 29; } @@ -403,8 +398,7 @@ class CI_Calendar { * * This is used in the event that the user has not created their own template * - * @access public - * @return array + * @return array */ public function default_template() { @@ -441,7 +435,6 @@ class CI_Calendar { * Harvests the data within the template {pseudo-variables} * used to display the calendar * - * @access public * @return void */ public function parse_template() @@ -457,7 +450,7 @@ class CI_Calendar { 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) { - if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match)) + if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match)) { $this->temp[$val] = $match[1]; } @@ -470,7 +463,5 @@ class CI_Calendar { } -// END CI_Calendar class - /* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */ +/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 68f098142cb71f6a57f74ce34b5f58616cc1ed2f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 10:38:32 -0400 Subject: Fix calendar and session libraries --- system/libraries/Calendar.php | 92 ++++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 23 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index b6f145d95..4db754f5e 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -38,14 +38,60 @@ */ class CI_Calendar { + /** + * Reference to CodeIgniter instance + * + * @var object + */ protected $CI; - public $lang; + + /** + * Current local time + * + * @var int + */ public $local_time; + + /** + * Calendar layout template + * + * @var string + */ public $template = ''; + + /** + * Day of the week to start the calendar on + * + * @var string + */ public $start_day = 'sunday'; + + /** + * How to display months + * + * @var string + */ public $month_type = 'long'; + + /** + * How to display names of days + * + * @var string + */ public $day_type = 'abr'; + + /** + * Whether to show next/prev month links + * + * @var bool + */ public $show_next_prev = FALSE; + + /** + * Url base to use for next/prev month links + * + * @var bool + */ public $next_prev_url = ''; /** @@ -403,28 +449,28 @@ class CI_Calendar { public function default_template() { return array ( - 'table_open' => '
', - '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_end_today' => '', - 'cal_row_end' => '', - 'table_close' => '
<<{heading}>>
{week_day}
', - 'cal_cell_start_today' => '', - 'cal_cell_content' => '{day}', - 'cal_cell_content_today' => '{day}', - 'cal_cell_no_content' => '{day}', - 'cal_cell_no_content_today' => '{day}', - 'cal_cell_blank' => ' ', - 'cal_cell_end' => '
' - ); + 'table_open' => '', + '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_end_today' => '', + 'cal_row_end' => '', + 'table_close' => '
<<{heading}>>
{week_day}
', + 'cal_cell_start_today' => '', + 'cal_cell_content' => '{day}', + 'cal_cell_content_today' => '{day}', + 'cal_cell_no_content' => '{day}', + 'cal_cell_no_content_today' => '{day}', + 'cal_cell_blank' => ' ', + 'cal_cell_end' => '
' + ); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 5645479c622eb36cf9869797896dc0921568c4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:32:19 +0300 Subject: Clean up the libraries --- system/libraries/Calendar.php | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 4db754f5e..92f372b20 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -44,55 +44,55 @@ class CI_Calendar { * @var object */ protected $CI; - + /** * Current local time * * @var int */ public $local_time; - + /** * Calendar layout template * * @var string */ public $template = ''; - + /** * Day of the week to start the calendar on * * @var string */ public $start_day = 'sunday'; - + /** * How to display months * * @var string */ public $month_type = 'long'; - + /** * How to display names of days * * @var string */ public $day_type = 'abr'; - + /** * Whether to show next/prev month links * * @var bool */ - public $show_next_prev = FALSE; - + public $show_next_prev = FALSE; + /** * Url base to use for next/prev month links * * @var bool */ - public $next_prev_url = ''; + public $next_prev_url = ''; /** * Constructor @@ -187,7 +187,7 @@ class CI_Calendar { // Set the starting day of the week $start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6); - $start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day]; + $start_day = isset($start_days[$this->start_day]) ? $start_days[$this->start_day] : 0; // Set the starting day number $local_date = mktime(12, 0, 0, $month, 1, $year); @@ -290,9 +290,7 @@ class CI_Calendar { $out .= "\n".$this->temp['cal_row_end']."\n"; } - $out .= "\n".$this->temp['table_close']; - - return $out; + return $out .= "\n".$this->temp['table_close']; } // -------------------------------------------------------------------- @@ -317,14 +315,9 @@ class CI_Calendar { $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'); } - $month = $month_names[$month]; - - if ($this->CI->lang->line($month) === FALSE) - { - return ucfirst(substr($month, 4)); - } - - return $this->CI->lang->line($month); + return ($this->CI->lang->line($month_names[$month]) === FALSE) + ? ucfirst(substr($month_names[$month], 4)) + : $this->CI->lang->line($month_names[$month]); } // -------------------------------------------------------------------- @@ -345,11 +338,11 @@ class CI_Calendar { $this->day_type = $day_type; } - if ($this->day_type == 'long') + if ($this->day_type === 'long') { $day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); } - elseif ($this->day_type == 'short') + elseif ($this->day_type === 'short') { $day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'); } @@ -448,7 +441,7 @@ class CI_Calendar { */ public function default_template() { - return array ( + return array( 'table_open' => '', 'heading_row_start' => '', 'heading_previous_cell' => '', -- cgit v1.2.3-24-g4f1b From d261b1e89c3d4d5191036d5a5660ef6764e593a0 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:12:16 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/libraries --- system/libraries/Calendar.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 92f372b20..753033a34 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -155,7 +155,7 @@ class CI_Calendar { public function generate($year = '', $month = '', $data = array()) { // Set and validate the supplied month/year - if ($year == '') + if ($year === '') { $year = date('Y', $this->local_time); } @@ -168,7 +168,7 @@ class CI_Calendar { $year = '20'.$year; } - if ($month == '') + if ($month === '') { $month = date('m', $this->local_time); } @@ -205,7 +205,7 @@ class CI_Calendar { $cur_month = date('m', $this->local_time); $cur_day = date('j', $this->local_time); - $is_current_month = ($cur_year == $year && $cur_month == $month); + $is_current_month = ($cur_year === $year && $cur_month === $month); // Generate the template data array $this->parse_template(); @@ -214,7 +214,7 @@ class CI_Calendar { $out = $this->temp['table_open']."\n\n".$this->temp['heading_row_start']."\n"; // "previous" month link - if ($this->show_next_prev == TRUE) + if ($this->show_next_prev === TRUE) { // Add a trailing slash to the URL if needed $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); @@ -224,7 +224,7 @@ class CI_Calendar { } // Heading containing the month/year - $colspan = ($this->show_next_prev == TRUE) ? 5 : 7; + $colspan = ($this->show_next_prev === TRUE) ? 5 : 7; $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->temp['heading_title_cell'])); @@ -232,7 +232,7 @@ class CI_Calendar { $out .= $this->temp['heading_title_cell']."\n"; // "next" month link - if ($this->show_next_prev == TRUE) + if ($this->show_next_prev === TRUE) { $adjusted_date = $this->adjust_date($month + 1, $year); $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']); @@ -258,21 +258,21 @@ 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']; + $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) { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month === TRUE && $day == $cur_day) ? + $temp = ($is_current_month === TRUE && $day === $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month === TRUE && $day == $cur_day) ? + $temp = ($is_current_month === TRUE && $day === $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } @@ -283,7 +283,7 @@ class CI_Calendar { $out .= $this->temp['cal_cell_blank']; } - $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $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++; } @@ -306,7 +306,7 @@ class CI_Calendar { */ public function get_month_name($month) { - if ($this->month_type == 'short') + if ($this->month_type === 'short') { $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'); } @@ -333,7 +333,7 @@ class CI_Calendar { */ public function get_day_names($day_type = '') { - if ($day_type != '') + if ($day_type !== '') { $this->day_type = $day_type; } @@ -419,9 +419,9 @@ class CI_Calendar { } // Is the year a leap year? - if ($month == 2) + if ($month === 2) { - if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0)) + if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0)) { return 29; } @@ -480,7 +480,7 @@ class CI_Calendar { { $this->temp = $this->default_template(); - if ($this->template == '') + if ($this->template === '') { return; } -- cgit v1.2.3-24-g4f1b From 5036c9caabb12f90b9533d7fb417610e02a652ff Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Jun 2012 15:34:56 +0300 Subject: Revert/optimize some changes from 773ccc318f2769c9b7579630569b5d8ba47b114b and d261b1e89c3d4d5191036d5a5660ef6764e593a0 --- system/libraries/Calendar.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 753033a34..969a7610a 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -205,7 +205,7 @@ class CI_Calendar { $cur_month = date('m', $this->local_time); $cur_day = date('j', $this->local_time); - $is_current_month = ($cur_year === $year && $cur_month === $month); + $is_current_month = ($cur_year == $year && $cur_month == $month); // Generate the template data array $this->parse_template(); @@ -258,21 +258,21 @@ 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']; + $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) { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month === TRUE && $day === $cur_day) ? + $temp = ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month === TRUE && $day === $cur_day) ? + $temp = ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } @@ -283,7 +283,7 @@ class CI_Calendar { $out .= $this->temp['cal_cell_blank']; } - $out .= ($is_current_month === TRUE && $day === $cur_day) ? $this->temp['cal_cell_end_today'] : $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++; } @@ -419,7 +419,7 @@ class CI_Calendar { } // Is the year a leap year? - if ($month === 2) + if ($month == 2) { if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0)) { -- cgit v1.2.3-24-g4f1b From f51b1fbafcf280d69633a37f4fc87c0ffcef78ad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 20:02:23 +0300 Subject: Fix CI_Calendar::generate() not accepting NULLs (introduced in d261b1e89c3d4d5191036d5a5660ef6764e593a0) --- system/libraries/Calendar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 969a7610a..a49f171b9 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -155,7 +155,7 @@ class CI_Calendar { public function generate($year = '', $month = '', $data = array()) { // Set and validate the supplied month/year - if ($year === '') + if (empty($year)) { $year = date('Y', $this->local_time); } @@ -168,7 +168,7 @@ class CI_Calendar { $year = '20'.$year; } - if ($month === '') + if (empty($month)) { $month = date('m', $this->local_time); } -- cgit v1.2.3-24-g4f1b From 3e9d2b8ae82948de3c83bd5a50151949f6e6ca90 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 27 Oct 2012 14:28:51 +0300 Subject: Docblock improvements --- system/libraries/Calendar.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index a49f171b9..95f537e42 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -95,11 +95,13 @@ class CI_Calendar { public $next_prev_url = ''; /** - * Constructor + * Class constructor * - * Loads the calendar language file and sets the default time reference + * Loads the calendar language file and sets the default time reference. * - * @param array + * @uses CI_Lang::$is_loaded + * + * @param array $config Calendar options * @return void */ public function __construct($config = array()) -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/libraries/Calendar.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 95f537e42..caa496a5e 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -1,4 +1,4 @@ - Date: Mon, 3 Dec 2012 14:37:47 +0200 Subject: [ci skip] Cleaned some spaces --- system/libraries/Calendar.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index caa496a5e..ec2b7bcc1 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -160,7 +160,7 @@ class CI_Calendar { // Set and validate the supplied month/year if (empty($year)) { - $year = date('Y', $this->local_time); + $year = date('Y', $this->local_time); } elseif (strlen($year) === 1) { @@ -219,8 +219,8 @@ class CI_Calendar { // "previous" month link if ($this->show_next_prev === TRUE) { - // Add a trailing slash to the URL if needed - $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); + // Add a trailing slash to the URL if needed + $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); $adjusted_date = $this->adjust_date($month - 1, $year); $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n"; @@ -444,7 +444,7 @@ class CI_Calendar { */ public function default_template() { - return array( + return array( 'table_open' => '
<<
', 'heading_row_start' => '', 'heading_previous_cell' => '', @@ -490,7 +490,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') as $val) { if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match)) { -- cgit v1.2.3-24-g4f1b From 80500afbd188600212ca913a7bac073009feac73 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 1 Jan 2013 08:16:53 +0200 Subject: [ci skip] Happy new year --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index ec2b7bcc1..23d8ffb42 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From a756125436884dd622fdeff67084f3a62fc71b98 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Sun, 21 Jul 2013 14:21:41 -0700 Subject: Updating Calendar lib docs --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 23d8ffb42..9c68c94c1 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -329,7 +329,7 @@ class CI_Calendar { * Get Day Names * * Returns an array of day names (Sunday, Monday, etc.) based - * on the type. Options: long, short, abrev + * on the type. Options: long, short, abr * * @param string * @return array -- cgit v1.2.3-24-g4f1b From 7977e1d4859d48be00bb11250446d9abeff6ac35 Mon Sep 17 00:00:00 2001 From: Marcos SF Filho Date: Wed, 8 Jan 2014 15:34:11 -0200 Subject: Update the Calendar Class --- system/libraries/Calendar.php | 54 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 23d8ffb42..a2d9db14b 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -95,6 +95,13 @@ class CI_Calendar { */ public $next_prev_url = ''; + /** + * Show days of other months + * + * @var bool + */ + public $show_other_days = FALSE; + /** * Class constructor * @@ -143,6 +150,15 @@ 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) + { + if (empty($this->next_prev_url)) + { + $this->next_prev_url = rtrim($this->CI->config->site_url($this->CI->router->class . '/' . $this->CI->router->method), '/') . '/'; + } + } } // -------------------------------------------------------------------- @@ -261,10 +277,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 +295,37 @@ 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']; } else { - // Blank cells - $out .= $this->temp['cal_cell_blank']; + if ($this->show_other_days === TRUE) + { + $out .= $this->temp['cal_cell_start_other']; + + if ($day <= 0) + { + // Day of previous month + $prev_month = $this->adjust_date(((int) $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_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 +496,16 @@ class CI_Calendar { 'cal_row_start' => '', 'cal_cell_start' => '', 'cal_cell_end_today' => '', + 'cal_cell_end_other' => '', 'cal_row_end' => '', 'table_close' => '
<<
', 'cal_cell_start_today' => '', + 'cal_cell_start_other' => '', 'cal_cell_content' => '{day}', 'cal_cell_content_today' => '{day}', 'cal_cell_no_content' => '{day}', 'cal_cell_no_content_today' => '{day}', 'cal_cell_blank' => ' ', + 'cal_cell_other' => '{day}', 'cal_cell_end' => '
' ); @@ -490,7 +532,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)) { -- cgit v1.2.3-24-g4f1b From a593e3eb218002a630b7d0cf90002ec4a6fd1db3 Mon Sep 17 00:00:00 2001 From: Marcos SF Filho Date: Wed, 8 Jan 2014 18:22:12 -0200 Subject: Code Corrections for the Calendar Pull Request --- system/libraries/Calendar.php | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index a2d9db14b..efaa49a34 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -156,7 +156,7 @@ class CI_Calendar { { if (empty($this->next_prev_url)) { - $this->next_prev_url = rtrim($this->CI->config->site_url($this->CI->router->class . '/' . $this->CI->router->method), '/') . '/'; + $this->next_prev_url = rtrim($this->CI->config->site_url($this->CI->router->class.'/'.$this->CI->router->method), '/').'/'; } } } @@ -298,32 +298,29 @@ class CI_Calendar { $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; } - else + elseif ($this->show_other_days === TRUE) { - if ($this->show_other_days === TRUE) + $out .= $this->temp['cal_cell_start_other']; + + if ($day <= 0) { - $out .= $this->temp['cal_cell_start_other']; - - if ($day <= 0) - { - // Day of previous month - $prev_month = $this->adjust_date(((int) $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']; + // Day of previous month + $prev_month = $this->adjust_date(((int) $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 { - // Blank cells - $out .= $this->temp['cal_cell_start'] . $this->temp['cal_cell_blank'] . $this->temp['cal_cell_end']; + // 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_start'].$this->temp['cal_cell_blank'].$this->temp['cal_cell_end']; } $day++; -- cgit v1.2.3-24-g4f1b From c4f661613eefb6ea15b4109beb61c823d9ec51cc Mon Sep 17 00:00:00 2001 From: Marcos SF Filho Date: Wed, 8 Jan 2014 18:57:09 -0200 Subject: Join two if statement into one --- system/libraries/Calendar.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index efaa49a34..e393345df 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -152,12 +152,9 @@ class CI_Calendar { } // Set the next_prev_url to the controller if required but not defined - if ($this->show_next_prev === TRUE) + if ($this->show_next_prev === TRUE && empty($this->next_prev_url)) { - if (empty($this->next_prev_url)) - { - $this->next_prev_url = rtrim($this->CI->config->site_url($this->CI->router->class.'/'.$this->CI->router->method), '/').'/'; - } + $this->next_prev_url = rtrim($this->CI->config->site_url($this->CI->router->class.'/'.$this->CI->router->method), '/').'/'; } } -- cgit v1.2.3-24-g4f1b From 0cd7c92ee59b4b03588e45229944d4b83eea3d8e Mon Sep 17 00:00:00 2001 From: Marcos SF Filho Date: Wed, 8 Jan 2014 19:38:00 -0200 Subject: Unnecessary rtrim and update docs for Calendar class --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index e393345df..de77e3d7f 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -154,7 +154,7 @@ class CI_Calendar { // 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 = rtrim($this->CI->config->site_url($this->CI->router->class.'/'.$this->CI->router->method), '/').'/'; + $this->next_prev_url = $this->CI->config->site_url($this->CI->router->class.'/'.$this->CI->router->method); } } -- cgit v1.2.3-24-g4f1b From 2e914b7dc6acaf2938fac4c332ff682a033b93d7 Mon Sep 17 00:00:00 2001 From: Marcos SF Filho Date: Thu, 9 Jan 2014 09:20:55 -0200 Subject: Updates for the Calendar Pull Request --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index de77e3d7f..711d23bec 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -302,7 +302,7 @@ class CI_Calendar { if ($day <= 0) { // Day of previous month - $prev_month = $this->adjust_date(((int) $month) - 1, $year); + $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']); } -- cgit v1.2.3-24-g4f1b From e0333dbd16ad1b173064f6d113aa50105f4726e4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 8 Feb 2014 01:24:00 -0600 Subject: simplify calendar library it seemed quite strange that we ask users to pass in a template string the we parse with REGEX, to extract key/value pairs, when we can simply ask users for an array. the class still contains default variables for each part of the template. Users can simply pass in an array (instead of a string) when they initialize, $config['template'], which overwrites default values. this cuts down a little on file size by removing parse_template() function. I think arrays are much more straightforward and easy to read than 'encoded' strings. don't have to keep a running list of all template keys like in previous parse_template() function. gets rid of $this->temp[] property and changes it to $this->template[] which is more descriptive when generating output --- system/libraries/Calendar.php | 103 ++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 68 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 711d23bec..89367dc6d 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -56,9 +56,9 @@ class CI_Calendar { /** * Calendar layout template * - * @var string + * @var array */ - public $template = ''; + public $template = array(); /** * Day of the week to start the calendar on @@ -150,6 +150,9 @@ class CI_Calendar { $this->$key = $val; } } + + // Set template options + $this->template(); // Set the next_prev_url to the controller if required but not defined if ($this->show_next_prev === TRUE && empty($this->next_prev_url)) @@ -223,11 +226,8 @@ class CI_Calendar { $is_current_month = ($cur_year == $year && $cur_month == $month); - // Generate the template data array - $this->parse_template(); - // Begin building the calendar output - $out = $this->temp['table_open']."\n\n".$this->temp['heading_row_start']."\n"; + $out = $this->template['table_open']."\n\n".$this->template['heading_row_start']."\n"; // "previous" month link if ($this->show_next_prev === TRUE) @@ -236,97 +236,97 @@ class CI_Calendar { $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); $adjusted_date = $this->adjust_date($month - 1, $year); - $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n"; + $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->template['heading_previous_cell'])."\n"; } // Heading containing the month/year $colspan = ($this->show_next_prev === TRUE) ? 5 : 7; - $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, - str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->temp['heading_title_cell'])); + $this->template['heading_title_cell'] = str_replace('{colspan}', $colspan, + str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->template['heading_title_cell'])); - $out .= $this->temp['heading_title_cell']."\n"; + $out .= $this->template['heading_title_cell']."\n"; // "next" month link if ($this->show_next_prev === TRUE) { $adjusted_date = $this->adjust_date($month + 1, $year); - $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']); + $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->template['heading_next_cell']); } - $out .= "\n".$this->temp['heading_row_end']."\n\n" + $out .= "\n".$this->template['heading_row_end']."\n\n" // Write the cells containing the days of the week - .$this->temp['week_row_start']."\n"; + .$this->template['week_row_start']."\n"; $day_names = $this->get_day_names(); for ($i = 0; $i < 7; $i ++) { - $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']); + $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->template['week_day_cell']); } - $out .= "\n".$this->temp['week_row_end']."\n"; + $out .= "\n".$this->template['week_row_end']."\n"; // Build the main body of the calendar while ($day <= $total_days) { - $out .= "\n".$this->temp['cal_row_start']."\n"; + $out .= "\n".$this->template['cal_row_start']."\n"; for ($i = 0; $i < 7; $i++) { 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']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->template['cal_cell_start_today'] : $this->template['cal_cell_start']; if (isset($data[$day])) { // Cells with content $temp = ($is_current_month === TRUE && $day == $cur_day) ? - $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; + $this->template['cal_cell_content_today'] : $this->template['cal_cell_content']; $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content $temp = ($is_current_month === TRUE && $day == $cur_day) ? - $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; + $this->template['cal_cell_no_content_today'] : $this->template['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']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->template['cal_cell_end_today'] : $this->template['cal_cell_end']; } elseif ($this->show_other_days === TRUE) { - $out .= $this->temp['cal_cell_start_other']; + $out .= $this->template['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']); + $out .= str_replace('{day}', $prev_month_days + $day, $this->template['cal_cell_other']); } else { // Day of next month - $out .= str_replace('{day}', $day - $total_days, $this->temp['cal_cell_other']); + $out .= str_replace('{day}', $day - $total_days, $this->template['cal_cell_other']); } - $out .= $this->temp['cal_cell_end_other']; + $out .= $this->template['cal_cell_end_other']; } else { // Blank cells - $out .= $this->temp['cal_cell_start'].$this->temp['cal_cell_blank'].$this->temp['cal_cell_end']; + $out .= $this->template['cal_cell_start'].$this->template['cal_cell_blank'].$this->template['cal_cell_end']; } $day++; } - $out .= "\n".$this->temp['cal_row_end']."\n"; + $out .= "\n".$this->template['cal_row_end']."\n"; } - return $out .= "\n".$this->temp['table_close']; + return $out .= "\n".$this->template['table_close']; } // -------------------------------------------------------------------- @@ -469,15 +469,15 @@ class CI_Calendar { // -------------------------------------------------------------------- /** - * Set Default Template Data + * Set Template Data * - * This is used in the event that the user has not created their own template + * This sets default template data. The user can override default values by passing in a template array * - * @return array + * @return null */ - public function default_template() + public function template() { - return array( + $default = array( 'table_open' => '', 'heading_row_start' => '', 'heading_previous_cell' => '', @@ -503,43 +503,10 @@ class CI_Calendar { 'cal_row_end' => '', 'table_close' => '
<<
' ); + + $this->template = array_merge($default, $this->template); } - - // -------------------------------------------------------------------- - - /** - * Parse Template - * - * Harvests the data within the template {pseudo-variables} - * used to display the calendar - * - * @return void - */ - public function parse_template() - { - $this->temp = $this->default_template(); - - if ($this->template === '') - { - return; - } - - $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', 'cal_cell_start_other', 'cal_cell_other', 'cal_cell_end_other') as $val) - { - if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match)) - { - $this->temp[$val] = $match[1]; - } - elseif (in_array($val, $today, TRUE)) - { - $this->temp[$val] = $this->temp[substr($val, 0, -6)]; - } - } - } - } /* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file +/* Location: ./system/libraries/Calendar.php */ -- cgit v1.2.3-24-g4f1b From 6f6102c805198101fad36024b82692ebce20f2c8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 8 Feb 2014 19:11:40 +0200 Subject: Add method chaining support to Calendar & Pagination libs --- system/libraries/Calendar.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index fc6599931..610b427cf 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -139,7 +139,7 @@ class CI_Calendar { * Accepts an associative array as input, containing display preferences * * @param array config preferences - * @return void + * @return CI_Calendar */ public function initialize($config = array()) { @@ -156,6 +156,8 @@ class CI_Calendar { { $this->next_prev_url = $this->CI->config->site_url($this->CI->router->class.'/'.$this->CI->router->method); } + + return $this; } // -------------------------------------------------------------------- @@ -513,7 +515,7 @@ class CI_Calendar { * Harvests the data within the template {pseudo-variables} * used to display the calendar * - * @return void + * @return CI_Calendar */ public function parse_template() { @@ -521,7 +523,7 @@ class CI_Calendar { if ($this->template === '') { - return; + return $this; } $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today'); @@ -537,6 +539,8 @@ class CI_Calendar { $this->temp[$val] = $this->temp[substr($val, 0, -6)]; } } + + return $this; } } -- cgit v1.2.3-24-g4f1b From 227a5d7ed9ef65fb1e0c32dc4aaa379c1a96d5b7 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 9 Feb 2014 15:32:44 -0600 Subject: template as array instead of string library accepts `$config['template']` as array and string, to perform template replacements. updated `$this->temp` var to `$this->replacements` to be less ambiguous about what it does --- system/libraries/Calendar.php | 130 +++++++++++++++++++++++++++++------------- 1 file changed, 91 insertions(+), 39 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 89367dc6d..977342249 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -56,44 +56,51 @@ class CI_Calendar { /** * Calendar layout template * + * @var string|array + */ + public $template = ''; + + /** + * Replacements array for template + * * @var array */ - public $template = array(); + public $replacements = array(); /** * Day of the week to start the calendar on * * @var string */ - public $start_day = 'sunday'; + public $start_day = 'sunday'; /** * How to display months * * @var string */ - public $month_type = 'long'; + public $month_type = 'long'; /** * How to display names of days * * @var string */ - public $day_type = 'abr'; + public $day_type = 'abr'; /** * Whether to show next/prev month links * * @var bool */ - public $show_next_prev = FALSE; + public $show_next_prev = FALSE; /** * Url base to use for next/prev month links * * @var bool */ - public $next_prev_url = ''; + public $next_prev_url = ''; /** * Show days of other months @@ -139,7 +146,7 @@ class CI_Calendar { * Accepts an associative array as input, containing display preferences * * @param array config preferences - * @return void + * @return CI_Calendar */ public function initialize($config = array()) { @@ -150,15 +157,14 @@ class CI_Calendar { $this->$key = $val; } } - - // Set template options - $this->template(); // 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); } + + return $this; } // -------------------------------------------------------------------- @@ -226,8 +232,11 @@ class CI_Calendar { $is_current_month = ($cur_year == $year && $cur_month == $month); + // Generate the template data array + $this->parse_template(); + // Begin building the calendar output - $out = $this->template['table_open']."\n\n".$this->template['heading_row_start']."\n"; + $out = $this->replacements['table_open']."\n\n".$this->replacements['heading_row_start']."\n"; // "previous" month link if ($this->show_next_prev === TRUE) @@ -236,97 +245,97 @@ class CI_Calendar { $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); $adjusted_date = $this->adjust_date($month - 1, $year); - $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->template['heading_previous_cell'])."\n"; + $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->replacements['heading_previous_cell'])."\n"; } // Heading containing the month/year $colspan = ($this->show_next_prev === TRUE) ? 5 : 7; - $this->template['heading_title_cell'] = str_replace('{colspan}', $colspan, - str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->template['heading_title_cell'])); + $this->replacements['heading_title_cell'] = str_replace('{colspan}', $colspan, + str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->replacements['heading_title_cell'])); - $out .= $this->template['heading_title_cell']."\n"; + $out .= $this->replacements['heading_title_cell']."\n"; // "next" month link if ($this->show_next_prev === TRUE) { $adjusted_date = $this->adjust_date($month + 1, $year); - $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->template['heading_next_cell']); + $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->replacements['heading_next_cell']); } - $out .= "\n".$this->template['heading_row_end']."\n\n" + $out .= "\n".$this->replacements['heading_row_end']."\n\n" // Write the cells containing the days of the week - .$this->template['week_row_start']."\n"; + .$this->replacements['week_row_start']."\n"; $day_names = $this->get_day_names(); for ($i = 0; $i < 7; $i ++) { - $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->template['week_day_cell']); + $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->replacements['week_day_cell']); } - $out .= "\n".$this->template['week_row_end']."\n"; + $out .= "\n".$this->replacements['week_row_end']."\n"; // Build the main body of the calendar while ($day <= $total_days) { - $out .= "\n".$this->template['cal_row_start']."\n"; + $out .= "\n".$this->replacements['cal_row_start']."\n"; for ($i = 0; $i < 7; $i++) { if ($day > 0 && $day <= $total_days) { - $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->template['cal_cell_start_today'] : $this->template['cal_cell_start']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->replacements['cal_cell_start_today'] : $this->replacements['cal_cell_start']; if (isset($data[$day])) { // Cells with content $temp = ($is_current_month === TRUE && $day == $cur_day) ? - $this->template['cal_cell_content_today'] : $this->template['cal_cell_content']; + $this->replacements['cal_cell_content_today'] : $this->replacements['cal_cell_content']; $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content $temp = ($is_current_month === TRUE && $day == $cur_day) ? - $this->template['cal_cell_no_content_today'] : $this->template['cal_cell_no_content']; + $this->replacements['cal_cell_no_content_today'] : $this->replacements['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } - $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->template['cal_cell_end_today'] : $this->template['cal_cell_end']; + $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->replacements['cal_cell_end_today'] : $this->replacements['cal_cell_end']; } elseif ($this->show_other_days === TRUE) { - $out .= $this->template['cal_cell_start_other']; + $out .= $this->replacements['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->template['cal_cell_other']); + $out .= str_replace('{day}', $prev_month_days + $day, $this->replacements['cal_cell_other']); } else { // Day of next month - $out .= str_replace('{day}', $day - $total_days, $this->template['cal_cell_other']); + $out .= str_replace('{day}', $day - $total_days, $this->replacements['cal_cell_other']); } - $out .= $this->template['cal_cell_end_other']; + $out .= $this->replacements['cal_cell_end_other']; } else { // Blank cells - $out .= $this->template['cal_cell_start'].$this->template['cal_cell_blank'].$this->template['cal_cell_end']; + $out .= $this->replacements['cal_cell_start'].$this->replacements['cal_cell_blank'].$this->replacements['cal_cell_end']; } $day++; } - $out .= "\n".$this->template['cal_row_end']."\n"; + $out .= "\n".$this->replacements['cal_row_end']."\n"; } - return $out .= "\n".$this->template['table_close']; + return $out .= "\n".$this->replacements['table_close']; } // -------------------------------------------------------------------- @@ -362,7 +371,7 @@ class CI_Calendar { * Get Day Names * * Returns an array of day names (Sunday, Monday, etc.) based - * on the type. Options: long, short, abrev + * on the type. Options: long, short, abr * * @param string * @return array @@ -469,15 +478,15 @@ class CI_Calendar { // -------------------------------------------------------------------- /** - * Set Template Data + * Set Default Template Data * - * This sets default template data. The user can override default values by passing in a template array + * This is used in the event that the user has not created their own template * - * @return null + * @return array */ - public function template() + public function default_template() { - $default = array( + return array( 'table_open' => '', 'heading_row_start' => '', 'heading_previous_cell' => '', @@ -503,9 +512,52 @@ class CI_Calendar { 'cal_row_end' => '', 'table_close' => '
<<
' ); + } + + // -------------------------------------------------------------------- + + /** + * Parse Template + * + * Harvests the data within the template {pseudo-variables} + * used to display the calendar + * + * @return CI_Calendar + */ + public function parse_template() + { + $this->replacements = $this->default_template(); + + if (!$this->template) + { + return $this; + } + + if(is_string($this->template)) + { + $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', 'cal_cell_start_other', 'cal_cell_other', 'cal_cell_end_other') as $val) + { + if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match)) + { + $this->replacements[$val] = $match[1]; + } + elseif (in_array($val, $today, TRUE)) + { + $this->replacements[$val] = $this->replacements[substr($val, 0, -6)]; + } + } + + return $this; + } - $this->template = array_merge($default, $this->template); + elseif(is_array($this->template)) + { + $this->replacements = array_merge($this->replacements, $this->template); + } } + } /* End of file Calendar.php */ -- cgit v1.2.3-24-g4f1b From 021f8edfee76a1a3a58fe34a1367e876f8f89003 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 9 Feb 2014 16:31:22 -0600 Subject: updates per narfbg's comments --- system/libraries/Calendar.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 977342249..3cb30dba2 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -56,7 +56,7 @@ class CI_Calendar { /** * Calendar layout template * - * @var string|array + * @var mixed */ public $template = ''; @@ -528,12 +528,12 @@ class CI_Calendar { { $this->replacements = $this->default_template(); - if (!$this->template) + if (empty($this->template)) { return $this; } - if(is_string($this->template)) + if (is_string($this->template)) { $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today'); @@ -551,11 +551,12 @@ class CI_Calendar { return $this; } - - elseif(is_array($this->template)) + elseif (is_array($this->template)) { $this->replacements = array_merge($this->replacements, $this->template); } + + return $this; } } -- cgit v1.2.3-24-g4f1b From 41713aaa665189dd0a191c333c73c4a7b9f37c78 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 11 Feb 2014 02:07:50 -0600 Subject: updates per narfbg request I did a bunch of Git tutorials, and (i think) understand a lot more now. this update is to address narfbg comments, and add to pull request. --- system/libraries/Calendar.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 3cb30dba2..688b495a6 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -548,8 +548,6 @@ class CI_Calendar { $this->replacements[$val] = $this->replacements[substr($val, 0, -6)]; } } - - return $this; } elseif (is_array($this->template)) { @@ -562,4 +560,4 @@ class CI_Calendar { } /* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */ +/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 871754af60251993d640981e107d2def5f2db396 Mon Sep 17 00:00:00 2001 From: darwinel Date: Tue, 11 Feb 2014 17:34:57 +0100 Subject: 2013 > 2014 Update copyright notices from 2013 to 2014. And update one calendar example in user_guide from year 2013/2014 to 2014/2015. --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 610b427cf..30f393318 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From 9bf3cf2e2b770db17953a8db87ccfa17e438aa2e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 18 Feb 2014 16:39:46 +0200 Subject: [ci skip] Clean-up following PR #2864 --- system/libraries/Calendar.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index b9c01ee68..23c389e4b 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -59,7 +59,7 @@ class CI_Calendar { * @var mixed */ public $template = ''; - + /** * Replacements array for template * @@ -532,11 +532,11 @@ class CI_Calendar { { return $this; } - + if (is_string($this->template)) { $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', 'cal_cell_start_other', 'cal_cell_other', 'cal_cell_end_other') as $val) { if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match)) @@ -553,7 +553,7 @@ class CI_Calendar { { $this->replacements = array_merge($this->replacements, $this->template); } - + return $this; } -- cgit v1.2.3-24-g4f1b From be368a82f789aaa9f0ac0c8b6fa72a2f7cd0b6d4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Feb 2014 15:46:05 +0200 Subject: Date helper days_in_month(), CI_Calendar::get_total_days() changes - days_in_month() now uses cal_days_in_month(), if available. - CI_Calendar::get_total_days() is now an alias for days_in_month(). --- system/libraries/Calendar.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 23c389e4b..7bdcdca09 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -456,23 +456,8 @@ class CI_Calendar { */ public function get_total_days($month, $year) { - $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); - - if ($month < 1 OR $month > 12) - { - return 0; - } - - // Is the year a leap year? - if ($month == 2) - { - if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0)) - { - return 29; - } - } - - return $days_in_month[$month - 1]; + $this->load->helper('date'); + return days_in_month($month, $year); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 083a22635140cb627cae7e4edf5d7127220c018e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Feb 2014 16:04:58 +0200 Subject: [ci skip] Fix date helper loading in CI_Calendar::get_total_days() --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 7bdcdca09..cdcbfe9d7 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -456,7 +456,7 @@ class CI_Calendar { */ public function get_total_days($month, $year) { - $this->load->helper('date'); + $this->CI->load->helper('date'); return days_in_month($month, $year); } -- cgit v1.2.3-24-g4f1b From 6125a279693a54d04cbd63d7aee03cf7b9a85f00 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 21 Feb 2014 16:58:13 +0200 Subject: Remove CI_Calendar:: Only use it in generate(). --- system/libraries/Calendar.php | 44 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index cdcbfe9d7..1a0d02ba0 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -39,20 +39,6 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_Calendar { - /** - * Reference to CodeIgniter instance - * - * @var object - */ - protected $CI; - - /** - * Current local time - * - * @var int - */ - public $local_time; - /** * Calendar layout template * @@ -109,6 +95,17 @@ class CI_Calendar { */ public $show_other_days = FALSE; + // -------------------------------------------------------------------- + + /** + * CI Singleton + * + * @var object + */ + protected $CI; + + // -------------------------------------------------------------------- + /** * Class constructor * @@ -128,12 +125,7 @@ class CI_Calendar { $this->CI->lang->load('calendar'); } - $this->local_time = time(); - - if (count($config) > 0) - { - $this->initialize($config); - } + empty($config) OR $this->initialize($config); log_message('debug', 'Calendar Class Initialized'); } @@ -179,10 +171,12 @@ class CI_Calendar { */ public function generate($year = '', $month = '', $data = array()) { + $local_time = time(); + // Set and validate the supplied month/year if (empty($year)) { - $year = date('Y', $this->local_time); + $year = date('Y', $local_time); } elseif (strlen($year) === 1) { @@ -195,7 +189,7 @@ class CI_Calendar { if (empty($month)) { - $month = date('m', $this->local_time); + $month = date('m', $local_time); } elseif (strlen($month) === 1) { @@ -226,9 +220,9 @@ class CI_Calendar { // Set the current month/year/day // We use this to determine the "today" date - $cur_year = date('Y', $this->local_time); - $cur_month = date('m', $this->local_time); - $cur_day = date('j', $this->local_time); + $cur_year = date('Y', $local_time); + $cur_month = date('m', $local_time); + $cur_day = date('j', $local_time); $is_current_month = ($cur_year == $year && $cur_month == $month); -- cgit v1.2.3-24-g4f1b From bdb96ca1b1dbfc1791172fd169d7751cbc4d7d55 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Oct 2014 00:13:31 +0200 Subject: [ci skip] Switch to MIT license; close #3293 --- system/libraries/Calendar.php | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 1a0d02ba0..627838e90 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -4,24 +4,35 @@ * * An open source application development framework for PHP 5.2.4 or newer * - * NOTICE OF LICENSE + * This content is released under the MIT License (MIT) * - * Licensed under the Open Software License version 3.0 + * Copyright (c) 2014, British Columbia Institute of Technology * - * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is - * also available through the world wide web at this URL: - * http://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to obtain it - * through the world wide web, please send an email to - * licensing@ellislab.com so we can send you a copy immediately. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * @package CodeIgniter - * @author EllisLab Dev Team + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @package CodeIgniter + * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * @link http://codeigniter.com - * @since Version 1.0 + * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @license http://opensource.org/licenses/MIT MIT License + * @link http://codeigniter.com + * @since Version 1.0.0 * @filesource */ defined('BASEPATH') OR exit('No direct script access allowed'); -- cgit v1.2.3-24-g4f1b From fe9309d22c1b088f5363954d6dac013c8c955894 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Jan 2015 17:48:58 +0200 Subject: Bulk (mostly documentation) update - Remove PHP version from license notices - Bump year number in copyright notices - Recommend PHP 5.4 or newer to be used - Tell Travis-CI to test on PHP 5.3.0 instead of the latest 5.3 version Related: #3450 --- system/libraries/Calendar.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 627838e90..e6ca225bf 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.2.4 or newer + * An open source application development framework for PHP * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014, British Columbia Institute of Technology + * Copyright (c) 2014 - 2015, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From 90726b8c769ea75aec34814ddfa91655d488e6c3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Jan 2015 12:39:22 +0200 Subject: [ci skip] Change some log messages' level 'Class Loaded' type of messages flood log files when log_threshold is set to 2 (debug). They're now logged as 'info' level. This is manually applying PR #1528, which was created to do the same thing, but became outdated. --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index e6ca225bf..fcca163a5 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -138,7 +138,7 @@ class CI_Calendar { empty($config) OR $this->initialize($config); - log_message('debug', 'Calendar Class Initialized'); + log_message('info', 'Calendar Class Initialized'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 4cbe463b4c442e0e2dae2f43565e77f7ac5ecb86 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 21 Jan 2015 22:56:22 +0100 Subject: Remove closing blocks at end of PHP files --- system/libraries/Calendar.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index fcca163a5..014daac58 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -548,6 +548,3 @@ class CI_Calendar { } } - -/* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 3549be4242d84b4cba0a00ecde0d58c90efbf0cd Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Wed, 25 Mar 2015 14:04:16 +0100 Subject: Fix language overriding for calendar library --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 014daac58..9059594bb 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -131,7 +131,7 @@ class CI_Calendar { { $this->CI =& get_instance(); - if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE)) + if ( ! array_key_exists('calendar_lang.php', $this->CI->lang->is_loaded)) { $this->CI->lang->load('calendar'); } -- cgit v1.2.3-24-g4f1b From 51fe87aea6a9588f24c9143338bdc5d0975821f9 Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Wed, 25 Mar 2015 19:15:02 +0100 Subject: use isset instead of array_key_exist --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 9059594bb..42fa00af2 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -131,7 +131,7 @@ class CI_Calendar { { $this->CI =& get_instance(); - if ( ! array_key_exists('calendar_lang.php', $this->CI->lang->is_loaded)) + if ( ! isset($this->CI->lang->is_loaded['calendar_lang.php'])) { $this->CI->lang->load('calendar'); } -- cgit v1.2.3-24-g4f1b From 03404890a5a0ea9c5e02c235a94312741bdf05b2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Mar 2015 20:58:19 +0200 Subject: Remove an unnecessary check #3700 #3706 --- system/libraries/Calendar.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 42fa00af2..f6a0c39c4 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -130,11 +130,7 @@ class CI_Calendar { public function __construct($config = array()) { $this->CI =& get_instance(); - - if ( ! isset($this->CI->lang->is_loaded['calendar_lang.php'])) - { - $this->CI->lang->load('calendar'); - } + $this->CI->lang->load('calendar'); empty($config) OR $this->initialize($config); -- cgit v1.2.3-24-g4f1b From 125ef4751080a2118cb203357d77687699e3eb25 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:33:00 +0200 Subject: [ci skip] Bump year to 2016 --- system/libraries/Calendar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index f6a0c39c4..fd32cfde6 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2015, British Columbia Institute of Technology + * Copyright (c) 2014 - 2016, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From bd202c91b0e9cf0a8c93bcaa71df9574f5909346 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:50:18 +0200 Subject: [ci skip] Update codeigniter.com links to https --- system/libraries/Calendar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index fd32cfde6..2a42b5844 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License - * @link http://codeigniter.com + * @link https://codeigniter.com * @since Version 1.0.0 * @filesource */ @@ -46,7 +46,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @subpackage Libraries * @category Libraries * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/calendar.html + * @link https://codeigniter.com/user_guide/libraries/calendar.html */ class CI_Calendar { -- cgit v1.2.3-24-g4f1b From 1924e879b165fb119847a49a7a5eab2f28295fa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:55:34 +0200 Subject: [ci skip] Update ellislab.com links to https too --- system/libraries/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 2a42b5844..1f8ef814f 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -28,7 +28,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com -- cgit v1.2.3-24-g4f1b From da60e9bc66ec90970fbd2dfd08b0a6e66b9f5f5f Mon Sep 17 00:00:00 2001 From: Master Yoda Date: Sat, 31 Dec 2016 08:46:18 -0800 Subject: Update copyright data to 2017 --- system/libraries/Calendar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Calendar.php') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 1f8ef814f..edb0fb4d9 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2016, British Columbia Institute of Technology + * Copyright (c) 2014 - 2017, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) - * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b