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

This commit is contained in:
denise 2012-07-30 18:53:57 -04:00
commit ecd926ae90
10 changed files with 207 additions and 124 deletions

View File

@ -27,6 +27,7 @@ class PlaylistController extends Zend_Controller_Action
->addActionContext('smart-block-criteria-save', 'json')
->addActionContext('smart-block-generate', 'json')
->addActionContext('smart-block-shuffle', 'json')
->addActionContext('get-block-info', 'json')
->initContext();
/*$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
@ -124,9 +125,9 @@ class PlaylistController extends Zend_Controller_Action
$this->view->error = $e->getMessage();
}
private function playlistDynamic($obj)
private function blockDynamic($obj)
{
$this->view->error = "You cannot add tracks to dynamic playlist.";
$this->view->error = "You cannot add tracks to dynamic block.";
$this->createFullResponse($obj);
}
@ -309,7 +310,7 @@ class PlaylistController extends Zend_Controller_Action
// if the dest is a block object
$obj->addAudioClips($ids, $afterItem, $addType);
} else {
throw new PlaylistDyanmicException;
throw new BlockDynamicException;
}
$this->createUpdateResponse($obj);
}
@ -319,8 +320,8 @@ class PlaylistController extends Zend_Controller_Action
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($obj_type);
}
catch (PlaylistDyanmicException $e) {
$this->playlistDynamic($obj);
catch (BlockDynamicException $e) {
$this->blockDynamic($obj);
}
catch (Exception $e) {
$this->playlistUnknownError($e);
@ -452,7 +453,7 @@ class PlaylistController extends Zend_Controller_Action
try {
$obj = $this->getPlaylist($type);
$obj->setPlaylistfades($fadeIn, $fadeOut);
$obj->setfades($fadeIn, $fadeOut);
$this->view->modified = $obj->getLastModified("U");
} catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($e);
@ -565,4 +566,18 @@ class PlaylistController extends Zend_Controller_Action
return $info;
}
public function getBlockInfoAction(){
$request = $this->getRequest();
$params = $request->getPost();
$bl = new Application_Model_Block($params['id']);
if ($bl->isStatic()) {
$out = $bl->getContents();
$out['isStatic'] = true;
} else {
$out = $bl->getCriteria();
$out['isStatic'] = false;
}
die(json_encode($out));
}
}

View File

@ -112,7 +112,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
->setValue($blockType);
$this->addElement($spType);
$storedCrit = Application_Model_Block::getCriteria($p_blockId);
$bl = new Application_Model_Block($p_blockId);
$storedCrit = $bl->getCriteria();
/* $modRoadMap stores the number of modifier rows each
* criteria row has. We need to know this so we display the

View File

@ -193,9 +193,11 @@ class Application_Model_Block
$files = array();
$sql = <<<"EOT"
SELECT pc.id as id, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout,
SELECT pc.id as id, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout, bl.type,
f.id as item_id, f.track_title, f.artist_name as creator, f.file_exists as exists, f.filepath as path FROM cc_blockcontents AS pc
LEFT JOIN cc_files AS f ON pc.file_id=f.id WHERE pc.block_id = {$this->id};
LEFT JOIN cc_files AS f ON pc.file_id=f.id
LEFT JOIN cc_block AS bl ON pc.block_id = bl.id
WHERE pc.block_id = {$this->id};
EOT;
$con = Propel::getConnection();
$rows = $con->query($sql)->fetchAll();
@ -1099,10 +1101,40 @@ EOT;
return $insertList;
}
public static function getCriteria($p_blockId)
public function getCriteria()
{
$criteriaOptions = array(
0 => "Select criteria",
"album_title" => "Album",
"bit_rate" => "Bit Rate",
"bpm" => "Bpm",
"comments" => "Comments",
"composer" => "Composer",
"conductor" => "Conductor",
"artist_name" => "Creator",
"disc_number" => "Disc Number",
"genre" => "Genre",
"isrc_number" => "ISRC",
"label" => "Label",
"language" => "Language",
"mtime" => "Last Modified",
"lptime" => "Last Played",
"length" => "Length",
"lyricist" => "Lyricist",
"mood" => "Mood",
"name" => "Name",
"orchestra" => "Orchestra",
"radio_station_name" => "Radio Station Name",
"rating" => "Rating",
"sample_rate" => "Sample Rate",
"track_title" => "Title",
"track_num" => "Track Number",
"utime" => "Uploaded",
"year" => "Year"
);
// Load criteria from db
$out = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($p_blockId);
$out = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($this->id);
$storedCrit = array();
foreach ($out as $crit) {
@ -1114,7 +1146,7 @@ EOT;
if ($criteria == "limit") {
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
} else {
$storedCrit["crit"][$criteria][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
$storedCrit["crit"][$criteria][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra, "display_name"=>$criteriaOptions[$criteria]);
}
}
@ -1125,45 +1157,34 @@ EOT;
// this function return list of propel object
public function getListofFilesMeetCriteria()
{
$out = CcBlockcriteriaQuery::create()->findByDbBlockId($this->id);
$storedCrit = array();
foreach ($out as $crit) {
$criteria = $crit->getDbCriteria();
$modifier = $crit->getDbModifier();
$value = $crit->getDbValue();
$extra = $crit->getDbExtra();
if($criteria == "limit"){
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
}else{
$storedCrit["crit"][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra);
}
}
$storedCrit = $this->getCriteria();
$qry = CcFilesQuery::create();
if (isset($storedCrit["crit"])) {
foreach ($storedCrit["crit"] as $criteria) {
$spCriteriaPhpName = self::$criteria2PeerMap[$criteria['criteria']];
$spCriteria = $criteria['criteria'];
$spCriteriaModifier = $criteria['modifier'];
$spCriteriaValue = $criteria['value'];
if ($spCriteriaModifier == "starts with") {
$spCriteriaValue = "$spCriteriaValue%";
} else if ($spCriteriaModifier == "ends with") {
$spCriteriaValue = "%$spCriteriaValue";
} else if ($spCriteriaModifier == "contains" || $spCriteriaModifier == "does not contain") {
$spCriteriaValue = "%$spCriteriaValue%";
} else if ($spCriteriaModifier == "is in the range") {
$spCriteriaValue = "$spCriteria > '$spCriteriaValue' AND $spCriteria < '$criteria[extra]'";
}
$spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier];
try{
$qry->filterBy($spCriteriaPhpName, $spCriteriaValue, $spCriteriaModifier);
$qry->addAscendingOrderByColumn('random()');
}catch (Exception $e){
Logging::log($e);
foreach ($storedCrit["crit"] as $crit) {
foreach ($crit as $criteria) {
$spCriteriaPhpName = self::$criteria2PeerMap[$criteria['criteria']];
$spCriteria = $criteria['criteria'];
$spCriteriaModifier = $criteria['modifier'];
$spCriteriaValue = $criteria['value'];
if ($spCriteriaModifier == "starts with") {
$spCriteriaValue = "$spCriteriaValue%";
} else if ($spCriteriaModifier == "ends with") {
$spCriteriaValue = "%$spCriteriaValue";
} else if ($spCriteriaModifier == "contains" || $spCriteriaModifier == "does not contain") {
$spCriteriaValue = "%$spCriteriaValue%";
} else if ($spCriteriaModifier == "is in the range") {
$spCriteriaValue = "$spCriteria > '$spCriteriaValue' AND $spCriteria < '$criteria[extra]'";
}
$spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier];
try{
$qry->filterBy($spCriteriaPhpName, $spCriteriaValue, $spCriteriaModifier);
$qry->addAscendingOrderByColumn('random()');
}catch (Exception $e){
Logging::log($e);
}
}
}
}

View File

@ -320,23 +320,6 @@ EOT;
}
}
/*private function buildStreamEntry($p_item, $pos)
{
$stream = CcWebstreamQuery::create()->findPK($p_item, $this->con);
if (isset($stream)) {
$entry = $this->plItem;
$entry["id"] = $stream->getDbId();
$entry["pos"] = $pos;
$entry["cliplength"] = $stream->getDbLength();
$entry["cueout"] = $stream->getDbLength();
return $entry;
} else {
throw new Exception("trying to add a stream that does not exist.");
}
}*/
/*
* @param array $p_items
* an array of audioclips to add to the playlist
@ -612,7 +595,7 @@ EOT;
return array("fadeIn" => $fadeIn, "fadeOut" => $fadeOut);
}
public function setPlaylistfades($fadein, $fadeout)
public function setfades($fadein, $fadeout)
{
if (isset($fadein)) {
Logging::log("Setting playlist fade in {$fadein}");
@ -872,4 +855,3 @@ EOT;
class PlaylistNotFoundException extends Exception {}
class PlaylistNoPermissionException extends Exception {}
class PlaylistOutDatedException extends Exception {}
class PlaylistDyanmicException extends Exception {}

View File

@ -182,9 +182,13 @@ class Application_Model_Scheduler
$data["id"] = $file->getDbId();
$data["cliplength"] = $file->getDbLength();
$data["cuein"] = "00:00:00";
$data["cueout"] = "00:00:00";
$data["fadein"] = "00:00:00";
$data["fadeout"] = "00:00:00";
$data["cueout"] = $file->getDbLength();
$defaultFade = Application_Model_Preference::GetDefaultFade();
if (isset($defaultFade)) {
//fade is in format SS.uuuuuu
$data["fadein"] = $defaultFade;
$data["fadeout"] = $defaultFade;
}
$data["type"] = 0;
$files[] = $data;
}
@ -192,48 +196,6 @@ class Application_Model_Scheduler
}
}
}
// find if the playslit is static or dynamic
/*$c = new Criteria();
$c->add(CcPlaylistPeer::ID, $id);
$pl = CcPlaylistPeer::doSelect($c);
$playlistType = $pl[0]->getDbType();
if ($playlistType == "static") {
$contents = CcPlaylistcontentsQuery::create()
->orderByDbPosition()
->filterByDbPlaylistId($id)
->find($this->con);
} else {
$pl = new Application_Model_Playlist($id);
$contents = $pl->getListOfFilesUnderLimit();
}
if (is_null($contents)) {
throw new Exception("A selected Playlist does not exist!");
}*/
/*foreach ($contents as $fileId => $plItem) {
$data = $this->fileInfo;
if ($plItem['type'] == 0){
$file = $plItem->getCcFiles($this->con);
if (isset($file) && $file->getDbFileExists()) {
$data["id"] = $plItem->getDbFileId();
$data["cliplength"] = $plItem->getDbCliplength();
$data["cuein"] = $plItem->getDbCuein();
$data["cueout"] = $plItem->getDbCueout();
$data["fadein"] = $plItem->getDbFadein();
$data["fadeout"] = $plItem->getDbFadeout();
}
} else {
// on dynamic playslsit, $fileId is id of files
$file = Application_Model_StoredFile::Recall($fileId)->getPropelOrm();
if (isset($file) && $file->getDbFileExists()) {
$data["id"] = $fileId;
$data["cliplength"] = $file->getDbLength();
}
}
$files[] = $data;
}*/
} else if ($type == "stream") {
//need to return
$stream = CcWebstreamQuery::create()->findPK($id, $this->con);
@ -256,6 +218,39 @@ class Application_Model_Scheduler
$files[] = $data;
}
} else if ($type == "block") {
$bl = new Application_Model_Block($id);
if ($bl->isStatic()) {
foreach ($bl->getContents() as $track) {
$data["id"] = $track['item_id'];
$data["cliplength"] = $track['length'];
$data["cuein"] = $track['cuein'];
$data["cueout"] = $track['cueout'];
$data["fadein"] = $track['fadein'];
$data["fadeout"] = $track['fadeout'];
$data["type"] = 0;
$files[] = $data;
}
} else {
$dynamicFiles = $bl->getListOfFilesUnderLimit();
foreach ($dynamicFiles as $fileId=>$f) {
$file = CcFilesQuery::create()->findPk($fileId);
if (isset($file) && $file->getDbFileExists()) {
$data["id"] = $file->getDbId();
$data["cliplength"] = $file->getDbLength();
$data["cuein"] = "00:00:00";
$data["cueout"] = $file->getDbLength();
$defaultFade = Application_Model_Preference::GetDefaultFade();
if (isset($defaultFade)) {
//fade is in format SS.uuuuuu
$data["fadein"] = $defaultFade;
$data["fadeout"] = $defaultFade;
}
$data["type"] = 0;
$files[] = $data;
}
}
}
}
return $files;
}

View File

@ -1,12 +1,16 @@
<dl id="spl_editor" class="inline-list">
<?php if ($this->item1Type == 0) {?>
<dt>Fade out (s):</dt>
<dd id="spl_fade_out_<?php echo $this->item1; ?>" class="spl_fade_out">
<span contenteditable="true" class="spl_text_input"><?php echo $this->fadeOut; ?></span>
</dd>
<dd class="edit-error"></dd>
<?php }
if ($this->item2Type == 0) {?>
<dt>Fade in (s):</dt>
<dd id="spl_fade_in_<?php echo $this->item2; ?>" class="spl_fade_in">
<span contenteditable="true" class="spl_text_input"><?php echo $this->fadeIn; ?></span>
</dd>
<dd class="edit-error"></dd>
<?php }?>
</dl>

View File

@ -2,23 +2,40 @@
$items = $this->obj->getContents();
if (count($items)) : ?>
<?php $i = 0; ?>
<?php foreach($items as $item) : ?>
<?php foreach($items as $item) :
$staticBlock = null;
if ($item['type'] == 2) {
$bl= new Application_Model_Block($item['item_id']);
$staticBlock = $bl->isStatic();
}
?>
<li class="ui-state-default" id="spl_<?php echo $item["id"] ?>" unqid="<?php echo $item["id"]; ?>">
<div class="list-item-container">
<?php if ($item['exists']):?>
<?php if ($item['type'] == 0 && $item['exists']):?>
<div class="big_play" audioFile="<?php echo $item["id"]; ?>">
<span class="ui-icon ui-icon-play"></span>
</div>
<?php elseif ($item['type'] == 2 && $item['exists']): ?>
<div class="big_play ui-state-hover">
<span class="ui-icon ui-icon-alert"></span>
</div>
<?php else: ?>
<div class="big_play ui-state-hover">
<span class="ui-icon ui-icon-alert"></span>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="text-row top">
<span class="spl_playlength"><?php echo $item["length"] ?></span>
<?php if ($item['type'] == 0) {?>
<span class="spl_cue ui-state-default"></span>
<?php } else if ($item['type'] == 2) {
if ($staticBlock) {?>
<span class="spl_block_expand close" id="expand_block_<?php echo $item['item_id']?>">Static Block Expand</span>
<?php } else { ?>
<span class="spl_block_expand close" id="expand_block_<?php echo $item['item_id']?>">Dynamic Block</span>
<?php }
} ?>
<span class="spl_title"><?php echo $item['track_title'] ?></span>
</div>
<div class="text-row">
@ -32,7 +49,7 @@ if (count($items)) : ?>
<?php endif; ?>
<span id="remove_<?php echo $item["id"] ?>" class="ui-icon ui-icon-closethick"></span>
</div>
<?php if ($item['type'] == 0) {?>
<div id="cues_<?php echo $i ?>" class="cue-edit clearfix" style="display: none">
<?php echo $this->partial('playlist/set-cue.phtml', array(
'id' => $item["id"],
@ -40,6 +57,7 @@ if (count($items)) : ?>
'cueOut' => $item['cueout'],
'origLength' => $item['length'])); ?>
</div>
<?php }?>
<?php //create a fade editor box
@ -50,11 +68,15 @@ if (count($items)) : ?>
<?php echo $this->partial('playlist/set-fade.phtml', array(
'item1' => $items[$i]['id'],
'item2' => $items[$i+1]['id'],
'item1Type' => $items[$i]['type'],
'item2Type' => $items[$i+1]['type'],
'fadeOut' => $items[$i]['fadeout'],
'fadeIn' => $items[$i+1]['fadein'])); ?>
</div>
<?php endif; ?>
<?php if ($item['type'] == 2) {?>
<div id="block_<?php echo $item['item_id']?>_info"></div>
<?php } ?>
</li>
<?php $i = $i+1; ?>
<?php endforeach; ?>

View File

@ -79,6 +79,16 @@
text-align:right;
}
.spl_block_expand {
float:right;
font-size: 9px;
height: 15px;
right: 35px;
width: 100px;
margin-top:2px;
cursor:pointer;
}
.spl_artist {
font-size:12px;
color:#d5d5d5;

View File

@ -88,8 +88,7 @@ var AIRTIME = (function(AIRTIME){
});
};
mod.dblClickAdd = function(id, type) {
mod.dblClickAdd = function(data, type) {
var i,
length,
temp,
@ -98,7 +97,7 @@ var AIRTIME = (function(AIRTIME){
aData = [];
//process selected files/playlists.
aMediaIds.push({"id": id, "type": type});
aMediaIds.push({"id": data.id, "type": type});
$("#show_builder_table tr.cursor-selected-row").each(function(i, el){
aData.push($(el).prev().data("aData"));
@ -114,6 +113,7 @@ var AIRTIME = (function(AIRTIME){
alert("Please select a cursor position on timeline.");
return false;
}
console.log(aMediaIds);
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
};

View File

@ -352,6 +352,40 @@ var AIRTIME = (function(AIRTIME){
//add the play function to the play icon
$pl.delegate(".big_play",
{"click": openAudioPreview});
$pl.delegate(".spl_block_expand",
{"click": function(ev){
var id = parseInt($(this).attr("id").split("_").pop(), 10);
if ($(this).hasClass('close')) {
var sUrl = "/playlist/get-block-info";
mod.disableUI();
$.post(sUrl, {format:"json", id:id}, function(json){
$html = "";
var data = $.parseJSON(json);
var isStatic = data.isStatic;
delete data.type;
if (isStatic) {
$.each(data, function(index, ele){
$html += "<div>"+ele.track_title+" "+ele.creator+" "+ele.length+"</div>";
})
} else {
for (var key in data.crit){
$.each(data.crit[key], function(index, ele){
var extra = (ele['extra']==null)?"":ele['extra'];
$html += "<div>"+ele['display_name']+" "+ele['modifier']+" "+ele['value']+" "+extra+"</div>";
});
}
$html += "<div>"+data.limit.value+" "+data.limit.modifier;
}
$pl.find("#block_"+id+"_info").html($html);
mod.enableUI();
});
$(this).removeClass('close');
} else {
$pl.find("#block_"+id+"_info").html("");
$(this).addClass('close');
}
}});
}
//sets events dynamically for the cue editor.
@ -384,7 +418,7 @@ var AIRTIME = (function(AIRTIME){
//main playlist fades events
$pl.on("click", "#spl_crossfade", function() {
var lastMod = getModified(),
type = $('#obj_type');
type = $('#obj_type').val();
if ($(this).hasClass("ui-state-active")) {
$(this).removeClass("ui-state-active");
@ -394,8 +428,7 @@ var AIRTIME = (function(AIRTIME){
$(this).addClass("ui-state-active");
var url = '/Playlist/get-playlist-fades';
$.get(url,
$.post(url,
{format: "json", modified: lastMod, type: type},
function(json){
if (json.error !== undefined){