Merge branch '2.0.x' of dev.sourcefabric.org:airtime into 2.0.x
This commit is contained in:
commit
b1a281be4e
3026 changed files with 193 additions and 781738 deletions
|
@ -17,9 +17,7 @@ $CC_CONFIG = array(
|
|||
'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A',
|
||||
'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs',
|
||||
|
||||
"rootDir" => __DIR__."/../..",
|
||||
'pearPath' => dirname(__FILE__).'/../../library/pear',
|
||||
'zendPath' => dirname(__FILE__).'/../../library/Zend'
|
||||
"rootDir" => __DIR__."/../.."
|
||||
);
|
||||
|
||||
|
||||
|
@ -50,12 +48,6 @@ $CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id';
|
|||
$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id';
|
||||
$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id';
|
||||
|
||||
// Add libs to the PHP path
|
||||
$old_include_path = get_include_path();
|
||||
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath']
|
||||
.PATH_SEPARATOR.$CC_CONFIG['zendPath']
|
||||
.PATH_SEPARATOR.$old_include_path);
|
||||
|
||||
class Config {
|
||||
public static function loadConfig($p_path) {
|
||||
global $CC_CONFIG;
|
||||
|
|
|
@ -35,7 +35,7 @@ class Application_Form_EditAudioMD extends Zend_Form
|
|||
|
||||
// Add artist field
|
||||
$this->addElement('text', 'artist_name', array(
|
||||
'label' => 'Artist:',
|
||||
'label' => 'Creator:',
|
||||
'class' => 'input_text',
|
||||
'filters' => array('StringTrim'),
|
||||
));
|
||||
|
|
|
@ -9,47 +9,47 @@ class Application_Model_Nowplaying
|
|||
|
||||
private static function CreateDatatableRows($p_dbRows){
|
||||
$dataTablesRows = array();
|
||||
|
||||
|
||||
$epochNow = time();
|
||||
|
||||
|
||||
foreach ($p_dbRows as $dbRow){
|
||||
|
||||
|
||||
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_starts']);
|
||||
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_ends']);
|
||||
$itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
|
||||
$itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
|
||||
|
||||
|
||||
$showStarts = $showStartDateTime->format("Y-m-d H:i:s");
|
||||
$showEnds = $showEndDateTime->format("Y-m-d H:i:s");
|
||||
$itemStarts = $itemStartDateTime->format("Y-m-d H:i:s");
|
||||
$itemEnds = $itemEndDateTime->format("Y-m-d H:i:s");
|
||||
|
||||
|
||||
$status = ($dbRow['show_ends'] < $dbRow['item_ends']) ? "x" : "";
|
||||
|
||||
|
||||
$type = "a";
|
||||
$type .= ($itemStartDateTime->getTimestamp() <= $epochNow
|
||||
$type .= ($itemStartDateTime->getTimestamp() <= $epochNow
|
||||
&& $epochNow < $itemEndDateTime->getTimestamp()
|
||||
&& $epochNow < $showEndDateTime->getTimestamp()) ? "c" : "";
|
||||
|
||||
|
||||
// remove millisecond from the time format
|
||||
$itemStart = explode('.', $dbRow['item_starts']);
|
||||
$itemEnd = explode('.', $dbRow['item_ends']);
|
||||
|
||||
|
||||
//format duration
|
||||
$duration = explode('.', $dbRow['clip_length']);
|
||||
$formatted = self::FormatDuration($duration[0]);
|
||||
$dataTablesRows[] = array($type, $showStarts, $itemStarts, $itemEnds,
|
||||
$dataTablesRows[] = array($type, $itemStarts, $itemStarts, $itemEnds,
|
||||
$formatted, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
|
||||
$dbRow['playlist_name'], $dbRow['show_name'], $status);
|
||||
}
|
||||
|
||||
return $dataTablesRows;
|
||||
}
|
||||
|
||||
|
||||
private static function CreateGapRow($p_gapTime){
|
||||
return array("g", "", "", "", $p_gapTime, "", "", "", "", "", "");
|
||||
}
|
||||
|
||||
|
||||
private static function CreateRecordingRow($p_showInstance){
|
||||
return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", "");
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class Application_Model_Nowplaying
|
|||
if ($viewType == "now"){
|
||||
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
|
||||
$timeNow = $dateTime->format("Y-m-d H:i:s");
|
||||
|
||||
|
||||
$startCutoff = 60;
|
||||
$endCutoff = 86400; //60*60*24 - seconds in a day
|
||||
} else {
|
||||
|
@ -71,30 +71,30 @@ class Application_Model_Nowplaying
|
|||
$startCutoff = $date->getNowDayStartDiff();
|
||||
$endCutoff = $date->getNowDayEndDiff();
|
||||
}
|
||||
|
||||
|
||||
$data = array();
|
||||
|
||||
$showIds = Application_Model_ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff);
|
||||
foreach ($showIds as $showId){
|
||||
$instanceId = $showId['id'];
|
||||
|
||||
|
||||
$si = new Application_Model_ShowInstance($instanceId);
|
||||
|
||||
|
||||
$showId = $si->getShowId();
|
||||
$show = new Application_Model_Show($showId);
|
||||
|
||||
|
||||
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceStart());
|
||||
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceEnd());
|
||||
|
||||
|
||||
//append show header row
|
||||
$data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s"));
|
||||
|
||||
|
||||
$scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff);
|
||||
$dataTablesRows = self::CreateDatatableRows($scheduledItems);
|
||||
|
||||
|
||||
//append show audio item rows
|
||||
$data = array_merge($data, $dataTablesRows);
|
||||
|
||||
|
||||
//append show gap time row
|
||||
$gapTime = self::FormatDuration($si->getShowEndGapTime(), true);
|
||||
if ($si->isRecorded())
|
||||
|
@ -117,7 +117,7 @@ class Application_Model_Nowplaying
|
|||
}
|
||||
/*
|
||||
* default $time format should be in format of 00:00:00
|
||||
* if $inSecond = true, then $time should be in seconds
|
||||
* if $inSecond = true, then $time should be in seconds
|
||||
*/
|
||||
private static function FormatDuration($time, $inSecond=false){
|
||||
if($inSecond == false){
|
||||
|
@ -128,13 +128,13 @@ class Application_Model_Nowplaying
|
|||
$duration[1] = intval(($time/60)%60);
|
||||
$duration[2] = $time%60;
|
||||
}
|
||||
|
||||
|
||||
if($duration[2] == 0){
|
||||
$duration[2] = '';
|
||||
}else{
|
||||
$duration[2] = intval($duration[2],10).'s';
|
||||
}
|
||||
|
||||
|
||||
if($duration[1] == 0){
|
||||
if($duration[2] == ''){
|
||||
$duration[1] = '';
|
||||
|
@ -144,13 +144,13 @@ class Application_Model_Nowplaying
|
|||
}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;
|
||||
}
|
||||
|
|
|
@ -58,21 +58,19 @@ class Application_Model_ShowInstance {
|
|||
/**
|
||||
* Return the start time of the Show (UTC time)
|
||||
* @return string in format "Y-m-d H:i:s" (PHP time notation)
|
||||
* TODO: make this function return a DateTime object instead.
|
||||
*/
|
||||
public function getShowInstanceStart()
|
||||
public function getShowInstanceStart($format="Y-m-d H:i:s")
|
||||
{
|
||||
return $this->_showInstance->getDbStarts();
|
||||
return $this->_showInstance->getDbStarts($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the end time of the Show (UTC time)
|
||||
* @return string in format "Y-m-d H:i:s" (PHP time notation)
|
||||
* TODO: make this function return a DateTime object instead.
|
||||
*/
|
||||
public function getShowInstanceEnd()
|
||||
public function getShowInstanceEnd($format="Y-m-d H:i:s")
|
||||
{
|
||||
return $this->_showInstance->getDbEnds();
|
||||
return $this->_showInstance->getDbEnds($format);
|
||||
}
|
||||
|
||||
public function getStartDate()
|
||||
|
@ -607,20 +605,26 @@ class Application_Model_ShowInstance {
|
|||
return $time;
|
||||
}
|
||||
|
||||
|
||||
public function getTimeScheduledSecs()
|
||||
{
|
||||
$time_filled = $this->getTimeScheduled();
|
||||
return Application_Model_Schedule::WallTimeToMillisecs($time_filled) / 1000;
|
||||
}
|
||||
|
||||
public function getDurationSecs()
|
||||
{
|
||||
$ends = $this->getShowInstanceEnd(null);
|
||||
$starts = $this->getShowInstanceStart(null);
|
||||
return $ends->format('U') - $starts->format('U');
|
||||
}
|
||||
|
||||
public function getPercentScheduled()
|
||||
{
|
||||
$start_timestamp = $this->getShowInstanceStart();
|
||||
$end_timestamp = $this->getShowInstanceEnd();
|
||||
$time_filled = $this->getTimeScheduled();
|
||||
$durationSeconds = $this->getDurationSecs();
|
||||
$timeSeconds = $this->getTimeScheduledSecs();
|
||||
|
||||
$s_epoch = strtotime($start_timestamp);
|
||||
$e_epoch = strtotime($end_timestamp);
|
||||
$i_epoch = Application_Model_Schedule::WallTimeToMillisecs($time_filled) / 1000;
|
||||
|
||||
$percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100);
|
||||
|
||||
if ($percent > 100)
|
||||
$percent = 100;
|
||||
$percent = ceil(($timeSeconds / $durationSeconds) * 100);
|
||||
|
||||
return $percent;
|
||||
}
|
||||
|
|
|
@ -36,4 +36,67 @@ class CcShowInstances extends BaseCcShowInstances {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [starts] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the raw DateTime object will be returned.
|
||||
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getDbStarts($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
if ($this->starts === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$dt = new DateTime($this->starts, new DateTimeZone("UTC"));
|
||||
} catch (Exception $x) {
|
||||
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->starts, true), $x);
|
||||
}
|
||||
|
||||
if ($format === null) {
|
||||
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||
return $dt;
|
||||
} elseif (strpos($format, '%') !== false) {
|
||||
return strftime($format, $dt->format('U'));
|
||||
} else {
|
||||
return $dt->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [ends] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the raw DateTime object will be returned.
|
||||
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getDbEnds($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
if ($this->ends === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$dt = new DateTime($this->ends, new DateTimeZone("UTC"));
|
||||
} catch (Exception $x) {
|
||||
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ends, true), $x);
|
||||
}
|
||||
|
||||
if ($format === null) {
|
||||
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||
return $dt;
|
||||
} elseif (strpos($format, '%') !== false) {
|
||||
return strftime($format, $dt->format('U'));
|
||||
} else {
|
||||
return $dt->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // CcShowInstances
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
$path = dirname(__FILE__).'/../../../library/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
$WHITE_SCREEN_OF_DEATH = false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue