CC-84: Smart Playlists

- some minor fix
This commit is contained in:
James 2012-07-26 15:30:49 -04:00
parent 8f2339f109
commit 8755500d30
3 changed files with 28 additions and 38 deletions

View file

@ -79,8 +79,6 @@ class LibraryController extends Zend_Controller_Action
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) { if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
if ($this->obj_sess->type === "playlist") { if ($this->obj_sess->type === "playlist") {
$menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy"); $menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
} else {
$menu["pl_add"] = array("name"=> "Add to Smart Playlist", "icon" => "add-playlist", "icon" => "copy");
} }
} }
} }

View file

@ -189,42 +189,35 @@ class Application_Model_Block
*/ */
public function getContents($filterFiles=false) public function getContents($filterFiles=false)
{ {
Logging::log("Getting contents for block {$this->id}"); Logging::log("Getting contents for playlist {$this->id}");
$files = array(); $files = array();
$query = CcBlockcontentsQuery::create() $sql = <<<"EOT"
->filterByDbBlockId($this->id); SELECT pc.id as id, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout,
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
if ($filterFiles) { LEFT JOIN cc_files AS f ON pc.file_id=f.id WHERE pc.block_id = {$this->id};
$query->useCcFilesQuery() EOT;
->filterByDbFileExists(true) Logging::debug($sql);
->endUse(); $con = Propel::getConnection();
} $rows = $con->query($sql)->fetchAll();
$query->orderByDbPosition()
->leftJoinWith('CcFiles'); $offset = 0;
$rows = $query->find($this->con); foreach ($rows as &$row) {
Logging::log($row);
$i = 0;
$offset = 0; $clipSec = Application_Common_DateHelper::playlistTimeToSeconds($row['length']);
foreach ($rows as $row) { $offset += $clipSec;
$files[$i] = $row->toArray(BasePeer::TYPE_FIELDNAME, true, true); $offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
//format the length for UI.
$clipSec = Application_Common_DateHelper::playlistTimeToSeconds($files[$i]['cliplength']); $formatter = new LengthFormatter($row['length']);
$offset += $clipSec; $row['length'] = $formatter->format();
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
$formatter = new LengthFormatter($offset_cliplength);
//format the length for UI. $row['offset'] = $formatter->format();
$formatter = new LengthFormatter($files[$i]['cliplength']); }
$files[$i]['cliplength'] = $formatter->format();
return $rows;
$formatter = new LengthFormatter($offset_cliplength);
$files[$i]['offset'] = $formatter->format();
$i++;
}
return $files;
} }
/** /**

View file

@ -621,7 +621,6 @@ class Application_Model_StoredFile
$plSelect[] = "login AS ".$key; $plSelect[] = "login AS ".$key;
$blSelect[] = "login AS ".$key; $blSelect[] = "login AS ".$key;
$fileSelect[] = $key; $fileSelect[] = $key;
$plSelect[] = "login AS ".$key;
$streamSelect[] = "login AS ".$key; $streamSelect[] = "login AS ".$key;
} }
//same columns in each table. //same columns in each table.