CC-1665: Scheduled stream rebroadcasting and recording
-ability to edit playlists
This commit is contained in:
parent
c3783a15b2
commit
0ea66fc33f
6 changed files with 89 additions and 28 deletions
|
@ -7,6 +7,7 @@ class WebstreamController extends Zend_Controller_Action
|
|||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||
$ajaxContext->addActionContext('new', 'json')
|
||||
->addActionContext('save', 'json')
|
||||
->addActionContext('edit', 'json')
|
||||
->initContext();
|
||||
//TODO
|
||||
//$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
||||
|
@ -29,6 +30,20 @@ class WebstreamController extends Zend_Controller_Action
|
|||
*/
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
$id = $request->getParam("id");
|
||||
if (is_null($id)) {
|
||||
throw new Exception("Missing parameter 'id'");
|
||||
}
|
||||
|
||||
$this->view->ws = new Application_Model_Webstream($id);
|
||||
$this->view->html = $this->view->render('webstream/webstream.phtml');
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
|
|
@ -4,34 +4,52 @@ class Application_Model_Webstream{
|
|||
|
||||
private $id;
|
||||
|
||||
public function __construct($id)
|
||||
public function __construct($id=-1)
|
||||
{
|
||||
$this->id = $id;
|
||||
if ($id == -1) {
|
||||
$this->webstream = new CcWebstream();
|
||||
|
||||
//We're not saving this object in the database, so -1 ID is OK.
|
||||
$this->webstream->setDbId(-1);
|
||||
$this->webstream->setDbName("Untitled Webstream");
|
||||
$this->webstream->setDbDescription("");
|
||||
$this->webstream->setDbUrl("http://");
|
||||
$this->webstream->setDbLength("00h 00m");
|
||||
$this->webstream->setDbName("Untitled Webstream");
|
||||
} else {
|
||||
$this->id = $id;
|
||||
$this->webstream = CcWebstreamQuery::create()->findPK($this->id);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getName()
|
||||
public function getName()
|
||||
{
|
||||
return "Default";
|
||||
return $this->webstream->getDbName();
|
||||
}
|
||||
|
||||
public static function getId()
|
||||
public function getId()
|
||||
{
|
||||
return "id";
|
||||
return $this->webstream->getDbId();
|
||||
}
|
||||
|
||||
public static function getLastModified($p_type)
|
||||
public function getLastModified($p_type)
|
||||
{
|
||||
return "modified";
|
||||
}
|
||||
|
||||
public static function getDefaultLength()
|
||||
public function getDefaultLength()
|
||||
{
|
||||
return "length";
|
||||
return $this->webstream->getDbLength();
|
||||
}
|
||||
|
||||
public static function getDescription()
|
||||
public function getDescription()
|
||||
{
|
||||
return "desc";
|
||||
return $this->webstream->getDbDescription();
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->webstream->getDbUrl();
|
||||
}
|
||||
|
||||
public function getMetadata()
|
||||
|
@ -41,11 +59,11 @@ class Application_Model_Webstream{
|
|||
|
||||
$username = $subjs->getDbLogin();
|
||||
return array(
|
||||
"name" => $webstream->getDbName(),
|
||||
"length" => $webstream->getDbLength(),
|
||||
"description" => $webstream->getDbDescription(),
|
||||
"name" => $this->webstream->getDbName(),
|
||||
"length" => $this->webstream->getDbLength(),
|
||||
"description" => $this->webstream->getDbDescription(),
|
||||
"login"=> $username,
|
||||
"url" => $webstream->getDbUrl(),
|
||||
"url" => $this->webstream->getDbUrl(),
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -93,7 +111,8 @@ Array
|
|||
public static function analyzeFormData($request)
|
||||
{
|
||||
$valid = array("length" => array(true, ''),
|
||||
"url" => array(true, ''));
|
||||
"url" => array(true, ''),
|
||||
"name" => array(true, ''));
|
||||
|
||||
$length = trim($request->getParam("length"));
|
||||
$result = preg_match("/^([0-9]{1,2})h ([0-5][0-9])m$/", $length, $matches);
|
||||
|
@ -120,6 +139,19 @@ Array
|
|||
$valid['name'][1] = 'Webstream name cannot be empty';
|
||||
}
|
||||
|
||||
$id = trim($request->getParam("id"));
|
||||
|
||||
if (!is_null($id)) {
|
||||
// user has performed a create stream action instead of edit
|
||||
// stream action. Check if user has the rights to edit this stream.
|
||||
|
||||
Logging::log("CREATE");
|
||||
} else {
|
||||
Logging::log("EDIT");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
|
@ -140,6 +172,7 @@ Array
|
|||
|
||||
$length = trim($request->getParam("length"));
|
||||
$result = preg_match("/^([0-9]{1,2})h ([0-5][0-9])m$/", $length, $matches);
|
||||
|
||||
if ($result == 1 && count($matches) == 3) {
|
||||
$hours = $matches[1];
|
||||
$minutes = $matches[2];
|
||||
|
@ -151,8 +184,14 @@ Array
|
|||
throw new Exception("Invalid date format: $length");
|
||||
}
|
||||
|
||||
#TODO: These should be validated by a Zend Form.
|
||||
$webstream = new CcWebstream();
|
||||
$id = $request->getParam("id");
|
||||
|
||||
if (is_null($id)) {
|
||||
$webstream = new CcWebstream();
|
||||
} else {
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
}
|
||||
|
||||
$webstream->setDbName($request->getParam("name"));
|
||||
$webstream->setDbDescription($request->getParam("description"));
|
||||
$webstream->setDbUrl($request->getParam("url"));
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
<div id="url-error" class="errors" style="display:none;"></div>
|
||||
<dt id="streamurl-label"><label for="streamurl">Stream URL:</label></dt>
|
||||
<dd id="streamurl-element">
|
||||
<input type="text" value="http://" size="40"/>
|
||||
<input type="text" value="<?php echo $this->ws->getUrl(); ?>" size="40"/>
|
||||
</dd>
|
||||
<div id="length-error" class="errors" style="display:none;"></div>
|
||||
<dt id="streamlength-label"><label for="streamlength">Default Length:</label></dt>
|
||||
<dd id="streamlength-element">
|
||||
<input type="text" value="00h 20m"/>
|
||||
<input type="text" value="<?php echo $this->ws->getDefaultLength() ?>"/>
|
||||
</dd>
|
||||
<dd id="submit-element" class="buttons">
|
||||
<input class="ui-button ui-state-default" type="submit" value="Save" id="webstream_save" name="submit">
|
||||
|
|
|
@ -611,12 +611,18 @@ var AIRTIME = (function(AIRTIME) {
|
|||
callback = function() {
|
||||
document.location.href = oItems.edit.url;
|
||||
};
|
||||
}
|
||||
else {
|
||||
} else if (data.ftype === "playlist" || data.ftype === "block") {
|
||||
callback = function() {
|
||||
//TODO
|
||||
AIRTIME.playlist.fnEdit(data.id, data.ftype);
|
||||
var url = '/Playlist/edit';
|
||||
AIRTIME.playlist.fnEdit(data.id, data.ftype, url);
|
||||
};
|
||||
} else if (data.ftype === "stream") {
|
||||
callback = function() {
|
||||
var url = '/Webstream/edit';
|
||||
AIRTIME.playlist.fnEdit(data.id, data.ftype, url);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Unknown type: " + data.ftype);
|
||||
}
|
||||
oItems.edit.callback = callback;
|
||||
}
|
||||
|
|
|
@ -532,6 +532,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
//stream url
|
||||
//default_length
|
||||
//playlist name
|
||||
var id = $pl.find("#ws_id").attr("value");
|
||||
var description = $pl.find("#description").val();
|
||||
var streamurl = $pl.find("#streamurl-element input").val();
|
||||
var length = $pl.find("#streamlength-element input").val();
|
||||
|
@ -542,7 +543,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
|
||||
var url = 'Webstream/save';
|
||||
$.post(url,
|
||||
{format: "json", description: description, url:streamurl, length: length, name: name},
|
||||
{format: "json", id:id, description: description, url:streamurl, length: length, name: name},
|
||||
function(json){
|
||||
if (json.analysis){
|
||||
for (var s in json.analysis){
|
||||
|
@ -730,8 +731,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
});
|
||||
};
|
||||
|
||||
mod.fnEdit = function(id, type) {
|
||||
var url = '/Playlist/edit';
|
||||
mod.fnEdit = function(id, type, url) {
|
||||
|
||||
stopAudioPreview();
|
||||
|
||||
|
@ -742,6 +742,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
mod.fnDelete = function(plid) {
|
||||
var url, id, lastMod;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ exec 2>&1
|
|||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "Please run as root user."
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Current dir
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue