Fix for bug #2050 - a playlist spanning multiple hours is not properly plotted on the DAY VIEW. Added code documentation.
This commit is contained in:
parent
22810e102a
commit
9c3108e75b
|
@ -1,7 +1,13 @@
|
|||
{$SCHEDULER->buildDay()}
|
||||
{assign var="_scale" value=$SCHEDULER->getDayTimingScale()} {* get the 24h scale *}
|
||||
{assign var="_entrys" value=$SCHEDULER->getDayEntrys()} {* get all entrys on given day from scheduler *}
|
||||
{assign var="_day" value=$SCHEDULER->curr} {* to have year, month, day in between_additem.tpl *}
|
||||
|
||||
{* get the 24h scale *}
|
||||
{assign var="_scale" value=$SCHEDULER->getDayTimingScale()}
|
||||
|
||||
{* get all entrys on given day from scheduler *}
|
||||
{assign var="_entrys" value=$SCHEDULER->getDayEntrys()}
|
||||
|
||||
{* to have year, month, day in between_additem.tpl *}
|
||||
{assign var="_day" value=$SCHEDULER->curr}
|
||||
|
||||
<div class="content">
|
||||
<div class="container_elements">
|
||||
|
@ -20,7 +26,7 @@
|
|||
|
||||
{foreach from=$_scale item="_hour"}
|
||||
|
||||
{if isset($_hour) && is_array($_entrys[$_hour])}
|
||||
{if is_array($_entrys[$_hour])}
|
||||
<tr class="blue1">
|
||||
<td style="border-left: 1px solid #ccc; cursor: pointer" {include file="scheduler/day_additem.tpl"}>
|
||||
{$_hour|string_format:"%02d"}:00
|
||||
|
@ -53,7 +59,7 @@
|
|||
<i>{$i.creator}</i>
|
||||
{if $i.endshere}
|
||||
{include file="scheduler/between_additem.tpl"}
|
||||
{/if}
|
||||
{/if}
|
||||
{else}
|
||||
{$i.start} - ##tomorrow## {$i.end}
|
||||
<i>{$i.creator}</i>
|
||||
|
@ -62,8 +68,10 @@
|
|||
{/foreach}
|
||||
{/if}
|
||||
|
||||
{if $_entrys.span[$_hour]}
|
||||
span
|
||||
{if $_entrys[$_hour].span}
|
||||
<div {include file="scheduler/removeitem.tpl"}>
|
||||
...
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -1,41 +1,91 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Sebastian Gobel <sebastian.goebel@web.de>
|
||||
* @author Paul Baranowski <paul@paulbaranowski.org>
|
||||
* @package Campcaster
|
||||
* @subpackage htmlUI
|
||||
* @version $Revision$
|
||||
* @copyright 2006 MDLF, Inc.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
* @link http://www.campware.org
|
||||
*/
|
||||
class uiCalendar
|
||||
{
|
||||
/**
|
||||
* An array of 10 array, one for each year, centered around the
|
||||
* current year. Each year array consists of:
|
||||
* ["year"] => int
|
||||
* ["isSelected"] => boolean
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Decade;
|
||||
|
||||
/**
|
||||
* An array of 12 arrays, each representing a month of the year.
|
||||
* Each array consists of:
|
||||
* ["month"] => int : numeric representation of the month
|
||||
* ["label"] => string : name of the month
|
||||
* ["isSelected"] => boolean : TRUE if the month is selected
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Year;
|
||||
|
||||
/**
|
||||
* An array of 30 arrays, one for each day of the month.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Month;
|
||||
|
||||
/**
|
||||
* An array of 7 arrays, one for each day of the week.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Week;
|
||||
|
||||
/**
|
||||
* An array of 24 arrays, one for each hour in the day.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Day;
|
||||
|
||||
/**
|
||||
* An array of 60 arrays, one for each minute in the hour.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Hour;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() { }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the internal "Decade" array, an array of 10 arrays,
|
||||
* one for each year centered around the current year.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function buildDecade()
|
||||
{
|
||||
// Return if already created.
|
||||
if (is_array($this->Decade)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ($Year = $this->curr['year']-5; $Year<=$this->curr['year']+5; $Year++) {
|
||||
$this->Decade[] = array(
|
||||
'year' => $Year,
|
||||
'isSelected' => $Year==$this->curr['year'] ? TRUE : FALSE
|
||||
);
|
||||
for ($Year = $this->curr['year'] - 5; $Year <= ($this->curr['year'] + 5); $Year++) {
|
||||
$this->Decade[] = array('year' => $Year,
|
||||
'isSelected' => ($Year==$this->curr['year']) ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function buildYear()
|
||||
{
|
||||
// Return if already created.
|
||||
if (is_array($this->Year)) {
|
||||
return;
|
||||
}
|
||||
|
@ -44,23 +94,22 @@ class uiCalendar
|
|||
require_once('Calendar/Month.php');
|
||||
|
||||
$Year = new Calendar_Year($this->curr['year']);
|
||||
# mark current month
|
||||
// mark current month
|
||||
$sel = new Calendar_Month($this->curr['year'], $this->curr['month']);
|
||||
$selections = array($sel);
|
||||
|
||||
$Year->build($selections, UI_SCHEDULER_FIRSTWEEKDAY);
|
||||
while ($Month = $Year->fetch()) {
|
||||
$this->Year[] = array(
|
||||
'month' => sprintf('%02d', $Month->thisMonth()),
|
||||
'label' => $this->_getMonthName($Month),
|
||||
'isSelected' => $Month->isSelected()
|
||||
);
|
||||
$this->Year[] = array('month' => sprintf('%02d', $Month->thisMonth()),
|
||||
'label' => uiCalendar::_getMonthName($Month),
|
||||
'isSelected' => $Month->isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function buildMonth()
|
||||
{
|
||||
// Return if already created.
|
||||
if (is_array($this->Month)) {
|
||||
return;
|
||||
}
|
||||
|
@ -73,22 +122,25 @@ class uiCalendar
|
|||
$Month->build($this->_scheduledDays('month'));
|
||||
while ($Day = $Month->fetch()) {
|
||||
// Next 2 lines are due to a bug in Calendar_Month_Weekdays
|
||||
$corrMonth = $Day->thisMonth()<=12 ? sprintf('%02d', $Day->thisMonth()) : '01';
|
||||
$corrYear = $Day->thisMonth()<=12 ? $Day->thisYear() : $Day->thisYear()+1;
|
||||
$corrMonth = ($Day->thisMonth() <= 12) ? sprintf('%02d', $Day->thisMonth()) : '01';
|
||||
$corrYear = ($Day->thisMonth() <= 12) ? $Day->thisYear() : $Day->thisYear() + 1;
|
||||
$isCurrent = ($Day->thisDay() == $this->curr['day']
|
||||
&& $Day->thisMonth() == $this->curr['month']) ? TRUE : FALSE;
|
||||
$isToday = ($Day->thisDay() == strftime("%d")
|
||||
&& $Day->thisMonth()==strftime("%m")) ? TRUE : FALSE;
|
||||
$this->Month[] = array(
|
||||
'day' => sprintf('%02d', $Day->thisDay()),
|
||||
'week' => $this->_getWeekNr($Day),
|
||||
'month' => $corrMonth,
|
||||
'year' => $corrYear,
|
||||
'label' => $this->_getDayName($Day),
|
||||
'isEmpty' => $Day->isEmpty(),
|
||||
'isFirst' => $Day->isFirst(),
|
||||
'isLast' => $Day->isLast(),
|
||||
'isSelected' => $Day->isSelected(),
|
||||
'isCurrent' => $Day->thisDay()==$this->curr['day'] && $Day->thisMonth()==$this->curr['month'] ? TRUE : FALSE,
|
||||
'isToday' => $Day->thisDay()==strftime("%d") && $Day->thisMonth()==strftime("%m") ? TRUE : FALSE,
|
||||
'timestamp' => $Day->thisDay(TRUE)
|
||||
);
|
||||
'day' => sprintf('%02d', $Day->thisDay()),
|
||||
'week' => uiCalendar::_getWeekNr($Day),
|
||||
'month' => $corrMonth,
|
||||
'year' => $corrYear,
|
||||
'label' => $this->_getDayName($Day),
|
||||
'isEmpty' => $Day->isEmpty(),
|
||||
'isFirst' => $Day->isFirst(),
|
||||
'isLast' => $Day->isLast(),
|
||||
'isSelected' => $Day->isSelected(),
|
||||
'isCurrent' => $isCurrent,
|
||||
'isToday' => $isToday,
|
||||
'timestamp' => $Day->thisDay(TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,19 +156,21 @@ class uiCalendar
|
|||
$Week = new Calendar_Week($this->curr['year'], $this->curr['month'], $this->curr['day'], UI_SCHEDULER_FIRSTWEEKDAY);
|
||||
$Week->build($this->_scheduledDays('week'));
|
||||
while ($Day = $Week->fetch()) {
|
||||
$corrMonth = $Day->thisMonth()<=12 ? sprintf('%02d', $Day->thisMonth()) : '01'; ## due to bug in
|
||||
$corrYear = $Day->thisMonth()<=12 ? $Day->thisYear() : $Day->thisYear()+1; ## Calendar_Month_Weekdays
|
||||
// Next 2 lines are due to a bug in Calendar_Month_Weekdays
|
||||
$corrMonth = ($Day->thisMonth() <= 12) ? sprintf('%02d', $Day->thisMonth()) : '01';
|
||||
$corrYear = ($Day->thisMonth() <= 12) ? $Day->thisYear() : $Day->thisYear()+1;
|
||||
$isToday = ($Day->thisDay()==strftime("%d")
|
||||
&& $Day->thisMonth()==strftime("%m")) ? TRUE : FALSE;
|
||||
$this->Week[] = array(
|
||||
'day' => sprintf('%02d', $Day->thisDay()),
|
||||
'week' => $this->_getWeekNr($Day),
|
||||
'month' => $corrMonth,
|
||||
'year' => $corrYear,
|
||||
'label' => $this->_getDayName($Day),
|
||||
'isSelected' => $Day->isSelected(),
|
||||
'isCurrent' => $Day->thisDay()==$this->curr['day'] ? TRUE : FALSE,
|
||||
'isToday' => $Day->thisDay()==strftime("%d") && $Day->thisMonth()==strftime("%m") ? TRUE : FALSE,
|
||||
'timestamp' => $Day->thisDay(TRUE)
|
||||
);
|
||||
'day' => sprintf('%02d', $Day->thisDay()),
|
||||
'week' => uiCalendar::_getWeekNr($Day),
|
||||
'month' => $corrMonth,
|
||||
'year' => $corrYear,
|
||||
'label' => $this->_getDayName($Day),
|
||||
'isSelected' => $Day->isSelected(),
|
||||
'isCurrent' => $Day->thisDay()==$this->curr['day'] ? TRUE : FALSE,
|
||||
'isToday' => $isToday,
|
||||
'timestamp' => $Day->thisDay(TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,20 +187,18 @@ class uiCalendar
|
|||
$Day->build();
|
||||
while ($Hour = $Day->fetch()) {
|
||||
// Next two lines are due to a bug in Calendar_Month_Weekdays
|
||||
$corrMonth = $Hour->thisMonth()<=12 ? sprintf('%02d', $Hour->thisMonth()) : '01';
|
||||
$corrYear = $Hour->thisMonth()<=12 ? $Day->thisYear() : $Hour->thisYear()+1;
|
||||
$corrMonth = ($Hour->thisMonth() <= 12) ? sprintf('%02d', $Hour->thisMonth()) : '01';
|
||||
$corrYear = ($Hour->thisMonth() <= 12) ? $Day->thisYear() : $Hour->thisYear()+1;
|
||||
$this->Day[] = array(
|
||||
'day' => sprintf('%02d', $Hour->thisDay()),
|
||||
'week' => $this->_getWeekNr($Hour),
|
||||
'month' => $corrMonth,
|
||||
'year' => $corrYear,
|
||||
'hour' => $Hour->thisHour(),
|
||||
'isSelected' => $Hour->isSelected(),
|
||||
'isCurrent' => $Hour->thisDay()==$this->curr['day'] ? TRUE : FALSE,
|
||||
'timestamp' => $Hour->thisHour(TRUE)
|
||||
);
|
||||
'day' => sprintf('%02d', $Hour->thisDay()),
|
||||
'week' => uiCalendar::_getWeekNr($Hour),
|
||||
'month' => $corrMonth,
|
||||
'year' => $corrYear,
|
||||
'hour' => $Hour->thisHour(),
|
||||
'isSelected' => $Hour->isSelected(),
|
||||
'isCurrent' => $Hour->thisDay()==$this->curr['day'] ? TRUE : FALSE,
|
||||
'timestamp' => $Hour->thisHour(TRUE));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,41 +213,61 @@ class uiCalendar
|
|||
$Hour = new Calendar_Hour($this->curr['year'], $this->curr['month'], $this->curr['day'], $this->curr['hour']);
|
||||
$Hour->build();
|
||||
while ($Min = $Hour->fetch()) {
|
||||
$isCurrent = ($Min->thisDay() == $this->curr['hour']) ? TRUE : FALSE;
|
||||
$this->Hour[] = array(
|
||||
'day' => sprintf('%02d', $Min->thisDay()),
|
||||
'week' => $this->_getWeekNr($Min),
|
||||
'month' => sprintf('%02d', $Min->thisMonth()),
|
||||
'year' => $Min->thisYear(),
|
||||
'hour' => $Min->thisHour(),
|
||||
'minute' => $Min->thisMinute(),
|
||||
'isSelected' => $Min->isSelected(),
|
||||
'isCurrent' => $Min->thisDay()==$this->curr['hour'] ? TRUE : FALSE
|
||||
);
|
||||
'day' => sprintf('%02d', $Min->thisDay()),
|
||||
'week' => uiCalendar::_getWeekNr($Min),
|
||||
'month' => sprintf('%02d', $Min->thisMonth()),
|
||||
'year' => $Min->thisYear(),
|
||||
'hour' => $Min->thisHour(),
|
||||
'minute' => $Min->thisMinute(),
|
||||
'isSelected' => $Min->isSelected(),
|
||||
'isCurrent' => $isCurrent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## some data which PEAR::Calendar does not provide ##########################################################################################
|
||||
function _getMonthName(&$date) {
|
||||
/**
|
||||
* Get the name of the month.
|
||||
*
|
||||
* @param Calendar_Month $date
|
||||
* @return array
|
||||
* With keys:
|
||||
* ['short'] => short name of the month
|
||||
* ['full'] => complete name of the month
|
||||
*/
|
||||
private static function _getMonthName(&$date) {
|
||||
$timestamp = mktime($date->thisHour(), $date->thisMinute(), $date->thisSecond(), $date->thisMonth(), $date->thisDay(), $date->thisYear());
|
||||
#echo $date->thisHour().$date->thisMinute().$date->thisSecond().$date->thisYear().$date->thisMonth().$date->thisDay().$timestamp."<br>";
|
||||
return array('short' => strftime("%b", $timestamp),
|
||||
'full' => strftime("%B", $timestamp));
|
||||
}
|
||||
|
||||
|
||||
function _getWeekNr(&$date) {
|
||||
/**
|
||||
* Get the week number (1 to 53)
|
||||
*
|
||||
* @param Calendar_Day|Calendar_Hour|Calendar_Minute $date
|
||||
* @return int
|
||||
*/
|
||||
private static function _getWeekNr(&$date) {
|
||||
$timestamp = mktime($date->thisHour(), $date->thisMinute(), $date->thisSecond(), $date->thisMonth(), $date->thisDay(), $date->thisYear());
|
||||
#echo $date->thisHour().$date->thisMinute().$date->thisSecond().$date->thisYear().$date->thisMonth().$date->thisDay().$timestamp."<br>";
|
||||
return strftime("%V", $timestamp);
|
||||
}
|
||||
|
||||
|
||||
function _getDayName(&$date) {
|
||||
/**
|
||||
* Get the name of the day.
|
||||
*
|
||||
* @param Calendar_Day $date
|
||||
* @return array
|
||||
* With keys:
|
||||
* ['short'] => short version of day name
|
||||
* ['full'] => day name
|
||||
*/
|
||||
private static function _getDayName(&$date) {
|
||||
$timestamp = mktime($date->thisHour(), $date->thisMinute(), $date->thisSecond(), $date->thisMonth(), $date->thisDay(), $date->thisYear());
|
||||
#echo $date->thisHour().$date->thisMinute().$date->thisSecond().$date->thisYear().$date->thisMonth().$date->thisDay().$timestamp."<br>";
|
||||
return array('short' => strftime("%a", $timestamp),
|
||||
'full' => strftime("%A", $timestamp));
|
||||
}
|
||||
}
|
||||
} // class uiCalendar
|
||||
?>
|
Loading…
Reference in New Issue