Merge branch 'master' of dev.sourcefabric.org:campcaster

Conflicts:
	.zfproject.xml
	application/configs/airtime-conf.php
	build/build.properties
	public/css/styles.css
This commit is contained in:
mkonecny 2011-02-09 13:07:36 -05:00
commit 50054befd6
18 changed files with 309 additions and 115 deletions

View file

@ -28,6 +28,7 @@
<actionMethod actionName="delete"/>
<actionMethod actionName="deleteActive"/>
<actionMethod actionName="close"/>
<actionMethod actionName="setPlaylistFades"/>
</controllerFile>
<controllerFile controllerName="Library">
<actionMethod actionName="index"/>
@ -302,6 +303,8 @@
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="User">
<viewScriptFile forActionName="removeUser"/>
<viewControllerScriptsDirectory forControllerName="Playlist">
<viewScriptFile forActionName="setPlaylistFades"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>

View file

@ -17,4 +17,4 @@ $conf = array (
'generator_version' => '1.5.2',
);
$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-airtime-conf.php');
return $conf;
return $conf;

View file

@ -19,15 +19,16 @@ class PlaylistController extends Zend_Controller_Action
->addActionContext('edit', 'json')
->addActionContext('delete-active', 'json')
->addActionContext('delete', 'json')
->addActionContext('set-playlist-fades', 'json')
->initContext();
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
}
private function getPlaylist()
{
$pl_sess = $this->pl_sess;
private function getPlaylist()
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$pl = Playlist::Recall($pl_sess->id);
@ -36,13 +37,13 @@ class PlaylistController extends Zend_Controller_Action
return;
}
return $pl;
}
}
private function changePlaylist($pl_id){
$pl_sess = $this->pl_sess;
}
}
private function changePlaylist($pl_id)
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$pl = Playlist::Recall($pl_sess->id);
@ -58,10 +59,10 @@ class PlaylistController extends Zend_Controller_Action
return FALSE;
}
$pl->lock($userInfo->id);
$pl_sess->id = $pl_id;
}
$pl_sess->id = $pl_id;
}
private function closePlaylist($pl)
private function closePlaylist($pl)
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$res = $pl->unlock($userInfo->id);
@ -78,9 +79,6 @@ class PlaylistController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet('/css/playlist_builder.css');
$this->_helper->viewRenderer->setResponseSegment('spl');
$pl_sess = $this->pl_sess;
$this->view->pl = $this->getPlaylist();
}
@ -94,14 +92,12 @@ class PlaylistController extends Zend_Controller_Action
$pl->setPLMetaData('dc:creator', $userInfo->login);
$this->changePlaylist($pl_id);
$form = new Application_Form_PlaylistMetadata();
$this->view->form = $form->__toString();
}
public function metadataAction()
{
{
$request = $this->getRequest();
$form = new Application_Form_PlaylistMetadata();
@ -141,8 +137,8 @@ class PlaylistController extends Zend_Controller_Action
public function editAction()
{
$pl_id = $this->_getParam('id', null);
$pl_id = $this->_getParam('id', null);
if(!is_null($pl_id)) {
$this->changePlaylist($pl_id);
}
@ -155,8 +151,8 @@ class PlaylistController extends Zend_Controller_Action
}
public function addItemAction()
{
$id = $this->_getParam('id');
{
$id = $this->_getParam('id');
$pos = $this->_getParam('pos', null);
if (!is_null($id)) {
@ -181,7 +177,7 @@ class PlaylistController extends Zend_Controller_Action
public function moveItemAction()
{
$oldPos = $this->_getParam('oldPos');
$oldPos = $this->_getParam('oldPos');
$newPos = $this->_getParam('newPos');
$pl = $this->getPlaylist();
@ -198,8 +194,8 @@ class PlaylistController extends Zend_Controller_Action
public function deleteItemAction()
{
$positions = $this->_getParam('pos', array());
$positions = $this->_getParam('pos', array());
if (!is_array($positions))
$positions = array($positions);
@ -218,12 +214,12 @@ class PlaylistController extends Zend_Controller_Action
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
unset($this->view->pl);
unset($this->view->pl);
}
public function setCueAction()
{
$request = $this->getRequest();
$request = $this->getRequest();
$pos = $this->_getParam('pos');
$pl = $this->getPlaylist();
@ -248,7 +244,7 @@ class PlaylistController extends Zend_Controller_Action
public function setFadeAction()
{
$request = $this->getRequest();
$request = $this->getRequest();
$pos = $this->_getParam('pos');
$pl = $this->getPlaylist();
@ -292,8 +288,8 @@ class PlaylistController extends Zend_Controller_Action
}
public function deleteActiveAction()
{
$pl = $this->getPlaylist();
{
$pl = $this->getPlaylist();
Playlist::Delete($pl->getId());
$pl_sess = $this->pl_sess;
@ -304,12 +300,38 @@ class PlaylistController extends Zend_Controller_Action
public function closeAction()
{
$pl = $this->getPlaylist();
$pl = $this->getPlaylist();
$this->closePlaylist($pl);
$this->view->html = $this->view->render('playlist/index.phtml');
$this->view->html = $this->view->render('playlist/index.phtml');
}
public function setPlaylistFadesAction()
{
$request = $this->getRequest();
$pl = $this->getPlaylist();
if($request->isPost()) {
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
if($fadeIn)
$response = $pl->changeFadeInfo(0, $fadeIn, $fadeOut);
else if($fadeOut)
$response = $pl->changeFadeInfo($pl->getSize(), $fadeIn, $fadeOut);
$this->view->response = $response;
return;
}
$fades = $pl->getFadeInfo(0);
$this->view->fadeIn = $fades[0];
$fades = $pl->getFadeInfo($pl->getSize());
$this->view->fadeOut = $fades[1];
}
}
@ -331,6 +353,8 @@ class PlaylistController extends Zend_Controller_Action

View file

@ -306,7 +306,8 @@ class ScheduleController extends Zend_Controller_Action
$end = explode(" ", $end_timestamp);
$startTime = explode(":", $start[1]);
$endTime = explode(":", $end[1]);
$dateInfo = getDate(strtotime($start_timestamp));
$dateInfo_s = getDate(strtotime($start_timestamp));
$dateInfo_e = getDate(strtotime($end_timestamp));
$this->view->showContent = $show->getShowContent();
$this->view->timeFilled = $show->getTimeScheduled();
@ -314,9 +315,12 @@ class ScheduleController extends Zend_Controller_Action
$this->view->showLength = $show->getShowLength();
$this->view->percentFilled = $show->getPercentScheduledInRange();
$this->view->wday = $dateInfo['weekday'];
$this->view->month = $dateInfo['month'];
$this->view->day = $dateInfo['mday'];
$this->view->s_wday = $dateInfo_s['weekday'];
$this->view->s_month = $dateInfo_s['month'];
$this->view->s_day = $dateInfo_s['mday'];
$this->view->e_wday = $dateInfo_e['weekday'];
$this->view->e_month = $dateInfo_e['month'];
$this->view->e_day = $dateInfo_e['mday'];
$this->view->startTime = sprintf("%d:%02d", $startTime[0], $startTime[1]);
$this->view->endTime = sprintf("%d:%02d", $endTime[0], $endTime[1]);

View file

@ -5,6 +5,17 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
public function init()
{
//Add type select
$this->addElement('select', 'add_show_repeat_type', array(
'required' => true,
'label' => 'Repeat Type:',
'multiOptions' => array(
"0" => "weekly",
"1" => "bi-weekly",
"2" => "monthly"
),
));
// Add days checkboxes
$this->addElement(
'multiCheckbox',
@ -29,16 +40,6 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
'viewScript' => 'form/add-show-checkbox.phtml'
))));
//Add type select
$this->addElement('select', 'add_show_repeat_type', array(
'required' => true,
'label' => 'Repeat Type:',
'multiOptions' => array(
"0" => "weekly",
"1" => "bi-weekly"
),
));
// Add end date element
$this->addElement('text', 'add_show_end_date', array(
'label' => 'Date End:',

View file

@ -355,6 +355,18 @@ class Playlist {
return $res + 1;
}
public function getSize() {
$res = CcPlaylistQuery::create()
->findPK($this->id)
->computeLastPosition();
if(is_null($res))
return 0;
return $res;
}
/**
* Get the entire playlist as a two dimentional array, sorted in order of play.
* @return array

View file

@ -71,37 +71,52 @@ class Show {
$showId = $show->getDbId();
foreach ($data['add_show_day_check'] as $day) {
//don't set day for monthly repeat type, it's invalid.
if($data['add_show_repeats'] && $data["add_show_repeat_type"] == 2) {
$showDay = new CcShowDays();
$showDay->setDbFirstShow($data['add_show_start_date']);
$showDay->setDbLastShow($endDate);
$showDay->setDbStartTime($data['add_show_start_time']);
$showDay->setDbDuration($data['add_show_duration']);
$showDay->setDbRepeatType($repeat_type);
$showDay->setDbShowId($showId);
$showDay->save();
}
else {
if($startDow !== $day){
foreach ($data['add_show_day_check'] as $day) {
if($startDow !== $day){
if($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day;
else
$daysAdd = $day - $startDow;
if($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day;
else
$daysAdd = $day - $startDow;
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '{$daysAdd} day' ";
$r = $con->query($sql);
$start = $r->fetchColumn(0);
}
else {
$start = $data['add_show_start_date'];
}
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '{$daysAdd} day' ";
$r = $con->query($sql);
$start = $r->fetchColumn(0);
}
else {
$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);
$showDay->setDbStartTime($data['add_show_start_time']);
$showDay->setDbDuration($data['add_show_duration']);
$showDay->setDbDay($day);
$showDay->setDbRepeatType($repeat_type);
$showDay->setDbShowId($showId);
$showDay->save();
}
}
$showDay = new CcShowDays();
$showDay->setDbFirstShow($start);
$showDay->setDbLastShow($endDate);
$showDay->setDbStartTime($data['add_show_start_time']);
$showDay->setDbDuration($data['add_show_duration']);
$showDay->setDbDay($day);
$showDay->setDbRepeatType($repeat_type);
$showDay->setDbShowId($showId);
$showDay->save();
}
}
}
//add selected hosts to cc_show_hosts table.
foreach ($data['add_show_hosts'] as $host) {
$showHost = new CcShowHosts();
$showHost->setDbShow($showId);
@ -158,6 +173,19 @@ class Show {
}
}
private static function setNextPop($next_date, $show_id, $day) {
$nextInfo = explode(" ", $next_date);
$repeatInfo = CcShowDaysQuery::create()
->filterByDbShowId($show_id)
->filterByDbDay($day)
->findOne();
$repeatInfo->setDbNextPopDate($nextInfo[0])
->save();
}
//for a show with repeat_type == 0
private static function populateWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
global $CC_DBC;
@ -186,15 +214,7 @@ class Show {
$next_date = $CC_DBC->GetOne($sql);
}
$nextInfo = explode(" ", $next_date);
$repeatInfo = CcShowDaysQuery::create()
->filterByDbShowId($show_id)
->filterByDbDay($day)
->findOne();
$repeatInfo->setDbNextPopDate($nextInfo[0])
->save();
Show::setNextPop($next_date, $show_id, $day);
}
//for a show with repeat_type == 1
@ -225,15 +245,38 @@ class Show {
$next_date = $CC_DBC->GetOne($sql);
}
$nextInfo = explode(" ", $next_date);
Show::setNextPop($next_date, $show_id, $day);
}
$repeatInfo = CcShowDaysQuery::create()
->filterByDbShowId($show_id)
->filterByDbDay($day)
->findOne();
//for a show with repeat_type == 2
private static function populateMonthlyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
global $CC_DBC;
$repeatInfo->setDbNextPopDate($nextInfo[0])
->save();
if(isset($next_pop_date)) {
$next_date = $next_pop_date." ".$start_time;
}
else {
$next_date = $first_show." ".$start_time;
}
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
$start = $next_date;
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
$end = $CC_DBC->GetOne($sql);
$newShow = new CcShowInstances();
$newShow->setDbShowId($show_id);
$newShow->setDbStarts($start);
$newShow->setDbEnds($end);
$newShow->save();
$sql = "SELECT timestamp '{$start}' + interval '1 month'";
$next_date = $CC_DBC->GetOne($sql);
}
Show::setNextPop($next_date, $show_id, $day);
}
private static function populateShow($repeat_type, $show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp) {
@ -247,6 +290,9 @@ class Show {
else if($repeat_type == 1) {
Show::populateBiWeeklyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp);
}
else if($repeat_type == 2) {
Show::populateMonthlyShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $end_timestamp);
}
}
//used to catch up a newly added show
@ -441,7 +487,7 @@ class ShowInstance {
$starts = $this->getShowStart();
$ends = $this->getShowEnd();
$sql = "SELECT timestamp '{$ends}' + interval '{$hours}:{$mins}'";
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
$new_ends = $CC_DBC->GetOne($sql);
//only need to check overlap if show increased in size.
@ -459,7 +505,7 @@ class ShowInstance {
$scheduledContentFits = $CC_DBC->GetOne($sql);
if($scheduledContentFits != "t") {
return "Must removed some scheduled content.";
return "Must remove some scheduled content.";
}
}

View file

@ -1791,7 +1791,7 @@ class StoredFile {
$fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
$datatables["optWhere"][] = "plt.length <= '{$p_length}'";
$datatables["optWhere"][] = "plt.length <= INTERVAL '{$p_length}'";
return StoredFile::searchFiles($fromTable, $datatables);

View file

@ -43,7 +43,7 @@ class CcShowDaysTableMap extends TableMap {
$this->addColumn('LAST_SHOW', 'DbLastShow', 'DATE', false, null, null);
$this->addColumn('START_TIME', 'DbStartTime', 'TIME', true, null, null);
$this->addColumn('DURATION', 'DbDuration', 'TIME', true, null, null);
$this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null);
$this->addColumn('DAY', 'DbDay', 'TINYINT', false, null, null);
$this->addColumn('REPEAT_TYPE', 'DbRepeatType', 'TINYINT', true, null, null);
$this->addColumn('NEXT_POP_DATE', 'DbNextPopDate', 'DATE', false, null, null);
$this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null);

View file

@ -1,6 +1,9 @@
<button id="spl_new" class="ui-button" role="button" aria-disabled="false">New</button>
<?php if (isset($this->pl)) : ?>
<button id="spl_delete" class="ui-button" role="button" aria-disabled="false">Delete</button>
<a href="#" id="spl_crossfade" class="ui-button ui-button-icon-only ui-widget ui-state-default crossfade-main-button">
<span class="ui-icon crossfade-main-icon"></span><span class="ui-button-text">Playlist crossfade</span>
</a>
<button id="spl_close" class="ui-button right-floated" role="button" aria-disabled="false">Done Editing</button>
<?php endif; ?>
@ -8,6 +11,18 @@
<h3 id="spl_name"><?php echo $this->pl->getName(); ?></h3>
<h4 id="spl_length"><?php echo $this->pl->getLength(); ?></h4>
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
<span class="ui-icon ui-icon-closethick"></span>
<dl id="spl_editor-main" class="inline-list">
<dt>Fade in:</dt>
<dd id="spl_fade_in_main"><span contenteditable="true" class="spl_text_input">00:00:00</span></dd>
<dd class="edit-error"></dd>
<dt>Fade out:</dt>
<dd id="spl_fade_out_main"><span contenteditable="true" class="spl_text_input">00:00:00</span></dd>
<dd class="edit-error"></dd>
</dl>
</div>
<div class="clear"></div>
<div class="" style="clear:both; float:none; width:100%;">
<ul id="spl_sortable">

View file

@ -0,0 +1 @@
<br /><br /><center>View script for controller <b>Playlist</b> and script/action name <b>setPlaylistFades</b></center>

View file

@ -1,5 +1,8 @@
<div id="schedule_playlist_dialog">
<h2 id="scheduled_playlist_name"><?php echo $this->showName; ?>: <span><?php echo $this->wday." ".$this->month." ".$this->day.", ".$this->startTime." - ".$this->endTime; ?></span></h2>
<h2 id="scheduled_playlist_name">
<?php echo $this->showName; ?>: <span><?php echo $this->s_wday." ".$this->s_month." ".$this->s_day." ".$this->startTime.
" - ".$this->e_wday." ".$this->e_month." ".$this->e_day." ".$this->endTime; ?></span>
</h2>
<div class="clearfix">
<div class="wrapp-one">
<table id="schedule_playlists" cellpadding="0" cellspacing="0" class="datatable">

View file

@ -143,7 +143,7 @@
<column name="last_show" phpName="DbLastShow" type="DATE" required="false"/>
<column name="start_time" phpName="DbStartTime" type="TIME" required="true"/>
<column name="duration" phpName="DbDuration" type="TIME" required="true"/>
<column name="day" phpName="DbDay" type="TINYINT" required="true"/>
<column name="day" phpName="DbDay" type="TINYINT" required="false"/>
<column name="repeat_type" phpName="DbRepeatType" type="TINYINT" required="true"/>
<column name="next_pop_date" phpName="DbNextPopDate" type="DATE" required="false"/>
<column name="show_id" phpName="DbShowId" type="INTEGER" required="true"/>

View file

@ -206,7 +206,7 @@ CREATE TABLE "cc_show_days"
"last_show" DATE,
"start_time" TIME NOT NULL,
"duration" TIME NOT NULL,
"day" INT2 NOT NULL,
"day" INT2,
"repeat_type" INT2 NOT NULL,
"next_pop_date" DATE,
"show_id" INTEGER NOT NULL,

View file

@ -36,7 +36,7 @@
list-style: none;
padding:0;
height: 400px;
overflow: auto;
overflow-y: scroll;
width:100%;
margin-top:0;
}

View file

@ -867,6 +867,7 @@ div.ui-datepicker {
margin-right:22px;
}
#schedule_playlist_chosen li > div > div > span {
float: right;
margin-right:46px;
@ -931,7 +932,7 @@ h2#scheduled_playlist_name span {
}
.time {
width: 80px;
width: 100px;
margin: 5px;
text-align: left;
}

View file

@ -146,21 +146,21 @@ function submitOnEnter(event) {
}
}
function setCueEvents() {
function setCueEvents(el) {
$(".spl_cue_in span:last").blur(changeCueIn);
$(".spl_cue_out span:last").blur(changeCueOut);
$(el).find(".spl_cue_in span:last").blur(changeCueIn);
$(el).find(".spl_cue_out span:last").blur(changeCueOut);
$(".spl_cue_in span:first, .spl_cue_out span:first")
$(el).find(".spl_cue_in span:first, .spl_cue_out span:first")
.keydown(submitOnEnter);
}
function setFadeEvents() {
function setFadeEvents(el) {
$(".spl_fade_in span:first").blur(changeFadeIn);
$(".spl_fade_out span:first").blur(changeFadeOut);
$(el).find(".spl_fade_in span:first").blur(changeFadeIn);
$(el).find(".spl_fade_out span:first").blur(changeFadeOut);
$(".spl_fade_in span:first, .spl_fade_out span:first")
$(el).find(".spl_fade_in span:first, .spl_fade_out span:first")
.keydown(submitOnEnter);
}
@ -198,7 +198,7 @@ function openFadeEditor(event) {
.append(json.html)
.show();
setFadeEvents();
setFadeEvents(li);
});
}
@ -231,7 +231,7 @@ function openCueEditor(event) {
.append(json.html)
.show();
setCueEvents();
setCueEvents(li);
});
}
@ -392,13 +392,83 @@ function setUpSPL() {
.button()
.click(closeSPL);
$("#spl_main_crossfade")
.button({
icons: {
primary: "crossfade-main-icon"
},
text: false
});
$("#spl_crossfade").click(function(){
if($(this).hasClass("ui-state-active")) {
$(this).removeClass("ui-state-active");
$("#crossfade_main").hide();
}
else {
$(this).addClass("ui-state-active");
var url = '/Playlist/set-playlist-fades';
$.get(url, {format: "json"}, function(json){
$("#spl_fade_in_main").find("span")
.empty()
.append(json.fadeIn);
$("#spl_fade_out_main").find("span")
.empty()
.append(json.fadeOut);
$("#crossfade_main").show();
});
}
});
$("#spl_fade_in_main span:first").blur(function(event){
event.stopPropagation();
var url, fadeIn, span;
span = $(this);
url = "/Playlist/set-playlist-fades";
fadeIn = span.text().trim();
if(!isTimeValid(fadeIn)){
showError(span, "please put in a time '00:00:00 (.000000)'");
return;
}
$.post(url, {format: "json", fadeIn: fadeIn}, function(json){
if(json.response.error) {
return;
}
hideError(span);
});
});
$("#spl_fade_out_main span:first").blur(function(event){
event.stopPropagation();
var url, fadeIn, span;
span = $(this);
url = "/Playlist/set-playlist-fades";
fadeOut = span.text().trim();
if(!isTimeValid(fadeOut)){
showError(span, "please put in a time '00:00:00 (.000000)'");
return;
}
$.post(url, {format: "json", fadeOut: fadeOut}, function(json){
if(json.response.error) {
return;
}
hideError(span);
});
});
$("#spl_fade_in_main span:first, #spl_fade_out_main span:first")
.keydown(submitOnEnter);
$("#crossfade_main > .ui-icon-closethick").click(function(){
$("#spl_crossfade").removeClass("ui-state-active");
$("#crossfade_main").hide();
});
$("#spl_delete")
.button()

View file

@ -70,6 +70,20 @@ function setAddShowEvents() {
$("#schedule-show-when > fieldset:last").toggle();
});
$("#add_show_repeat_type").change(function(){
var x = $(this).val();
if($(this).val() == 2) {
$("#add_show_day_check-label, #add_show_day_check-element").hide();
}
else {
$("#add_show_day_check-label, #add_show_day_check-element").show();
}
});
$("#add_show_no_end").click(function(){
$("#add_show_end_date").toggle();
});
start = $("#add_show_start_date");
end = $("#add_show_end_date");