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

@ -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);