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;
} }
@ -354,17 +353,18 @@ class uiScheduler extends uiCalendar {
$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); $startHour = (int)strftime('%H', $start);
$endHour = (int)strftime('%H', $end); $endHour = (int)strftime('%H', $end);
$startTime = substr($val['start'], strpos($val['start'], 'T')+1); $startTime = substr($val['start'], strpos($val['start'], ' ')+1);
$endTime = substr($val['end'], strpos($val['end'], 'T') + 1); $endTime = substr($val['end'], strpos($val['end'], ' ') + 1);
$title = $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE); $track = StoredFile::Recall($val["file_id"]);
$creator = $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR); $trackMetadata = $track->getMetadata();
$title = $trackMetadata["track_title"];
$creator = $trackMetadata["artist_name"];
// Item starts today // Item starts today
if (strftime('%Y%m%d', $start) === $thisDay) { if (strftime('%Y-%m-%d', $start) === $thisDay) {
$endsToday = (strftime('%d', $start) === strftime('%d', $end)) ? TRUE : FALSE; $endsToday = (strftime('%d', $start) === strftime('%d', $end)) ? TRUE : FALSE;
$endsHere = strftime('%H', $start) === strftime('%H', $end) ? TRUE : FALSE; $endsHere = strftime('%H', $start) === strftime('%H', $end) ? TRUE : FALSE;
$items[$startHour]['start'][] = $items[$startHour]['start'][] =
@ -380,7 +380,7 @@ class uiScheduler extends uiCalendar {
} }
// Item ends today // Item ends today
if ( (strftime('%Y%m%d', $end) === $thisDay) && ($startHour !== $endHour) ) { if ( (strftime('%Y-%m-%d', $end) === $thisDay) && ($startHour !== $endHour) ) {
$startsYesterday = (strftime('%d', $start) === strftime('%d', $end)) ? FALSE : TRUE; $startsYesterday = (strftime('%d', $start) === strftime('%d', $end)) ? FALSE : TRUE;
$items[$endHour]['end'][] = $items[$endHour]['end'][] =
@ -400,7 +400,7 @@ class uiScheduler extends uiCalendar {
// $skip becomes true if we dont actually have to do // $skip becomes true if we dont actually have to do
// this section. // this section.
$skip = false; $skip = false;
if (strftime('%Y%m%d', $start) === $thisDay) { if (strftime('%Y-%m-%d', $start) === $thisDay) {
// For the edge case of starting at the end of // For the edge case of starting at the end of
// today. // today.
if ($startHour == 23) { if ($startHour == 23) {
@ -410,7 +410,7 @@ class uiScheduler extends uiCalendar {
} else { } else {
$countStart = 0; $countStart = 0;
} }
if (strftime('%Y%m%d', $end) === $thisDay) { if (strftime('%Y-%m-%d', $end) === $thisDay) {
// For the edge case of ending at the beginning // For the edge case of ending at the beginning
// of today. // of today.
if ($endHour == 0) { if ($endHour == 0) {
@ -434,6 +434,7 @@ class uiScheduler extends uiCalendar {
} }
} }
} }
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;