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

Conflicts:
	airtime_mvc/application/controllers/PreferenceController.php
	airtime_mvc/application/models/Preference.php
This commit is contained in:
james 2011-06-20 18:09:37 -04:00
commit 05dc48fa71
55 changed files with 907 additions and 664 deletions

View file

@ -54,7 +54,7 @@ class ApiController extends Zend_Controller_Action
* Allows remote client to download requested media file.
*
* @return void
* The given value increased by the increment amount.
*
*/
public function getMediaAction()
{
@ -65,7 +65,7 @@ class ApiController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender(true);
$api_key = $this->_getParam('api_key');
$downlaod = $this->_getParam('download');
$download = ("true" == $this->_getParam('download'));
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
{
@ -87,7 +87,6 @@ class ApiController extends Zend_Controller_Action
exit;
}
// possibly use fileinfo module here in the future.
// http://www.php.net/manual/en/book.fileinfo.php
$ext = pathinfo($filename, PATHINFO_EXTENSION);
@ -96,7 +95,12 @@ class ApiController extends Zend_Controller_Action
else if ($ext == "mp3")
header("Content-Type: audio/mpeg");
if ($download){
header('Content-Disposition: attachment; filename="'.$media->getName().'"');
//path_info breaks up a file path into seperate pieces of informaiton.
//We just want the basename which is the file name with the path
//information stripped away. We are using Content-Disposition to specify
//to the browser what name the file should be saved as.
$path_parts = pathinfo($media->getPropelOrm()->getDbFilepath());
header('Content-Disposition: attachment; filename="'.$path_parts['basename'].'"');
}
header("Content-Length: " . filesize($filepath));
@ -408,7 +412,8 @@ class ApiController extends Zend_Controller_Action
public function reloadMetadataAction() {
global $CC_CONFIG;
$api_key = $this->_getParam('api_key');
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
@ -416,8 +421,16 @@ class ApiController extends Zend_Controller_Action
exit;
}
$md = $this->_getParam('md');
$mode = $this->_getParam('mode');
$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;
}
}
if ($mode == "create") {
$md5 = $md['MDATA_KEY_MD5'];

View file

@ -28,6 +28,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jquery.jplayer.min.js');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript');
@ -166,7 +167,7 @@ class LibraryController extends Zend_Controller_Action
$data = $file->getMetadata();
RabbitMq::SendFileMetaData($data);
RabbitMq::SendMessageToMediaMonitor("md_update", $data);
$this->_helper->redirector('index');
}

View file

@ -113,8 +113,8 @@ class PlaylistController extends Zend_Controller_Action
$this->changePlaylist($pl_id);
$pl = $this->getPlaylist();
$title = $pl->getPLMetaData(UI_MDATA_KEY_TITLE);
$desc = $pl->getPLMetaData(UI_MDATA_KEY_DESCRIPTION);
$title = $pl->getPLMetaData("dc:title");
$desc = $pl->getPLMetaData("dc:description");
$data = array( 'title' => $title, 'description' => $desc);
$form->populate($data);
@ -130,7 +130,7 @@ class PlaylistController extends Zend_Controller_Action
$pl->setName($title);
if(isset($description)) {
$pl->setPLMetaData(UI_MDATA_KEY_DESCRIPTION, $description);
$pl->setPLMetaData("dc:description", $description);
}
$this->view->pl = $pl;

View file

@ -19,23 +19,24 @@ class PreferenceController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/preferences.js','text/javascript');
$this->view->statusMsg = "";
$form = new Application_Form_Preferences();
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$values = $form->getValues();
Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view);
Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]);
Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view);
Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]);
Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]);
Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]);
Application_Model_Preference::SetWatchedDirectory($values["preferences_general"]["watchedFolder"]);
Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]);
Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]);
Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]);
Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]);
Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]);
Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]);
@ -54,11 +55,13 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetStationDescription($values["preferences_support"]["Description"]);
Application_Model_Preference::SetStationLogo($imagePath);
$data = array();
$data["directory"] = $values["preferences_general"]["watchedFolder"];
RabbitMq::SendMessageToMediaMonitor("new_watch", $data);
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
}
}
$this->view->supportFeedback = Application_Model_Preference::GetSupportFeedback();
$logo = Application_Model_Preference::GetStationLogo();
if($logo){

View file

@ -33,15 +33,15 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
'label' => 'Default Fade:',
'required' => false,
'filters' => array('StringTrim'),
'validators' => array(array('regex', false,
array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/',
'validators' => array(array('regex', false,
array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/',
'messages' => 'enter a time 00:00:00{.000000}'))),
'value' => $defaultFade,
'decorators' => array(
'ViewHelper'
)
));
$stream_format = new Zend_Form_Element_Radio('streamFormat');
$stream_format->setLabel('Stream Label:');
$stream_format->setMultiOptions(array("Artist - Title",
@ -58,6 +58,18 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
$third_party_api->setDecorators(array('ViewHelper'));
$this->addElement($third_party_api);
//Default station fade
$this->addElement('text', 'watchedFolder', array(
'class' => 'input_text',
'label' => 'WatchedFolder:',
'required' => false,
'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetWatchedDirectory(),
'decorators' => array(
'ViewHelper'
)
));
}

View file

@ -127,5 +127,35 @@ class DateHelper
$explode = explode(" ", $p_timestamp);
return $explode[1];
}
/* Given a track length in the format HH:MM:SS.mm, we want to
* convert this to seconds. This is useful for Liquidsoap which
* likes input parameters give in seconds.
* For example, 00:06:31.444, should be converted to 391.444 seconds
* @param int $p_time
* The time interval in format HH:MM:SS.mm we wish to
* convert to seconds.
* @return int
* The input parameter converted to seconds.
*/
public static function calculateLengthInSeconds($p_time){
if (2 !== substr_count($p_time, ":")){
return FALSE;
}
if (1 === substr_count($p_time, ".")){
list($hhmmss, $ms) = explode(".", $p_time);
} else {
$hhmmss = $p_time;
$ms = 0;
}
list($hours, $minutes, $seconds) = explode(":", $hhmmss);
$totalSeconds = $hours*3600 + $minutes*60 + $seconds + $ms/1000;
return $totalSeconds;
}
}

View file

@ -393,7 +393,7 @@ class Playlist {
->orderByDbPosition()
->filterByDbPlaylistId($this->id)
->find();
$i = 0;
$offset = 0;
foreach ($rows as $row) {
@ -502,7 +502,7 @@ class Playlist {
}
$metadata = $media->getMetadata();
$length = $metadata["dcterms:extent"];
$length = $metadata['MDATA_KEY_DURATION'];
if (!is_null($p_clipLength)) {
$length = $p_clipLength;

View file

@ -36,7 +36,7 @@ class Application_Model_Preference
else if(is_null($id)) {
$sql = "INSERT INTO cc_pref (keystr, valstr)"
." VALUES ('$key', '$value')";
}
}
else {
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
." VALUES ($id, '$key', '$value')";
@ -188,6 +188,7 @@ class Application_Model_Preference
return $val;
}
}
<<<<<<< HEAD
public static function SetPhone($phone){
Application_Model_Preference::SetValue("phone", $phone);
@ -350,5 +351,16 @@ class Application_Model_Preference
return Application_Model_Preference::GetValue("remindme");
}
=======
public static function SetWatchedDirectory($directory) {
Application_Model_Preference::SetValue("watched_directory", $directory);
}
public static function GetWatchedDirectory() {
return Application_Model_Preference::GetValue("watched_directory");
}
>>>>>>> 898cdc64dc65c03d2ed6e3f3344b273df7c0d201
}

View file

@ -40,10 +40,12 @@ class RabbitMq
}
}
public static function SendFileMetaData($md)
public static function SendMessageToMediaMonitor($event_type, $md)
{
global $CC_CONFIG;
$md["event_type"] = $event_type;
$conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"],
$CC_CONFIG["rabbitmq"]["port"],
$CC_CONFIG["rabbitmq"]["user"],

View file

@ -184,7 +184,9 @@ class ScheduleGroup {
." st.cue_out,"
." st.clip_length,"
." st.fade_in,"
." st.fade_out"
." st.fade_out,"
." st.starts,"
." st.ends"
." FROM $CC_CONFIG[scheduleTable] as st"
." LEFT JOIN $CC_CONFIG[showInstances] as si"
." ON st.instance_id = si.id"
@ -676,7 +678,7 @@ class Schedule {
$timestamp = strtotime($start);
$playlists[$pkey]['source'] = "PLAYLIST";
$playlists[$pkey]['x_ident'] = $dx['group_id'];
$playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
//$playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
$playlists[$pkey]['timestamp'] = $timestamp;
$playlists[$pkey]['duration'] = $dx['clip_length'];
$playlists[$pkey]['played'] = '0';
@ -696,27 +698,24 @@ class Schedule {
$scheduleGroup = new ScheduleGroup($playlist["schedule_id"]);
$items = $scheduleGroup->getItems();
$medias = array();
$playlist['subtype'] = '1';
foreach ($items as $item)
{
$storedFile = StoredFile::Recall($item["file_id"]);
$uri = $storedFile->getFileUrl();
// For pypo, a cueout of zero means no cueout
$cueOut = "0";
if (Schedule::TimeDiff($item["cue_out"], $item["clip_length"]) > 0.001) {
$cueOut = Schedule::WallTimeToMillisecs($item["cue_out"]);
}
$medias[] = array(
$starts = Schedule::AirtimeTimeToPypoTime($item["starts"]);
$medias[$starts] = array(
'row_id' => $item["id"],
'id' => $storedFile->getGunid(),
'uri' => $uri,
'fade_in' => Schedule::WallTimeToMillisecs($item["fade_in"]),
'fade_out' => Schedule::WallTimeToMillisecs($item["fade_out"]),
'fade_cross' => 0,
'cue_in' => Schedule::WallTimeToMillisecs($item["cue_in"]),
'cue_out' => $cueOut,
'export_source' => 'scheduler'
'cue_in' => DateHelper::CalculateLengthInSeconds($item["cue_in"]),
'cue_out' => DateHelper::CalculateLengthInSeconds($item["cue_out"]),
'export_source' => 'scheduler',
'start' => $starts,
'end' => Schedule::AirtimeTimeToPypoTime($item["ends"])
);
}
$playlist['medias'] = $medias;

View file

@ -63,6 +63,10 @@ class StoredFile {
return $this->_file->getDbFtype();
}
public function getPropelOrm(){
return $this->_file;
}
public function setFormat($p_format)
{
$this->_file->setDbFtype($p_format);

View file

@ -73,6 +73,19 @@
</ul>
<?php endif; ?>
</dd>
<dt id="watchedFolder-label" class="block-display">
<label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label>
</dt>
<dd id="watchedFolder-element" class="block-display">
<?php echo $this->element->getElement('watchedFolder') ?>
<?php if($this->element->getElement('watchedFolder')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('watchedFolder')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
</dl>
</fieldset>