Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
28f1d885f2
53 changed files with 625 additions and 294 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class DateHelper
|
||||
class Application_Model_DateHelper
|
||||
{
|
||||
private $_dateTime;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class Application_Model_MusicDir {
|
|||
$temp_show->updateScheduledTime();
|
||||
}
|
||||
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,7 +184,7 @@ class Application_Model_MusicDir {
|
|||
|
||||
$data = array();
|
||||
$data["directory"] = $p_path;
|
||||
RabbitMq::SendMessageToMediaMonitor("new_watch", $data);
|
||||
Application_Model_RabbitMq::SendMessageToMediaMonitor("new_watch", $data);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ class Application_Model_MusicDir {
|
|||
$data = array();
|
||||
$data["directory"] = $p_dir;
|
||||
$data["dir_id"] = $dirId;
|
||||
RabbitMq::SendMessageToMediaMonitor("change_stor", $data);
|
||||
Application_Model_RabbitMq::SendMessageToMediaMonitor("change_stor", $data);
|
||||
return array("code"=>0);
|
||||
}else{
|
||||
return array("code"=>1, "error"=>"'$p_dir' is already set as the current storage dir or in the watched folders list.");
|
||||
|
@ -292,7 +292,7 @@ class Application_Model_MusicDir {
|
|||
$dir->remove();
|
||||
$data = array();
|
||||
$data["directory"] = $p_dir;
|
||||
RabbitMq::SendMessageToMediaMonitor("remove_watch", $data);
|
||||
Application_Model_RabbitMq::SendMessageToMediaMonitor("remove_watch", $data);
|
||||
return array("code"=>0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ class Application_Model_Nowplaying
|
|||
|
||||
foreach ($p_dbRows as $dbRow){
|
||||
|
||||
$showStartDateTime = DateHelper::ConvertToLocalDateTime($dbRow['show_starts']);
|
||||
$showEndDateTime = DateHelper::ConvertToLocalDateTime($dbRow['show_ends']);
|
||||
$itemStartDateTime = DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
|
||||
$itemEndDateTime = DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
|
||||
$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");
|
||||
|
@ -61,7 +61,7 @@ class Application_Model_Nowplaying
|
|||
$startCutoff = 60;
|
||||
$endCutoff = 86400; //60*60*24 - seconds in a day
|
||||
} else {
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$time = $date->getTime();
|
||||
$date->setDate($dateString." ".$time);
|
||||
$timeNow = $date->getUtcTimestamp();
|
||||
|
@ -81,8 +81,8 @@ class Application_Model_Nowplaying
|
|||
$showId = $si->getShowId();
|
||||
$show = new Application_Model_Show($showId);
|
||||
|
||||
$showStartDateTime = DateHelper::ConvertToLocalDateTime($si->getShowStart());
|
||||
$showEndDateTime = DateHelper::ConvertToLocalDateTime($si->getShowEnd());
|
||||
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowStart());
|
||||
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowEnd());
|
||||
|
||||
//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"));
|
||||
|
|
|
@ -81,7 +81,7 @@ class Application_Model_Preference
|
|||
self::SetValue("station_name", $title);
|
||||
$defaultNamespace = new Zend_Session_Namespace('title_name');
|
||||
$defaultNamespace->title = $title;
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
|
||||
//set session variable to new station name so that html title is updated.
|
||||
//should probably do this in a view helper to keep this controller as minimal as possible.
|
||||
|
@ -107,7 +107,7 @@ class Application_Model_Preference
|
|||
|
||||
public static function SetStreamLabelFormat($type){
|
||||
self::SetValue("stream_label_format", $type);
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public static function GetStreamLabelFormat(){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
require_once 'php-amqplib/amqp.inc';
|
||||
|
||||
class RabbitMq
|
||||
class Application_Model_RabbitMq
|
||||
{
|
||||
static public $doPush = FALSE;
|
||||
|
||||
|
@ -9,7 +9,7 @@ class RabbitMq
|
|||
* Sets a flag to push the schedule at the end of the request.
|
||||
*/
|
||||
public static function PushSchedule() {
|
||||
RabbitMq::$doPush = TRUE;
|
||||
Application_Model_RabbitMq::$doPush = TRUE;
|
||||
}
|
||||
|
||||
public static function SendMessageToPypo($event_type, $md)
|
||||
|
|
|
@ -143,7 +143,7 @@ class Application_Model_Schedule {
|
|||
|
||||
global $CC_CONFIG;
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timeNow = $date->getUtcTimestamp();
|
||||
return array("env"=>APPLICATION_ENV,
|
||||
"schedulerTime"=>$timeNow,
|
||||
|
@ -499,8 +499,8 @@ class Application_Model_Schedule {
|
|||
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),
|
||||
'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]),
|
||||
'fade_cross' => 0,
|
||||
'cue_in' => DateHelper::CalculateLengthInSeconds($item["cue_in"]),
|
||||
'cue_out' => DateHelper::CalculateLengthInSeconds($item["cue_out"]),
|
||||
'cue_in' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_in"]),
|
||||
'cue_out' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_out"]),
|
||||
'export_source' => 'scheduler',
|
||||
'start' => $starts,
|
||||
'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["ends"])
|
||||
|
|
|
@ -116,7 +116,7 @@ class Application_Model_ScheduleGroup {
|
|||
}
|
||||
}
|
||||
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
return $this->groupId;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ class Application_Model_ScheduleGroup {
|
|||
." WHERE group_id = ".$this->groupId;
|
||||
//echo $sql;
|
||||
$retVal = $CC_DBC->query($sql);
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class Application_Model_Show {
|
|||
{
|
||||
$show = CcShowQuery::create()->findPK($this->_showId);
|
||||
$show->setDbName($name);
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
|
@ -119,7 +119,7 @@ class Application_Model_Show {
|
|||
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,7 +137,7 @@ class Application_Model_Show {
|
|||
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
||||
$showId = $this->getId();
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$sql = "DELETE FROM cc_show_instances"
|
||||
|
@ -302,7 +302,7 @@ class Application_Model_Show {
|
|||
public function deleteAllInstances(){
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$showId = $this->getId();
|
||||
|
@ -321,7 +321,7 @@ class Application_Model_Show {
|
|||
public function deleteAllRebroadcasts(){
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$showId = $this->getId();
|
||||
|
@ -343,11 +343,11 @@ class Application_Model_Show {
|
|||
public function removeAllInstancesFromDate($p_date=null){
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
if(is_null($p_date)) {
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$p_date = $date->getDate();
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ class Application_Model_Show {
|
|||
public function removeAllInstancesBeforeDate($p_date){
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$showId = $this->getId();
|
||||
|
@ -481,7 +481,7 @@ class Application_Model_Show {
|
|||
* true if the StartDate is in the past, false otherwise
|
||||
*/
|
||||
public function isStartDateTimeInPast(){
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$current_timestamp = $date->getTimestamp();
|
||||
return ($current_timestamp > $this->getStartDate()." ".$this->getStartTime());
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ class Application_Model_Show {
|
|||
public function getAllFutureInstanceIds(){
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$showId = $this->getId();
|
||||
|
@ -517,7 +517,7 @@ class Application_Model_Show {
|
|||
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$sql = "UPDATE cc_show_days "
|
||||
|
@ -538,7 +538,7 @@ class Application_Model_Show {
|
|||
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new DateHelper;
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$sql = "UPDATE cc_show_days "
|
||||
|
@ -871,7 +871,7 @@ class Application_Model_Show {
|
|||
}
|
||||
|
||||
Application_Model_Show::populateShowUntil($showId);
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
return $showId;
|
||||
}
|
||||
|
||||
|
@ -955,7 +955,7 @@ class Application_Model_Show {
|
|||
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
|
||||
$end = $CC_DBC->GetOne($sql);
|
||||
|
||||
$date = new DateHelper();
|
||||
$date = new Application_Model_DateHelper();
|
||||
$currentTimestamp = $date->getTimestamp();
|
||||
|
||||
$show = new Application_Model_Show($show_id);
|
||||
|
@ -1008,7 +1008,7 @@ class Application_Model_Show {
|
|||
}
|
||||
}
|
||||
}
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
//for a show with repeat_type == 0,1,2
|
||||
|
@ -1028,7 +1028,7 @@ class Application_Model_Show {
|
|||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
$show = new Application_Model_Show($show_id);
|
||||
|
||||
$date = new DateHelper();
|
||||
$date = new Application_Model_DateHelper();
|
||||
$currentTimestamp = $date->getTimestamp();
|
||||
|
||||
while(strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
|
||||
|
@ -1091,7 +1091,7 @@ class Application_Model_Show {
|
|||
}
|
||||
|
||||
Application_Model_Show::setNextPop($next_date, $show_id, $day);
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
private static function populateShow($repeatType, $show_id, $next_pop_date,
|
||||
|
|
|
@ -111,14 +111,14 @@ class Application_Model_ShowInstance {
|
|||
{
|
||||
$this->_showInstance->setDbStarts($start)
|
||||
->save();
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public function setShowEnd($end)
|
||||
{
|
||||
$this->_showInstance->setDbEnds($end)
|
||||
->save();
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public function updateScheduledTime()
|
||||
|
@ -153,7 +153,7 @@ class Application_Model_ShowInstance {
|
|||
$CC_DBC->query($sql);
|
||||
}
|
||||
}
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public function moveShow($deltaDay, $deltaMin)
|
||||
|
@ -219,7 +219,7 @@ class Application_Model_ShowInstance {
|
|||
$show->setShowLastShow($new_ends);
|
||||
}
|
||||
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public function resizeShow($deltaDay, $deltaMin)
|
||||
|
@ -263,7 +263,7 @@ class Application_Model_ShowInstance {
|
|||
}
|
||||
|
||||
$this->setShowEnd($new_ends);
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -295,7 +295,7 @@ class Application_Model_ShowInstance {
|
|||
else {
|
||||
$groupId = $sched->addPlaylistAfter($this->_instanceId, $lastGroupId, $plId);
|
||||
}
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
$this->updateScheduledTime();
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ class Application_Model_ShowInstance {
|
|||
else {
|
||||
$groupId = $sched->addFileAfter($this->_instanceId, $lastGroupId, $file_id);
|
||||
}
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
$this->updateScheduledTime();
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ class Application_Model_ShowInstance {
|
|||
WHERE starts >= '{$groupBoundry["end_timestamp"]}' AND instance_id = {$this->_instanceId}";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
$this->updateScheduledTime();
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ class Application_Model_ShowInstance {
|
|||
CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($this->_instanceId)
|
||||
->delete();
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
$this->updateScheduledTime();
|
||||
}
|
||||
|
||||
|
@ -373,9 +373,9 @@ class Application_Model_ShowInstance {
|
|||
CcShowInstancesQuery::create()
|
||||
->findPK($this->_instanceId)
|
||||
->delete();
|
||||
RabbitMq::PushSchedule();
|
||||
Application_Model_RabbitMq::PushSchedule();
|
||||
if($recording){
|
||||
RabbitMq::SendMessageToShowRecorder("cancel_recording");
|
||||
Application_Model_RabbitMq::SendMessageToShowRecorder("cancel_recording");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require_once 'soundcloud-api/Services/Soundcloud.php';
|
||||
|
||||
class ATSoundcloud {
|
||||
class Application_Model_AtSoundcloud {
|
||||
|
||||
private $_soundcloud;
|
||||
|
||||
|
|
|
@ -945,7 +945,7 @@ class Application_Model_StoredFile {
|
|||
$release = $file->getDbYear();
|
||||
|
||||
try {
|
||||
$soundcloud = new ATSoundcloud();
|
||||
$soundcloud = new Application_Model_AtSoundcloud();
|
||||
$soundcloud_id = $soundcloud->uploadTrack($this->getFilePath(), $this->getName(), $description, $tag, $release, $genre);
|
||||
$this->setSoundCloudFileId($soundcloud_id);
|
||||
break;
|
||||
|
|
|
@ -1,7 +1,43 @@
|
|||
<?php
|
||||
class Application_Model_StreamSetting {
|
||||
public function __construct(){
|
||||
|
||||
|
||||
/* Returns the id's of all streams that are enabled in an array. An
|
||||
* example of the array returned in JSON notation is ["s1", "s2", "s3"] */
|
||||
public static function getEnabledStreamIds(){
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * "
|
||||
."FROM cc_stream_setting "
|
||||
."WHERE keyname LIKE '%_output' "
|
||||
."AND value != 'disabled'";
|
||||
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$ids = array();
|
||||
|
||||
foreach ($rows as $row){
|
||||
$ids[] = substr($row["keyname"], 0, strpos($row["keyname"], "_"));
|
||||
}
|
||||
|
||||
//Logging::log(print_r($ids, true));
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/* Returns all information related to a specific stream. An example
|
||||
* of a stream id is 's1' or 's2'. */
|
||||
public static function getStreamData($p_streamId){
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * "
|
||||
."FROM cc_stream_setting "
|
||||
."WHERE keyname LIKE '${p_streamId}_%'";
|
||||
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$data = array();
|
||||
|
||||
foreach($rows as $row){
|
||||
$data[$row["keyname"]] = $row["value"];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getStreamSetting(){
|
||||
|
@ -12,6 +48,7 @@ class Application_Model_StreamSetting {
|
|||
$rows = $CC_DBC->getAll($sql);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function setStreamSetting($data){
|
||||
global $CC_DBC;
|
||||
foreach($data as $key=>$d){
|
||||
|
@ -37,4 +74,4 @@ class Application_Model_StreamSetting {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,9 +97,9 @@ while ($showTime < $endDate) {
|
|||
$showNumber = $showNumber + 1;
|
||||
}
|
||||
|
||||
if (RabbitMq::$doPush) {
|
||||
if (Application_Model_RabbitMq::$doPush) {
|
||||
$md = array('schedule' => Application_Model_Schedule::GetScheduledPlaylists());
|
||||
RabbitMq::SendMessageToPypo("update_schedule", $md);
|
||||
Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue