Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
Conflicts: airtime_mvc/application/models/Block.php
This commit is contained in:
commit
028e089c82
9 changed files with 193 additions and 55 deletions
|
@ -408,9 +408,14 @@ EOT;
|
|||
|
||||
foreach ($p_items as $ac) {
|
||||
Logging::log("Adding audio file {$ac}");
|
||||
|
||||
$res = $this->insertBlockElement($this->buildEntry($ac, $pos));
|
||||
$pos = $pos + 1;
|
||||
|
||||
if (is_array($ac) && $ac[1] == 'audioclip') {
|
||||
$res = $this->insertBlockElement($this->buildEntry($ac[0], $pos));
|
||||
$pos = $pos + 1;
|
||||
} elseif (!is_array($ac)) {
|
||||
$res = $this->insertBlockElement($this->buildEntry($ac, $pos));
|
||||
$pos = $pos + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//reset the positions of the remaining items.
|
||||
|
|
|
@ -75,20 +75,82 @@ class Application_Model_Webstream{
|
|||
return $leftOvers;
|
||||
|
||||
}
|
||||
/*
|
||||
Array
|
||||
(
|
||||
[controller] => Webstream
|
||||
[action] => save
|
||||
[module] => default
|
||||
[format] => json
|
||||
[description] => desc
|
||||
[url] => http://
|
||||
[length] => 00h 20m
|
||||
[name] => Default
|
||||
)
|
||||
*/
|
||||
|
||||
|
||||
public static function analyzeFormData($request)
|
||||
{
|
||||
$valid = array("length" => array(true, ''),
|
||||
"url" => array(true, ''));
|
||||
|
||||
$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) {
|
||||
$valid['length'][0] = false;
|
||||
$valid['length'][1] = 'Length should be of form "00h 00m"';
|
||||
}
|
||||
|
||||
|
||||
$url = trim($request->getParam("url"));
|
||||
//simple validator that checks to make sure that the url starts with http(s),
|
||||
//and that the domain is at least 1 letter long followed by a period.
|
||||
$result = preg_match("/^(http|https):\/\/.+\./", $url, $matches);
|
||||
|
||||
if ($result == 0) {
|
||||
$valid['url'][0] = false;
|
||||
$valid['url'][1] = 'URL should be of form "http://www.domain.com/mount"';
|
||||
}
|
||||
|
||||
|
||||
$name = trim($request->getParam("name"));
|
||||
if (strlen($name) == 0) {
|
||||
$valid['name'][0] = false;
|
||||
$valid['name'][1] = 'Webstream name cannot be empty';
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
public static function isValid($analysis)
|
||||
{
|
||||
foreach ($analysis as $k => $v) {
|
||||
if ($v[0] == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function save($request)
|
||||
{
|
||||
Logging::log($request->getParams());
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
Logging::log($userInfo);
|
||||
|
||||
$length = trim($request->getParam("length"));
|
||||
preg_match("/^([0-9]{1,2})h ([0-5][0-9])m$/", $length, $matches);
|
||||
$hours = $matches[1];
|
||||
$minutes = $matches[2];
|
||||
$di = new DateInterval("PT{$hours}H{$minutes}M");
|
||||
$dblength = $di->format("%H:%I");
|
||||
|
||||
$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];
|
||||
$di = new DateInterval("PT{$hours}H{$minutes}M");
|
||||
$dblength = $di->format("%H:%I");
|
||||
} else {
|
||||
//This should never happen because we should have already validated
|
||||
//in the controller
|
||||
throw new Exception("Invalid date format: $length");
|
||||
}
|
||||
|
||||
#TODO: These should be validated by a Zend Form.
|
||||
$webstream = new CcWebstream();
|
||||
$webstream->setDbName($request->getParam("name"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue