Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Naomi Aro 2011-11-26 13:32:05 +01:00
commit f1e1b747ad
14 changed files with 93 additions and 37 deletions

View File

@ -18,7 +18,11 @@ class NowplayingController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js','text/javascript');
//nowplayingdatagrid.js requires this variable, so that datePicker widget can be offset to server time instead of client time
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowplayingdatagrid.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowview.js','text/javascript');
$refer_sses = new Zend_Session_Namespace('referrer');
@ -104,7 +108,11 @@ class NowplayingController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.min.js','text/javascript');
//nowplayingdatagrid.js requires this variable, so that datePicker widget can be offset to server time instead of client time
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/nowplayingdatagrid.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/nowplaying/dayview.js','text/javascript');
}

View File

@ -199,7 +199,6 @@ class PreferenceController extends Zend_Controller_Action
$values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
}
var_dump($form->getValue('icecast_vorbis_metadata'));
if(!$error){
Application_Model_StreamSetting::setStreamSetting($values);
$data = array();

View File

@ -46,7 +46,11 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/fullcalendar/fullcalendar.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker-0.0.6.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/colorpicker/js/colorpicker.js','text/javascript');
//full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
$this->view->headScript()->appendScript("var timezoneOffset = ".date("Z")."; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/full-calendar-functions.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/schedule.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js','text/javascript');

View File

@ -77,8 +77,9 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
// which is something we don't want
'allowEmpty' => false,
'validators' => array(
new PasswordNotEmpty(array('UploadToSoundcloudOption'=>'1'))
)
new ConditionalNotEmpty(array('UploadToSoundcloudOption'=>'1'))
),
'renderPassword' => true
));
// Add the description element

View File

@ -28,7 +28,7 @@ class Application_Form_StreamSetting extends Zend_Form
}
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
$icecast_vorbis_metadata->setLabel('Icecast Vorbis Meatadata')
$icecast_vorbis_metadata->setLabel('Icecast Vorbis Metadata')
->setRequired(false)
->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0)
->setDecorators(array('ViewHelper'));

View File

@ -1538,23 +1538,44 @@ class Application_Model_Show {
return $event;
}
public function setShowFirstShow($s_date){
/* Takes in a UTC DateTime object.
* Converts this to local time, since cc_show days
* requires local time. */
public function setShowFirstShow($p_dt){
//clone object since we are modifying it and it was passed by reference.
$dt = clone $p_dt;
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId)
->findOne();
$showDay->setDbFirstShow($s_date)
$showDay->setDbFirstShow($dt)
->save();
Logging::log("setting show's first show.");
}
public function setShowLastShow($e_date){
/* Takes in a UTC DateTime object
* Converts this to local time, since cc_show days
* requires local time. */
public function setShowLastShow($p_dt){
//clone object since we are modifying it and it was passed by reference.
$dt = clone $p_dt;
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
//add one day since the Last Show date in CcShowDays is non-inclusive.
$dt->add(new DateInterval("P1D"));
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($this->_showId)
->findOne();
$showDay->setDbLastShow($e_date)
$showDay->setDbLastShow($dt)
->save();
}
@ -1573,7 +1594,8 @@ class Application_Model_Show {
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id"
." AND si.starts <= TIMESTAMP '$timeNow'"
." AND si.ends > TIMESTAMP '$timeNow'";
." AND si.ends > TIMESTAMP '$timeNow'"
." AND modified_instance != TRUE";
// Convert back to local timezone
$rows = $CC_DBC->GetAll($sql);
@ -1611,6 +1633,7 @@ class Application_Model_Show {
." WHERE si.show_id = s.id"
." AND si.starts >= TIMESTAMP '$timeStart'"
." AND si.starts < TIMESTAMP $timeEnd"
." AND modified_instance != TRUE"
." ORDER BY si.starts";
// defaults to retrieve all shows within the interval if $limit not set
@ -1633,6 +1656,9 @@ class Application_Model_Show {
public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) {
$timezone = date_default_timezone_get();
if (!is_array($rows)) {
return;
}
foreach($rows as &$row) {
foreach($columnsToConvert as $column) {
$row[$column] = Application_Model_DateHelper::ConvertToLocalDateTimeString($row[$column]);

View File

@ -29,6 +29,10 @@ class Application_Model_ShowInstance {
return new Application_Model_Show($this->getShowId());
}
/* This function is weird. It should return a boolean, but instead returns
* an integer if it is a rebroadcast, or returns null if it isn't. You can convert
* it to boolean by using is_null(isRebroadcast), where true means isn't and false
* means that it is. */
public function isRebroadcast()
{
return $this->_showInstance->getDbOriginalShow();
@ -231,9 +235,9 @@ class Application_Model_ShowInstance {
$this->correctScheduleStartTimes();
$show = new Application_Model_Show($this->getShowId());
if(!$show->isRepeating()){
$show->setShowFirstShow($new_starts);
$show->setShowLastShow($new_ends);
if(!$show->isRepeating() && is_null($this->isRebroadcast())){
$show->setShowFirstShow($newStartsDateTime);
$show->setShowLastShow($newEndsDateTime);
}
Application_Model_RabbitMq::PushSchedule();

View File

@ -22,6 +22,22 @@ class Application_Model_StreamSetting {
return $ids;
}
/* Retruns only global data as array*/
public static function getGlobalData(){
global $CC_DBC;
$sql = "SELECT * "
."FROM cc_stream_setting "
."WHERE keyname IN ('output_sound_device', 'icecast_vorbis_metadata')";
$rows = $CC_DBC->getAll($sql);
$data = array();
foreach($rows as $row){
$data[$row["keyname"]] = $row["value"];
}
return $data;
}
/* Returns all information related to a specific stream. An example
* of a stream id is 's1' or 's2'. */
public static function getStreamData($p_streamId){
@ -66,7 +82,6 @@ class Application_Model_StreamSetting {
$CC_DBC->query($sql);
}
else{
var_dump($key);
$temp = explode('_', $key);
$prefix = $temp[0];
foreach($d as $k=>$v){

View File

@ -6,3 +6,16 @@ $(document).ready(function() {
savePanelSpace: true
});
});
function adjustDateToServerDate(date, serverTimezoneOffset){
//date object stores time in the browser's localtime. We need to artificially shift
//it to
var timezoneOffset = date.getTimezoneOffset()*60*1000;
date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000);
/* date object has been shifted to artificial UTC time. Now let's
* shift it to the server's timezone */
return date;
}

View File

@ -204,7 +204,7 @@ $(document).ready(function() {
$("#datepicker").datepicker({
onSelect: function(dateText, inst)
{ getData();}});
$("#datepicker").datepicker("setDate", new Date());
$("#datepicker").datepicker("setDate", adjustDateToServerDate(new Date(), timezoneOffset));
} else {
$('#day_view').click(function(){redirect('/Nowplaying/day-view')});
}

View File

@ -23,7 +23,6 @@ function endDpSelect(dateText, inst) {
time = dateText.split("-");
date = new Date(time[0], time[1] - 1, time[2]);
//$("#add_show_start_date").datepicker( "option", "maxDate", date);
if (inst.input)
inst.input.trigger('change');
}
@ -32,7 +31,7 @@ function createDateInput(el, onSelect) {
var date;
el.datepicker({
minDate: new Date(),
minDate: adjustDateToServerDate(new Date(), timezoneOffset),
onSelect: onSelect,
dateFormat: 'yy-mm-dd'
});
@ -188,7 +187,7 @@ function setAddShowEvents() {
});
form.find('input[name^="add_show_rebroadcast_date_absolute"]').datepicker({
minDate: new Date(),
minDate: adjustDateToServerDate(new Date(), timezoneOffset),
dateFormat: 'yy-mm-dd'
});
form.find('input[name^="add_show_rebroadcast_time"]').timepicker({

View File

@ -75,19 +75,6 @@ function makeTimeStamp(date){
return timestamp;
}
function adjustDateToServerDate(date, serverTimezoneOffset){
//date object stores time in the browser's localtime. We need to artificially shift
//it to
var timezoneOffset = date.getTimezoneOffset()*60*1000;
date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000);
/* date object has been shifted to artificial UTC time. Now let's
* shift it to the server's timezone */
return date;
}
function pad(number, length) {
var str = '' + number;
while (str.length < length) {

View File

@ -50,7 +50,7 @@ martin@Thinkpad-T410:~/workspace/airtime/airtime_mvc/public/js/fullcalendar$ dif
+})(jQuery);
adjustDateToServerDate() function is defined in "js/airtime/schedule/full-calendar-functions.js"
adjustDateToServerDate() function is defined in "js/airtime/common/common.js"
Please make this change before updating!!!

View File

@ -38,14 +38,14 @@ echo -e "\n*** Creating Virtualenv for Airtime ***"
EXTRAOPTION=$(virtualenv --help | grep extra-search-dir)
if [ "$?" -eq "0" ]; then
virtualenv --extra-search-dir=${SCRIPTPATH}/3rd_party --no-site-package -p /usr/bin/python2.6 /usr/lib/airtime/airtime_virtualenv || exit 1
virtualenv --extra-search-dir=${SCRIPTPATH}/3rd_party --no-site-package -p /usr/bin/python2.6 /usr/lib/airtime/airtime_virtualenv 2>/dev/null || exit 1
else
# copy distribute-0.6.10.tar.gz to /usr/share/python-virtualenv/
# this is due to the bug in virtualenv 1.4.9
if [ -d "$VIRTUAL_ENV_SHARE" ]; then
cp ${SCRIPTPATH}/3rd_party/distribute-0.6.10.tar.gz /usr/share/python-virtualenv/
fi
virtualenv --no-site-package -p /usr/bin/python2.6 /usr/lib/airtime/airtime_virtualenv || exit 1
virtualenv --no-site-package -p /usr/bin/python2.6 /usr/lib/airtime/airtime_virtualenv 2>/dev/null || exit 1
fi
echo -e "\n*** Installing Python Libraries ***"