Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
martin 2011-06-27 16:56:39 -04:00
commit 752293948c
7 changed files with 181 additions and 165 deletions

View file

@ -5,64 +5,71 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
public function init() public function init()
{ {
// Add start date element
//$this->setDisableLoadDefaultDecorators(true); $startDate = new Zend_Form_Element_Text('add_show_start_date');
//$this->removeDecorator('DtDdWrapper'); $startDate->class = 'input_text';
$startDate->setRequired(true)
// Add start date element ->setLabel('Date/Time Start:')
$this->addElement('text', 'add_show_start_date', array( ->setValue(date("Y-m-d"))
'label' => 'Date/Time Start:', ->setFilters(array('StringTrim'))
'class' => 'input_text', ->setValidators(array(
'required' => true, 'NotEmpty',
'value' => date("Y-m-d"), array('date', false, array('YYYY-MM-DD'))))
'filters' => array('StringTrim'), ->setDecorators(array(
'validators' => array( array(array('open'=>'HtmlTag'), array('tag' => 'dd', 'openOnly'=>true)),
'NotEmpty', 'ViewHelper',
array('date', false, array('YYYY-MM-DD')) 'Description',
) array('Label', array('tag' =>'dt'))));
)); $this->addElement($startDate);
// Add start time element // Add start time element
$startTime = $this->addElement('text', 'add_show_start_time', array( $startTime = new Zend_Form_Element_Text('add_show_start_time');
'decorators' => array('ViewHelper', array('HtmlTag', array('tag'=>'dd'))), $startTime->class = 'input_text';
'class' => 'input_text', $startTime->setRequired(true)
'required' => true, ->setValue('00:00')
'value' => '00:00', ->setFilters(array('StringTrim'))
'filters' => array('StringTrim'), ->setValidators(array(
'validators' => array( 'NotEmpty',
'NotEmpty', array('date', false, array('HH:mm')),
array('date', false, array('HH:mm')), array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) ->setDecorators(array(
) 'ViewHelper',
)); 'Errors',
array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true))));
$this->addElement($startTime);
// Add end date element // Add end date element
$this->addElement('text', 'add_show_end_date_no_repeat', array( $endDate = new Zend_Form_Element_Text('add_show_end_date_no_repeat');
'label' => 'Date/Time End:', $endDate->class = 'input_text';
'class' => 'input_text', $endDate->setRequired(true)
'required' => true, ->setLabel('Date/Time End:')
'value' => date("Y-m-d"), ->setValue(date("Y-m-d"))
'filters' => array('StringTrim'), ->setFilters(array('StringTrim'))
'validators' => array( ->setValidators(array(
'NotEmpty', 'NotEmpty',
array('date', false, array('YYYY-MM-DD')) array('date', false, array('YYYY-MM-DD'))))
) ->setDecorators(array(
)); array(array('open'=>'HtmlTag'), array('tag' => 'dd', 'openOnly'=>true)),
'ViewHelper',
'Description',
array('Label', array('tag' =>'dt'))));
$this->addElement($endDate);
// Add end time element // Add end time element
$this->addElement('text', 'add_show_end_time', array( $endTime = new Zend_Form_Element_Text('add_show_end_time');
'decorators' => array('ViewHelper', array('HtmlTag', array('tag'=>'dd'))), $endTime->class = 'input_text';
'class' => 'input_text', $endTime->setRequired(true)
'required' => true, ->setValue('01:00')
'value' => '01:00', ->setFilters(array('StringTrim'))
'filters' => array('StringTrim'), ->setValidators(array(
'validators' => array( 'NotEmpty',
'NotEmpty', array('date', false, array('HH:mm')),
array('date', false, array('HH:mm')), array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered')) ->setDecorators(array(
) 'ViewHelper',
'Errors',
)); array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true))));
$this->addElement($endTime);
// Add duration element // Add duration element
$this->addElement('text', 'add_show_duration', array( $this->addElement('text', 'add_show_duration', array(
@ -93,7 +100,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){ if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){
if($start_epoch < $now_epoch) { if($start_epoch < $now_epoch) {
$this->getElement('add_show_start_date')->setErrors(array('Cannot create show in the past')); $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
$valid = false; $valid = false;
} }
} }
@ -101,8 +108,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
if( $formData["add_show_duration"] == "0m" ) { if( $formData["add_show_duration"] == "0m" ) {
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 0m')); $this->getElement('add_show_duration')->setErrors(array('Cannot have duration 0m'));
$valid = false; $valid = false;
}elseif(strpos($formData["add_show_duration"], 'h') !== false && intval(substr($formData["add_show_duration"], 0, strpos($formData["add_show_duration"], 'h'))) > 23) { }elseif(strpos($formData["add_show_duration"], 'h') !== false && intval(substr($formData["add_show_duration"], 0, strpos($formData["add_show_duration"], 'h'))) > 24) {
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration > 24h')); $this->getElement('add_show_duration')->setErrors(array('Cannot have duration greater than 24h'));
$valid = false; $valid = false;
}elseif( strstr($formData["add_show_duration"], '-') ){ }elseif( strstr($formData["add_show_duration"], '-') ){
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m')); $this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m'));

View file

@ -8,55 +8,28 @@ class Application_Model_Nowplaying
} }
public static function CreateDatatableRows($p_dbRows){ public static function CreateDatatableRows($p_dbRows){
$dataTablesRows = array();
$dataTablesRows = array();
$date = new DateHelper;
$date = new DateHelper; $timeNow = $date->getTimestamp();
$timeNow = $date->getTimestamp();
foreach ($p_dbRows as $dbRow){
$status = ($dbRow['show_ends'] < $dbRow['item_ends']) ? "x" : "";
foreach ($p_dbRows as $dbRow){
$status = ($dbRow['show_ends'] < $dbRow['item_ends']) ? "x" : ""; $type = "a";
$type .= ($dbRow['item_ends'] > $timeNow && $dbRow['item_starts'] <= $timeNow) ? "c" : "";
$type = "a";
$type .= ($dbRow['item_ends'] > $timeNow && $dbRow['item_starts'] <= $timeNow) ? "c" : ""; // remove millisecond from the time format
$itemStart = explode('.', $dbRow['item_starts']);
// remove millisecond from the time format $itemEnd = explode('.', $dbRow['item_ends']);
$itemStart = explode('.', $dbRow['item_starts']);
$itemEnd = explode('.', $dbRow['item_ends']); //format duration
$duration = explode('.', $dbRow['clip_length']);
//format duration $formated = Application_Model_Nowplaying::FormatDuration($duration[0]);
$duration = explode('.', $dbRow['clip_length']); $dataTablesRows[] = array($type, $dbRow['show_starts'], $itemStart[0], $itemEnd[0],
$duration = explode(':', $duration[0]); $formated, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
$dbRow['playlist_name'], $dbRow['show_name'], $status);
if($duration[2] == 0){ }
$duration[2] = '';
}else{
$duration[2] = intval($duration[2],10).'s';
}
if($duration[1] == 0){
if($duration[2] == ''){
$duration[1] = '';
}else{
$duration[1] = intval($duration[1],10).'m';
}
}else{
$duration[1] = intval($duration[1],10).'m';
}
if($duration[0] == 0){
$duration[0] = '';
}else{
$duration[0] = intval($duration[0],10).'h';
}
$duration = $duration[0].$duration[1].$duration[2];
$dataTablesRows[] = array($type, $dbRow['show_starts'], $itemStart[0], $itemEnd[0],
$duration, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
$dbRow['playlist_name'], $dbRow['show_name'], $status);
}
return $dataTablesRows; return $dataTablesRows;
} }
@ -87,42 +60,81 @@ class Application_Model_Nowplaying
$endCutoff = $date->getNowDayEndDiff(); $endCutoff = $date->getNowDayEndDiff();
} }
$data = array(); $data = array();
$showIds = ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff); $showIds = ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff);
foreach ($showIds as $showId){ foreach ($showIds as $showId){
$instanceId = $showId['id']; $instanceId = $showId['id'];
$si = new ShowInstance($instanceId);
$showId = $si->getShowId();
$show = new Show($showId);
//append show header row
$data[] = Application_Model_Nowplaying::CreateHeaderRow($show->getName(), $si->getShowStart(), $si->getShowEnd());
$scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff);
$dataTablesRows = Application_Model_Nowplaying::CreateDatatableRows($scheduledItems);
//append show audio item rows
$data = array_merge($data, $dataTablesRows);
//append show gap time row
$gapTime = Application_Model_Nowplaying::FormatDuration($si->getShowEndGapTime(), true);
if ($si->isRecorded())
$data[] = Application_Model_Nowplaying::CreateRecordingRow($si);
else if ($gapTime > 0)
$data[] = Application_Model_Nowplaying::CreateGapRow($gapTime);
}
$si = new ShowInstance($instanceId); return array("currentShow"=>Show_DAL::GetCurrentShow($timeNow), "rows"=>$data);
}
$showId = $si->getShowId();
$show = new Show($showId); public static function ShouldShowPopUp(){
$today = mktime(0, 0, 0, date("m") , date("d"), date("Y"));
//append show header row $remindDate = Application_Model_Preference::GetRemindMeDate();
$data[] = Application_Model_Nowplaying::CreateHeaderRow($show->getName(), $si->getShowStart(), $si->getShowEnd()); if($remindDate == NULL || $today >= $remindDate){
return true;
$scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff); }
$dataTablesRows = Application_Model_Nowplaying::CreateDatatableRows($scheduledItems); }
/*
//append show audio item rows * default $time format should be in format of 00:00:00
$data = array_merge($data, $dataTablesRows); * if $inSecond = true, then $time should be in seconds
*/
//append show gap time row public static function FormatDuration($time, $inSecond=false){
$gapTime = $si->getShowEndGapTime(); if($inSecond == false){
if ($si->isRecorded()) $duration = explode(':', $time);
$data[] = Application_Model_Nowplaying::CreateRecordingRow($si); }else{
else if ($gapTime > 0) $duration = array();
$data[] = Application_Model_Nowplaying::CreateGapRow($gapTime); $duration[0] = intval(($time/3600)%24);
} $duration[1] = intval(($time/60)%60);
$duration[2] = $time%60;
return array("currentShow"=>Show_DAL::GetCurrentShow($timeNow), "rows"=>$data); }
}
if($duration[2] == 0){
public static function ShouldShowPopUp(){ $duration[2] = '';
$today = mktime(0, 0, 0, date("m") , date("d"), date("Y")); }else{
$remindDate = Application_Model_Preference::GetRemindMeDate(); $duration[2] = intval($duration[2],10).'s';
if($remindDate == NULL || $today >= $remindDate){ }
return true;
} if($duration[1] == 0){
} if($duration[2] == ''){
$duration[1] = '';
}else{
$duration[1] = intval($duration[1],10).'m ';
}
}else{
$duration[1] = intval($duration[1],10).'m ';
}
if($duration[0] == 0){
$duration[0] = '';
}else{
$duration[0] = intval($duration[0],10).'h ';
}
$out = $duration[0].$duration[1].$duration[2];
return $out;
}
} }

View file

@ -30,7 +30,7 @@
<?php endif; ?> <?php endif; ?>
</dd> </dd>
</dl> </dl>
<div class="info-text" style="clear: both;padding: 4px 0 4px 15px;"><p> Note: In order to publicise your station, "Send support feedback" must be enabled</p></div> <div class="info-text" style="clear: both;padding: 4px 0 4px 15px;"><p> Note: In order to promote your station, "Send support feedback" must be enabled</p></div>
<dl id="public-info" style="display:none;"> <dl id="public-info" style="display:none;">
<dt id="Phone-label" class="block-display"> <dt id="Phone-label" class="block-display">
<label class="optional" for="Phone"><?php echo $this->element->getElement('Phone')->getLabel() ?></label> <label class="optional" for="Phone"><?php echo $this->element->getElement('Phone')->getLabel() ?></label>

View file

@ -20,7 +20,7 @@
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<dt class="block-display info-text"> <dt class="block-display info-text">
Click the box below to advertise your station on <a id="link_to_whos_using" href="">Sourcefabric.org</a>. In order to publicise your station, "Send support feedback" must be enabled Click the box below to advertise your station on <a id="link_to_whos_using" href="">Sourcefabric.org</a>. In order to promote your station, "Send support feedback" must be enabled
</dt> </dt>
<dd id="publicize-element" class="block-display"> <dd id="publicize-element" class="block-display">
<label class="optional" for="Publicise"> <label class="optional" for="Publicise">

View file

@ -112,21 +112,17 @@ label.wrapp-label input[type="checkbox"] {
overflow: auto; overflow: auto;
} }
#add_show_start_time { #add_show_start_time, #add_show_end_time {
float: left; width: 60px;
width: 70px; margin-left:10px;
}
#add_show_end_time {
width: 70px;
} }
#add_show_end_date_no_repeat, #add_show_start_date { #add_show_end_date_no_repeat, #add_show_start_date {
width: 100px; width: 95px;
} }
#add_show_duration { #add_show_duration {
background: #AAAAAA; background: #AAAAAA;
cursor: default; cursor: default;
width: 100px; width: 50px;
} }

View file

@ -167,26 +167,17 @@ function createDataGrid(){
nGroup.appendChild(nCell); nGroup.appendChild(nCell);
nTrs[i].parentNode.replaceChild(nGroup, nTrs[i]); nTrs[i].parentNode.replaceChild(nGroup, nTrs[i]);
} else if ( sType.indexOf("g") != -1 ){ } else if ( sType.indexOf("g") != -1 ){
//gap row found //gap row found
var gapTime = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[4]; var gapTime = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[4];
var hours = parseInt( gapTime / 3600 ) % 24;
var minutes = parseInt( gapTime / 60 ) % 60;
var seconds = gapTime % 60;
var gapTimeFormat = (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds);
var nGroup = document.createElement('tr'); var nGroup = document.createElement('tr');
var nCell = document.createElement('td'); var nCell = document.createElement('td');
nCell.colSpan = iColspan; nCell.colSpan = iColspan;
nCell.className = "gap"; nCell.className = "gap";
nCell.innerHTML = "Gap until show end: " + gapTimeFormat; nCell.innerHTML = "Gap until show end: " + gapTime;
nGroup.appendChild(nCell); nGroup.appendChild(nCell);
nTrs[i].parentNode.replaceChild(nGroup, nTrs[i]); nTrs[i].parentNode.replaceChild(nGroup, nTrs[i]);
} else if ( sType.indexOf("r") != -1 ){ } else if ( sType.indexOf("r") != -1 ){
//gap row found //gap row found
var showName = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[4]; var showName = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[4];
var nGroup = document.createElement('tr'); var nGroup = document.createElement('tr');

View file

@ -329,7 +329,17 @@ function setAddShowEvents() {
var endDateTime = new Date(endDate[0], parseInt(endDate[1])-1, endDate[2], endTime[0], endTime[1], 0, 0); var endDateTime = new Date(endDate[0], parseInt(endDate[1])-1, endDate[2], endTime[0], endTime[1], 0, 0);
if(startDateTime.getTime() > endDateTime.getTime()){ if(startDateTime.getTime() > endDateTime.getTime()){
endDateTime = new Date(startDateTime.getTime() + (1*60*60*1000)); var duration = $('#add_show_duration').val();
// parse duration
var time = 0;
var info = duration.split(' ');
var h = parseInt(info[0]);
time += h * 60 * 60* 1000;
if(info.length >1 && $.trim(info[1]) !== ''){
var m = parseInt(info[1]);
time += m * 60 * 1000;
}
endDateTime = new Date(startDateTime.getTime() + time);
} }
var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2); var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2);