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

This commit is contained in:
mkonecny 2011-01-24 19:20:06 -05:00
commit 51f77dba50
14 changed files with 383 additions and 347 deletions

View file

@ -72,6 +72,7 @@
<controllerFile controllerName="User">
<actionMethod actionName="index"/>
<actionMethod actionName="addUser"/>
<actionMethod actionName="getHosts"/>
</controllerFile>
<controllerFile controllerName="SidePlaylist">
<actionMethod actionName="index"/>
@ -254,6 +255,9 @@
<viewControllerScriptsDirectory forControllerName="Nowplaying">
<viewScriptFile forActionName="getDataGridData"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="User">
<viewScriptFile forActionName="getHosts"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>

View file

@ -56,7 +56,16 @@ $pages = array(
'module' => 'default',
'controller' => 'Schedule',
'action' => 'index',
'resource' => 'schedule',
'pages' => array(
array(
'label' => 'Add Show',
'module' => 'default',
'controller' => 'Schedule',
'action' => 'add-show-dialog',
'resource' => 'schedule'
)
)
),
array(
'label' => 'Logout',

View file

@ -33,15 +33,12 @@ class ScheduleController extends Zend_Controller_Action
{
$this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript');
$this->view->headScript()->appendFile('/js/contextmenu/jquery.contextMenu.js','text/javascript');
$this->view->headScript()->appendFile('/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript');
$this->view->headScript()->appendFile('/js/colorpicker/js/colorpicker.js','text/javascript');
//$this->view->headScript()->appendFile('/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript');
$this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript');
$this->view->headScript()->appendFile('/js/airtime/schedule/schedule.js','text/javascript');
$this->view->headLink()->appendStylesheet('/css/jquery.contextMenu.css');
$this->view->headLink()->appendStylesheet('/css/fullcalendar.css');
$this->view->headLink()->appendStylesheet('/css/colorpicker/css/colorpicker.css');
$this->view->headLink()->appendStylesheet('/css/schedule.css');
@ -76,6 +73,15 @@ class ScheduleController extends Zend_Controller_Action
public function addShowDialogAction()
{
$this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript');
$this->view->headScript()->appendFile('/js/colorpicker/js/colorpicker.js','text/javascript');
$this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript');
$this->view->headScript()->appendFile('/js/airtime/schedule/add-show.js','text/javascript');
$this->view->headLink()->appendStylesheet('/css/fullcalendar.css');
$this->view->headLink()->appendStylesheet('/css/colorpicker/css/colorpicker.css');
$this->view->headLink()->appendStylesheet('/css/add-show.css');
$request = $this->getRequest();
$formWhat = new Application_Form_AddShowWhat();
$formWhat->removeDecorator('DtDdWrapper');
@ -88,17 +94,17 @@ class ScheduleController extends Zend_Controller_Action
$formStyle = new Application_Form_AddShowStyle();
$formStyle->removeDecorator('DtDdWrapper');
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
if ($request->isPost()) {
$data = $request->getPost();
if ($formStyle->isValid($data) && $formWhen->isValid($data) && $formWho->isValid($data) && $formStyle->isValid($data)) {
$what = $formWhat->isValid($data);
$when = $formWhen->isValid($data);
$repeats = $formRepeats->isValid($data);
$who = $formWho->isValid($data);
$style = $formStyle->isValid($data);
if ($what && $when && $repeats && $who && $style) {
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
@ -107,15 +113,18 @@ class ScheduleController extends Zend_Controller_Action
if(isset($overlap)) {
$this->view->overlap = $overlap;
$this->view->form = $this->view->render('schedule/add-show-dialog.phtml');
}
return;
else {
$this->_redirect('Schedule');
}
}
}
$this->view->content = $this->view->render('schedule/add-show-dialog.phtml');
$this->view->hosts = User::getHosts();
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
}
public function moveShowAction()

View file

@ -30,7 +30,15 @@ class UserController extends Zend_Controller_Action
$this->view->form = $form;
}
public function getHostsAction()
{
$this->view->hosts = User::getHosts();
}
}

View file

@ -39,15 +39,14 @@ class User {
}
public static function getUsers($type=NULL) {
public static function getUsers($type=NULL, $search=NULL) {
global $CC_DBC;
$sql;
$sql_gen = "SELECT id, login, type FROM cc_subjs ";
$sql_gen = "SELECT id, login FROM cc_subjs ";
$sql = $sql_gen;
if(!is_null($type)){
if(is_array($type)) {
@ -62,6 +61,9 @@ class User {
$sql = $sql_gen ." WHERE ". $sql_type;
}
if(!is_null($search)) {
$like = "login ILIKE '{$search}'";
}
$sql = $sql . " ORDER BY login";

View file

@ -1,5 +1,6 @@
<form>
<div id="tabs">
<div id="schedule-add-show">
<form method="post" action="">
<div id="schedule-add-show-tabs">
<ul>
<li><a href="#schedule-show-what"><span>What</span></a></li>
<li><a href="#schedule-show-when"><span>When</span></a></li>
@ -10,7 +11,6 @@
<?php echo $this->what ?>
</div>
<div id="schedule-show-when">
<div id="show_overlap_error"/>
<?php echo $this->when ?>
<?php echo $this->repeats ?>
</div>
@ -22,3 +22,13 @@
</div>
</div>
</form>
<button id="add-show-submit">Add</button>
</div>
<div id="fullcalendar_show_display"></div>
<div id="schedule-add-show-overlap">
<?php if(isset($this->overlap)) : ?>
<div>Overlap</div>
<?php echo $this->partialLoop('schedule/show-overlap.phtml', $this->overlap); ?>
<?php endif;?>
</div>

View file

@ -1,4 +1,3 @@
<div><span id='schedule_add_show'>Add Show</span></div>
<div id='schedule_calendar'></div>
<ul id="schedule_event_default_menu" class="contextMenu">

View file

@ -0,0 +1,4 @@
<div>
<span><?php echo $this->name ?></span>
<span><?php echo $this->start_time ?></span>-<span><?php echo $this->end_time ?></span>
</div>

View file

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

22
public/css/add-show.css Normal file
View file

@ -0,0 +1,22 @@
#schedule-add-show,
#fullcalendar_show_display {
float: left;
}
#schedule-add-show {
font-size: 12px;
width: 600px;
}
#schedule-add-show textarea {
width: 100%;
height: 100px;
}
#fullcalendar_show_display {
width: 400px;
}
#schedule-add-show-overlap {
clear: left;
}

View file

@ -120,4 +120,8 @@ div.ui-datepicker {
height: 200px;
}
#fullcalendar_show_display {
width: 400px;
}

View file

@ -0,0 +1,105 @@
/**
*
* Schedule Dialog creation methods.
*
*/
//dateText mm-dd-yy
function startDpSelect(dateText, inst) {
var time, date;
time = dateText.split("-");
date = new Date(time[0], time[1] - 1, time[2]);
$("#end_date").datepicker("option", "minDate", date);
}
function endDpSelect(dateText, inst) {
var time, date;
time = dateText.split("-");
date = new Date(time[0], time[1] - 1, time[2]);
$("#start_date").datepicker( "option", "maxDate", date);
}
function createDateInput(el, onSelect) {
var date;
el.datepicker({
minDate: new Date(),
onSelect: onSelect,
dateFormat: 'yy-mm-dd'
});
date = $.datepicker.formatDate("yy-mm-dd", new Date());
el.val(date);
}
function autoSelect(event, ui) {
$("#hosts-"+ui.item.value).attr("checked", "checked");
event.preventDefault();
}
function findHosts(request, callback) {
var search = request.term;
}
function setAddShowEvents() {
var start, end;
$("#schedule-add-show-tabs").tabs();
start = $("#add_show_start_date");
end = $("#add_show_end_date");
createDateInput(start, startDpSelect);
createDateInput(end, endDpSelect);
$("#add_show_hosts_autocomplete").autocomplete({
source: findHosts,
select: autoSelect
});
$("#schedule-show-style input").ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}
});
$("#add-show-submit")
.button()
.click(function(){
$("form").submit();
});
}
$(document).ready(function() {
setAddShowEvents();
$("#fullcalendar_show_display").fullCalendar({
header: {
left: 'prev, next, today',
center: '',
right: ''
},
defaultView: 'agendaDay',
editable: false,
allDaySlot: false,
lazyFetching: false,
events: getFullCalendarEvents,
//callbacks
eventRender: eventRender
});
});

View file

@ -0,0 +1,147 @@
/**
*
* Full Calendar callback methods.
*
*/
function makeTimeStamp(date){
var sy, sm, sd, h, m, s, timestamp;
sy = date.getFullYear();
sm = date.getMonth() + 1;
sd = date.getDate();
h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
timestamp = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s;
return timestamp;
}
function dayClick(date, allDay, jsEvent, view) {
var x;
}
function eventRender(event, element, view) {
//element.qtip({
// content: event.description
// });
if(view.name === 'agendaDay' || view.name === 'agendaWeek') {
var div = $('<div/>');
div
.height('5px')
.width('100px')
.css('margin-top', '5px')
.progressbar({
value: event.percent
});
if(event.percent === 0) {
// even at 0, the bar still seems to display a little bit of progress...
div.find("div").hide();
}
$(element).find(".fc-event-title").after(div);
}
if(event.backgroundColor !== "") {
$(element)
.css({'border-color': '#'+event.backgroundColor})
.find(".fc-event-time, a")
.css({'background-color': '#'+event.backgroundColor, 'border-color': '#'+event.backgroundColor});
}
if(event.color !== "") {
$(element)
.find(".fc-event-time, a")
.css({'color': '#'+event.color});
}
}
function eventAfterRender( event, element, view ) {
var today = new Date();
if(event.isHost === true && event.start > today) {
$(element).contextMenu(
{menu: 'schedule_event_host_menu'}, eventMenu
);
}
else{
$(element).contextMenu(
{menu: 'schedule_event_default_menu'}, eventMenu
);
}
$(element).data({'event': event});
}
function eventClick(event, jsEvent, view) {
var x;
}
function eventMouseover(event, jsEvent, view) {
}
function eventMouseout(event, jsEvent, view) {
}
function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
var url;
if (event.repeats && dayDelta !== 0) {
revertFunc();
return;
}
url = '/Schedule/move-show/format/json';
$.post(url,
{day: dayDelta, min: minuteDelta, showId: event.id},
function(json){
if(json.overlap) {
revertFunc();
}
});
}
function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) {
var url;
url = '/Schedule/resize-show/format/json';
$.post(url,
{day: dayDelta, min: minuteDelta, showId: event.id},
function(json){
if(json.overlap) {
revertFunc();
}
});
}
function getFullCalendarEvents(start, end, callback) {
var url, start_date, end_date;
var sy, sm, sd, ey, em, ed;
sy = start.getFullYear();
sm = start.getMonth() + 1;
sd = start.getDate();
start_date = sy +"-"+ sm +"-"+ sd;
ey = end.getFullYear();
em = end.getMonth() + 1;
ed = end.getDate();
end_date = ey +"-"+ em +"-"+ ed;
url = '/Schedule/event-feed';
if ((ed - sd) === 1) {
url = url + '/weekday/' + start.getDay();
}
var d = new Date();
$.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){
callback(json.events);
});
}

View file

@ -4,166 +4,11 @@
*
*/
function makeTimeStamp(date){
var sy, sm, sd, h, m, s, timestamp;
sy = date.getFullYear();
sm = date.getMonth() + 1;
sd = date.getDate();
h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
timestamp = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s;
return timestamp;
}
//dateText mm-dd-yy
function startDpSelect(dateText, inst) {
var time, date;
time = dateText.split("-");
date = new Date(time[0], time[1] - 1, time[2]);
$("#end_date").datepicker("option", "minDate", date);
}
function endDpSelect(dateText, inst) {
var time, date;
time = dateText.split("-");
date = new Date(time[0], time[1] - 1, time[2]);
$("#start_date").datepicker( "option", "maxDate", date);
}
function createDateInput(el, onSelect) {
var date;
el.datepicker({
minDate: new Date(),
onSelect: onSelect,
dateFormat: 'yy-mm-dd'
});
date = $.datepicker.formatDate("yy-mm-dd", new Date());
el.val(date);
}
function submitShow() {
var formData, dialog;
formData = $("#schedule_add_event_dialog").find("form").serializeArray();
dialog = $(this);
$.post("/Schedule/add-show-dialog/format/json",
formData,
function(data){
if(data.content) {
dialog.find("form").remove();
makeShowDialog(dialog, data);
if(data.overlap) {
var div, table, tr, days;
div = dialog.find("#show_overlap_error");
table = $('<table/>');
days = $.datepicker.regional[''].dayNamesShort;
$.each(data.overlap, function(i, val){
tr = $("<tr/>");
tr
.append("<td>"+val.name+"</td>")
.append("<td>"+days[val.day]+"</td>")
.append("<td>"+val.start_time+"</td>")
.append("<td>"+val.end_time+"</td>");
table.append(tr);
});
div.append("<span>Cannot add show. New show overlaps the following shows:</span>");
div.append(table);
dialog.append(div);
}
}
else {
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
dialog.remove();
}
});
}
function closeDialog(event, ui) {
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
$(this).remove();
}
function autoSelect(event, ui) {
$("#hosts-"+ui.item.value).attr("checked", "checked");
event.preventDefault();
}
function makeShowDialog(dialog, json) {
dialog.append(json.content);
dialog.find("#tabs").tabs();
var start = dialog.find("#add_show_start_date");
var end = dialog.find("#add_show_end_date");
createDateInput(start, startDpSelect);
createDateInput(end, endDpSelect);
var auto = json.hosts.map(function(el) {
return {value: el.id, label: el.login};
});
dialog.find("#add_show_hosts_autocomplete").autocomplete({
source: auto,
select: autoSelect
});
dialog.find("#schedule-show-style input").ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}
});
return dialog;
}
function openShowDialog() {
var url;
url = '/Schedule/add-show-dialog/format/json';
$.get(url, function(json){
var dialog;
//main jqueryUI dialog
dialog = $('<div id="schedule_add_event_dialog" />');
makeShowDialog(dialog, json);
dialog.dialog({
autoOpen: false,
title: 'Add Show',
width: 1100,
height: 500,
modal: true,
close: closeDialog,
buttons: { "Cancel": closeDialog, "Ok": submitShow}
});
dialog.dialog('open');
});
}
function setScheduleDialogHtml(json) {
@ -315,15 +160,18 @@ function openScheduleDialog(show) {
}
function eventMenu(action, el, pos) {
var method, event, date;
var method, event, start_timestamp, url;
method = action.split('/').pop();
event = $(el).data('event');
date = makeTimeStamp(event.start);
start_timestamp = makeTimeStamp(event.start);
if (method === 'delete-show') {
url = '/Schedule/delete-show';
$.post(action,
{format: "json", showId: event.id, date: date},
{format: "json", showId: event.id, date: start_timestamp},
function(json){
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
});
@ -333,125 +181,17 @@ function eventMenu(action, el, pos) {
openScheduleDialog(event);
}
else if (method === 'clear-show') {
start_date = makeTimeStamp(event.start);
url = '/Schedule/clear-show/format/json';
url = '/Schedule/clear-show';
$.post(url,
{start: start_date, showId: event.id},
{format: "json", start: start_timestamp, showId: event.id},
function(json){
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
});
}
}
/**
*
* Full Calendar callback methods.
*
*/
function dayClick(date, allDay, jsEvent, view) {
var x;
}
function eventRender(event, element, view) {
//element.qtip({
// content: event.description
// });
if(view.name === 'agendaDay' || view.name === 'agendaWeek') {
var div = $('<div/>');
div
.height('5px')
.width('100px')
.css('margin-top', '5px')
.progressbar({
value: event.percent
});
if(event.percent === 0) {
// even at 0, the bar still seems to display a little bit of progress...
div.find("div").hide();
}
$(element).find(".fc-event-title").after(div);
}
if(event.backgroundColor !== "") {
$(element)
.css({'border-color': '#'+event.backgroundColor})
.find(".fc-event-time, a")
.css({'background-color': '#'+event.backgroundColor, 'border-color': '#'+event.backgroundColor});
}
if(event.color !== "") {
$(element)
.find(".fc-event-time, a")
.css({'color': '#'+event.color});
}
}
function eventAfterRender( event, element, view ) {
var today = new Date();
if(event.isHost === true && event.start > today) {
$(element).contextMenu(
{menu: 'schedule_event_host_menu'}, eventMenu
);
}
else{
$(element).contextMenu(
{menu: 'schedule_event_default_menu'}, eventMenu
);
}
$(element).data({'event': event});
}
function eventClick(event, jsEvent, view) {
var x;
}
function eventMouseover(event, jsEvent, view) {
}
function eventMouseout(event, jsEvent, view) {
}
function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
var url;
if (event.repeats && dayDelta !== 0) {
revertFunc();
return;
}
url = '/Schedule/move-show/format/json';
$.post(url,
{day: dayDelta, min: minuteDelta, showId: event.id},
function(json){
if(json.overlap) {
revertFunc();
}
});
}
function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) {
var url;
url = '/Schedule/resize-show/format/json';
$.post(url,
{day: dayDelta, min: minuteDelta, showId: event.id},
function(json){
if(json.overlap) {
revertFunc();
}
});
}
$(document).ready(function() {
$('#schedule_calendar').fullCalendar({
@ -465,35 +205,9 @@ $(document).ready(function() {
allDaySlot: false,
lazyFetching: false,
events: function(start, end, callback) {
var url, start_date, end_date;
events: getFullCalendarEvents,
var sy, sm, sd, ey, em, ed;
sy = start.getFullYear();
sm = start.getMonth() + 1;
sd = start.getDate();
start_date = sy +"-"+ sm +"-"+ sd;
ey = end.getFullYear();
em = end.getMonth() + 1;
ed = end.getDate();
end_date = ey +"-"+ em +"-"+ ed;
url = '/Schedule/event-feed';
if ((ed - sd) === 1) {
url = url + '/weekday/' + start.getDay();
}
var d = new Date();
$.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){
callback(json.events);
});
},
//callbacks
//callbacks (from full-calendar-functions.js
dayClick: dayClick,
eventRender: eventRender,
eventAfterRender: eventAfterRender,
@ -503,9 +217,7 @@ $(document).ready(function() {
eventDrop: eventDrop,
eventResize: eventResize
})
$('#schedule_add_show').click(openShowDialog);
});
});