Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class ncalendar extends obj

Hide Inherited MembersCalendar
Description
No description.
 
Constants
No constants.
 
Properties
protected_date[ ncalendar ]
protected_day[ ncalendar ]
protected_dirty[ obj ]
protected_month[ ncalendar ]
publicproperty_objects_array[ obj ]
protected_year[ ncalendar ]
 
Methods
publiccal_from_jd ( julian )[ ncalendar ]
Parameters
requiredjulian
Code
101  public function cal_from_jd($__julian)
102  {
103      if ($__julian == 60)
104      {
105          $this->_day    = 29;
106          $this->_month  = 2;
107          $this->_year   = 1900;
108 
109          return $this->date_string;
110      }
111      else if ($__julian < 60)
112      {
113          // Because of the 29-02-1900 bug, any serial date
114 
115          // under 60 is one off... Compensate.
116 
117          $__julian++;
118      }
119 
120      // Modified Julian to DMY calculation with an addition of 2415019
121 
122      $l = $__julian + 68569 + 2415019;
123      $n = intval(( 4 * $l ) / 146097);
124      $l = $l - intval(( 146097 * $n + 3 ) / 4);
125      $i = intval(( 4000 * ( $l + 1 ) ) / 1461001);
126      $l = $l - intval(( 1461 * $i ) / 4) + 31;
127      $j = intval(( 80 * $l ) / 2447);
128      $this->_day = $l - intval(( 2447 * $j ) / 80);
129      $l = intval($j / 11);
130      $this->_month = $j + 2 - ( 12 * $l );
131      $this->_year = 100 * ( $n - 49 ) + $i + $l;
132     
133      //set the date properties with the new values
134      $this->_date = new date($this->date_string);
135      return $this->date_string;
136  }
public__construct ( date )[ ncalendar ]
Parameters
optionaldate
Code
011  public function __construct($__date=null)
012  {
013     
014      if (is_null($__date))
015      {
016          $__date = new date();
017      }
018      $this->_date = $__date;
019      $this->_month = $this->_date->month;
020      $this->_day = $this->_date->day;
021      $this->_year = $this->_date->year;
022  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicget_date_string ( )[ ncalendar ]
Parameters
No parameters for this method
Code
091  public function get_date_string()
092  {
093      $yyyy = $this->_year;
094      $mm = (strlen($this->_month)==1) ? "0$this->_month" : $this->_month;
095      $dd = (strlen($this->_day)==1) ? "0$this->_day" : $this->_day;
096      return "$yyyy-$mm-$dd";
097  }
publicget_days ( )[ ncalendar ]
Parameters
No parameters for this method
Code
086  public function get_days()
087  {
088      return date("t",$this->_date->utime);
089  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicget_first_day_num ( )[ ncalendar ]
Parameters
No parameters for this method
Code
066  public function get_first_day_num()
067  {
068      return date("w",mktime(null,null,null,$this->month,1,$this->year)) + 1;
069  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicget_month_name ( )[ ncalendar ]
Parameters
No parameters for this method
Code
071  public function get_month_name()
072  {
073      return date("F",$this->_date->utime);
074  }
publicget_next_days ( date )[ ncalendar ]
Parameters
optionaldate
Code
060  public function get_next_days($date=null)
061  {
062      $ntime = mktime($this->_date->hour,$this->_date->minute,$this->_date->second,$this->next_month,$this->_date->day,$this->previous_next_year);
063      return date("t",$ntime);
064  }
publicget_next_month ( )[ ncalendar ]
Parameters
No parameters for this method
Code
045  public function get_next_month()
046  {
047      return ($this->_date->month==12) ? 1 : ($this->_date->month+1);
048  }
publicget_next_month_name ( )[ ncalendar ]
Parameters
No parameters for this method
Code
081  public function get_next_month_name()
082  {
083      return date("F",mktime(null,null,null,$this->next_month,1,$this->next_month_year));
084  }
publicget_next_month_year ( )[ ncalendar ]
Parameters
No parameters for this method
Code
050  public function get_next_month_year()
051  {
052      return ($this->_date->month==12) ? ($this->next_year) : $this->_date->year;
053  }
publicget_next_year ( date )[ ncalendar ]
Parameters
optionaldate
Code
055  public function get_next_year($date=null)
056  {
057      return ($this->_date->year + 1);
058  }
publicget_previous_days ( )[ ncalendar ]
Parameters
No parameters for this method
Code
039  public function get_previous_days()
040  {
041      $ptime = mktime($this->_date->hour,$this->_date->minute,$this->_date->second,$this->previous_month,$this->_date->day,$this->previous_month_year);
042      return date("t",$ptime);
043  }
publicget_previous_month ( )[ ncalendar ]
Parameters
No parameters for this method
Code
024  public function get_previous_month()
025  {
026      return ($this->_date->month==1) ? 12 : ($this->_date->month-1);
027  }
publicget_previous_month_name ( )[ ncalendar ]
Parameters
No parameters for this method
Code
076  public function get_previous_month_name()
077  {
078      return date("F",mktime(null,null,null,$this->previous_month,1,$this->previous_month_year));
079  }
publicget_previous_month_year ( )[ ncalendar ]
Parameters
No parameters for this method
Code
029  public function get_previous_month_year()
030  {
031      return ($this->_date->month==1) ? ($this->previous_year) : $this->_date->year;
032  }
publicget_previous_year ( )[ ncalendar ]
Parameters
No parameters for this method
Code
034  public function get_previous_year()
035  {
036      return ($this->_date->year - 1);
037  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicdate_string[ ncalendar ]
Code
091  public function get_date_string()
092  {
093      $yyyy = $this->_year;
094      $mm = (strlen($this->_month)==1) ? "0$this->_month" : $this->_month;
095      $dd = (strlen($this->_day)==1) ? "0$this->_day" : $this->_day;
096      return "$yyyy-$mm-$dd";
097  }
publicdays[ ncalendar ]
Code
086  public function get_days()
087  {
088      return date("t",$this->_date->utime);
089  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicfirst_day_num[ ncalendar ]
Code
066  public function get_first_day_num()
067  {
068      return date("w",mktime(null,null,null,$this->month,1,$this->year)) + 1;
069  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicmonth_name[ ncalendar ]
Code
071  public function get_month_name()
072  {
073      return date("F",$this->_date->utime);
074  }
publicnext_days[ ncalendar ]
Code
060  public function get_next_days($date=null)
061  {
062      $ntime = mktime($this->_date->hour,$this->_date->minute,$this->_date->second,$this->next_month,$this->_date->day,$this->previous_next_year);
063      return date("t",$ntime);
064  }
publicnext_month[ ncalendar ]
Code
045  public function get_next_month()
046  {
047      return ($this->_date->month==12) ? 1 : ($this->_date->month+1);
048  }
publicnext_month_name[ ncalendar ]
Code
081  public function get_next_month_name()
082  {
083      return date("F",mktime(null,null,null,$this->next_month,1,$this->next_month_year));
084  }
publicnext_month_year[ ncalendar ]
Code
050  public function get_next_month_year()
051  {
052      return ($this->_date->month==12) ? ($this->next_year) : $this->_date->year;
053  }
publicnext_year[ ncalendar ]
Code
055  public function get_next_year($date=null)
056  {
057      return ($this->_date->year + 1);
058  }
publicprevious_days[ ncalendar ]
Code
039  public function get_previous_days()
040  {
041      $ptime = mktime($this->_date->hour,$this->_date->minute,$this->_date->second,$this->previous_month,$this->_date->day,$this->previous_month_year);
042      return date("t",$ptime);
043  }
publicprevious_month[ ncalendar ]
Code
024  public function get_previous_month()
025  {
026      return ($this->_date->month==1) ? 12 : ($this->_date->month-1);
027  }
publicprevious_month_name[ ncalendar ]
Code
076  public function get_previous_month_name()
077  {
078      return date("F",mktime(null,null,null,$this->previous_month,1,$this->previous_month_year));
079  }
publicprevious_month_year[ ncalendar ]
Code
029  public function get_previous_month_year()
030  {
031      return ($this->_date->month==1) ? ($this->previous_year) : $this->_date->year;
032  }
publicprevious_year[ ncalendar ]
Code
034  public function get_previous_year()
035  {
036      return ($this->_date->year - 1);
037  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads