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 = $this->_helper->getHelper('AjaxContext');
|
||||||
$ajaxContext->addActionContext('new', 'json')
|
$ajaxContext->addActionContext('new', 'json')
|
||||||
->addActionContext('save', 'json')
|
->addActionContext('save', 'json')
|
||||||
|
->addActionContext('edit', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
//TODO
|
//TODO
|
||||||
//$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
//$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()
|
public function saveAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
|
@ -4,34 +4,52 @@ class Application_Model_Webstream{
|
||||||
|
|
||||||
private $id;
|
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";
|
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()
|
public function getMetadata()
|
||||||
|
@ -41,11 +59,11 @@ class Application_Model_Webstream{
|
||||||
|
|
||||||
$username = $subjs->getDbLogin();
|
$username = $subjs->getDbLogin();
|
||||||
return array(
|
return array(
|
||||||
"name" => $webstream->getDbName(),
|
"name" => $this->webstream->getDbName(),
|
||||||
"length" => $webstream->getDbLength(),
|
"length" => $this->webstream->getDbLength(),
|
||||||
"description" => $webstream->getDbDescription(),
|
"description" => $this->webstream->getDbDescription(),
|
||||||
"login"=> $username,
|
"login"=> $username,
|
||||||
"url" => $webstream->getDbUrl(),
|
"url" => $this->webstream->getDbUrl(),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,7 +111,8 @@ Array
|
||||||
public static function analyzeFormData($request)
|
public static function analyzeFormData($request)
|
||||||
{
|
{
|
||||||
$valid = array("length" => array(true, ''),
|
$valid = array("length" => array(true, ''),
|
||||||
"url" => array(true, ''));
|
"url" => array(true, ''),
|
||||||
|
"name" => array(true, ''));
|
||||||
|
|
||||||
$length = trim($request->getParam("length"));
|
$length = trim($request->getParam("length"));
|
||||||
$result = preg_match("/^([0-9]{1,2})h ([0-5][0-9])m$/", $length, $matches);
|
$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';
|
$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;
|
return $valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +172,7 @@ Array
|
||||||
|
|
||||||
$length = trim($request->getParam("length"));
|
$length = trim($request->getParam("length"));
|
||||||
$result = preg_match("/^([0-9]{1,2})h ([0-5][0-9])m$/", $length, $matches);
|
$result = preg_match("/^([0-9]{1,2})h ([0-5][0-9])m$/", $length, $matches);
|
||||||
|
|
||||||
if ($result == 1 && count($matches) == 3) {
|
if ($result == 1 && count($matches) == 3) {
|
||||||
$hours = $matches[1];
|
$hours = $matches[1];
|
||||||
$minutes = $matches[2];
|
$minutes = $matches[2];
|
||||||
|
@ -150,9 +183,15 @@ Array
|
||||||
//in the controller
|
//in the controller
|
||||||
throw new Exception("Invalid date format: $length");
|
throw new Exception("Invalid date format: $length");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$id = $request->getParam("id");
|
||||||
|
|
||||||
|
if (is_null($id)) {
|
||||||
|
$webstream = new CcWebstream();
|
||||||
|
} else {
|
||||||
|
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||||
|
}
|
||||||
|
|
||||||
#TODO: These should be validated by a Zend Form.
|
|
||||||
$webstream = new CcWebstream();
|
|
||||||
$webstream->setDbName($request->getParam("name"));
|
$webstream->setDbName($request->getParam("name"));
|
||||||
$webstream->setDbDescription($request->getParam("description"));
|
$webstream->setDbDescription($request->getParam("description"));
|
||||||
$webstream->setDbUrl($request->getParam("url"));
|
$webstream->setDbUrl($request->getParam("url"));
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
<div id="url-error" class="errors" style="display:none;"></div>
|
<div id="url-error" class="errors" style="display:none;"></div>
|
||||||
<dt id="streamurl-label"><label for="streamurl">Stream URL:</label></dt>
|
<dt id="streamurl-label"><label for="streamurl">Stream URL:</label></dt>
|
||||||
<dd id="streamurl-element">
|
<dd id="streamurl-element">
|
||||||
<input type="text" value="http://" size="40"/>
|
<input type="text" value="<?php echo $this->ws->getUrl(); ?>" size="40"/>
|
||||||
</dd>
|
</dd>
|
||||||
<div id="length-error" class="errors" style="display:none;"></div>
|
<div id="length-error" class="errors" style="display:none;"></div>
|
||||||
<dt id="streamlength-label"><label for="streamlength">Default Length:</label></dt>
|
<dt id="streamlength-label"><label for="streamlength">Default Length:</label></dt>
|
||||||
<dd id="streamlength-element">
|
<dd id="streamlength-element">
|
||||||
<input type="text" value="00h 20m"/>
|
<input type="text" value="<?php echo $this->ws->getDefaultLength() ?>"/>
|
||||||
</dd>
|
</dd>
|
||||||
<dd id="submit-element" class="buttons">
|
<dd id="submit-element" class="buttons">
|
||||||
<input class="ui-button ui-state-default" type="submit" value="Save" id="webstream_save" name="submit">
|
<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() {
|
callback = function() {
|
||||||
document.location.href = oItems.edit.url;
|
document.location.href = oItems.edit.url;
|
||||||
};
|
};
|
||||||
}
|
} else if (data.ftype === "playlist" || data.ftype === "block") {
|
||||||
else {
|
|
||||||
callback = function() {
|
callback = function() {
|
||||||
//TODO
|
var url = '/Playlist/edit';
|
||||||
AIRTIME.playlist.fnEdit(data.id, data.ftype);
|
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;
|
oItems.edit.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,6 +532,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
//stream url
|
//stream url
|
||||||
//default_length
|
//default_length
|
||||||
//playlist name
|
//playlist name
|
||||||
|
var id = $pl.find("#ws_id").attr("value");
|
||||||
var description = $pl.find("#description").val();
|
var description = $pl.find("#description").val();
|
||||||
var streamurl = $pl.find("#streamurl-element input").val();
|
var streamurl = $pl.find("#streamurl-element input").val();
|
||||||
var length = $pl.find("#streamlength-element input").val();
|
var length = $pl.find("#streamlength-element input").val();
|
||||||
|
@ -542,7 +543,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
|
|
||||||
var url = 'Webstream/save';
|
var url = 'Webstream/save';
|
||||||
$.post(url,
|
$.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){
|
function(json){
|
||||||
if (json.analysis){
|
if (json.analysis){
|
||||||
for (var s in json.analysis){
|
for (var s in json.analysis){
|
||||||
|
@ -730,8 +731,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.fnEdit = function(id, type) {
|
mod.fnEdit = function(id, type, url) {
|
||||||
var url = '/Playlist/edit';
|
|
||||||
|
|
||||||
stopAudioPreview();
|
stopAudioPreview();
|
||||||
|
|
||||||
|
@ -741,6 +741,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
openPlaylist(json);
|
openPlaylist(json);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
mod.fnDelete = function(plid) {
|
mod.fnDelete = function(plid) {
|
||||||
var url, id, lastMod;
|
var url, id, lastMod;
|
||||||
|
|
|
@ -8,7 +8,7 @@ exec 2>&1
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
echo "Please run as root user."
|
echo "Please run as root user."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Current dir
|
#Current dir
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue