CC-84: Smart Playlists
- added 'Smart Block' filter in datatable - added block files to library datatable
This commit is contained in:
parent
1f3cbd8aba
commit
bef9ba1eea
9 changed files with 147 additions and 50 deletions
|
@ -648,49 +648,60 @@ Logging::log("getting media! - 2");
|
|||
);
|
||||
|
||||
$plSelect = array();
|
||||
$blSelect = array();
|
||||
$fileSelect = array();
|
||||
foreach ($displayColumns as $key) {
|
||||
|
||||
if ($key === "id") {
|
||||
$plSelect[] = "PL.id AS ".$key;
|
||||
$blSelect[] = "BL.id AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} elseif ($key === "track_title") {
|
||||
$plSelect[] = "name AS ".$key;
|
||||
$blSelect[] = "name AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} elseif ($key === "ftype") {
|
||||
$plSelect[] = "'playlist'::varchar AS ".$key;
|
||||
$blSelect[] = "'block'::varchar AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} elseif ($key === "artist_name") {
|
||||
$plSelect[] = "login AS ".$key;
|
||||
$blSelect[] = "login AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
}
|
||||
//same columns in each table.
|
||||
else if (in_array($key, array("length", "utime", "mtime"))) {
|
||||
$plSelect[] = $key;
|
||||
$blSelect[] = $key;
|
||||
$fileSelect[] = $key;
|
||||
} elseif ($key === "year") {
|
||||
|
||||
$plSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key;
|
||||
$blSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key;
|
||||
$fileSelect[] = "year AS ".$key;
|
||||
}
|
||||
//need to cast certain data as ints for the union to search on.
|
||||
else if (in_array($key, array("track_number", "bit_rate", "sample_rate"))) {
|
||||
$plSelect[] = "NULL::int AS ".$key;
|
||||
$blSelect[] = "NULL::int AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} else {
|
||||
$plSelect[] = "NULL::text AS ".$key;
|
||||
$blSelect[] = "NULL::text AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
$plSelect = "SELECT ". join(",", $plSelect);
|
||||
$blSelect = "SELECT ". join(",", $blSelect);
|
||||
$fileSelect = "SELECT ". join(",", $fileSelect);
|
||||
|
||||
$type = intval($datatables["type"]);
|
||||
|
||||
$plTable = "({$plSelect} FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))";
|
||||
$blTable = "({$blSelect} FROM cc_block AS BL LEFT JOIN cc_subjs AS sub ON (sub.id = BL.creator_id))";
|
||||
$fileTable = "({$fileSelect} FROM cc_files AS FILES WHERE file_exists = 'TRUE')";
|
||||
$unionTable = "({$plTable} UNION {$fileTable} ) AS RESULTS";
|
||||
$unionTable = "({$plTable} UNION {$blTable} UNION {$fileTable} ) AS RESULTS";
|
||||
|
||||
//choose which table we need to select data from.
|
||||
switch ($type) {
|
||||
|
@ -703,6 +714,9 @@ Logging::log("getting media! - 2");
|
|||
case 2:
|
||||
$fromTable = $plTable." AS Playlist"; //need an alias for the table if it's standalone.
|
||||
break;
|
||||
case 3:
|
||||
$fromTable = $blTable." AS Block"; //need an alias for the table if it's standalone.
|
||||
break;
|
||||
default:
|
||||
$fromTable = $unionTable;
|
||||
}
|
||||
|
@ -723,16 +737,15 @@ Logging::log("getting media! - 2");
|
|||
$formatter = new BitrateFormatter($row['bit_rate']);
|
||||
$row['bit_rate'] = $formatter->format();
|
||||
}
|
||||
|
||||
|
||||
//convert mtime and utime to localtime
|
||||
$row['mtime'] = new DateTime($row['mtime'], new DateTimeZone('UTC'));
|
||||
$row['mtime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
||||
$row['mtime'] = $row['mtime']->format('Y-m-d H:i:s');
|
||||
|
||||
$row['utime'] = new DateTime($row['utime'], new DateTimeZone('UTC'));
|
||||
$row['utime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
||||
$row['utime'] = $row['utime']->format('Y-m-d H:i:s');
|
||||
|
||||
|
||||
// add checkbox row
|
||||
$row['checkbox'] = "<input type='checkbox' name='cb_".$row['id']."'>";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue