Merge branch 'master' of dev.sourcefabric.org:campcaster
This commit is contained in:
commit
e902d3b3d4
|
@ -397,8 +397,8 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new User($userInfo->id);
|
||||
if($user->isAdmin()) {
|
||||
Show::addShow($data);
|
||||
if ($user->isAdmin()) {
|
||||
Show::create($data);
|
||||
}
|
||||
|
||||
//send back a new form for the user.
|
||||
|
|
|
@ -102,27 +102,9 @@ class Playlist {
|
|||
return $res;
|
||||
}
|
||||
|
||||
public static function Insert($p_values)
|
||||
|
||||
public static function Delete($id)
|
||||
{
|
||||
// Create the StoredPlaylist object
|
||||
$storedPlaylist = new Playlist();
|
||||
$storedPlaylist->name = isset($p_values['filename']) ? $p_values['filename'] : date("H:i:s");
|
||||
$storedPlaylist->mtime = new DateTime("now");
|
||||
|
||||
$pl = new CcPlaylist();
|
||||
$pl->setDbName($storedPlaylist->name);
|
||||
$pl->setDbState("incomplete");
|
||||
$pl->setDbMtime($storedPlaylist->mtime);
|
||||
$pl->save();
|
||||
|
||||
$storedPlaylist->id = $pl->getDbId();
|
||||
$storedPlaylist->setState('ready');
|
||||
|
||||
return $storedPlaylist->id;
|
||||
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
if($pl === NULL)
|
||||
return FALSE;
|
||||
|
@ -207,7 +189,7 @@ class Playlist {
|
|||
return $this->name;
|
||||
}
|
||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
if($pl === NULL)
|
||||
if ($pl === NULL)
|
||||
return FALSE;
|
||||
|
||||
return $pl->getDbName();
|
||||
|
@ -395,18 +377,27 @@ class Playlist {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create instance of Playlist object and insert empty file
|
||||
* Create instance of a Playlist object.
|
||||
*
|
||||
* @param string $fname
|
||||
* name of new file
|
||||
* @return instance of Playlist object
|
||||
* @param string $p_fname
|
||||
* Name of the playlist
|
||||
* @return Playlist
|
||||
*/
|
||||
public function create($fname=NULL)
|
||||
public function create($p_fname=NULL)
|
||||
{
|
||||
$values = array("filename" => $fname);
|
||||
$pl_id = Playlist::Insert($values);
|
||||
$this->id = $pl_id;
|
||||
return $this->id;
|
||||
$this->name = !empty($p_fname) ? $p_fname : date("H:i:s");
|
||||
$this->mtime = new DateTime("now");
|
||||
|
||||
$pl = new CcPlaylist();
|
||||
$pl->setDbName($this->name);
|
||||
$pl->setDbState("incomplete");
|
||||
$pl->setDbMtime($this->mtime);
|
||||
$pl->save();
|
||||
|
||||
$this->id = $pl->getDbId();
|
||||
$this->setState('ready');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,8 @@ class ScheduleGroup {
|
|||
/**
|
||||
* Add a music clip or playlist to the schedule.
|
||||
*
|
||||
* @param int $p_showInstance
|
||||
* ID of the show.
|
||||
* @param $p_datetime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
|
||||
* @param $p_audioFileId
|
||||
|
@ -40,7 +42,7 @@ class ScheduleGroup {
|
|||
* Return PEAR_Error if the item could not be added.
|
||||
* Error code 555 is a scheduling conflict.
|
||||
*/
|
||||
public function add($show_instance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
|
||||
public function add($p_showInstance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
if (!is_null($p_audioFileId)) {
|
||||
|
@ -64,7 +66,7 @@ class ScheduleGroup {
|
|||
|
||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||
." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)"
|
||||
." VALUES ($show_instance, TIMESTAMP '$p_datetime', "
|
||||
." VALUES ($p_showInstance, TIMESTAMP '$p_datetime', "
|
||||
." (TIMESTAMP '$p_datetime' + INTERVAL '$length'),"
|
||||
." '$length',"
|
||||
." {$this->groupId}, $p_audioFileId, '$length')";
|
||||
|
@ -103,7 +105,7 @@ class ScheduleGroup {
|
|||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||
." (instance_id, playlist_id, starts, ends, group_id, file_id,"
|
||||
." clip_length, cue_in, cue_out, fade_in, fade_out)"
|
||||
." VALUES ($show_instance, $p_playlistId, TIMESTAMP '$itemStartTime', "
|
||||
." VALUES ($p_showInstance, $p_playlistId, TIMESTAMP '$itemStartTime', "
|
||||
." (TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'),"
|
||||
." '{$this->groupId}', '{$row['file_id']}', '$trackLength', '{$row['cuein']}',"
|
||||
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
|
||||
|
|
|
@ -58,11 +58,16 @@ class Show {
|
|||
$show->setDbBackgroundColor($backgroundColor);
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->_showId;
|
||||
}
|
||||
|
||||
public function getHosts()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$sql = "SELECT first_name, last_name
|
||||
$sql = "SELECT first_name, last_name
|
||||
FROM cc_show_hosts LEFT JOIN cc_subjs ON cc_show_hosts.subjs_id = cc_subjs.id
|
||||
WHERE show_id = {$this->_showId}";
|
||||
|
||||
|
@ -70,7 +75,7 @@ class Show {
|
|||
|
||||
$res = array();
|
||||
foreach($hosts as $host) {
|
||||
$res[] = $host['first_name']." ".$host['last_name'];
|
||||
$res[] = $host['first_name']." ".$host['last_name'];
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
@ -93,8 +98,17 @@ class Show {
|
|||
RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
//end dates are non inclusive.
|
||||
public static function addShow($data)
|
||||
|
||||
/**
|
||||
* Create a show.
|
||||
*
|
||||
* Note: end dates are non inclusive.
|
||||
*
|
||||
* @param array $data
|
||||
* @return int
|
||||
* Show ID
|
||||
*/
|
||||
public static function create($data)
|
||||
{
|
||||
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
|
||||
|
||||
|
@ -106,11 +120,11 @@ class Show {
|
|||
$r = $con->query($sql);
|
||||
$startDow = $r->fetchColumn(0);
|
||||
|
||||
if($data['add_show_no_end']) {
|
||||
if ($data['add_show_no_end']) {
|
||||
$endDate = NULL;
|
||||
$data['add_show_repeats'] = 1;
|
||||
}
|
||||
else if($data['add_show_repeats']) {
|
||||
else if ($data['add_show_repeats']) {
|
||||
$sql = "SELECT date '{$data['add_show_end_date']}' + INTERVAL '1 day' ";
|
||||
$r = $con->query($sql);
|
||||
$endDate = $r->fetchColumn(0);
|
||||
|
@ -122,15 +136,15 @@ class Show {
|
|||
}
|
||||
|
||||
//only want the day of the week from the start date.
|
||||
if(!$data['add_show_repeats']) {
|
||||
if (!$data['add_show_repeats']) {
|
||||
$data['add_show_day_check'] = array($startDow);
|
||||
}
|
||||
else if($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
||||
else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
||||
$data['add_show_day_check'] = array($startDow);
|
||||
}
|
||||
|
||||
//find repeat type or set to a non repeating show.
|
||||
if($data['add_show_repeats']) {
|
||||
if ($data['add_show_repeats']) {
|
||||
$repeat_type = $data["add_show_repeat_type"];
|
||||
}
|
||||
else {
|
||||
|
@ -147,7 +161,7 @@ class Show {
|
|||
|
||||
$showId = $show->getDbId();
|
||||
|
||||
if($data['add_show_record']){
|
||||
if ($data['add_show_record']){
|
||||
$isRecorded = 1;
|
||||
}
|
||||
else {
|
||||
|
@ -155,7 +169,7 @@ class Show {
|
|||
}
|
||||
|
||||
//don't set day for monthly repeat type, it's invalid.
|
||||
if($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
|
||||
if ($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($data['add_show_start_date']);
|
||||
$showDay->setDbLastShow($endDate);
|
||||
|
@ -168,7 +182,7 @@ class Show {
|
|||
}
|
||||
else {
|
||||
foreach ($data['add_show_day_check'] as $day) {
|
||||
if($startDow !== $day){
|
||||
if ($startDow !== $day){
|
||||
|
||||
if ($startDow > $day)
|
||||
$daysAdd = 6 - $startDow + 1 + $day;
|
||||
|
@ -183,7 +197,7 @@ class Show {
|
|||
$start = $data['add_show_start_date'];
|
||||
}
|
||||
|
||||
if(strtotime($start) < strtotime($endDate) || is_null($endDate)) {
|
||||
if (strtotime($start) < strtotime($endDate) || is_null($endDate)) {
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($start);
|
||||
$showDay->setDbLastShow($endDate);
|
||||
|
@ -199,11 +213,11 @@ class Show {
|
|||
}
|
||||
|
||||
//adding rows to cc_show_rebroadcast
|
||||
if($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type != -1) {
|
||||
if ($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type != -1) {
|
||||
|
||||
for($i=1; $i<=5; $i++) {
|
||||
for ($i=1; $i<=5; $i++) {
|
||||
|
||||
if($data['add_show_rebroadcast_date_'.$i]) {
|
||||
if ($data['add_show_rebroadcast_date_'.$i]) {
|
||||
$showRebroad = new CcShowRebroadcast();
|
||||
$showRebroad->setDbDayOffset($data['add_show_rebroadcast_date_'.$i]);
|
||||
$showRebroad->setDbStartTime($data['add_show_rebroadcast_time_'.$i]);
|
||||
|
@ -212,11 +226,11 @@ class Show {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type == -1){
|
||||
else if ($data['add_show_record'] && $data['add_show_rebroadcast'] && $repeat_type == -1){
|
||||
|
||||
for($i=1; $i<=5; $i++) {
|
||||
for ($i=1; $i<=5; $i++) {
|
||||
|
||||
if($data['add_show_rebroadcast_absolute_date_'.$i]) {
|
||||
if ($data['add_show_rebroadcast_absolute_date_'.$i]) {
|
||||
$sql = "SELECT date '{$data['add_show_rebroadcast_absolute_date_'.$i]}' - date '{$data['add_show_start_date']}' ";
|
||||
$r = $con->query($sql);
|
||||
$offset_days = $r->fetchColumn(0);
|
||||
|
@ -230,7 +244,7 @@ class Show {
|
|||
}
|
||||
}
|
||||
|
||||
if(is_array($data['add_show_hosts'])) {
|
||||
if (is_array($data['add_show_hosts'])) {
|
||||
//add selected hosts to cc_show_hosts table.
|
||||
foreach ($data['add_show_hosts'] as $host) {
|
||||
$showHost = new CcShowHosts();
|
||||
|
@ -240,10 +254,19 @@ class Show {
|
|||
}
|
||||
}
|
||||
|
||||
Show::populateShowUntilLastGeneratedDate($showId);
|
||||
Show::populateShowUntil($showId);
|
||||
RabbitMq::PushSchedule();
|
||||
return $showId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $start_timestamp
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
* @param string $end_timestamp
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
* @param unknown_type $excludeInstance
|
||||
* @param boolean $onlyRecord
|
||||
*/
|
||||
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE)
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
@ -301,7 +324,7 @@ class Show {
|
|||
|
||||
$next_date = $first_show." ".$start_time;
|
||||
|
||||
if(strtotime($next_date) < strtotime($end_timestamp)) {
|
||||
if (strtotime($next_date) < strtotime($end_timestamp)) {
|
||||
|
||||
$start = $next_date;
|
||||
|
||||
|
@ -345,7 +368,8 @@ class Show {
|
|||
|
||||
//for a show with repeat_type == 0,1,2
|
||||
private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show,
|
||||
$start_time, $duration, $day, $record, $end_timestamp, $interval) {
|
||||
$start_time, $duration, $day, $record, $end_timestamp, $interval)
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
if(isset($next_pop_date)) {
|
||||
|
@ -422,53 +446,81 @@ class Show {
|
|||
}
|
||||
}
|
||||
|
||||
//used to catch up a newly added show
|
||||
private static function populateShowUntilLastGeneratedDate($show_id) {
|
||||
global $CC_DBC;
|
||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$show_id}";
|
||||
/**
|
||||
* Generate repeating show instances for a single show up to the given date.
|
||||
* If no date is given, use the one in the user's preferences, which is stored
|
||||
* automatically by FullCalendar as the furthest date in the future the user
|
||||
* has looked at.
|
||||
*
|
||||
* @param int $p_showId
|
||||
* @param string $p_date
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
*/
|
||||
public static function populateShowUntil($p_showId, $p_date = NULL)
|
||||
{
|
||||
global $CC_DBC;
|
||||
if (is_null($p_date)) {
|
||||
$p_date = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = {$p_showId}";
|
||||
$res = $CC_DBC->GetAll($sql);
|
||||
|
||||
foreach($res as $row) {
|
||||
foreach ($res as $row) {
|
||||
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
|
||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $showsPopUntil);
|
||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_date);
|
||||
}
|
||||
}
|
||||
|
||||
public static function populateShowsUntil($pop_timestamp, $end_timestamp) {
|
||||
/**
|
||||
* Generate all the repeating shows in the given range.
|
||||
*
|
||||
* @param string $p_startTimestamp
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
* @param string $p_endTimestamp
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
*/
|
||||
public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp)
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
if($pop_timestamp != "") {
|
||||
if ($pop_timestamp != "") {
|
||||
$sql = "SELECT * FROM cc_show_days
|
||||
WHERE last_show IS NULL
|
||||
OR first_show < '{$end_timestamp}' AND last_show > '{$pop_timestamp}'";
|
||||
WHERE last_show IS NULL
|
||||
OR first_show < '{$p_endTimestamp}' AND last_show > '{$p_startTimestamp}'";
|
||||
}
|
||||
else {
|
||||
$today_timestamp = date("Y-m-d");
|
||||
|
||||
$sql = "SELECT * FROM cc_show_days
|
||||
WHERE last_show IS NULL
|
||||
OR first_show < '{$end_timestamp}' AND last_show > '{$today_timestamp}'";
|
||||
WHERE last_show IS NULL
|
||||
OR first_show < '{$p_endTimestamp}' AND last_show > '{$today_timestamp}'";
|
||||
}
|
||||
|
||||
$res = $CC_DBC->GetAll($sql);
|
||||
|
||||
foreach($res as $row) {
|
||||
foreach ($res as $row) {
|
||||
Show::populateShow($row["repeat_type"], $row["show_id"], $row["next_pop_date"], $row["first_show"],
|
||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $end_timestamp);
|
||||
$row["last_show"], $row["start_time"], $row["duration"], $row["day"], $row["record"], $p_endTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFullCalendarEvents($start, $end, $editable=false) {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $start
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
* @param string $end
|
||||
* In the format "YYYY-MM-DD HH:mm:ss"
|
||||
* @param boolean $editable
|
||||
*/
|
||||
public static function getFullCalendarEvents($start, $end, $editable=false)
|
||||
{
|
||||
$events = array();
|
||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
||||
//if fullcalendar is requesting shows past our previous populated until date, generate shows up until this point.
|
||||
if($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) {
|
||||
|
||||
Show::populateShowsUntil($showsPopUntil, $end);
|
||||
if ($showsPopUntil == "" || strtotime($showsPopUntil) < strtotime($end)) {
|
||||
Show::populateAllShowsInRange($showsPopUntil, $end);
|
||||
Application_Model_Preference::SetShowsPopulatedUntil($end);
|
||||
}
|
||||
|
||||
|
@ -476,7 +528,7 @@ class Show {
|
|||
|
||||
$today_timestamp = date("Y-m-d H:i:s");
|
||||
foreach ($shows as $show) {
|
||||
if($editable && strtotime($today_timestamp) < strtotime($show["starts"]))
|
||||
if ($editable && strtotime($today_timestamp) < strtotime($show["starts"]))
|
||||
$events[] = Show::makeFullCalendarEvent($show, array("editable" => true));
|
||||
else
|
||||
$events[] = Show::makeFullCalendarEvent($show);
|
||||
|
@ -696,6 +748,10 @@ class ShowInstance {
|
|||
RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the group ID for this show.
|
||||
*
|
||||
*/
|
||||
private function getLastGroupId()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
@ -704,13 +760,18 @@ class ShowInstance {
|
|||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a playlist as the last item of the current show.
|
||||
*
|
||||
* @param int $plId
|
||||
* Playlist ID.
|
||||
*/
|
||||
public function addPlaylistToShow($plId)
|
||||
{
|
||||
$sched = new ScheduleGroup();
|
||||
$lastGroupId = $this->getLastGroupId();
|
||||
|
||||
if(is_null($lastGroupId)) {
|
||||
|
||||
if (is_null($lastGroupId)) {
|
||||
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), null, $plId);
|
||||
}
|
||||
else {
|
||||
|
@ -719,14 +780,18 @@ class ShowInstance {
|
|||
RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public function addFileToShow($file_id)
|
||||
/**
|
||||
* Add a media file as the last item in the show.
|
||||
*
|
||||
* @param int $file_id
|
||||
*/
|
||||
public function addFileToShow($file_id)
|
||||
{
|
||||
$sched = new ScheduleGroup();
|
||||
$lastGroupId = $this->getLastGroupId();
|
||||
|
||||
if(is_null($lastGroupId)) {
|
||||
|
||||
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id);
|
||||
if (is_null($lastGroupId)) {
|
||||
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id);
|
||||
}
|
||||
else {
|
||||
$groupId = $sched->addFileAfter($this->_instanceId, $lastGroupId, $file_id);
|
||||
|
@ -734,12 +799,18 @@ class ShowInstance {
|
|||
RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public function scheduleShow($plIds) {
|
||||
|
||||
foreach($plIds as $plId) {
|
||||
$this->addPlaylistToShow($plId);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add the given playlists to the show.
|
||||
*
|
||||
* @param array $plIds
|
||||
* An array of playlist IDs.
|
||||
*/
|
||||
public function scheduleShow($plIds)
|
||||
{
|
||||
foreach ($plIds as $plId) {
|
||||
$this->addPlaylistToShow($plId);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeGroupFromShow($group_id)
|
||||
{
|
||||
|
@ -974,7 +1045,7 @@ class Show_DAL {
|
|||
//Result: 5
|
||||
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT"
|
||||
$sql = "SELECT"
|
||||
." si.starts as show_starts,"
|
||||
." si.ends as show_ends,"
|
||||
." s.name as show_name,"
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
set_include_path(__DIR__.'/..' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../library' . PATH_SEPARATOR . get_include_path());
|
||||
require_once __DIR__.'/../Shows.php';
|
||||
require_once __DIR__.'/../StoredFile.php';
|
||||
require_once __DIR__.'/../Playlist.php';
|
||||
require_once __DIR__.'/../Schedule.php';
|
||||
require_once __DIR__.'/../Preference.php';
|
||||
require_once __DIR__.'/../RabbitMq.php';
|
||||
require_once __DIR__.'/../../configs/conf.php';
|
||||
require_once __DIR__.'/../../../install/include/AirtimeIni.php';
|
||||
require_once __DIR__.'/../../../install/include/AirtimeInstall.php';
|
||||
require_once __DIR__.'/../../../library/propel/runtime/lib/Propel.php';
|
||||
|
||||
Propel::init(__DIR__.'/../../configs/airtime-conf.php');
|
||||
|
||||
|
||||
AirtimeInstall::DbConnect(true);
|
||||
|
||||
// Create a playlist
|
||||
$playlist = new Playlist();
|
||||
$playlist->create("Calendar Load test playlist ".uniqid());
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => __DIR__."/test10001.mp3");
|
||||
$storedFile = StoredFile::Insert($values, false);
|
||||
$result = $playlist->addAudioClip($storedFile->getId());
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => __DIR__."/test10002.mp3");
|
||||
$storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
$result = $playlist->addAudioClip($storedFile2->getId());
|
||||
$result = $playlist->addAudioClip($storedFile2->getId());
|
||||
|
||||
echo "Created playlist ".$playlist->getName()." with ID ".$playlist->getId()."\n";
|
||||
|
||||
// Create the shows
|
||||
|
||||
$data = array();
|
||||
|
||||
$currentDate = date("Y\\-m\\-d");
|
||||
|
||||
$year = date("Y");
|
||||
$month = date("m");
|
||||
$day = date("d");
|
||||
|
||||
$nextDay = $currentDate;
|
||||
|
||||
#echo $currentDate;
|
||||
$currentHour = date("H");
|
||||
$setHour = $currentHour + 1;
|
||||
|
||||
$showNumber = 1;
|
||||
for ($days=1; $days<100; $days=$days+1)
|
||||
{
|
||||
// Adding shows until the end of the day
|
||||
while ($setHour < 24)
|
||||
{
|
||||
echo 'Adding show: '.$nextDay. ' '.$setHour.":00\n";
|
||||
$data['add_show_name'] = 'automated show '.$showNumber;
|
||||
$data['add_show_start_date'] = $nextDay;
|
||||
$data['add_show_start_time'] = $setHour.':00';
|
||||
$showNumber = $showNumber + 1;
|
||||
$data['add_show_duration'] = '1:00';
|
||||
$data['add_show_no_end'] = 0;
|
||||
$data['add_show_repeats'] = 0;
|
||||
$data['add_show_description'] = 'automated show';
|
||||
$data['add_show_url'] = 'http://www.OfirGal.com';
|
||||
$data['add_show_color'] = "";
|
||||
$data['add_show_background_color'] = "";
|
||||
$data['add_show_record'] = 0;
|
||||
$data['add_show_hosts'] ="";
|
||||
$showId = Show::create($data);
|
||||
Show::populateShowUntil($showId, "2012-01-01 00:00:00");
|
||||
|
||||
// populating the show with a playlist
|
||||
$show = new ShowInstance($showId);
|
||||
$show->scheduleShow(array($playlist->getId()));
|
||||
|
||||
$setHour = $setHour + 1;
|
||||
}
|
||||
// set the next day
|
||||
$setHour = 0;
|
||||
if ($day<30) {
|
||||
$day = $day + 1;
|
||||
} else {
|
||||
$day = 1;
|
||||
if ($month<12)
|
||||
{
|
||||
$month = $month + 1;
|
||||
} else {
|
||||
$month = 1;
|
||||
$year = $year + 1;
|
||||
}
|
||||
}
|
||||
$nextDay = $year."-".$month."-".$day;
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
var defaults = {
|
||||
updatePeriod: 20, //seconds
|
||||
sourceDomain: "http://localhost/", //where to get show status from
|
||||
text: {onAirToday:"On air today"}
|
||||
};
|
||||
var options = $.extend(defaults, options);
|
||||
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
||||
|
@ -30,7 +31,7 @@
|
|||
}
|
||||
|
||||
tableString = "";
|
||||
tableString += "<h3>On air today</h3>";
|
||||
tableString += "<h3>"+options.text.onAirToday+"</h3>";
|
||||
tableString += "<table width='100%' border='0' cellspacing='0' cellpadding='0' class='widget widget no-playing-list small'>"+
|
||||
"<tbody>";
|
||||
|
||||
|
@ -41,7 +42,7 @@
|
|||
tableString +=
|
||||
"<tr>" +
|
||||
"<td class='time'>"+shows[i].getRange()+"</td>" +
|
||||
"<td><a href='#'>"+shows[i].getName()+"</a> <a href='#' class='listen'>Listen</a></td>" +
|
||||
"<td><a href='#'>"+shows[i].getName()+"</a></td>" +
|
||||
"</tr>";
|
||||
}
|
||||
|
||||
|
@ -55,10 +56,13 @@
|
|||
updateWidget();
|
||||
}
|
||||
|
||||
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||
}
|
||||
|
||||
function getServerData(){
|
||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
||||
processData(data);
|
||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
||||
}, error:airtimeScheduleJsonpError});
|
||||
setTimeout(getServerData, options.updatePeriod*1000);
|
||||
}
|
||||
});
|
||||
|
@ -72,7 +76,8 @@
|
|||
var defaults = {
|
||||
updatePeriod: 5, //seconds
|
||||
sourceDomain: "http://localhost/", //where to get show status from
|
||||
audioStreamSource: "http://localhost:8000/airtime.mp3" //where to get audio stream from
|
||||
audioStreamSource: "http://localhost:8000/airtime.mp3", //where to get audio stream from
|
||||
text: {listenLive:"Listen WADR Live", onAirNow:"On Air Now", offline:"Offline", current:"Current", next:"Next"}
|
||||
};
|
||||
var options = $.extend(defaults, options);
|
||||
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
||||
|
@ -86,7 +91,7 @@
|
|||
var currentShow = sd.getCurrentShow();
|
||||
var nextShows = sd.getNextShows();
|
||||
|
||||
var showStatus = "Offline";
|
||||
var showStatus = options.text.offline;
|
||||
var currentShowName = "";
|
||||
var timeElapsed = "";
|
||||
var timeRemaining = "";
|
||||
|
@ -95,7 +100,7 @@
|
|||
var nextShowRange = "";
|
||||
|
||||
if (currentShow.length > 0){
|
||||
showStatus = "On Air Now";
|
||||
showStatus = options.text.onAirNow;
|
||||
currentShowName = currentShow[0].getName();
|
||||
|
||||
timeElapsed = sd.getShowTimeElapsed(currentShow[0]);
|
||||
|
@ -108,14 +113,14 @@
|
|||
}
|
||||
|
||||
obj.empty();
|
||||
obj.append("<a id='listenWadrLive' href='"+options.audioStreamSource+"'><span>Listen WADR Live</span></a>");
|
||||
obj.append("<a id='listenWadrLive' href='"+options.audioStreamSource+"'><span>"+options.text.listenLive+"</span></a>");
|
||||
obj.append("<h4>"+showStatus+" >></h4>");
|
||||
obj.append("<ul class='widget no-playing-bar'>" +
|
||||
"<li class='current'>Current: "+currentShowName+
|
||||
"<li class='current'>"+options.text.current+": "+currentShowName+
|
||||
"<span id='time-elapsed' class='time-elapsed'>"+timeElapsed+"</span>" +
|
||||
"<span id='time-remaining' class='time-remaining'>"+timeRemaining+"</span>"+
|
||||
"</li>" +
|
||||
"<li class='next'>Next: "+nextShowName+"<span>"+nextShowRange+"</span></li>" +
|
||||
"<li class='next'>"+options.text.next+": "+nextShowName+"<span>"+nextShowRange+"</span></li>" +
|
||||
"</ul>");
|
||||
|
||||
//refresh the UI to update the elapsed/remaining time
|
||||
|
@ -127,10 +132,13 @@
|
|||
updateWidget();
|
||||
}
|
||||
|
||||
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||
}
|
||||
|
||||
function getServerData(){
|
||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
||||
processData(data);
|
||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
||||
}, error:airtimeScheduleJsonpError});
|
||||
setTimeout(getServerData, options.updatePeriod*1000);
|
||||
}
|
||||
});
|
||||
|
@ -220,10 +228,13 @@
|
|||
updateWidget(data);
|
||||
}
|
||||
|
||||
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||
}
|
||||
|
||||
function getServerData(){
|
||||
$.ajax({ url: options.sourceDomain + "api/week-info/", dataType:"jsonp", success:function(data){
|
||||
processData(data);
|
||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
||||
}, error:airtimeScheduleJsonpError});
|
||||
setTimeout(getServerData, options.updatePeriod*1000);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
DROP TABLE cc_backup;
|
||||
DROP TABLE cc_trans;
|
Loading…
Reference in New Issue