for his help developing this code * This subclass generates weekly calendars as a html table (XHTML Valid) using the activeCalendar class * Support, feature requests and bug reports please at : https://www.micronetwork.de/activecalendar/ */ defined('_JEXEC') or die; require_once('calendar.class.php'); class ActiveCalendarWeek extends JEMCalendar { /* ******************************************************************************** Names of the generated html classes. You may change them to avoid any conflicts with your existing CSS ******************************************************************************** */ var $cssWeeksTable="week"; var $cssMonthWeek="monthweek"; /* ---------------------- @START PUBLIC METHODS ---------------------- */ /* ******************************************************************************** PUBLIC class constructor. Calls the main class constructor ******************************************************************************** */ public function __construct($year=false, $month=false, $day=false, $GMTDiff="none") { parent::__construct($year, $month, $day, $GMTDiff); $this->GMT=$GMTDiff; } /* ******************************************************************************** PUBLIC showWeeks() -> returns the week view as html table string The week calendar starts on the date set in the constructor It generates as many rows as set in $numberOfWeeks ******************************************************************************** */ function showWeeks($numberOfWeeks=1) { $out=$this->mkWeeksHead(); $out.=$this->mkWeekDayz(); $out.=$this->mkWeeksBody($numberOfWeeks); $out.=$this->mkWeeksFoot(); return $out; } /* ******************************************************************************** PUBLIC showWeeksByID() -> returns the week view as html table string The week calendar starts with the week row, that has the same week number of the year as set in the weekID It generates as many rows as set in $numberOfWeeks ******************************************************************************** */ function showWeeksByID($weekID=1, $numberOfWeeks=1) { $xday=1; $from = ($weekID-2) * 7; $to = ($weekID+1) * 7; for ($day = $from; $day < $to; $day++) { $tmp=parent::getWeekNum($day); if ($tmp==$weekID) { $xday=$day; break; } } if ($this->startOnSun) $xday=$xday-1; $this->__construct($this->actyear, $this->actmonth, $xday, $this->GMT); return $this->showWeeks($numberOfWeeks); } /* ******************************************************************************** PUBLIC getFirstDayTime() -> returns the first day of given week as unixtime ******************************************************************************** */ function getFirstDayTimeOfWeek($weekID = 1) { $unixdate = false; /* There should be an inverse function but for now trying some days is ok */ $from = ($weekID-2) * 7; $to = ($weekID+1) * 7; for ($day = $from; $day < $to; $day++) { $tmp = parent::getWeekNum($day); if ($tmp == $weekID) { $xday = ($this->startOnSun) ? $day - 1 : $day; $unixdate = $this->mkActiveTime(0, 0, 1, $this->actmonth, $xday, $this->actyear); break; } } return $unixdate; } /* ---------------------- @START PRIVATE METHODS ---------------------- */ /* ******************************************************************************** PRIVATE mkWeeksHead() -> creates the week table tag ******************************************************************************** */ function mkWeeksHead() { return "
| cssWeekNumTitle . "\">" . $this->weekNumTitle . " | "; } for ($x=0; $x<=6; $x++) { $out.=$this->mkSingleWeekDay($this->actday+$x); } $out.="
| cssWeekNum."\">".$weeknumber." | "; for ($i = 0; $i <= 6; $i++) { $out.=$this->mkDay($this->actday); $this->__construct($this->actyear, $this->actmonth, $this->actday+1, $this->GMT); $this->resetSelectedToToday(); } $out.="