Fixed Scheduler UI so that it now works for the "Day" view.

This commit is contained in:
paul.baranowski 2010-09-22 17:25:11 -04:00
parent 47e0233e47
commit 1d141c56ae
4 changed files with 95 additions and 97 deletions

View File

@ -106,13 +106,13 @@ function SCHEDULE_snap2Next()
function SCHEDULE_selectedDuration() function SCHEDULE_selectedDuration()
{ {
var arr = document.forms["schedule"].elements["gunid_duration"].value.split("|"); var arr = document.forms["schedule"].elements["id_duration"].value.split("|");
return arr[1].slice(0, 8); return arr[1].slice(0, 8);
} }
function SCHEDULE_selectedGunid() function SCHEDULE_selectedGunid()
{ {
var arr = document.forms["schedule"].elements["gunid_duration"].value.split("|"); var arr = document.forms["schedule"].elements["id_duration"].value.split("|");
return arr[0]; return arr[0];
} }
{/literal} {/literal}

View File

@ -339,7 +339,6 @@ class uiScheduler extends uiCalendar {
$thisDay = strftime("%Y-%m-%d", $this->Day[0]['timestamp']); $thisDay = strftime("%Y-%m-%d", $this->Day[0]['timestamp']);
$nextDay = strftime("%Y-%m-%d", $this->Day[0]['timestamp'] + 86400); $nextDay = strftime("%Y-%m-%d", $this->Day[0]['timestamp'] + 86400);
$arr = $this->displayScheduleMethod($thisDay.' 00:00:00', $nextDay.' 00:00:00'); $arr = $this->displayScheduleMethod($thisDay.' 00:00:00', $nextDay.' 00:00:00');
//$_SESSION["debug"] = $arr;
if (!is_array($arr)) { if (!is_array($arr)) {
return FALSE; return FALSE;
} }
@ -347,93 +346,95 @@ class uiScheduler extends uiCalendar {
$items = array(); $items = array();
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$start = self::datetimeToTimestamp($val['start']); $start = self::datetimeToTimestamp($val['start']);
$end = self::datetimeToTimestamp($val['end']); $end = self::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));
$h = number_format(strftime('%H', $start)); $h = number_format(strftime('%H', $start));
$M = number_format(strftime('%i', $start)); $M = number_format(strftime('%i', $start));
$id = BasicStor::IdFromGunid($val['playlistId']); $id = $val['playlistId'];
$startHour = (int)strftime('%H', $start);
$endHour = (int)strftime('%H', $end);
$startTime = substr($val['start'], strpos($val['start'], ' ')+1);
$endTime = substr($val['end'], strpos($val['end'], ' ') + 1);
$track = StoredFile::Recall($val["file_id"]);
$trackMetadata = $track->getMetadata();
$title = $trackMetadata["track_title"];
$creator = $trackMetadata["artist_name"];
$startHour = (int)strftime('%H', $start); // Item starts today
$endHour = (int)strftime('%H', $end); if (strftime('%Y-%m-%d', $start) === $thisDay) {
$startTime = substr($val['start'], strpos($val['start'], 'T')+1); $endsToday = (strftime('%d', $start) === strftime('%d', $end)) ? TRUE : FALSE;
$endTime = substr($val['end'], strpos($val['end'], 'T') + 1); $endsHere = strftime('%H', $start) === strftime('%H', $end) ? TRUE : FALSE;
$title = $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE); $items[$startHour]['start'][] =
$creator = $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR); array('id' => $id,
'scheduleid' => $val['id'],
'start' => $startTime,
'end' => $endTime,
'title' => $title,
'creator' => $creator,
'type' => 'Playlist',
'endstoday' => $endsToday,
'endshere' => $endsHere);
}
// Item starts today // Item ends today
if (strftime('%Y%m%d', $start) === $thisDay) { if ( (strftime('%Y-%m-%d', $end) === $thisDay) && ($startHour !== $endHour) ) {
$endsToday = (strftime('%d', $start) === strftime('%d', $end)) ? TRUE : FALSE; $startsYesterday = (strftime('%d', $start) === strftime('%d', $end)) ? FALSE : TRUE;
$endsHere = strftime('%H', $start) === strftime('%H', $end) ? TRUE : FALSE;
$items[$startHour]['start'][] =
array('id' => $id,
'scheduleid' => $val['id'],
'start' => $startTime,
'end' => $endTime,
'title' => $title,
'creator' => $creator,
'type' => 'Playlist',
'endstoday' => $endsToday,
'endshere' => $endsHere);
}
// Item ends today $items[$endHour]['end'][] =
if ( (strftime('%Y%m%d', $end) === $thisDay) && ($startHour !== $endHour) ) { array('id' => $id,
$startsYesterday = (strftime('%d', $start) === strftime('%d', $end)) ? FALSE : TRUE; 'scheduleid' => $val['id'],
'start' => $startTime,
'end' => $endTime,
'title' => $title,
'creator' => $creator,
'type' => 'Playlist',
'startsyesterday' => $startsYesterday);
}
$items[$endHour]['end'][] = $diffHours = floor(($end - $start)/3600);
array('id' => $id, // If the item spans three hours or more
'scheduleid' => $val['id'], if ( $diffHours > 2 ) {
'start' => $startTime, // $skip becomes true if we dont actually have to do
'end' => $endTime, // this section.
'title' => $title, $skip = false;
'creator' => $creator, if (strftime('%Y-%m-%d', $start) === $thisDay) {
'type' => 'Playlist', // For the edge case of starting at the end of
'startsyesterday' => $startsYesterday); // today.
} if ($startHour == 23) {
$skip = true;
$diffHours = floor(($end - $start)/3600); }
// If the item spans three hours or more $countStart = $startHour + 1;
if ( $diffHours > 2 ) { } else {
// $skip becomes true if we dont actually have to do $countStart = 0;
// this section. }
$skip = false; if (strftime('%Y-%m-%d', $end) === $thisDay) {
if (strftime('%Y%m%d', $start) === $thisDay) { // For the edge case of ending at the beginning
// For the edge case of starting at the end of // of today.
// today. if ($endHour == 0) {
if ($startHour == 23) { $skip = true;
$skip = true; }
} $countEnd = $endHour - 1;
$countStart = $startHour + 1; } else {
} else { $countEnd = 23;
$countStart = 0; }
} if (!$skip) {
if (strftime('%Y%m%d', $end) === $thisDay) { for ($i = $countStart; $i <= $countEnd; $i++) {
// For the edge case of ending at the beginning $items[$i]['span'] =
// of today. array('id' => $id,
if ($endHour == 0) { 'scheduleid' => $val['id'],
$skip = true; 'start' => $startTime,
} 'end' => $endTime,
$countEnd = $endHour - 1; 'title' => $title,
} else { 'creator' => $creator,
$countEnd = 23; 'type' => 'Playlist');
} }
if (!$skip) { }
for ($i = $countStart; $i <= $countEnd; $i++) { }
$items[$i]['span'] =
array('id' => $id,
'scheduleid' => $val['id'],
'start' => $startTime,
'end' => $endTime,
'title' => $title,
'creator' => $creator,
'type' => 'Playlist');
}
}
}
} }
return $items; return $items;
} // fn getDayEntrys } // fn getDayEntrys
@ -522,7 +523,7 @@ class uiScheduler extends uiCalendar {
{ {
global $ui_fmask; global $ui_fmask;
foreach ($this->availablePlaylists as $val) { foreach ($this->availablePlaylists as $val) {
$ui_fmask['schedule']['gunid_duration']['options'][$val['gunid'].'|'.$val['duration']] = $val['title']; $ui_fmask['schedule']['id_duration']['options'][$val['id'].'|'.$val['duration']] = $val['title'];
} }
$form = new HTML_QuickForm('schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER);
@ -549,6 +550,7 @@ class uiScheduler extends uiCalendar {
$this->Base->SCRATCHPAD->addItem($id); $this->Base->SCRATCHPAD->addItem($id);
$this->availablePlaylists[] = array( $this->availablePlaylists[] = array(
'gunid' => BasicStor::GunidFromId($id), 'gunid' => BasicStor::GunidFromId($id),
'id' => $id,
'title' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE),
'duration' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_DURATION), 'duration' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_DURATION),
); );
@ -742,9 +744,10 @@ class uiScheduler extends uiCalendar {
*/ */
public static function datetimeToTimestamp($i) public static function datetimeToTimestamp($i)
{ {
$i = str_replace('T', ' ', $i); $i = str_replace('-', '', $i);
$formatted = $i[0].$i[1].$i[2].$i[3].'-'.$i[4].$i[5].'-'.$i[6].$i[7].strrchr($i, ' '); $i = str_replace(' ', 'T', $i);
return self::strtotime($formatted); $i = substr($i, 0, 17);
return self::strtotime($i);
} // fn datetimeToTimestamp } // fn datetimeToTimestamp
@ -1043,7 +1046,7 @@ class uiScheduler extends uiCalendar {
$item = new ScheduleGroup(); $item = new ScheduleGroup();
$groupId = $item->add($datetime, null, $gunid); $groupId = $item->add($datetime, null, $gunid);
$_SESSION["debug"] = $groupId; //$_SESSION["debug"] = $groupId;
return is_numeric($groupId); return is_numeric($groupId);
// $r = $this->spc->UploadPlaylistMethod($this->Base->sessid, $gunid, $datetime); // $r = $this->spc->UploadPlaylistMethod($this->Base->sessid, $gunid, $datetime);
// if ($this->_isError($r)) { // if ($this->_isError($r)) {
@ -1087,16 +1090,9 @@ class uiScheduler extends uiCalendar {
*/ */
function displayScheduleMethod($from, $to) function displayScheduleMethod($from, $to)
{ {
// NOTE: Need to fix times.
//$_SESSION["debug"] = "FROM: $from, TO: $to<br>";
//$from = substr($from, 0, 4)."-".
$items = Schedule::GetItems($from, $to); $items = Schedule::GetItems($from, $to);
//$_SESSION["debug"] = $items;
return $items; return $items;
// $r = $this->spc->displayScheduleMethod($this->Base->sessid, $from, $to);
// if ($this->_isError($r)) {
// return FALSE;
// }
// return $r;
} // fn displayScheduleMethod } // fn displayScheduleMethod

View File

@ -1112,7 +1112,7 @@ class BasicStor {
$sql .= " ORDER BY ".join(",", $orderBySql); $sql .= " ORDER BY ".join(",", $orderBySql);
} }
$_SESSION["debug"] = $sql; //$_SESSION["debug"] = $sql;
$countRowsSql = "SELECT COUNT(*) " $countRowsSql = "SELECT COUNT(*) "
. " FROM ".$CC_CONFIG["filesTable"] . " FROM ".$CC_CONFIG["filesTable"]

View File

@ -241,7 +241,9 @@ class Schedule {
* "id" (DB id) * "id" (DB id)
* *
* @param $fromDateTime * @param $fromDateTime
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
* @param $toDateTime * @param $toDateTime
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
*/ */
public static function GetItems($fromDateTime, $toDateTime, $playlistsOnly = true) { public static function GetItems($fromDateTime, $toDateTime, $playlistsOnly = true) {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;