Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
a9cf597f14
16 changed files with 993 additions and 67 deletions
|
@ -37,6 +37,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
|
@ -56,6 +57,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
|
||||
if (isset($obj_sess->id)) {
|
||||
$objInfo = Application_Model_Library::getObjInfo($obj_sess->type);
|
||||
Logging::info($obj_sess->id);
|
||||
Logging::info($obj_sess->type);
|
||||
$objInfo = Application_Model_Library::getObjInfo($obj_sess->type);
|
||||
|
|
|
@ -74,6 +74,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version']),'text/javascript');
|
||||
|
|
|
@ -50,6 +50,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
|
|
|
@ -451,6 +451,10 @@ EOT;
|
|||
$this->block->save($this->con);
|
||||
|
||||
$this->con->commit();
|
||||
|
||||
//check if block is in any playlists and update the playlist's length
|
||||
Application_Model_Playlist::updatePlaylistsLengthWithBlock($this->id, $this->getLength());
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
|
@ -562,6 +566,11 @@ EOT;
|
|||
$this->block->save($this->con);
|
||||
|
||||
$this->con->commit();
|
||||
|
||||
|
||||
//check if block is in any playlists and update the playlist's length
|
||||
Application_Model_Playlist::updatePlaylistsLengthWithBlock($this->id, $this->getLength());
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
|
@ -1166,6 +1175,9 @@ EOT;
|
|||
// multiply 1000 because we store only number value
|
||||
// e.g 192kps is stored as 192000
|
||||
$spCriteriaValue = $criteria['value']*1000;
|
||||
if (isset($criteria['extra'])) {
|
||||
$criteria['extra'] *= 1000;
|
||||
}
|
||||
} else {
|
||||
$spCriteriaValue = addslashes($criteria['value']);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,74 @@
|
|||
|
||||
class Application_Model_Datatables
|
||||
{
|
||||
private static function buildWhereClauseForAdvancedSearch($dbname2searchTerm)
|
||||
{
|
||||
$where = array();
|
||||
foreach ($dbname2searchTerm as $dbname=>$term) {
|
||||
$isRange = false;
|
||||
if (strstr($term, '~')) {
|
||||
$info = explode('~', $term);
|
||||
$input1 = isset($info[0])?$info[0]:null;
|
||||
$input2 = isset($info[1])?$info[1]:null;
|
||||
$isRange = true;
|
||||
} else {
|
||||
$input1 = $term;
|
||||
}
|
||||
|
||||
if ($isRange) {
|
||||
$sub = array();
|
||||
if ($input1 != null) {
|
||||
$sub[] = $dbname." >= '".$input1."'";
|
||||
}
|
||||
if ($input2 != null) {
|
||||
$sub[] = $dbname." <= '".$input2."'";
|
||||
}
|
||||
if (!empty($sub)) {
|
||||
$where[] = "(".implode(' AND ', $sub).")";
|
||||
}
|
||||
} else {
|
||||
if (trim($input1) !== "") {
|
||||
$where[] = $dbname." ILIKE "."'%".$input1."%'";
|
||||
}
|
||||
}
|
||||
}
|
||||
return implode(" AND ", $where);
|
||||
}
|
||||
/*
|
||||
* query used to return data for a paginated/searchable datatable.
|
||||
*/
|
||||
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
|
||||
{
|
||||
$librarySetting = Application_Model_Preference::getCurrentLibraryTableSetting();
|
||||
|
||||
// map that maps original column position to db name
|
||||
$current2dbname = array();
|
||||
// array of search terms
|
||||
$orig2searchTerm= array();
|
||||
foreach ($data as $key=>$d) {
|
||||
if (strstr($key, "mDataProp_")) {
|
||||
list($dump, $index) = explode("_", $key);
|
||||
$current2dbname[$index] = $d;
|
||||
} else if (strstr($key, "sSearch_")) {
|
||||
list($dump, $index) = explode("_", $key);
|
||||
$orig2searchTerm[$index] = $d;
|
||||
}
|
||||
}
|
||||
// map that maps current column position to original position
|
||||
$current2orig = $librarySetting['ColReorder'];
|
||||
|
||||
// map that maps dbname to searchTerm
|
||||
$dbname2searchTerm = array();
|
||||
foreach ($current2dbname as $currentPos=>$dbname) {
|
||||
$dbname2searchTerm[$dbname] = $orig2searchTerm[$current2orig[$currentPos]];
|
||||
}
|
||||
|
||||
$where = array();
|
||||
|
||||
$advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm);
|
||||
if ($advancedWhere != "") {
|
||||
$where[] = $advancedWhere;
|
||||
}
|
||||
|
||||
if ($data["sSearch"] !== "") {
|
||||
$searchTerms = explode(" ", $data["sSearch"]);
|
||||
|
|
|
@ -913,6 +913,26 @@ SQL;
|
|||
{
|
||||
CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* After items get deleted/added from/to a block
|
||||
* this function updates the length of playlists
|
||||
* that contain that block
|
||||
*/
|
||||
public static function updatePlaylistsLengthWithBlock($p_blockId, $p_blockLength) {
|
||||
$playlists = CcPlaylistQuery::create()->find();
|
||||
foreach ($playlists as $pl) {
|
||||
$contents = CcPlaylistcontentsQuery::create()->findByDbPlaylistId($pl->getDbId());
|
||||
//check if the block is in each playlist
|
||||
foreach ($contents as $item) {
|
||||
if ($item->getDbBlockId() == $p_blockId) {
|
||||
$item->setDbCliplength($p_blockLength);
|
||||
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
|
||||
$item->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // class Playlist
|
||||
|
||||
|
|
|
@ -1099,4 +1099,8 @@ class Application_Model_Preference
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getCurrentLibraryTableSetting(){
|
||||
return unserialize(self::getValue("library_datatable"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -853,58 +853,55 @@ class Application_Model_StoredFile
|
|||
{
|
||||
$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $tempname;
|
||||
Logging::info('copyFileToStor: moving file '.$audio_file);
|
||||
$md5 = md5_file($audio_file);
|
||||
$duplicate = Application_Model_StoredFile::RecallByMd5($md5, true);
|
||||
|
||||
$result = null;
|
||||
if ($duplicate) {
|
||||
if (file_exists($duplicate->getFilePath())) {
|
||||
$duplicateName = $duplicate->getMetadataValue('MDATA_KEY_TITLE');
|
||||
$result = array( "code" => 106, "message" => "An identical audioclip named '$duplicateName' already exists on the server.");
|
||||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$stor = $storDir->getDirectory();
|
||||
// check if "organize" dir exists and if not create one
|
||||
if (!file_exists($stor."/organize")) {
|
||||
if (!mkdir($stor."/organize", 0777)) {
|
||||
return array(
|
||||
"code" => 109,
|
||||
"message" => "Failed to create 'organize' directory.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($result)) {//The file has no duplicate, so proceed to copy.
|
||||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
$stor = $storDir->getDirectory();
|
||||
// check if "organize" dir exists and if not create one
|
||||
if (!file_exists($stor."/organize")) {
|
||||
if (!mkdir($stor."/organize", 0777)) {
|
||||
$result = array("code" => 109, "message" => "Failed to create 'organize' directory.");
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if (chmod($audio_file, 0644) === false) {
|
||||
Logging::info("Warning: couldn't change permissions of $audio_file to 0644");
|
||||
}
|
||||
|
||||
//check to see if there is enough space in $stor to continue.
|
||||
if (self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
|
||||
$audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
|
||||
|
||||
if (self::liquidsoapFilePlayabilityTest($audio_file)) {
|
||||
|
||||
Logging::info("copyFileToStor: moving file $audio_file to $audio_stor");
|
||||
|
||||
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
|
||||
if (@rename($audio_file, $audio_stor) === false) {
|
||||
#something went wrong likely there wasn't enough space in the audio_stor to move the file too.
|
||||
#warn the user that the file wasn't uploaded and they should check if there is enough disk space.
|
||||
unlink($audio_file);//remove the file after failed rename
|
||||
$result = array("code" => 108, "message" => "The file was not uploaded, this error can occur if the computer hard drive does not have enough disk space or the stor directory does not have correct write permissions.");
|
||||
}
|
||||
} else {
|
||||
$result = array("code" => 110, "message" => "This file appears to be corrupted and will not be added to media library.");
|
||||
}
|
||||
|
||||
} else {
|
||||
$result = array("code" => 107, "message" => "The file was not uploaded, there is ".$freeSpace."MB of disk space left and the file you are uploading has a size of ".$fileSize."MB.");
|
||||
}
|
||||
if (chmod($audio_file, 0644) === false) {
|
||||
Logging::info("Warning: couldn't change permissions of $audio_file to 0644");
|
||||
}
|
||||
|
||||
return $result;
|
||||
// Check if we have enough space before copying
|
||||
if(!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
|
||||
$freeSpace = disk_free_space($stor);
|
||||
return array("code" => 107,
|
||||
"message" => "The file was not uploaded, there is
|
||||
".$freeSpace."MB of disk space left and the file you are
|
||||
uploading has a size of ".$fileSize."MB.");
|
||||
}
|
||||
|
||||
// Check if liquidsoap can play this file
|
||||
if(!self::liquidsoapFilePlayabilityTest($audio_file)) {
|
||||
return array(
|
||||
"code" => 110,
|
||||
"message" => "This file appears to be corrupted and will not
|
||||
be added to media library.");
|
||||
}
|
||||
|
||||
// Did all the checks for realz, now trying to copy
|
||||
$audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
|
||||
Logging::info("copyFileToStor: moving file $audio_file to $audio_stor");
|
||||
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
|
||||
if (@rename($audio_file, $audio_stor) === false) {
|
||||
#something went wrong likely there wasn't enough space in the audio_stor to move the file too.
|
||||
#warn the user that the file wasn't uploaded and they should check if there is enough disk space.
|
||||
unlink($audio_file);//remove the file after failed rename
|
||||
return array(
|
||||
"code" => 108,
|
||||
"message" => "
|
||||
The file was not uploaded, this error can occur if the computer
|
||||
hard drive does not have enough disk space or the stor
|
||||
directory does not have correct write permissions. ");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<tr><td>Album:</td><td><?php echo ($this->md["MDATA_KEY_SOURCE"]);?></td></tr>
|
||||
<tr><td>Track:</td><td><?php echo ($this->md["MDATA_KEY_TRACKNUMBER"]);?></td></tr>
|
||||
<tr><td>Length:</td><td><?php echo ($this->md["MDATA_KEY_DURATION"]);?></td></tr>
|
||||
<tr><td>Sample Rate:</td><td><?php echo ($this->md["MDATA_KEY_SAMPLERATE"]);?></td></tr>
|
||||
<tr><td class='file-md-qtip-nowrap'>Sample Rate:</td><td><?php echo ($this->md["MDATA_KEY_SAMPLERATE"]);?></td></tr>
|
||||
<tr><td>Bit Rate:</td><td><?php echo ($this->md["MDATA_KEY_BITRATE"]);?></td></tr>
|
||||
<tr><td>Mood:</td><td><?php echo ($this->md["MDATA_KEY_MOOD"]);?></td></tr>
|
||||
<tr><td>Genre:</td><td><?php echo ($this->md["MDATA_KEY_GENRE"]);?></td></tr>
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
<div id="import_status" class="library_import" style="display:none">File import in progress... <img src="/css/images/file_import_loader.gif"></img></div>
|
||||
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable"></table>
|
||||
<div id="advanced_search">
|
||||
</div>
|
||||
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable">
|
||||
</table>
|
|
@ -24,6 +24,10 @@ if ($item['type'] == 2) {
|
|||
<div class="big_play ui-state-hover" blockId="<?php echo $item["item_id"]; ?>">
|
||||
<span class="ui-icon ui-icon-alert"></span>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<div class="big_play ui-state-hover">
|
||||
<span class="ui-icon ui-icon-alert"></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="text-row top">
|
||||
<span class="spl_playlength"><?php echo $item["length"] ?></span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue