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

This commit is contained in:
Martin Konecny 2012-08-02 16:27:00 -04:00
commit a146fdcd37
45 changed files with 1725 additions and 58 deletions

View file

@ -127,7 +127,7 @@ class PlaylistController extends Zend_Controller_Action
private function blockDynamic($obj)
{
$this->view->error = "You cannot add tracks to dynamic block.";
$this->view->error = "You cannot add tracks to dynamic blocks.";
$this->createFullResponse($obj);
}
@ -152,6 +152,11 @@ class PlaylistController extends Zend_Controller_Action
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
}
private function playlistDenied($obj) {
$this->view->error = "You cannot add playlists to smart playlists.";
$this->createFullResponse($obj);
}
public function indexAction()
{
@ -307,9 +312,15 @@ class PlaylistController extends Zend_Controller_Action
$obj->addAudioClips($ids, $afterItem, $addType);
} else if ($obj->isStatic()) {
// if the dest is a block object
//check if any items are playlists
foreach($ids as $id) {
if (is_array($id) && isset($id[1]) && $id[1] == 'playlist') {
throw new Exception('playlist to block');
}
}
$obj->addAudioClips($ids, $afterItem, $addType);
} else {
throw new BlockDynamicException;
throw new Exception('track to dynamic');
}
$this->createUpdateResponse($obj);
}
@ -319,11 +330,14 @@ class PlaylistController extends Zend_Controller_Action
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($obj_type);
}
catch (BlockDynamicException $e) {
$this->blockDynamic($obj);
}
catch (Exception $e) {
$this->playlistUnknownError($e);
if ($e->getMessage() == 'playlist to block') {
$this->playlistDenied($obj);
} else if ($e->getMessage() == 'track to dynamic') {
$this->blockDynamic($obj);
} else {
$this->playlistUnknownError($e);
}
}
}

View file

@ -33,7 +33,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
"rating" => "Rating",
"sample_rate" => "Sample Rate",
"track_title" => "Title",
"track_num" => "Track Number",
"track_number" => "Track Number",
"utime" => "Uploaded",
"year" => "Year"
);
@ -64,7 +64,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
"rating" => "n",
"sample_rate" => "n",
"track_title" => "s",
"track_num" => "n",
"track_number" => "n",
"year" => "n"
);

View file

@ -76,11 +76,11 @@ class Application_Model_Block
"mood" => "DbMood",
"name" => "DbName",
"orchestra" => "DbOrchestra",
"radio_station_name" => "DbRadioStation",
"radio_station_name" => "DbRadioStationName",
"rating" => "DbRating",
"sample_rate" => "DbSampleRate",
"track_title" => "DbTrackTitle",
"track_num" => "DbTrackNum",
"track_number" => "DbTrackNumber",
"year" => "DbYear"
);
@ -245,11 +245,35 @@ EOT;
// function return "N/A" if dynamic
public function getLength()
{
$length = $this->block->getDbLength();
if ($this->isStatic()){
$length = $this->block->getDbLength();
} else {
$length = $this->getDynamicBlockLength();
}
$length = $length == null ? "N/A" : $length;
return $length;
}
public function getDynamicBlockLength()
{
$result = CcBlockcriteriaQuery::create()->filterByDbBlockId($this->id)
->filterByDbCriteria('limit')->findOne();
$modifier = $result->getDbModifier();
$value = $result->getDbValue();
if ($modifier == "items") {
$length = $value." ".$modifier;
} else {
if ($modifier == "minutes") {
$timestamp = "00:".$value.":00";
} else if ($modifier == "hours") {
$timestamp = $value.":00:00.0";
}
$formatter = new LengthFormatter($timestamp);
$length = "~".$formatter->format();
}
return $length;
}
//
public function getStaticLength(){
$sql = "SELECT SUM(cliplength) as length FROM cc_blockcontents WHERE block_id={$this->id}";
@ -364,9 +388,14 @@ EOT;
foreach ($p_items as $ac) {
Logging::log("Adding audio file {$ac}");
$res = $this->insertBlockElement($this->buildEntry($ac, $pos));
$pos = $pos + 1;
if (is_array($ac) && $ac[1] == 'audioclip') {
$res = $this->insertBlockElement($this->buildEntry($ac[0], $pos));
$pos = $pos + 1;
} elseif (!is_array($ac)) {
$res = $this->insertBlockElement($this->buildEntry($ac, $pos));
$pos = $pos + 1;
}
}
//reset the positions of the remaining items.
@ -1033,7 +1062,7 @@ EOT;
// as it cannot be calculated
if ($blockType == 'dynamic') {
$this->setLength(null);
$output['blockLength'] = "N/A";
$output['blockLength'] = $this->getDynamicBlockLength();
} else {
$length = $this->getStaticLength();
$this->setLength($length);
@ -1169,7 +1198,7 @@ EOT;
"rating" => "Rating",
"sample_rate" => "Sample Rate",
"track_title" => "Title",
"track_num" => "Track Number",
"track_number" => "Track Number",
"utime" => "Uploaded",
"year" => "Year"
);

View file

@ -93,6 +93,9 @@ class Application_Model_Datatables
if ($r['ftype'] == 'playlist') {
$pl = new Application_Model_Playlist($r['id']);
$r['length'] = $pl->getLength();
} else if ($r['ftype'] == "block") {
$bl = new Application_Model_Block($r['id']);
$r['length'] = $bl->getLength();
}
}
} catch (Exception $e) {

View file

@ -196,7 +196,12 @@ EOT;
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
//format the length for UI.
$formatter = new LengthFormatter($row['length']);
if ($row['type'] == 2){
$bl = new Application_Model_Block($row['item_id']);
$formatter = new LengthFormatter($bl->getLength());
} else {
$formatter = new LengthFormatter($row['length']);
}
$row['length'] = $formatter->format();
$formatter = new LengthFormatter($offset_cliplength);
@ -268,7 +273,6 @@ EOT;
//aggregate column on playlistcontents cliplength column.
public function getLength()
{
Logging::log($this->hasDynamicBlockOrWebStream());
if ($this->hasDynamicBlockOrWebStream()){
return "N/A";
} else {

View file

@ -39,7 +39,7 @@ class CcBlockcriteriaTableMap extends TableMap {
$this->setPrimaryKeyMethodInfo('cc_blockcriteria_id_seq');
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('CRITERIA', 'DbCriteria', 'VARCHAR', true, 16, null);
$this->addColumn('CRITERIA', 'DbCriteria', 'VARCHAR', true, 32, null);
$this->addColumn('MODIFIER', 'DbModifier', 'VARCHAR', true, 16, null);
$this->addColumn('VALUE', 'DbValue', 'VARCHAR', true, 512, null);
$this->addColumn('EXTRA', 'DbExtra', 'VARCHAR', false, 512, null);

View file

@ -16,8 +16,8 @@ class LengthFormatter {
}
public function format() {
if ($this->_length == "N/A" || $this->_length == "") {
return "N/A";
if (!preg_match("/^[0-9]{2}:[0-9]{2}:[0-9]{2}/", $this->_length)) {
return $this->_length;
}
$pieces = explode(":", $this->_length);

View file

@ -1,24 +1,25 @@
<?php if($this->type == "audioclip") : ?>
<div><span>Title:</span><span><?php echo ($this->md["MDATA_KEY_TITLE"]);?></span></div>
<div><span>Creator:</span><span><?php echo ($this->md["MDATA_KEY_CREATOR"]);?></span></div>
<div><span>Album:</span><span><?php echo ($this->md["MDATA_KEY_SOURCE"]);?></span></div>
<div><span>Track:</span><span><?php echo ($this->md["MDATA_KEY_TRACKNUMBER"]);?></span></div>
<div><span>Length:</span><span><?php echo ($this->md["MDATA_KEY_DURATION"]);?></span></div>
<div><span>Sample Rate:</span><span><?php echo ($this->md["MDATA_KEY_SAMPLERATE"]);?></span></div>
<div><span>Bit Rate:</span><span><?php echo ($this->md["MDATA_KEY_BITRATE"]);?></span></div>
<div><span>Mood:</span><span><?php echo ($this->md["MDATA_KEY_MOOD"]);?></span></div>
<div><span>Genre:</span><span><?php echo ($this->md["MDATA_KEY_GENRE"]);?></span></div>
<div><span>Year:</span><span><?php echo ($this->md["MDATA_KEY_YEAR"]);?></span></div>
<div><span>Label:</span><span><?php echo ($this->md["MDATA_KEY_LABEL"]);?></span></div>
<div><span>BPM:</span><span><?php echo ($this->md["MDATA_KEY_BPM"]);?></span></div>
<div><span>Composer:</span><span><?php echo ($this->md["MDATA_KEY_COMPOSER"]);?></span></div>
<div><span>Conductor:</span><span><?php echo ($this->md["MDATA_KEY_CONDUCTOR"]);?></span></div>
<div><span>Copyright:</span><span><?php echo ($this->md["MDATA_KEY_COPYRIGHT"]);?></span></div>
<div><span>Isrc Number:</span><span><?php echo ($this->md["MDATA_KEY_ISRC"]);?></span></div>
<div><span>Website:</span><span><?php echo ($this->md["MDATA_KEY_URL"]);?></span></div>
<div><span>Language:</span><span><?php echo ($this->md["MDATA_KEY_LANGUAGE"]);?></span></div>
<div><span>File&nbsp;Path:</span><span><?php echo ($this->md["MDATA_KEY_FILEPATH"]);?></span></div>
<table class='library-track-md'>
<tr><td>Title:</td><td><?php echo ($this->md["MDATA_KEY_TITLE"]);?></td></tr>
<tr><td>Creator:</td><td><?php echo ($this->md["MDATA_KEY_CREATOR"]);?></td></tr>
<tr><td>Album:</td><td><?php echo ($this->md["MDATA_KEY_SOURCE"]);?></td></tr>
<tr><td>Track:</td><td><?php echo ($this->md["MDATA_KEY_TRACKNUMBER"]);?></td></tr>
<tr><td>Length:</td><td><?php echo ($this->md["MDATA_KEY_DURATION"]);?></td></tr>
<tr><td>Sample Rate:</td><td><?php echo ($this->md["MDATA_KEY_SAMPLERATE"]);?></td></tr>
<tr><td>Bit Rate:</td><td><?php echo ($this->md["MDATA_KEY_BITRATE"]);?></td></tr>
<tr><td>Mood:</td><td><?php echo ($this->md["MDATA_KEY_MOOD"]);?></td></tr>
<tr><td>Genre:</td><td><?php echo ($this->md["MDATA_KEY_GENRE"]);?></td></tr>
<tr><td>Year:</td><td><?php echo ($this->md["MDATA_KEY_YEAR"]);?></td></tr>
<tr><td>Label:</td><td><?php echo ($this->md["MDATA_KEY_LABEL"]);?></td></tr>
<tr><td>BPM:</td><td><?php echo ($this->md["MDATA_KEY_BPM"]);?></td></tr>
<tr><td>Composer:</td><td><?php echo ($this->md["MDATA_KEY_COMPOSER"]);?></td></tr>
<tr><td>Conductor:</td><td><?php echo ($this->md["MDATA_KEY_CONDUCTOR"]);?></td></tr>
<tr><td>Copyright:</td><td><?php echo ($this->md["MDATA_KEY_COPYRIGHT"]);?></td></tr>
<tr><td>Isrc Number:</td><td><?php echo ($this->md["MDATA_KEY_ISRC"]);?></td></tr>
<tr><td>Website:</td><td><?php echo ($this->md["MDATA_KEY_URL"]);?></td></tr>
<tr><td>Language:</td><td><?php echo ($this->md["MDATA_KEY_LANGUAGE"]);?></td></tr>
<tr><td>File&nbsp;Path:</td><td><?php echo ($this->md["MDATA_KEY_FILEPATH"]);?></td></tr>
</table>
<?php endif; ?>
<?php if($this->type == "playlist" || $this->type == "block") : ?>
@ -93,18 +94,22 @@
<?php } elseif ($this->blType == "Dynamic") { ?>
<div><span>Dynamic Playlist Criteria: </span></div>
<table class='library-get-file-md'>
<table class='library-get-file-md table-small'>
<?php foreach ($this->contents["crit"] as $criterias) : ?>
<?php foreach ($criterias as $crit ) : ?>
<?php
$maxStrLen = 25;
if (strlen($crit["value"]) > $maxStrLen) {
$valMaxStrLen = 25;
if (strlen($crit["value"]) > $valMaxStrLen) {
$crit["value"] = substr($crit["value"], 0, 24)."...";
}
$critMaxStrLen = 13;
if (strlen($crit["display_name"]) > $critMaxStrLen) {
$crit["display_name"] = substr($crit["display_name"], 0, 12)."...";
}
?>
<tr>
<td class='file-md-qtip-criteria-width-small'><?php echo $crit["display_name"] ?></td>
<td class='file-md-qtip-criteria-width-small'><?php echo $crit["modifier"] ?></td>
<td class='file-md-qtip-criteria-width-crit'><?php echo $crit["display_name"] ?></td>
<td class='file-md-qtip-criteria-width-mod'><?php echo $crit["modifier"] ?></td>
<td class='file-md-qtip-criteria-width'><?php echo $crit["value"] ?>
<?php if (isset($crit["extra"])) { ?>
to <?php echo $crit["extra"] ?></td>