summaryrefslogtreecommitdiffstats
path: root/system/libraries/Calendar.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-04-03 19:21:39 +0200
committerAndrey Andreev <narf@bofh.bg>2012-04-03 19:21:39 +0200
commit320d37c090cbc1497d3951f64da1c16e86bae609 (patch)
tree51e1bf36e4d63e233e0b9b550420805d65548945 /system/libraries/Calendar.php
parent31cf46eaec3b4613d5b46f9caed8bdd346b581cc (diff)
parent78f55772adb86b48d0d50572545c24c18f528ff9 (diff)
Merge upstream branch
Diffstat (limited to 'system/libraries/Calendar.php')
-rw-r--r--system/libraries/Calendar.php61
1 files changed, 26 insertions, 35 deletions
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