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

This commit is contained in:
Martin Konecny 2012-08-29 17:40:07 -04:00
commit 7f8b5ab92e
11 changed files with 164 additions and 119 deletions

View File

@ -405,9 +405,9 @@ class ApiController extends Zend_Controller_Action
public function uploadRecordedAction() public function uploadRecordedAction()
{ {
$show_instance_id = $this->_getParam('showinstanceid'); $show_instance_id = $this->_getParam('showinstanceid');
$file_id = $this->_getParam('fileid'); $file_id = $this->_getParam('fileid');
$this->view->fileid = $file_id; $this->view->fileid = $file_id;
$this->view->showinstanceid = $show_instance_id; $this->view->showinstanceid = $show_instance_id;
$this->uploadRecordedActionParam($show_instance_id, $file_id); $this->uploadRecordedActionParam($show_instance_id, $file_id);
} }

View File

@ -271,10 +271,10 @@ class LibraryController extends Zend_Controller_Action
$user = Application_Model_User::getCurrentUser(); $user = Application_Model_User::getCurrentUser();
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$files = array(); $files = array();
$playlists = array(); $playlists = array();
$blocks = array(); $blocks = array();
$streams = array(); $streams = array();
$message = null; $message = null;

View File

@ -97,7 +97,11 @@ class PlaylistController extends Zend_Controller_Action
unset($this->view->obj); unset($this->view->obj);
} }
} else { } else {
$this->view->html = $this->view->render($viewPath); if ($isJson) {
return $this->view->render($viewPath);
} else {
$this->view->html = $this->view->render($viewPath);
}
} }
} }
@ -112,13 +116,19 @@ class PlaylistController extends Zend_Controller_Action
$this->createFullResponse($obj); $this->createFullResponse($obj);
} }
private function playlistNotFound($p_type) private function playlistNotFound($p_type, $p_isJson = false)
{ {
$p_type = ucfirst($p_type);
$this->view->error = "{$p_type} not found"; $this->view->error = "{$p_type} not found";
Logging::info("{$p_type} not found"); Logging::info("{$p_type} not found");
Application_Model_Library::changePlaylist(null, $p_type); Application_Model_Library::changePlaylist(null, $p_type);
$this->createFullResponse(null);
if (!$p_isJson) {
$this->createFullResponse(null);
} else {
die(json_encode(array("error"=>$this->view->error, "result"=>1, "html"=>$this->createFullResponse(null, $p_isJson))));
}
} }
private function playlistNoPermission($p_type) private function playlistNoPermission($p_type)
@ -278,6 +288,8 @@ class PlaylistController extends Zend_Controller_Action
$this->wrongTypeToPlaylist($obj); $this->wrongTypeToPlaylist($obj);
} catch (BlockDynamicException $e) { } catch (BlockDynamicException $e) {
$this->blockDynamic($obj); $this->blockDynamic($obj);
} catch (BlockNotFoundException $e) {
$this->playlistNotFound($obj_type);
} catch (Exception $e) { } catch (Exception $e) {
$this->playlistUnknownError($e); $this->playlistUnknownError($e);
} }
@ -446,14 +458,13 @@ class PlaylistController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
$result = array(); $result = array();
$this->setPlaylistNameDescAction();
if ($params['type'] == 'block') { if ($params['type'] == 'block') {
$form = new Application_Form_SmartBlockCriteria(); $form = new Application_Form_SmartBlockCriteria();
$form->startForm($params['obj_id']); $form->startForm($params['obj_id']);
$bl = new Application_Model_Block($params['obj_id']); $bl = new Application_Model_Block($params['obj_id']);
if ($form->isValid($params)) { if ($form->isValid($params)) {
$this->setPlaylistNameDescAction();
$bl->saveSmartBlockCriteria($params['data']); $bl->saveSmartBlockCriteria($params['data']);
$result['html'] = $this->createFullResponse($bl, true, true); $result['html'] = $this->createFullResponse($bl, true, true);
$result['result'] = 0; $result['result'] = 0;
@ -461,10 +472,14 @@ class PlaylistController extends Zend_Controller_Action
$this->view->obj = $bl; $this->view->obj = $bl;
$this->view->id = $bl->getId(); $this->view->id = $bl->getId();
$this->view->form = $form; $this->view->form = $form;
$this->view->unsavedName = $params['name'];
$this->view->unsavedDesc = $params['description'];
$viewPath = 'playlist/smart-block.phtml'; $viewPath = 'playlist/smart-block.phtml';
$result['html'] = $this->view->render($viewPath); $result['html'] = $this->view->render($viewPath);
$result['result'] = 1; $result['result'] = 1;
} }
} else if ($params['type'] == 'playlist') {
$this->setPlaylistNameDescAction();
} }
$result["modified"] = $this->view->modified; $result["modified"] = $this->view->modified;
@ -475,26 +490,29 @@ class PlaylistController extends Zend_Controller_Action
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
$form = new Application_Form_SmartBlockCriteria();
$form->startForm($params['obj_id']); //make sure block exists
$bl = new Application_Model_Block($params['obj_id']); try {
if ($form->isValid($params)) { $bl = new Application_Model_Block($params['obj_id']);
$result = $bl->generateSmartBlock($params['data']);
try { $form = new Application_Form_SmartBlockCriteria();
$form->startForm($params['obj_id']);
if ($form->isValid($params)) {
$result = $bl->generateSmartBlock($params['data']);
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true)))); die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true))));
} catch (PlaylistNotFoundException $e) { } else {
$this->playlistNotFound('block'); $this->view->obj = $bl;
} catch (Exception $e) { $this->view->id = $bl->getId();
$this->playlistUnknownError($e); $this->view->form = $form;
$viewPath = 'playlist/smart-block.phtml';
$result['html'] = $this->view->render($viewPath);
$result['result'] = 1;
die(json_encode($result));
} }
} else { } catch (BlockNotFoundException $e) {
$this->view->obj = $bl; $this->playlistNotFound('block', true);
$this->view->id = $bl->getId(); } catch (Exception $e) {
$this->view->form = $form; $this->playlistUnknownError($e);
$viewPath = 'playlist/smart-block.phtml';
$result['html'] = $this->view->render($viewPath);
$result['result'] = 1;
die(json_encode($result));
} }
} }
@ -502,17 +520,19 @@ class PlaylistController extends Zend_Controller_Action
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
$bl = new Application_Model_Block($params['obj_id']); try {
$result = $bl->shuffleSmartBlock(); $bl = new Application_Model_Block($params['obj_id']);
$result = $bl->shuffleSmartBlock();
if ($result['result'] == 0) {
try { if ($result['result'] == 0) {
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true))));
} catch (PlaylistNotFoundException $e) { } else {
$this->playlistNotFound('block'); die(json_encode($result));
} }
} else { } catch (BlockNotFoundException $e) {
die(json_encode($result)); $this->playlistNotFound('block', true);
} catch (Exception $e) {
$this->playlistUnknownError($e);
} }
} }

View File

@ -137,7 +137,7 @@ class Application_Form_EditAudioMD extends Zend_Form
'ignore' => true, 'ignore' => true,
'class' => 'ui-button ui-state-default ui-button-text-only md-cancel', 'class' => 'ui-button ui-state-default ui-button-text-only md-cancel',
'label' => 'Cancel', 'label' => 'Cancel',
'onclick' => 'javascript:document.location.href = "/Playlist"', 'onclick' => 'javascript:document.location.href = "/Library"',
'decorators' => array( 'decorators' => array(
'ViewHelper' 'ViewHelper'
) )

View File

@ -18,8 +18,11 @@ class Application_Form_RegisterAirtime extends Zend_Form
} }
$this->setDecorators(array( $this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/register-dialog.phtml', 'privacyChecked'=>$privacyChecked)), array('ViewScript', array('viewScript' =>
array('File', array('viewScript' => 'form/register-dialog.phtml', 'placement' => false))) 'form/register-dialog.phtml', 'privacyChecked'=>$privacyChecked)),
array('File', array('viewScript' => 'form/register-dialog.phtml',
'placement' => false)))
); );
// Station Name // Station Name
@ -36,7 +39,7 @@ class Application_Form_RegisterAirtime extends Zend_Form
'label' => 'Phone:', 'label' => 'Phone:',
'required' => false, 'required' => false,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetPhone(), 'value' => Application_Model_Preference::GetPhone(),
'decorators' => array( 'decorators' => array(
'ViewHelper' 'ViewHelper'
) )
@ -48,7 +51,7 @@ class Application_Form_RegisterAirtime extends Zend_Form
'label' => 'Email:', 'label' => 'Email:',
'required' => false, 'required' => false,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetEmail(), 'value' => Application_Model_Preference::GetEmail(),
'decorators' => array( 'decorators' => array(
'ViewHelper' 'ViewHelper'
) )
@ -68,10 +71,10 @@ class Application_Form_RegisterAirtime extends Zend_Form
// county list dropdown // county list dropdown
$this->addElement('select', 'Country', array( $this->addElement('select', 'Country', array(
'label' => 'Country:', 'label' => 'Country:',
'required' => false, 'required' => false,
'value' => Application_Model_Preference::GetStationCountry(), 'value' => Application_Model_Preference::GetStationCountry(),
'multiOptions' => $country_list, 'multiOptions' => $country_list,
'decorators' => array( 'decorators' => array(
'ViewHelper' 'ViewHelper'
) )
)); ));
@ -128,13 +131,13 @@ class Application_Form_RegisterAirtime extends Zend_Form
// text area for sending detail // text area for sending detail
$this->addElement('textarea', 'SendInfo', array( $this->addElement('textarea', 'SendInfo', array(
'class' => 'sending_textarea', 'class' => 'sending_textarea',
'required' => false, 'required' => false,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'readonly' => true, 'readonly' => true,
'rows' => 5, 'rows' => 5,
'cols' => 61, 'cols' => 61,
'value' => Application_Model_Preference::GetSystemInfo(false, true), 'value' => Application_Model_Preference::GetSystemInfo(false, true),
'decorators' => array( 'decorators' => array(
'ViewHelper' 'ViewHelper'
) )

View File

@ -2,86 +2,86 @@
class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
{ {
private $criteriaOptions = array( private $criteriaOptions = array(
0 => "Select criteria", 0 => "Select criteria",
"album_title" => "Album", "album_title" => "Album",
"bit_rate" => "Bit Rate (Kbps)", "bit_rate" => "Bit Rate (Kbps)",
"bpm" => "Bpm", "bpm" => "Bpm",
"comments" => "Comments", "comments" => "Comments",
"composer" => "Composer", "composer" => "Composer",
"conductor" => "Conductor", "conductor" => "Conductor",
"artist_name" => "Creator", "artist_name" => "Creator",
"disc_number" => "Disc Number", "disc_number" => "Disc Number",
"genre" => "Genre", "genre" => "Genre",
"isrc_number" => "ISRC", "isrc_number" => "ISRC",
"label" => "Label", "label" => "Label",
"language" => "Language", "language" => "Language",
"mtime" => "Last Modified", "mtime" => "Last Modified",
"lptime" => "Last Played", "lptime" => "Last Played",
"length" => "Length", "length" => "Length",
"lyricist" => "Lyricist", "lyricist" => "Lyricist",
"mood" => "Mood", "mood" => "Mood",
"name" => "Name", "name" => "Name",
"orchestra" => "Orchestra", "orchestra" => "Orchestra",
"rating" => "Rating", "rating" => "Rating",
"sample_rate" => "Sample Rate (kHz)", "sample_rate" => "Sample Rate (kHz)",
"track_title" => "Title", "track_title" => "Title",
"track_number" => "Track Number", "track_number" => "Track Number",
"utime" => "Uploaded", "utime" => "Uploaded",
"year" => "Year" "year" => "Year"
); );
private $criteriaTypes = array( private $criteriaTypes = array(
0 => "", 0 => "",
"album_title" => "s", "album_title" => "s",
"artist_name" => "s", "artist_name" => "s",
"bit_rate" => "n", "bit_rate" => "n",
"bpm" => "n", "bpm" => "n",
"comments" => "s", "comments" => "s",
"composer" => "s", "composer" => "s",
"conductor" => "s", "conductor" => "s",
"utime" => "n", "utime" => "n",
"mtime" => "n", "mtime" => "n",
"lptime" => "n", "lptime" => "n",
"disc_number" => "n", "disc_number" => "n",
"genre" => "s", "genre" => "s",
"isrc_number" => "s", "isrc_number" => "s",
"label" => "s", "label" => "s",
"language" => "s", "language" => "s",
"length" => "n", "length" => "n",
"lyricist" => "s", "lyricist" => "s",
"mood" => "s", "mood" => "s",
"name" => "s", "name" => "s",
"orchestra" => "s", "orchestra" => "s",
"rating" => "n", "rating" => "n",
"sample_rate" => "n", "sample_rate" => "n",
"track_title" => "s", "track_title" => "s",
"track_number" => "n", "track_number" => "n",
"year" => "n" "year" => "n"
); );
private $stringCriteriaOptions = array( private $stringCriteriaOptions = array(
"0" => "Select modifier", "0" => "Select modifier",
"contains" => "contains", "contains" => "contains",
"does not contain" => "does not contain", "does not contain" => "does not contain",
"is" => "is", "is" => "is",
"is not" => "is not", "is not" => "is not",
"starts with" => "starts with", "starts with" => "starts with",
"ends with" => "ends with" "ends with" => "ends with"
); );
private $numericCriteriaOptions = array( private $numericCriteriaOptions = array(
"0" => "Select modifier", "0" => "Select modifier",
"is" => "is", "is" => "is",
"is not" => "is not", "is not" => "is not",
"is greater than" => "is greater than", "is greater than" => "is greater than",
"is less than" => "is less than", "is less than" => "is less than",
"is in the range" => "is in the range" "is in the range" => "is in the range"
); );
private $limitOptions = array( private $limitOptions = array(
"hours" => "hours", "hours" => "hours",
"minutes" => "minutes", "minutes" => "minutes",
"items" => "items" "items" => "items"
); );
public function init() public function init()

View File

@ -9,8 +9,8 @@ class Application_Model_Datatables
$isRange = false; $isRange = false;
if (strstr($term, '~')) { if (strstr($term, '~')) {
$info = explode('~', $term); $info = explode('~', $term);
$input1 = isset($info[0])?$info[0]:null; $input1 = isset($info[0])?Application_Common_DateHelper::ConvertToUtcDateTimeString($info[0]):null;
$input2 = isset($info[1])?$info[1]:null; $input2 = isset($info[1])?Application_Common_DateHelper::ConvertToUtcDateTimeString($info[1]):null;
$isRange = true; $isRange = true;
} else { } else {
$input1 = $term; $input1 = $term;

View File

@ -19,7 +19,12 @@ if (isset($this->obj)) {
<input id='obj_type' type='hidden' value='block'></input> <input id='obj_type' type='hidden' value='block'></input>
<div class="playlist_title"> <div class="playlist_title">
<h3 id="obj_name"> <h3 id="obj_name">
<a id="playlist_name_display" contenteditable="true"><?php echo $this->obj->getName(); ?></a> <a id="playlist_name_display" contenteditable="true">
<?php
if (isset($this->unsavedName)) echo $this->unsavedName;
else echo $this->obj->getName();
?>
</a>
</h3> </h3>
<h4 id="obj_length"><?php echo $this->length; ?></h4> <h4 id="obj_length"><?php echo $this->length; ?></h4>
</div> </div>
@ -30,7 +35,10 @@ if (isset($this->obj)) {
<dl class="zend_form"> <dl class="zend_form">
<dt id="description-label"><label for="description">Description</label></dt> <dt id="description-label"><label for="description">Description</label></dt>
<dd id="description-element"> <dd id="description-element">
<textarea cols="80" rows="24" id="description" name="description"><?php echo $this->obj->getDescription(); ?></textarea> <textarea cols="80" rows="24" id="description" name="description"><?php
if (isset($this->unsavedDesc)) echo $this->unsavedDesc;
else echo $this->obj->getDescription();?>
</textarea>
</dd> </dd>
</dl> </dl>
</fieldset> </fieldset>

View File

@ -141,7 +141,11 @@ var AIRTIME = (function(AIRTIME){
if (aMediaIds.length > 0) { if (aMediaIds.length > 0) {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after'); AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
} else { } else {
alert('You can only add tracks to smart blocks.'); if ($('#obj_type').val() == 'block') {
alert('You can only add tracks to smart blocks.');
} else if ($('#obj_type').val() == 'playlist') {
alert('You can only add tracks and smart blocks to playlists.');
}
} }
}); });

View File

@ -437,6 +437,9 @@ function callback(data, type) {
dt = $('table[id="library_display"]').dataTable(); dt = $('table[id="library_display"]').dataTable();
if (type == 'shuffle' || type == 'generate') { if (type == 'shuffle' || type == 'generate') {
if (json.error !== undefined) {
alert(json.error);
}
AIRTIME.playlist.fnOpenPlaylist(json); AIRTIME.playlist.fnOpenPlaylist(json);
var form = $('#smart-block-form'); var form = $('#smart-block-form');
if (json.result == "0") { if (json.result == "0") {

View File

@ -109,6 +109,7 @@ CREATE TABLE cc_webstream_metadata (
ALTER TABLE cc_files ALTER TABLE cc_files
DROP COLUMN gunid, DROP COLUMN gunid,
ADD COLUMN replay_gain character varying(16), ADD COLUMN replay_gain character varying(16),
ADD COLUMN owner_id integer;
ALTER COLUMN bpm TYPE integer using airtime_to_int(bpm) /* TYPE change - table: cc_files original: character varying(8) new: integer */; ALTER COLUMN bpm TYPE integer using airtime_to_int(bpm) /* TYPE change - table: cc_files original: character varying(8) new: integer */;
ALTER TABLE cc_playlistcontents ALTER TABLE cc_playlistcontents
@ -159,3 +160,9 @@ ALTER TABLE cc_webstream_metadata
ADD CONSTRAINT cc_schedule_inst_fkey FOREIGN KEY (instance_id) REFERENCES cc_schedule(id) ON DELETE CASCADE; ADD CONSTRAINT cc_schedule_inst_fkey FOREIGN KEY (instance_id) REFERENCES cc_schedule(id) ON DELETE CASCADE;
DROP FUNCTION airtime_to_int(chartoconvert character varying); DROP FUNCTION airtime_to_int(chartoconvert character varying);
UPDATE cc_files
SET owner_id=(SELECT id FROM cc_subjs WHERE type='A' LIMIT 1)
WHERE owner_id is NULL