diff --git a/airtime_mvc/application/controllers/AudiopreviewController.php b/airtime_mvc/application/controllers/AudiopreviewController.php index 037eeca30..948d57c7a 100644 --- a/airtime_mvc/application/controllers/AudiopreviewController.php +++ b/airtime_mvc/application/controllers/AudiopreviewController.php @@ -101,16 +101,16 @@ class AudiopreviewController extends Zend_Controller_Action 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']:"", + $elementMap = array( 'element_title' => isset($track['track_title'])?$track['track_title']:"", + 'element_artist' => isset($track['artist_name'])?$track['artist_name']:"", 'element_id' => isset($track['id'])?$track['id']:"", 'element_position' => isset($track['position'])?$track['position']:"", ); - $fileExtension = pathinfo($track['CcFiles']['filepath'], PATHINFO_EXTENSION); + $fileExtension = pathinfo($track['filepath'], PATHINFO_EXTENSION); if (strtolower($fileExtension) === 'mp3') { - $elementMap['element_mp3'] = $track['CcFiles']['gunid'].'.'.$fileExtension; + $elementMap['element_mp3'] = $track['gunid'].'.'.$fileExtension; } elseif (strtolower($fileExtension) === 'ogg') { - $elementMap['element_oga'] = $track['CcFiles']['gunid'].'.'.$fileExtension; + $elementMap['element_oga'] = $track['gunid'].'.'.$fileExtension; } else { //the media was neither mp3 or ogg } diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 570f35326..30e62f5b8 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -293,8 +293,8 @@ class PlaylistController extends Zend_Controller_Action public function addItemsAction() { - $ids = $this->_getParam('ids', array()); - $ids = (!is_array($ids)) ? array($ids) : $ids; + $aItems = $this->_getParam('aItems', array()); + $aItems = (!is_array($aItems)) ? array($aItems) : $aItems; $afterItem = $this->_getParam('afterItem', null); $addType = $this->_getParam('type', 'after'); $obj_type = $this->_getParam('obj_type'); @@ -307,17 +307,13 @@ class PlaylistController extends Zend_Controller_Action } else { throw new PlaylistDyanmicException; } - } - catch (PlaylistOutDatedException $e) { - $this->playlistOutdated($e); - } - catch (PlaylistNotFoundException $e) { - $this->playlistNotFound($obj_type); - } - catch (PlaylistDyanmicException $e) { - $this->playlistDynamic($obj); - } - catch (Exception $e) { + } catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($pl, $e); + } catch (PlaylistNotFoundException $e) { + $this->playlistNotFound(); + } catch (PlaylistDyanmicException $e) { + $this->playlistDynamic($pl); + } catch (Exception $e) { $this->playlistUnknownError($e); } } diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 8de5ec463..d0cc6bebd 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -157,6 +157,7 @@ class Application_Model_Playlist Logging::log("Getting contents for playlist {$this->id}"); $files = array(); + /* $query = CcPlaylistcontentsQuery::create() ->filterByDbPlaylistId($this->id); @@ -166,15 +167,63 @@ class Application_Model_Playlist ->endUse(); } $query->orderByDbPosition() + ->filterByDbType(0) ->leftJoinWith('CcFiles'); $rows = $query->find($this->con); + */ + $sql = <<<"EOT" +((SELECT pc.file_id as id, pc.type, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout, + f.track_title, f.artist_name as creator, f.file_exists as exists, f.filepath as path FROM cc_playlistcontents AS pc + LEFT JOIN cc_files AS f ON pc.file_id=f.id WHERE pc.playlist_id = {$this->id} AND type = 0) +UNION ALL +(SELECT pc.file_id as id, pc.type, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout, +ws.name as title, ws.login as creator, NULL::boolean as exists, ws.url as path FROM cc_playlistcontents AS pc +LEFT JOIN cc_webstream AS ws on pc.file_id=ws.id WHERE pc.playlist_id = {$this->id} AND type = 1)); +EOT; + Logging::debug($sql); + $con = Propel::getConnection(); + $rows = $con->query($sql)->fetchAll(); + Logging::debug($rows); +/* +#id +#cliplength +#cuein +#cueout +#fadeout +#fadein + +gunid +#file_exists +filepath +#track_title +#artist_name +album_title +#length +*/ + $offset = 0; + foreach ($rows as &$row) { + Logging::log($row); + + $clipSec = Application_Model_Playlist::playlistTimeToSeconds($row['cliplength']); + $offset += $clipSec; + $offset_cliplength = Application_Model_Playlist::secondsToPlaylistTime($offset); + + //format the length for UI. + $formatter = new LengthFormatter($row['cliplength']); + $row['cliplength'] = $formatter->format(); + + $formatter = new LengthFormatter($offset_cliplength); + $row['offset'] = $formatter->format(); + } + + /* $i = 0; $offset = 0; foreach ($rows as $row) { + Logging::log($row); $files[$i] = $row->toArray(BasePeer::TYPE_FIELDNAME, true, true); - $clipSec = Application_Common_DateHelper::playlistTimeToSeconds($files[$i]['cliplength']); $offset += $clipSec; $offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset); @@ -188,8 +237,9 @@ class Application_Model_Playlist $i++; } + */ - return $files; + return $rows; } /** @@ -199,19 +249,21 @@ class Application_Model_Playlist **/ public function normalizeFade($fade) { - //First get rid of the first six characters 00:00: which will be added back later for db update - $fade = substr($fade, 6); + //First get rid of the first six characters 00:00: which will be added back later for db update + $fade = substr($fade, 6); + + //Second add .000000 if the fade does't have milliseconds format already + $dbFadeStrPos = strpos( $fade, '.' ); + if ($dbFadeStrPos === false) { + $fade .= '.000000'; + } else { + while (strlen($fade) < 9) { + $fade .= '0'; + } + } - //Second add .000000 if the fade does't have milliseconds format already - $dbFadeStrPos = strpos( $fade, '.' ); - if ( $dbFadeStrPos === False ) - $fade .= '.000000'; - else - while( strlen( $fade ) < 9 ) - $fade .= '0'; - - //done, just need to set back the formated values - return $fade; + //done, just need to set back the formated values + return $fade; } //aggregate column on playlistcontents cliplength column. @@ -220,7 +272,7 @@ class Application_Model_Playlist return $this->pl->getDbLength(); } - private function insertPlaylistElement($info) + private function insertPlaylistElement($info, $type) { $row = new CcPlaylistcontents(); $row->setDbPlaylistId($this->id); @@ -231,6 +283,7 @@ class Application_Model_Playlist $row->setDbCueout($info["cueout"]); $row->setDbFadein($info["fadein"]); $row->setDbFadeout($info["fadeout"]); + $row->setDbType($type); $row->save($this->con); // above save result update on cc_playlist table on length column. // but $this->pl doesn't get updated automatically @@ -259,6 +312,23 @@ class Application_Model_Playlist } } + 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 @@ -267,7 +337,7 @@ class Application_Model_Playlist * @param string (before|after) $addAfter * whether to add the clips before or after the selected item. */ - public function addAudioClips($p_items, $p_afterItem=NULL, $addType = 'after') + public function addAudioClips($p_items, $p_afterItem=null, $addType = 'after') { $this->con->beginTransaction(); $contentsToUpdate = array(); @@ -288,8 +358,6 @@ class Application_Model_Playlist ->orderByDbPosition() ->find($this->con); - Logging::log("Adding to playlist"); - Logging::log("at position {$pos}"); } else { //add to the end of the playlist @@ -312,15 +380,27 @@ class Application_Model_Playlist ->orderByDbPosition() ->find($this->con); - Logging::log("Adding to playlist"); - Logging::log("at position {$pos}"); } + Logging::log("Adding to playlist"); + Logging::log("at position {$pos}"); + foreach ($p_items as $ac) { + list($item, $type) = $ac; + if ($type == "audioclip") { + $res = $this->insertPlaylistElement($this->buildEntry($item, $pos), 0); + $pos = $pos + 1; + } else if ($type == "playlist") { + + } else if ($type == "stream") { + $res = $this->insertPlaylistElement($this->buildStreamEntry($item, $pos), 1); + $pos = $pos + 1; + } else { + throw new Exception("Unknown file type"); + } + Logging::log("Adding audio file {$ac}"); - $res = $this->insertPlaylistElement($this->buildEntry($ac, $pos)); - $pos = $pos + 1; } //reset the positions of the remaining items. diff --git a/airtime_mvc/application/models/airtime/map/CcPlaylistcontentsTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlaylistcontentsTableMap.php index 936475187..19a33dada 100644 --- a/airtime_mvc/application/models/airtime/map/CcPlaylistcontentsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPlaylistcontentsTableMap.php @@ -42,6 +42,7 @@ class CcPlaylistcontentsTableMap extends TableMap { $this->addForeignKey('PLAYLIST_ID', 'DbPlaylistId', 'INTEGER', 'cc_playlist', 'ID', false, null, null); $this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null); $this->addForeignKey('BLOCK_ID', 'DbBlockId', 'INTEGER', 'cc_block', 'ID', false, null, null); + $this->addColumn('TYPE', 'DbType', 'INTEGER', true, null, 0); $this->addColumn('POSITION', 'DbPosition', 'INTEGER', false, null, null); $this->addColumn('CLIPLENGTH', 'DbCliplength', 'VARCHAR', false, null, '00:00:00'); $this->addColumn('CUEIN', 'DbCuein', 'VARCHAR', false, null, '00:00:00'); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php index 572bc9849..a0e3fe679 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php @@ -48,6 +48,13 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent */ protected $block_id; + /** + * The value for the type field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $type; + /** * The value for the position field. * @var int @@ -129,6 +136,7 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent */ public function applyDefaultValues() { + $this->type = 0; $this->cliplength = '00:00:00'; $this->cuein = '00:00:00'; $this->cueout = '00:00:00'; @@ -186,6 +194,16 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent return $this->block_id; } + /** + * Get the [type] column value. + * + * @return int + */ + public function getDbType() + { + return $this->type; + } + /** * Get the [position] column value. * @@ -384,6 +402,26 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent return $this; } // setDbBlockId() + /** + * Set the value of [type] column. + * + * @param int $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbType($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->type !== $v || $this->isNew()) { + $this->type = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::TYPE; + } + + return $this; + } // setDbType() + /** * Set the value of [position] column. * @@ -574,6 +612,10 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { + if ($this->type !== 0) { + return false; + } + if ($this->cliplength !== '00:00:00') { return false; } @@ -620,12 +662,13 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent $this->playlist_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; $this->file_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; $this->block_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->cliplength = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->cuein = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->cueout = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->fadein = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->fadeout = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->type = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->position = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->cliplength = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->cuein = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->cueout = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->fadein = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->fadeout = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; $this->resetModified(); $this->setNew(false); @@ -634,7 +677,7 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 10; // 10 = CcPlaylistcontentsPeer::NUM_COLUMNS - CcPlaylistcontentsPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 11; // 11 = CcPlaylistcontentsPeer::NUM_COLUMNS - CcPlaylistcontentsPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcPlaylistcontents object", $e); @@ -1010,21 +1053,24 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent return $this->getDbBlockId(); break; case 4: - return $this->getDbPosition(); + return $this->getDbType(); break; case 5: - return $this->getDbCliplength(); + return $this->getDbPosition(); break; case 6: - return $this->getDbCuein(); + return $this->getDbCliplength(); break; case 7: - return $this->getDbCueout(); + return $this->getDbCuein(); break; case 8: - return $this->getDbFadein(); + return $this->getDbCueout(); break; case 9: + return $this->getDbFadein(); + break; + case 10: return $this->getDbFadeout(); break; default: @@ -1055,12 +1101,13 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent $keys[1] => $this->getDbPlaylistId(), $keys[2] => $this->getDbFileId(), $keys[3] => $this->getDbBlockId(), - $keys[4] => $this->getDbPosition(), - $keys[5] => $this->getDbCliplength(), - $keys[6] => $this->getDbCuein(), - $keys[7] => $this->getDbCueout(), - $keys[8] => $this->getDbFadein(), - $keys[9] => $this->getDbFadeout(), + $keys[4] => $this->getDbType(), + $keys[5] => $this->getDbPosition(), + $keys[6] => $this->getDbCliplength(), + $keys[7] => $this->getDbCuein(), + $keys[8] => $this->getDbCueout(), + $keys[9] => $this->getDbFadein(), + $keys[10] => $this->getDbFadeout(), ); if ($includeForeignObjects) { if (null !== $this->aCcFiles) { @@ -1116,21 +1163,24 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent $this->setDbBlockId($value); break; case 4: - $this->setDbPosition($value); + $this->setDbType($value); break; case 5: - $this->setDbCliplength($value); + $this->setDbPosition($value); break; case 6: - $this->setDbCuein($value); + $this->setDbCliplength($value); break; case 7: - $this->setDbCueout($value); + $this->setDbCuein($value); break; case 8: - $this->setDbFadein($value); + $this->setDbCueout($value); break; case 9: + $this->setDbFadein($value); + break; + case 10: $this->setDbFadeout($value); break; } // switch() @@ -1161,12 +1211,13 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent if (array_key_exists($keys[1], $arr)) $this->setDbPlaylistId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setDbFileId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setDbBlockId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbPosition($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbCliplength($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbCuein($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbCueout($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbFadein($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbFadeout($arr[$keys[9]]); + if (array_key_exists($keys[4], $arr)) $this->setDbType($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbPosition($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbCliplength($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbCuein($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbCueout($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbFadein($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbFadeout($arr[$keys[10]]); } /** @@ -1182,6 +1233,7 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent if ($this->isColumnModified(CcPlaylistcontentsPeer::PLAYLIST_ID)) $criteria->add(CcPlaylistcontentsPeer::PLAYLIST_ID, $this->playlist_id); if ($this->isColumnModified(CcPlaylistcontentsPeer::FILE_ID)) $criteria->add(CcPlaylistcontentsPeer::FILE_ID, $this->file_id); if ($this->isColumnModified(CcPlaylistcontentsPeer::BLOCK_ID)) $criteria->add(CcPlaylistcontentsPeer::BLOCK_ID, $this->block_id); + if ($this->isColumnModified(CcPlaylistcontentsPeer::TYPE)) $criteria->add(CcPlaylistcontentsPeer::TYPE, $this->type); if ($this->isColumnModified(CcPlaylistcontentsPeer::POSITION)) $criteria->add(CcPlaylistcontentsPeer::POSITION, $this->position); if ($this->isColumnModified(CcPlaylistcontentsPeer::CLIPLENGTH)) $criteria->add(CcPlaylistcontentsPeer::CLIPLENGTH, $this->cliplength); if ($this->isColumnModified(CcPlaylistcontentsPeer::CUEIN)) $criteria->add(CcPlaylistcontentsPeer::CUEIN, $this->cuein); @@ -1252,6 +1304,7 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent $copyObj->setDbPlaylistId($this->playlist_id); $copyObj->setDbFileId($this->file_id); $copyObj->setDbBlockId($this->block_id); + $copyObj->setDbType($this->type); $copyObj->setDbPosition($this->position); $copyObj->setDbCliplength($this->cliplength); $copyObj->setDbCuein($this->cuein); @@ -1461,6 +1514,7 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent $this->playlist_id = null; $this->file_id = null; $this->block_id = null; + $this->type = null; $this->position = null; $this->cliplength = null; $this->cuein = null; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsPeer.php index de309bde6..a498b6c04 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcPlaylistcontentsPeer { const TM_CLASS = 'CcPlaylistcontentsTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 11; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -43,6 +43,9 @@ abstract class BaseCcPlaylistcontentsPeer { /** the column name for the BLOCK_ID field */ const BLOCK_ID = 'cc_playlistcontents.BLOCK_ID'; + /** the column name for the TYPE field */ + const TYPE = 'cc_playlistcontents.TYPE'; + /** the column name for the POSITION field */ const POSITION = 'cc_playlistcontents.POSITION'; @@ -77,12 +80,12 @@ abstract class BaseCcPlaylistcontentsPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('DbId', 'DbPlaylistId', 'DbFileId', 'DbBlockId', 'DbPosition', 'DbCliplength', 'DbCuein', 'DbCueout', 'DbFadein', 'DbFadeout', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbPlaylistId', 'dbFileId', 'dbBlockId', 'dbPosition', 'dbCliplength', 'dbCuein', 'dbCueout', 'dbFadein', 'dbFadeout', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::PLAYLIST_ID, self::FILE_ID, self::BLOCK_ID, self::POSITION, self::CLIPLENGTH, self::CUEIN, self::CUEOUT, self::FADEIN, self::FADEOUT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PLAYLIST_ID', 'FILE_ID', 'BLOCK_ID', 'POSITION', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'playlist_id', 'file_id', 'block_id', 'position', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbPlaylistId', 'DbFileId', 'DbBlockId', 'DbType', 'DbPosition', 'DbCliplength', 'DbCuein', 'DbCueout', 'DbFadein', 'DbFadeout', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbPlaylistId', 'dbFileId', 'dbBlockId', 'dbType', 'dbPosition', 'dbCliplength', 'dbCuein', 'dbCueout', 'dbFadein', 'dbFadeout', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::PLAYLIST_ID, self::FILE_ID, self::BLOCK_ID, self::TYPE, self::POSITION, self::CLIPLENGTH, self::CUEIN, self::CUEOUT, self::FADEIN, self::FADEOUT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PLAYLIST_ID', 'FILE_ID', 'BLOCK_ID', 'TYPE', 'POSITION', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'playlist_id', 'file_id', 'block_id', 'type', 'position', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -92,12 +95,12 @@ abstract class BaseCcPlaylistcontentsPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbPlaylistId' => 1, 'DbFileId' => 2, 'DbBlockId' => 3, 'DbPosition' => 4, 'DbCliplength' => 5, 'DbCuein' => 6, 'DbCueout' => 7, 'DbFadein' => 8, 'DbFadeout' => 9, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbPlaylistId' => 1, 'dbFileId' => 2, 'dbBlockId' => 3, 'dbPosition' => 4, 'dbCliplength' => 5, 'dbCuein' => 6, 'dbCueout' => 7, 'dbFadein' => 8, 'dbFadeout' => 9, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::PLAYLIST_ID => 1, self::FILE_ID => 2, self::BLOCK_ID => 3, self::POSITION => 4, self::CLIPLENGTH => 5, self::CUEIN => 6, self::CUEOUT => 7, self::FADEIN => 8, self::FADEOUT => 9, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PLAYLIST_ID' => 1, 'FILE_ID' => 2, 'BLOCK_ID' => 3, 'POSITION' => 4, 'CLIPLENGTH' => 5, 'CUEIN' => 6, 'CUEOUT' => 7, 'FADEIN' => 8, 'FADEOUT' => 9, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'playlist_id' => 1, 'file_id' => 2, 'block_id' => 3, 'position' => 4, 'cliplength' => 5, 'cuein' => 6, 'cueout' => 7, 'fadein' => 8, 'fadeout' => 9, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbPlaylistId' => 1, 'DbFileId' => 2, 'DbBlockId' => 3, 'DbType' => 4, 'DbPosition' => 5, 'DbCliplength' => 6, 'DbCuein' => 7, 'DbCueout' => 8, 'DbFadein' => 9, 'DbFadeout' => 10, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbPlaylistId' => 1, 'dbFileId' => 2, 'dbBlockId' => 3, 'dbType' => 4, 'dbPosition' => 5, 'dbCliplength' => 6, 'dbCuein' => 7, 'dbCueout' => 8, 'dbFadein' => 9, 'dbFadeout' => 10, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::PLAYLIST_ID => 1, self::FILE_ID => 2, self::BLOCK_ID => 3, self::TYPE => 4, self::POSITION => 5, self::CLIPLENGTH => 6, self::CUEIN => 7, self::CUEOUT => 8, self::FADEIN => 9, self::FADEOUT => 10, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PLAYLIST_ID' => 1, 'FILE_ID' => 2, 'BLOCK_ID' => 3, 'TYPE' => 4, 'POSITION' => 5, 'CLIPLENGTH' => 6, 'CUEIN' => 7, 'CUEOUT' => 8, 'FADEIN' => 9, 'FADEOUT' => 10, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'playlist_id' => 1, 'file_id' => 2, 'block_id' => 3, 'type' => 4, 'position' => 5, 'cliplength' => 6, 'cuein' => 7, 'cueout' => 8, 'fadein' => 9, 'fadeout' => 10, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -173,6 +176,7 @@ abstract class BaseCcPlaylistcontentsPeer { $criteria->addSelectColumn(CcPlaylistcontentsPeer::PLAYLIST_ID); $criteria->addSelectColumn(CcPlaylistcontentsPeer::FILE_ID); $criteria->addSelectColumn(CcPlaylistcontentsPeer::BLOCK_ID); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::TYPE); $criteria->addSelectColumn(CcPlaylistcontentsPeer::POSITION); $criteria->addSelectColumn(CcPlaylistcontentsPeer::CLIPLENGTH); $criteria->addSelectColumn(CcPlaylistcontentsPeer::CUEIN); @@ -184,6 +188,7 @@ abstract class BaseCcPlaylistcontentsPeer { $criteria->addSelectColumn($alias . '.PLAYLIST_ID'); $criteria->addSelectColumn($alias . '.FILE_ID'); $criteria->addSelectColumn($alias . '.BLOCK_ID'); + $criteria->addSelectColumn($alias . '.TYPE'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CLIPLENGTH'); $criteria->addSelectColumn($alias . '.CUEIN'); diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsQuery.php index c9c0b42b5..9a8c4e4a1 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsQuery.php @@ -10,6 +10,7 @@ * @method CcPlaylistcontentsQuery orderByDbPlaylistId($order = Criteria::ASC) Order by the playlist_id column * @method CcPlaylistcontentsQuery orderByDbFileId($order = Criteria::ASC) Order by the file_id column * @method CcPlaylistcontentsQuery orderByDbBlockId($order = Criteria::ASC) Order by the block_id column + * @method CcPlaylistcontentsQuery orderByDbType($order = Criteria::ASC) Order by the type column * @method CcPlaylistcontentsQuery orderByDbPosition($order = Criteria::ASC) Order by the position column * @method CcPlaylistcontentsQuery orderByDbCliplength($order = Criteria::ASC) Order by the cliplength column * @method CcPlaylistcontentsQuery orderByDbCuein($order = Criteria::ASC) Order by the cuein column @@ -21,6 +22,7 @@ * @method CcPlaylistcontentsQuery groupByDbPlaylistId() Group by the playlist_id column * @method CcPlaylistcontentsQuery groupByDbFileId() Group by the file_id column * @method CcPlaylistcontentsQuery groupByDbBlockId() Group by the block_id column + * @method CcPlaylistcontentsQuery groupByDbType() Group by the type column * @method CcPlaylistcontentsQuery groupByDbPosition() Group by the position column * @method CcPlaylistcontentsQuery groupByDbCliplength() Group by the cliplength column * @method CcPlaylistcontentsQuery groupByDbCuein() Group by the cuein column @@ -51,6 +53,7 @@ * @method CcPlaylistcontents findOneByDbPlaylistId(int $playlist_id) Return the first CcPlaylistcontents filtered by the playlist_id column * @method CcPlaylistcontents findOneByDbFileId(int $file_id) Return the first CcPlaylistcontents filtered by the file_id column * @method CcPlaylistcontents findOneByDbBlockId(int $block_id) Return the first CcPlaylistcontents filtered by the block_id column + * @method CcPlaylistcontents findOneByDbType(int $type) Return the first CcPlaylistcontents filtered by the type column * @method CcPlaylistcontents findOneByDbPosition(int $position) Return the first CcPlaylistcontents filtered by the position column * @method CcPlaylistcontents findOneByDbCliplength(string $cliplength) Return the first CcPlaylistcontents filtered by the cliplength column * @method CcPlaylistcontents findOneByDbCuein(string $cuein) Return the first CcPlaylistcontents filtered by the cuein column @@ -62,6 +65,7 @@ * @method array findByDbPlaylistId(int $playlist_id) Return CcPlaylistcontents objects filtered by the playlist_id column * @method array findByDbFileId(int $file_id) Return CcPlaylistcontents objects filtered by the file_id column * @method array findByDbBlockId(int $block_id) Return CcPlaylistcontents objects filtered by the block_id column + * @method array findByDbType(int $type) Return CcPlaylistcontents objects filtered by the type column * @method array findByDbPosition(int $position) Return CcPlaylistcontents objects filtered by the position column * @method array findByDbCliplength(string $cliplength) Return CcPlaylistcontents objects filtered by the cliplength column * @method array findByDbCuein(string $cuein) Return CcPlaylistcontents objects filtered by the cuein column @@ -287,6 +291,37 @@ abstract class BaseCcPlaylistcontentsQuery extends ModelCriteria return $this->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $dbBlockId, $comparison); } + /** + * Filter the query on the type column + * + * @param int|array $dbType The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbType($dbType = null, $comparison = null) + { + if (is_array($dbType)) { + $useMinMax = false; + if (isset($dbType['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbType['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + return $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType, $comparison); + } + /** * Filter the query on the position column * diff --git a/airtime_mvc/application/views/scripts/library/get-file-meta-data.ajax.phtml b/airtime_mvc/application/views/scripts/library/get-file-meta-data.ajax.phtml index 45bf68c0c..83d8c3e3b 100644 --- a/airtime_mvc/application/views/scripts/library/get-file-meta-data.ajax.phtml +++ b/airtime_mvc/application/views/scripts/library/get-file-meta-data.ajax.phtml @@ -29,9 +29,9 @@
Contents: contents as $row) : ?>
- - - + + +
diff --git a/airtime_mvc/application/views/scripts/playlist/update.phtml b/airtime_mvc/application/views/scripts/playlist/update.phtml index 9a538a638..65b73e348 100644 --- a/airtime_mvc/application/views/scripts/playlist/update.phtml +++ b/airtime_mvc/application/views/scripts/playlist/update.phtml @@ -3,11 +3,11 @@ $items = $this->obj->getContents(); if (count($items)) : ?> -
  • " unqid=""> +
  • " unqid="">
    - -
    "> + +
    ">
    @@ -19,10 +19,10 @@ if (count($items)) : ?>
    - +
    - +
    'id' => $item["id"], 'cueIn' => $item['cuein'], 'cueOut' => $item['cueout'], - 'origLength' => $item["CcFiles"]['length'])); ?> + 'origLength' => $item['length'])); ?>
    diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml index f2b7b8b96..fcde9fbc1 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -239,6 +239,11 @@ + + diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql index 9aeb1d710..fc3612322 100644 --- a/airtime_mvc/build/sql/schema.sql +++ b/airtime_mvc/build/sql/schema.sql @@ -322,6 +322,7 @@ CREATE TABLE "cc_playlistcontents" "playlist_id" INTEGER, "file_id" INTEGER, "block_id" INTEGER, + "type" INTEGER default 0 NOT NULL, "position" INTEGER, "cliplength" interval default '00:00:00', "cuein" interval default '00:00:00', diff --git a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js index 4f93a02b0..b5789b161 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js @@ -30,8 +30,9 @@ var AIRTIME = (function(AIRTIME){ if (aData.ftype === "audioclip") { $nRow.addClass("lib-audio"); - } - else { + } else if (aData.ftype === "stream"){ + $nRow.addClass("lib-stream"); + } else { $nRow.addClass("lib-pl"); } @@ -45,7 +46,7 @@ var AIRTIME = (function(AIRTIME){ mod.redrawChosen(); mod.checkToolBarIcons(); - $('#library_display tr.lib-audio').draggable({ + $('#library_display tr.lib-audio, tr.lib-stream, tr.lib-pl').draggable({ helper: function(){ var $el = $(this), diff --git a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js index 15ec22f66..96057126d 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js @@ -27,11 +27,12 @@ var AIRTIME = (function(AIRTIME){ mod.fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { var $nRow = $(nRow); - + if (aData.ftype === "audioclip") { $nRow.addClass("lib-audio"); - } - else { + } else if (aData.ftype === "stream"){ + $nRow.addClass("lib-stream"); + } else { $nRow.addClass("lib-pl"); } @@ -45,7 +46,7 @@ var AIRTIME = (function(AIRTIME){ mod.redrawChosen(); mod.checkToolBarIcons(); - $('#library_display tr.lib-audio, tr.lib-pl').draggable({ + $('#library_display tr.lib-audio, tr.lib-pl, tr.lib-stream').draggable({ helper: function(){ var $el = $(this), @@ -178,4 +179,4 @@ var AIRTIME = (function(AIRTIME){ return AIRTIME; -}(AIRTIME || {})); \ No newline at end of file +}(AIRTIME || {})); diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index d64fa26de..157511584 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -40,7 +40,7 @@ var AIRTIME = (function(AIRTIME) { cItem, i, length, count = 0, - reAudio=/^au/ ; + reAudio=/^(au|st|pl)/ ; // Get visible items and check if any chosenItems are visible $trs = $libTable.find("tbody input:checkbox").parents("tr"); diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 6570e3c4f..1f0a4d8ac 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -575,9 +575,8 @@ var AIRTIME = (function(AIRTIME){ aSelected = AIRTIME.library.getSelectedData(); for (i = 0, length = aSelected.length; i < length; i++) { - if (aSelected[i].ftype === "audioclip") { - aItems.push(aSelected[i].id); - } + var type = aSelected[i].ftype; + aItems.push(new Array(aSelected[i].id, type)); } aReceiveItems = aItems; @@ -648,7 +647,7 @@ var AIRTIME = (function(AIRTIME){ } mod.fnNew = function() { - var url = '/Webstream/new'; + var url = '/Playlist/new'; stopAudioPreview(); @@ -765,7 +764,7 @@ var AIRTIME = (function(AIRTIME){ mod.fnAddItems = function(aItems, iAfter, sAddType) { var sUrl = "/playlist/add-items"; - oData = {"ids": aItems, "afterItem": iAfter, "type": sAddType}; + oData = {"aItems": aItems, "afterItem": iAfter, "type": sAddType}; playlistRequest(sUrl, oData); };