Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

Conflicts:
	airtime_mvc/application/models/Block.php
	airtime_mvc/public/css/styles.css
This commit is contained in:
Martin Konecny 2012-09-12 15:55:43 -04:00
commit 20f5fe6480
32 changed files with 5963 additions and 3894 deletions

View file

@ -8,33 +8,33 @@ class ApiController extends Zend_Controller_Action
$this->checkAuth();
/* Initialize action controller here */
$context = $this->_helper->getHelper('contextSwitch');
$context->addActionContext('version', 'json')
->addActionContext('recorded-shows', 'json')
->addActionContext('calendar-init', 'json')
->addActionContext('upload-file', 'json')
->addActionContext('upload-recorded', 'json')
->addActionContext('media-monitor-setup', 'json')
->addActionContext('media-item-status', 'json')
->addActionContext('reload-metadata', 'json')
->addActionContext('list-all-files', 'json')
->addActionContext('list-all-watched-dirs', 'json')
->addActionContext('add-watched-dir', 'json')
->addActionContext('remove-watched-dir', 'json')
->addActionContext('set-storage-dir', 'json')
->addActionContext('get-stream-setting', 'json')
->addActionContext('status', 'json')
->addActionContext('register-component', 'json')
->addActionContext('update-liquidsoap-status', 'json')
->addActionContext('live-chat', 'json')
->addActionContext('update-file-system-mount', 'json')
->addActionContext('handle-watched-dir-missing', 'json')
->addActionContext('rabbitmq-do-push', 'json')
->addActionContext('check-live-stream-auth', 'json')
->addActionContext('update-source-status', 'json')
->addActionContext('get-bootstrap-info', 'json')
->addActionContext('get-files-without-replay-gain', 'json')
->addActionContext('reload-metadata-group', 'json')
->addActionContext('notify-webstream-data', 'json')
$context->addActionContext('version' , 'json')
->addActionContext('recorded-shows' , 'json')
->addActionContext('calendar-init' , 'json')
->addActionContext('upload-file' , 'json')
->addActionContext('upload-recorded' , 'json')
->addActionContext('media-monitor-setup' , 'json')
->addActionContext('media-item-status' , 'json')
->addActionContext('reload-metadata' , 'json')
->addActionContext('list-all-files' , 'json')
->addActionContext('list-all-watched-dirs' , 'json')
->addActionContext('add-watched-dir' , 'json')
->addActionContext('remove-watched-dir' , 'json')
->addActionContext('set-storage-dir' , 'json')
->addActionContext('get-stream-setting' , 'json')
->addActionContext('status' , 'json')
->addActionContext('register-component' , 'json')
->addActionContext('update-liquidsoap-status' , 'json')
->addActionContext('live-chat' , 'json')
->addActionContext('update-file-system-mount' , 'json')
->addActionContext('handle-watched-dir-missing' , 'json')
->addActionContext('rabbitmq-do-push' , 'json')
->addActionContext('check-live-stream-auth' , 'json')
->addActionContext('update-source-status' , 'json')
->addActionContext('get-bootstrap-info' , 'json')
->addActionContext('get-files-without-replay-gain' , 'json')
->addActionContext('reload-metadata-group' , 'json')
->addActionContext('notify-webstream-data' , 'json')
->initContext();
}
@ -73,7 +73,8 @@ class ApiController extends Zend_Controller_Action
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$jsonStr = json_encode(array("version"=>Application_Model_Preference::GetAirtimeVersion()));
$jsonStr = json_encode( array(
"version" => Application_Model_Preference::GetAirtimeVersion()));
echo $jsonStr;
}
@ -94,11 +95,11 @@ class ApiController extends Zend_Controller_Action
}
$this->view->calendarInit = array(
"timestamp" => time(),
"timestamp" => time(),
"timezoneOffset" => date("Z"),
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
"timeScale" => Application_Model_Preference::GetCalendarTimeScale(),
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
);
}
@ -454,6 +455,8 @@ class ApiController extends Zend_Controller_Action
$showCanceled = true;
}
// TODO : the following is inefficient because it calls save on both
// fields
$file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder");
$file->setMetadataValue('MDATA_KEY_TRACKNUMBER', $show_instance_id);
@ -481,11 +484,12 @@ class ApiController extends Zend_Controller_Action
public function dispatchMetadata($md, $mode)
{
// Replace this compound result in a hash with proper error handling later on
$return_hash = array();
Application_Model_Preference::SetImportTimestamp();
//Logging::info("--->Mode: $mode || file: {$md['MDATA_KEY_FILEPATH']} ");
//Logging::info( $md );
// create also modifies the file if it exists
if ($mode == "create") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = Application_Common_OsPath::normpath($filepath);
@ -513,11 +517,11 @@ class ApiController extends Zend_Controller_Action
$file->setMetadata($md);
}
} elseif ($mode == "moved") {
$md5 = $md['MDATA_KEY_MD5'];
$file = Application_Model_StoredFile::RecallByMd5($md5);
$file = Application_Model_StoredFile::RecallByFilepath(
$md['MDATA_KEY_ORIGINAL_PATH']);
if (is_null($file)) {
return "File doesn't exist in Airtime.";
$return_hash['error'] = 'File does not exist in Airtime';
} else {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
@ -549,7 +553,8 @@ class ApiController extends Zend_Controller_Action
return $return_hash;
}
$return_hash['fileid'] = $file->getId();
$return_hash['fileid'] = is_null($file) ? '-1' : $file->getId();
return $return_hash;
}
@ -604,100 +609,6 @@ class ApiController extends Zend_Controller_Action
die( json_encode($responses) );
}
public function reloadMetadataAction()
{
$request = $this->getRequest();
$mode = $request->getParam('mode');
$params = $request->getParams();
$md = array();
//extract all file metadata params from the request.
foreach ($params as $key => $value) {
if (preg_match('/^MDATA_KEY/', $key)) {
$md[$key] = $value;
}
}
Logging::info( $md );
// update import timestamp
Application_Model_Preference::SetImportTimestamp();
if ($mode == "create") {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
//$filepath = str_replace("//", "/", $filepath);
$filepath = Application_Common_OsPath::normpath($filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
if (is_null($file)) {
$file = Application_Model_StoredFile::Insert($md);
} else {
// path already exist
if ($file->getFileExistsFlag()) {
// file marked as exists
$this->view->error = "File already exists in Airtime.";
return;
} else {
// file marked as not exists
$file->setFileExistsFlag(true);
$file->setMetadata($md);
}
}
} elseif ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
//File is not in database anymore.
if (is_null($file)) {
$this->view->error = "File does not exist in Airtime.";
return;
} else {
//Updating a metadata change.
$file->setMetadata($md);
}
} elseif ($mode == "moved") {
$md5 = $md['MDATA_KEY_MD5'];
$file = Application_Model_StoredFile::RecallByMd5($md5);
if (is_null($file)) {
$this->view->error = "File doesn't exist in Airtime.";
return;
} else {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
$file->setFilePath($filepath);
}
} elseif ($mode == "delete") {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
if (is_null($file)) {
$this->view->error = "File doesn't exist in Airtime.";
return;
} else {
$file->deleteByMediaMonitor();
}
} elseif ($mode == "delete_dir") {
$filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath);
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
foreach ($files as $file) {
$file->deleteByMediaMonitor();
}
return;
}
$this->view->id = $file->getId();
}
public function listAllFilesAction()
{
$request = $this->getRequest();

View file

@ -50,7 +50,7 @@ class WebstreamController extends Zend_Controller_Action
//clear the session in case an old playlist was open: CC-4196
Application_Model_Library::changePlaylist(null, null);
$this->view->obj = new Application_Model_Webstream($webstream);
$this->view->obj = new Application_Model_Webstream($webstream->getDbId());
$this->view->action = "new";
$this->view->html = $this->view->render('webstream/webstream.phtml');
}
@ -68,7 +68,7 @@ class WebstreamController extends Zend_Controller_Action
if ($webstream) {
Application_Model_Library::changePlaylist($id, "stream");
}
$this->view->obj = new Application_Model_Webstream($webstream);
$this->view->obj = new Application_Model_Webstream($webstream->getDbId());
$this->view->action = "edit";
$this->view->html = $this->view->render('webstream/webstream.phtml');
}