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

This commit is contained in:
Naomi Aro 2012-04-25 12:51:00 +02:00
commit 7aeddf5bb0
15 changed files with 122 additions and 60 deletions

View File

@ -42,4 +42,25 @@ class Application_Common_OsPath{
else
return '.';
}
/* Similar to the os.path.join python method
* http://stackoverflow.com/a/1782990/276949 */
function join() {
$args = func_get_args();
$paths = array();
foreach($args as $arg) {
$paths = array_merge($paths, (array)$arg);
}
foreach($paths as &$path) {
$path = trim($path, DIRECTORY_SEPARATOR);
}
if (substr($args[0], 0, 1) == DIRECTORY_SEPARATOR) {
$paths[0] = DIRECTORY_SEPARATOR . $paths[0];
}
return join(DIRECTORY_SEPARATOR, $paths);
}
}

View File

@ -37,12 +37,13 @@ $ccAcl->allow('G', 'index')
->allow('H', 'usersettings')
->allow('H', 'plupload')
->allow('H', 'library')
->allow('H', 'playlist')
->allow('A', 'playouthistory')
->allow('A', 'user')
->allow('A', 'systemstatus')
->allow('A', 'preference')
->allow('A', 'audiopreview');
->allow('H', 'playlist')
->allow('H', 'audiopreview')
->allow('A', 'playouthistory')
->allow('A', 'user')
->allow('A', 'systemstatus')
->allow('A', 'preference');
$aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl);

View File

@ -98,7 +98,7 @@ class AudiopreviewController extends Zend_Controller_Action
$pl = new Application_Model_Playlist($playlistID);
$result = Array();
foreach ( $pl->getContents() as $track ){
foreach ( $pl->getContents(true) as $track ){
$elementMap = array( 'element_title' => isset($track['CcFiles']['track_title'])?$track['CcFiles']['track_title']:"",
'element_artist' => isset($track['CcFiles']['artist_name'])?$track['CcFiles']['artist_name']:"",
@ -115,7 +115,7 @@ class AudiopreviewController extends Zend_Controller_Action
}
$result[] = $elementMap;
}
$this->_helper->json($result);
}

View File

@ -373,7 +373,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->switch_status = $switch_status;
$this->view->entries = $range;
$this->view->show_name = $show[0]["name"];
$this->view->show_name = isset($show[0])?$show[0]["name"]:"";
}
public function removeGroupAction()
@ -752,12 +752,11 @@ class ScheduleController extends Zend_Controller_Action
//Changing the start date was disabled, since the
//array key does not exist. We need to repopulate this entry from the db.
//The start date will be returned in UTC time, so lets convert it to local time.
$dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDate());
$dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime());
$data['add_show_start_date'] = $dt->format("Y-m-d");
if (!array_key_exists('add_show_start_time', $data)){
$startTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartTime());
$data['add_show_start_time'] = $startTime->format("H:i");
$data['add_show_start_time'] = $dt->format("H:i");
$validateStartTime = false;
}
$validateStartDate = false;

View File

@ -99,10 +99,8 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$live_dj_connection_url = "N/A";
}
$overrideDescription = "If Airtime is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151. For more detail, please read the <a target=\"_blank\" href=\"http://manuals.sourcefabric.org/\">Airtime manual</a>.";
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url,'overrideDescription' => $overrideDescription))
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url))
));
}

View File

@ -140,18 +140,26 @@ class Application_Model_Playlist {
/**
* Get the entire playlist as a two dimentional array, sorted in order of play.
* @param boolean $filterFiles if this is true, it will only return files that has
* file_exists flag set to true
* @return array
*/
public function getContents() {
public function getContents($filterFiles=false) {
Logging::log("Getting contents for playlist {$this->id}");
$files = array();
$rows = CcPlaylistcontentsQuery::create()
->joinWith('CcFiles')
->orderByDbPosition()
->filterByDbPlaylistId($this->id)
->find($this->con);
$query = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id);
if($filterFiles){
$query->useCcFilesQuery()
->filterByDbFileExists(true)
->endUse();
}
$query->orderByDbPosition()
->leftJoinWith('CcFiles');
$rows = $query->find($this->con);
$i = 0;
$offset = 0;

View File

@ -557,15 +557,15 @@ class Application_Model_Show {
$con->exec($sql);
}
/**
* Get the start date of the current show in UTC timezone.
*
* @return string
* The start date in the format YYYY-MM-DD
*/
public function getStartDate(){
$con = Propel::getConnection();
public function getStartDateAndTime(){
$con = Propel::getConnection();
$showId = $this->getId();
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
@ -583,10 +583,21 @@ class Application_Model_Show {
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
$dt->setTimezone(new DateTimeZone("UTC"));
return $dt->format("Y-m-d");
return $dt->format("Y-m-d H:i");
}
}
/**
* Get the start date of the current show in UTC timezone.
*
* @return string
* The start date in the format YYYY-MM-DD
*/
public function getStartDate(){
list($date,) = explode(" ", $this->getStartDateAndTime());
return $date;
}
/**
* Get the start time of the current show in UTC timezone.
*
@ -595,25 +606,8 @@ class Application_Model_Show {
*/
public function getStartTime(){
$con = Propel::getConnection();
$showId = $this->getId();
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
." WHERE show_id = $showId"
." ORDER BY first_show"
." LIMIT 1";
$query = $con->query($sql);
if ($query->rowCount() == 0){
return "";
} else {
$rows = $query->fetchAll();
$row = $rows[0];
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
$dt->setTimezone(new DateTimeZone("UTC"));
return $dt->format("H:i");
}
list(,$time) = explode(" ", $this->getStartDateAndTime());
return $time;
}
/**
@ -856,8 +850,8 @@ class Application_Model_Show {
." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
." AND show_id = $showId";
$query = $con->query();
$row = $query ? $query->fetchColumn(0) : null;
$query = $con->query($sql);
$row = ($query !== false) ? $query->fetchColumn(0) : null;
return CcShowInstancesQuery::create()
->findPk($row);
}

View File

@ -224,7 +224,7 @@ class Application_Model_ShowBuilder {
$this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row);
$row["id"] = intval($p_item["sched_id"]);
$row["image"] = $p_item["file_exists"] == "t" ? true : false;
$row["image"] = $p_item["file_exists"];
$row["instance"] = intval($p_item["si_id"]);
$row["starts"] = $schedStartDT->format("H:i:s");
$row["ends"] = $schedEndDT->format("H:i:s");

View File

@ -841,8 +841,7 @@ Logging::log("getting media! - 2");
//check to see if there is enough space in $stor to continue.
$enough_space = Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file);
if ($enough_space){
$stor .= "/organize";
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
$audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
Logging::log("copyFileToStor: moving file $audio_file to $audio_stor");
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation

View File

@ -77,10 +77,7 @@
</dt>
<dd id="master_dj_connection_url-element">
<span id="stream_url"><?php echo $this->master_dj_connection_url ?></span> <a href=# id="connection_url_override" style="font-size: 12px;">override</a>&nbsp;&nbsp;
<span class='info-tooltip'>
<span>
<?php echo $this->overrideDescription ?>
</span>
<span class="override_help_icon">
</span><br>
<div id="master_dj_connection_url_tb" style="display:none"><input type="text"><a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a></div>
</dd>
@ -118,10 +115,7 @@
</dt>
<dd id="live_dj_connection_url-element">
<span id="stream_url"><?php echo $this->live_dj_connection_url ?></span> <a href=# id="connection_url_override" style="font-size: 12px;">override</a>&nbsp;&nbsp;
<span class='info-tooltip'>
<span>
<?php echo $this->overrideDescription?>
</span>
<span class="override_help_icon">
</span><br>
<div id="live_dj_connection_url_tb" style="display:none"><input type="text"><a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a></div>
</dd>

View File

@ -93,6 +93,17 @@ select {
}
/* Version Notification Ends*/
.override_help_icon {
cursor: help;
position: relative;
display:inline-block; zoom:1; display:inline;
width:14px; height:14px;
background:url(/css/images/icon_info.png) 0 0 no-repeat;
float:right; position:relative; top:2px; right:7px;
line-height:16px !important;
}
/* Info Tooltip Starts */
.info-tooltip {
cursor: help;

View File

@ -114,7 +114,9 @@ function buildplaylist(p_url, p_playIndex) {
}
myPlaylist[index] = media;
_idToPostionLookUp[data[index]['element_id']] = data[index]['element_position'];
// we should create a map according to the new position in the player itself
// total is the index on the player
_idToPostionLookUp[data[index]['element_id']] = total;
total++;
}
@ -135,6 +137,9 @@ function buildplaylist(p_url, p_playIndex) {
*/
function play(p_playlistIndex){
playlistIndex = _idToPostionLookUp[p_playlistIndex];
if(playlistIndex == undefined){
playlistIndex = 0
}
//_playlist_jplayer.select(playlistIndex);
_playlist_jplayer.play(playlistIndex);
}

View File

@ -85,8 +85,8 @@ function updateProgressBarValue(){
if (songPercentDone < 0 || songPercentDone > 100){
songPercentDone = 0;
currentSong = null;
} else {
if (currentSong.media_item_played == "t" && currentShow.length > 0){
} else {
if (currentSong.media_item_played == true && currentShow.length > 0){
scheduled_play_line_to_switch.attr("class", "line-to-switch on");
scheduled_play_div.addClass("ready")
scheduled_play_source = true;

View File

@ -235,4 +235,26 @@ $(document).ready(function() {
showErrorSections()
setInterval('checkLiquidsoapStatus()', 1000)
// qtip for help text
$(".override_help_icon").qtip({
content: {
text: "If Airtime is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151. For more detail, please read the <a target=\"_blank\" href=\"http://manuals.sourcefabric.org/\">Airtime manual</a>."
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
})
});

View File

@ -5,6 +5,7 @@ import sys
import os
import signal
import traceback
import locale
from api_clients import api_client as apc
from std_err_override import LogWriter
@ -38,7 +39,16 @@ except Exception, e:
logger.info("\n\n*** Media Monitor bootup ***\n\n")
try:
fs_encoding = locale.getdefaultlocale()[1].lower()
if fs_encoding not in ['utf-8', 'utf8']:
logger.error("Filesystem encoding needs to be UTF-8. Currently '%s'. Exiting..." % fs_encoding)
sys.exit(1)
else:
logger.debug("Filesystem encoding: '%s'" % fs_encoding)
config = AirtimeMediaConfig(logger)
api_client = apc.api_client_factory(config.cfg)
api_client.register_component("media-monitor")