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

View file

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