Merge branch 'CC-3174' into devel
This commit is contained in:
commit
bc8106c5fa
|
@ -580,7 +580,6 @@ class Application_Model_StoredFile {
|
|||
}
|
||||
|
||||
public static function searchFilesForPlaylistBuilder($datatables) {
|
||||
global $CC_CONFIG;
|
||||
|
||||
$displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length",
|
||||
"year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url",
|
||||
|
@ -594,29 +593,42 @@ class Application_Model_StoredFile {
|
|||
if ($key === "id") {
|
||||
$plSelect[] = "PL.id AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} else if ($key === "track_title") {
|
||||
}
|
||||
else if ($key === "track_title") {
|
||||
$plSelect[] = "name AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} else if ($key === "ftype") {
|
||||
$plSelect[] = "'playlist' AS ".$key;
|
||||
}
|
||||
else if ($key === "ftype") {
|
||||
$plSelect[] = "'playlist'::varchar AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} else if ($key === "artist_name") {
|
||||
}
|
||||
else if ($key === "artist_name") {
|
||||
$plSelect[] = "login AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} else if ($key === "length") {
|
||||
}
|
||||
else if ($key === "length") {
|
||||
$plSelect[] = $key;
|
||||
$fileSelect[] = $key."::interval";
|
||||
} else if ($key === "year") {
|
||||
}
|
||||
else if ($key === "year") {
|
||||
$plSelect[] = "CAST(utime AS varchar) AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
} else if ($key === "utime") {
|
||||
}
|
||||
else if ($key === "utime") {
|
||||
$plSelect[] = $key;
|
||||
$fileSelect[] = $key;
|
||||
} else if ($key === "mtime") {
|
||||
}
|
||||
else if ($key === "mtime") {
|
||||
$plSelect[] = $key;
|
||||
$fileSelect[] = $key;
|
||||
} else {
|
||||
$plSelect[] = "NULL AS ".$key;
|
||||
}
|
||||
//need to cast certain data as ints for the union to search on.
|
||||
else if (in_array($key, array("track_number"))){
|
||||
$plSelect[] = "NULL::int AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
}
|
||||
else {
|
||||
$plSelect[] = "NULL::text AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
}
|
||||
}
|
||||
|
@ -624,13 +636,28 @@ class Application_Model_StoredFile {
|
|||
$plSelect = "SELECT ". join(",", $plSelect);
|
||||
$fileSelect = "SELECT ". join(",", $fileSelect);
|
||||
|
||||
$fromTable = " (({$plSelect} FROM cc_playlist AS PL
|
||||
LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))
|
||||
UNION
|
||||
({$fileSelect} FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS";
|
||||
$type = intval($datatables["type"]);
|
||||
|
||||
$plTable = "({$plSelect} FROM cc_playlist AS PL LEFT JOIN cc_subjs AS sub ON (sub.id = PL.creator_id))";
|
||||
$fileTable = "({$fileSelect} FROM cc_files AS FILES WHERE file_exists = 'TRUE')";
|
||||
$unionTable = "({$plTable} UNION {$fileTable} ) AS RESULTS";
|
||||
|
||||
$results = Application_Model_StoredFile::searchFiles($displayColumns, $fromTable, $datatables);
|
||||
//choose which table we need to select data from.
|
||||
switch ($type) {
|
||||
case 0:
|
||||
$fromTable = $unionTable;
|
||||
break;
|
||||
case 1:
|
||||
$fromTable = $fileTable." AS File"; //need an alias for the table if it's standalone.
|
||||
break;
|
||||
case 2:
|
||||
$fromTable = $plTable." AS Playlist"; //need an alias for the table if it's standalone.
|
||||
break;
|
||||
default:
|
||||
$fromTable = $unionTable;
|
||||
}
|
||||
|
||||
$results = Application_Model_StoredFile::searchFiles($displayColumns, $fromTable, $datatables);
|
||||
|
||||
|
||||
foreach ($results['aaData'] as &$row) {
|
||||
|
@ -671,22 +698,12 @@ class Application_Model_StoredFile {
|
|||
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
|
||||
$where = array();
|
||||
|
||||
/*
|
||||
$columnsDisplayed = array();
|
||||
for ($i = 0; $i < $data["iColumns"]; $i++) {
|
||||
if (in_array($data["mDataProp_".$i], $displayColumns)) {
|
||||
$columnsDisplayed[] = $data["mDataProp_".$i];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ($data["sSearch"] !== "") {
|
||||
$searchTerms = explode(" ", $data["sSearch"]);
|
||||
}
|
||||
|
||||
$selectorCount = "SELECT COUNT(*)";
|
||||
//$selectorRows = "SELECT ". join(",", $displayColumns);
|
||||
$selectorRows = "SELECT *";
|
||||
$selectorCount = "SELECT COUNT(*) ";
|
||||
$selectorRows = "SELECT ".join(",", $displayColumns)." ";
|
||||
|
||||
$sql = $selectorCount." FROM ".$fromTable;
|
||||
$sqlTotalRows = $sql;
|
||||
|
|
|
@ -559,6 +559,12 @@ dl.inline-list dd {
|
|||
float: left;
|
||||
margin: 0 3px 0 -2px;
|
||||
}
|
||||
.dataTables_type {
|
||||
float:right;
|
||||
margin:0 8px 0 0;
|
||||
|
||||
}
|
||||
|
||||
.dataTables_length {
|
||||
float:right;
|
||||
margin:0 8px 0 0;
|
||||
|
@ -574,7 +580,7 @@ dl.inline-list dd {
|
|||
margin:8px 0 0 8px;
|
||||
}
|
||||
.dataTables_filter .auto-search {
|
||||
width:60%;
|
||||
width:55%;
|
||||
}
|
||||
.dataTables_processing {
|
||||
font-size:11px;
|
||||
|
|
|
@ -306,7 +306,15 @@ $(document).ready(function() {
|
|||
|
||||
"sAjaxSource": "/Library/contents",
|
||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
||||
var type;
|
||||
|
||||
aoData.push( { name: "format", value: "json"} );
|
||||
|
||||
//push whether to search files/playlists or all.
|
||||
type = $("#library_display_type").find("select").val();
|
||||
type = (type === undefined) ? 0 : type;
|
||||
aoData.push( { name: "type", value: type} );
|
||||
|
||||
$.ajax( {
|
||||
"dataType": 'json',
|
||||
"type": "GET",
|
||||
|
@ -376,7 +384,7 @@ $(document).ready(function() {
|
|||
},
|
||||
|
||||
// R = ColReorder, C = ColVis, T = TableTools
|
||||
"sDom": 'Rlfr<"H"T<"library_toolbar"C>>t<"F"ip>',
|
||||
"sDom": 'Rl<"#library_display_type">fr<"H"T<"library_toolbar"C>>t<"F"ip>',
|
||||
|
||||
"oTableTools": {
|
||||
"sRowSelect": "multi",
|
||||
|
@ -418,6 +426,18 @@ $(document).ready(function() {
|
|||
oTable.fnSetFilteringDelay(350);
|
||||
|
||||
AIRTIME.library.events.setupLibraryToolbar(oTable);
|
||||
|
||||
$("#library_display_type")
|
||||
.addClass("dataTables_type")
|
||||
.append('<select name="library_display_type" />')
|
||||
.find("select")
|
||||
.append('<option value="0">All</option>')
|
||||
.append('<option value="1">Files</option>')
|
||||
.append('<option value="2">Playlists</option>')
|
||||
.end()
|
||||
.change(function(ev){
|
||||
oTable.fnDraw();
|
||||
});
|
||||
|
||||
$('[name="pl_cb_all"]').click(function(){
|
||||
var oTT = TableTools.fnGetInstance('library_display');
|
||||
|
|
Loading…
Reference in New Issue