diff --git a/legacy/application/assets.json b/legacy/application/assets.json index 75b107429..6968c6759 100644 --- a/legacy/application/assets.json +++ b/legacy/application/assets.json @@ -59,7 +59,7 @@ "js/airtime/dashboard/versiontooltip.js": "53ed1c2f7dd9527cba80bbcdb239ac88", "js/airtime/library/events/library_playlistbuilder.js": "7191ee58ad07b8f652be02bb131eb5e6", "js/airtime/library/events/library_showbuilder.js": "f3d3f65fe1e7a80cd17c228889c6a1ae", - "js/airtime/library/library.js": "bf61a213cf38521d1892034628faf17c", + "js/airtime/library/library.js": "869b3117dc2c119fac61775d78f63fa9", "js/airtime/library/plupload.js": "0f6be5b133650828b9ffc74e7852dc89", "js/airtime/library/podcast.js": "4dedd84cb571cdba2401bfb8ba621e69", "js/airtime/library/publish.js": "ab3a1452dd332cdb0773241a1c17b7e0", diff --git a/legacy/application/controllers/LibraryController.php b/legacy/application/controllers/LibraryController.php index dfd50f570..f05da1ae6 100644 --- a/legacy/application/controllers/LibraryController.php +++ b/legacy/application/controllers/LibraryController.php @@ -398,7 +398,6 @@ class LibraryController extends Zend_Controller_Action $this->view->id = $file_id; $this->view->title = $file->getPropelOrm()->getDbTrackTitle(); $this->view->artist_name = $file->getPropelOrm()->getDbArtistName(); - $this->view->filePath = $file->getPropelOrm()->getDbFilepath(); $this->view->artwork = $file->getPropelOrm()->getDbArtwork(); $this->view->replay_gain = $file->getPropelOrm()->getDbReplayGain(); $this->view->cuein = $file->getPropelOrm()->getDbCuein(); @@ -406,6 +405,28 @@ class LibraryController extends Zend_Controller_Action $this->view->format = $file->getPropelOrm()->getDbFormat(); $this->view->bit_rate = $file->getPropelOrm()->getDbBitRate(); $this->view->sample_rate = $file->getPropelOrm()->getDbSampleRate(); + $filePath = $file->getPropelOrm()->getDbFilepath(); + if ($isAdmin) { + $this->view->file_name = $filePath; + } else { + $fileParts = explode(DIRECTORY_SEPARATOR, $filePath); + $filename = end($fileParts); + $this->view->file_name = $filename; + } + // 1000 B in KB and 1000 KB in MB and 1000 MB in GB + $size = $file->getPropelOrm()->getFileSize(); + if ($size < 1000) { + // Use B up to 1 KB + $this->view->file_size = $size . ' B'; + } elseif ($size < (500 * 1000)) { + // Use KB up to 500 KB + $this->view->file_size = round($size / 1000, 1) . ' KB'; + } elseif ($size < (1 * 1000 * 1000 * 1000)) { + // Use MB up to 1 GB + $this->view->file_size = round($size / 1000 / 1000, 1) . ' MB'; + } else { + $this->view->file_size = round($size / 1000 / 1000 / 1000, 1) . ' GB'; + } $this->view->html = $this->view->render('library/edit-file-md.phtml'); } diff --git a/legacy/application/models/StoredFile.php b/legacy/application/models/StoredFile.php index 118d0dd2a..e79d1692c 100644 --- a/legacy/application/models/StoredFile.php +++ b/legacy/application/models/StoredFile.php @@ -750,7 +750,7 @@ SQL; } elseif ($key === 'filepath') { $plSelect[] = 'NULL::VARCHAR AS ' . $key; $blSelect[] = 'NULL::VARCHAR AS ' . $key; - $fileSelect[] = $key; + $fileSelect[] = "split_part({$key}, '/', -1) as {$key}"; $streamSelect[] = 'url AS ' . $key; } elseif ($key == 'mime') { $plSelect[] = 'NULL::VARCHAR AS ' . $key; diff --git a/legacy/application/views/scripts/library/edit-file-md.phtml b/legacy/application/views/scripts/library/edit-file-md.phtml index 09380f07d..9dc035988 100644 --- a/legacy/application/views/scripts/library/edit-file-md.phtml +++ b/legacy/application/views/scripts/library/edit-file-md.phtml @@ -18,6 +18,7 @@ $baseUrl = Config::getBasePath();