Fix for bug #1973 - schedule popup broken. Got rid of some warnings and did some code cleanup as well.

This commit is contained in:
paul 2006-11-15 18:56:11 +00:00
parent 02e9120ff6
commit d0f967b90a
1 changed files with 38 additions and 36 deletions

View File

@ -6,14 +6,14 @@
*/ */
class uiScheduler extends uiCalendar { class uiScheduler extends uiCalendar {
public $curr; public $curr;
private $scheduleAtTime; public $scheduleAtTime;
private $schedulePrev; public $schedulePrev;
private $scheduleNext; public $scheduleNext;
private $error; public $error;
private $Base; public $Base;
private $reloadUrl; public $reloadUrl;
private $closeUrl; public $closeUrl;
private $firstDayOfWeek; public $firstDayOfWeek;
public function __construct(&$uiBase) public function __construct(&$uiBase)
@ -135,38 +135,38 @@ class uiScheduler extends uiCalendar {
if (isset($today)) { if (isset($today)) {
list($year, $month, $day) = explode("-", strftime("%Y-%m-%d")); list($year, $month, $day) = explode("-", strftime("%Y-%m-%d"));
} }
if (is_numeric($year)) { if (isset($year) && is_numeric($year)) {
$this->curr['year'] = sprintf('%04d', $year); $this->curr['year'] = sprintf('%04d', $year);
} }
if (is_numeric($month)) { if (isset($month) && is_numeric($month)) {
$this->curr['month'] = sprintf('%02d', $month); $this->curr['month'] = sprintf('%02d', $month);
} }
if (is_numeric($day)) { if (isset($day) && is_numeric($day)) {
$this->curr['day'] = sprintf('%02d', $day); $this->curr['day'] = sprintf('%02d', $day);
} }
if (is_numeric($hour)) { if (isset($hour) && is_numeric($hour)) {
$this->curr['hour'] = sprintf('%02d', $hour); $this->curr['hour'] = sprintf('%02d', $hour);
} }
$stampNow = $this->_datetime2timestamp($this->curr['year'].$this->curr['month'].$this->curr['day'].'T'.$this->curr['hour'].':00:00'); $stampNow = $this->datetimeToTimestamp($this->curr['year'].$this->curr['month'].$this->curr['day'].'T'.$this->curr['hour'].':00:00');
$stampTarget = $stampNow; $stampTarget = $stampNow;
if ($month==='++') { if (isset($month) && ($month==='++')) {
$stampTarget = strtotime("+1 month", $stampNow); $stampTarget = strtotime("+1 month", $stampNow);
} }
if ($month==='--') { if (isset($month) && ($month==='--')) {
$stampTarget = strtotime("-1 month", $stampNow); $stampTarget = strtotime("-1 month", $stampNow);
} }
if ($week==='++') { if (isset($week) && ($week==='++')) {
$stampTarget = strtotime("+1 week", $stampNow); $stampTarget = strtotime("+1 week", $stampNow);
} }
if ($week==='--') { if (isset($week) && ($week==='--')) {
$stampTarget = strtotime("-1 week", $stampNow); $stampTarget = strtotime("-1 week", $stampNow);
} }
if ($day==='++') { if (isset($day) && ($day==='++')) {
$stampTarget = strtotime("+1 day", $stampNow); $stampTarget = strtotime("+1 day", $stampNow);
} }
if ($day==='--') { if (isset($day) && ($day==='--')) {
$stampTarget = strtotime("-1 day", $stampNow); $stampTarget = strtotime("-1 day", $stampNow);
} }
@ -234,7 +234,7 @@ class uiScheduler extends uiCalendar {
$this->scheduleAtTime['second'] = sprintf('%02d', $second); $this->scheduleAtTime['second'] = sprintf('%02d', $second);
} }
$this->scheduleAtTime['stamp'] = $this->_datetime2timestamp($this->scheduleAtTime['year'].$this->scheduleAtTime['month'].$this->scheduleAtTime['day'].'T'. $this->scheduleAtTime['stamp'] = $this->datetimeToTimestamp($this->scheduleAtTime['year'].$this->scheduleAtTime['month'].$this->scheduleAtTime['day'].'T'.
$this->scheduleAtTime['hour'].':'.$this->scheduleAtTime['minute'].':'.$this->scheduleAtTime['second']); $this->scheduleAtTime['hour'].':'.$this->scheduleAtTime['minute'].':'.$this->scheduleAtTime['second']);
if (is_array($week = $this->getWeekEntrys())) { if (is_array($week = $this->getWeekEntrys())) {
@ -287,14 +287,15 @@ class uiScheduler extends uiCalendar {
return FALSE; return FALSE;
} }
$items = array();
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$items[strftime('%d', $this->_datetime2timestamp($val['start']))][number_format(strftime('%H', $this->_datetime2timestamp($val['start'])))][]= array ( $items[strftime('%d', $this->datetimeToTimestamp($val['start']))][number_format(strftime('%H', $this->datetimeToTimestamp($val['start'])))][]= array (
'id' => $this->Base->gb->_idFromGunid($val['playlistId']), 'id' => $this->Base->gb->_idFromGunid($val['playlistId']),
'scheduleid'=> $val['id'], 'scheduleid'=> $val['id'],
'start' => substr($val['start'], strpos($val['start'], 'T')+1), 'start' => substr($val['start'], strpos($val['start'], 'T')+1),
'end' => substr($val['end'], strpos($val['end'], 'T')+1), 'end' => substr($val['end'], strpos($val['end'], 'T')+1),
'start_stamp' => $this->_datetime2timestamp($val['start']), 'start_stamp' => $this->datetimeToTimestamp($val['start']),
'end_stamp' => $this->_datetime2timestamp($val['end']), 'end_stamp' => $this->datetimeToTimestamp($val['end']),
'title' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
'creator' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR), 'creator' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR),
'type' => 'Playlist' 'type' => 'Playlist'
@ -319,9 +320,10 @@ class uiScheduler extends uiCalendar {
return FALSE; return FALSE;
} }
$items = array();
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$start = $this->_datetime2timestamp($val['start']); $start = $this->datetimeToTimestamp($val['start']);
$end = $this->_datetime2timestamp($val['end']); $end = $this->datetimeToTimestamp($val['end']);
$Y = strftime('%Y', $start); $Y = strftime('%Y', $start);
$m = number_format(strftime('%m', $start)); $m = number_format(strftime('%m', $start));
$d = number_format(strftime('%d', $start)); $d = number_format(strftime('%d', $start));
@ -377,7 +379,7 @@ class uiScheduler extends uiCalendar {
if (!count($arr)) if (!count($arr))
return FALSE; return FALSE;
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$items[date('H', $this->_datetime2timestamp($val['start']))][]= array ( $items[date('H', $this->datetimeToTimestamp($val['start']))][]= array (
'start' => substr($val['start'], strpos($val['start'], 'T')+1), 'start' => substr($val['start'], strpos($val['start'], 'T')+1),
'end' => substr($val['end'], strpos($val['end'], 'T') + 1), 'end' => substr($val['end'], strpos($val['end'], 'T') + 1),
'title' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
@ -402,8 +404,8 @@ class uiScheduler extends uiCalendar {
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$arr[$key]['title'] = $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE); $arr[$key]['title'] = $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE);
$arr[$key]['creator'] = $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR); $arr[$key]['creator'] = $this->Base->getMetadataValue($this->Base->gb->_idFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR);
$arr[$key]['pos'] = $this->_datetime2timestamp($val['start']); $arr[$key]['pos'] = $this->datetimeToTimestamp($val['start']);
$arr[$key]['span'] = date('H', $this->_datetime2timestamp($val['end'])) - date('H', $this->_datetime2timestamp($val['start'])) +1; $arr[$key]['span'] = date('H', $this->datetimeToTimestamp($val['end'])) - date('H', $this->datetimeToTimestamp($val['start'])) +1;
} }
//print_r($arr); //print_r($arr);
return $arr; return $arr;
@ -417,7 +419,7 @@ class uiScheduler extends uiCalendar {
} }
foreach ($arr as $val) { foreach ($arr as $val) {
$duration += ($this->_datetime2timestamp($val['end'])-$this->_datetime2timestamp($val['start']))/86400*100; $duration += ($this->datetimeToTimestamp($val['end'])-$this->datetimeToTimestamp($val['start']))/86400*100;
} }
return $duration; return $duration;
} // fn getDayUsagePercentage } // fn getDayUsagePercentage
@ -509,7 +511,7 @@ class uiScheduler extends uiCalendar {
$pl = current($pl); $pl = current($pl);
// subtract difference to UTC // subtract difference to UTC
$offset = strftime('%H:%M:%S', time() - $this->_datetime2timestamp($pl['start']) - 3600 * strftime('%H', 0)); $offset = strftime('%H:%M:%S', time() - $this->datetimeToTimestamp($pl['start']) - 3600 * strftime('%H', 0));
$clip = $this->Base->gb->displayPlaylistClipAtOffset($this->Base->sessid, $pl['playlistId'], $offset, $distance, $_SESSION['langid'], UI_DEFAULT_LANGID); $clip = $this->Base->gb->displayPlaylistClipAtOffset($this->Base->sessid, $pl['playlistId'], $offset, $distance, $_SESSION['langid'], UI_DEFAULT_LANGID);
@ -562,13 +564,13 @@ class uiScheduler extends uiCalendar {
} // fn getNowNextClip4jscom } // fn getNowNextClip4jscom
function _datetime2timestamp($i) private function datetimeToTimestamp($i)
{ {
$i = str_replace('T', ' ', $i); $i = str_replace('T', ' ', $i);
$formatted = $i[0].$i[1].$i[2].$i[3].'-'.$i[4].$i[5].'-'.$i[6].$i[7].strrchr($i, ' '); $formatted = $i[0].$i[1].$i[2].$i[3].'-'.$i[4].$i[5].'-'.$i[6].$i[7].strrchr($i, ' ');
//echo "input: $i formatted:".$formatted; //echo "input: $i formatted:".$formatted;
return $this->_strtotime($formatted); return $this->_strtotime($formatted);
} // fn _datetime2timestamp } // fn datetimeToTimestamp
/** /**
@ -643,12 +645,12 @@ class uiScheduler extends uiCalendar {
$pStampArr = null; $pStampArr = null;
foreach ($pArr as $val) { foreach ($pArr as $val) {
#print_r($val); #print_r($val);
$pStampArr[] = array('start' => $this->_datetime2timestamp($val['start']), $pStampArr[] = array('start' => $this->datetimeToTimestamp($val['start']),
'end' => $this->_datetime2timestamp($val['end'])); 'end' => $this->datetimeToTimestamp($val['end']));
} }
if (is_array($pStampArr)) { if (is_array($pStampArr)) {
#print_r($pStampArr); #print_r($pStampArr);
for ($n=$this->_datetime2timestamp($dfrom); $n<=$this->_datetime2timestamp($dto); $n+=86400) { for ($n=$this->datetimeToTimestamp($dfrom); $n<=$this->datetimeToTimestamp($dto); $n+=86400) {
foreach ($pStampArr as $val) { foreach ($pStampArr as $val) {
if ($val['start'] < $n+86400 && $val['end'] >= $n) { if ($val['start'] < $n+86400 && $val['end'] >= $n) {
$days[date('Ymd', $n)] = array('year' => date('Y', $n), $days[date('Ymd', $n)] = array('year' => date('Y', $n),
@ -708,7 +710,7 @@ class uiScheduler extends uiCalendar {
return FALSE; return FALSE;
} }
if (isset($r['scheduleEntryId'])) { if (isset($r['scheduleEntryId'])) {
$this->Base->_retMsg('Entry added at $1 with ScheduleId $2.', strftime("%Y-%m-%d %H:%M:%S", $this->_datetime2timestamp($datetime)), $r['scheduleEntryId']); $this->Base->_retMsg('Entry added at $1 with ScheduleId $2.', strftime("%Y-%m-%d %H:%M:%S", $this->datetimeToTimestamp($datetime)), $r['scheduleEntryId']);
} }
} // fn uploadPlaylistMethod } // fn uploadPlaylistMethod