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

This commit is contained in:
denise 2012-08-13 14:41:59 -04:00
commit cfc5587043
20 changed files with 274 additions and 132 deletions

View File

@ -132,29 +132,19 @@ class ApiController extends Zend_Controller_Action
$file_base_name = substr($file_base_name, 1); $file_base_name = substr($file_base_name, 1);
} }
// possibly use fileinfo module here in the future.
// http://www.php.net/manual/en/book.fileinfo.php
$ext = pathinfo($file_base_name, PATHINFO_EXTENSION);
//Download user left clicks a track and selects Download. //Download user left clicks a track and selects Download.
if ("true" == $this->_getParam('download')) { if ("true" == $this->_getParam('download')) {
//path_info breaks up a file path into seperate pieces of informaiton. //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 //We just want the basename which is the file name with the path
//information stripped away. We are using Content-Disposition to specify //information stripped away. We are using Content-Disposition to specify
//to the browser what name the file should be saved as. //to the browser what name the file should be saved as.
//
// By james.moon:
// I'm removing pathinfo() since it strips away UTF-8 characters.
// Using manualy parsing
header('Content-Disposition: attachment; filename="'.$file_base_name.'"'); header('Content-Disposition: attachment; filename="'.$file_base_name.'"');
} else { } else {
//user clicks play button for track and downloads it. //user clicks play button for track and downloads it.
header('Content-Disposition: inline; filename="'.$file_base_name.'"'); header('Content-Disposition: inline; filename="'.$file_base_name.'"');
} }
if (strtolower($ext) === 'mp3') {
$this->smartReadFile($filepath, 'audio/mpeg'); $this->smartReadFile($filepath, $media->getPropelOrm()->getDbMime());
} else {
$this->smartReadFile($filepath, 'audio/'.$ext);
}
exit; exit;
} else { } else {
header ("HTTP/1.1 404 Not Found"); header ("HTTP/1.1 404 Not Found");
@ -259,7 +249,7 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$type = $request->getParam('type'); $type = $request->getParam('type');
/* This is some *extremely* lazy programming that needs to bi fixed. For some reason /* This is some *extremely* lazy programming that needs to bi fixed. For some reason
* we are using two entirely different codepaths for very similar functionality (type = endofday * we are using two entirely different codepaths for very similar functionality (type = endofday
* vs type = interval). Needs to be fixed for 2.2 - MK */ * vs type = interval). Needs to be fixed for 2.2 - MK */
if ($type == "endofday") { if ($type == "endofday") {
$limit = $request->getParam('limit'); $limit = $request->getParam('limit');
@ -275,25 +265,25 @@ class ApiController extends Zend_Controller_Action
"nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd) "nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd)
); );
Application_Model_Show::convertToLocalTimeZone($result["currentShow"], Application_Model_Show::convertToLocalTimeZone($result["currentShow"],
array("starts", "ends", "start_timestamp", "end_timestamp")); array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::convertToLocalTimeZone($result["nextShow"], Application_Model_Show::convertToLocalTimeZone($result["nextShow"],
array("starts", "ends", "start_timestamp", "end_timestamp")); array("starts", "ends", "start_timestamp", "end_timestamp"));
} else { } else {
$result = Application_Model_Schedule::GetPlayOrderRange(); $result = Application_Model_Schedule::GetPlayOrderRange();
//Convert from UTC to localtime for Web Browser. //Convert from UTC to localtime for Web Browser.
Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"],
array("starts", "ends", "start_timestamp", "end_timestamp")); array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"],
array("starts", "ends", "start_timestamp", "end_timestamp")); array("starts", "ends", "start_timestamp", "end_timestamp"));
} }
//used by caller to determine if the airtime they are running or widgets in use is out of date. //used by caller to determine if the airtime they are running or widgets in use is out of date.
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;
header("Content-type: text/javascript"); header("Content-type: text/javascript");
// If a callback is not given, then just provide the raw JSON. // If a callback is not given, then just provide the raw JSON.
echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result); echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result);
} else { } else {
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');
@ -327,8 +317,8 @@ class ApiController extends Zend_Controller_Action
} }
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date.
header("Content-type: text/javascript"); header("Content-type: text/javascript");
Logging::log($result);
// If a callback is not given, then just provide the raw JSON. // If a callback is not given, then just provide the raw JSON.
echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result); echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result);
} else { } else {
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');
@ -466,8 +456,8 @@ class ApiController extends Zend_Controller_Action
$this->view->watched_dirs = $watchedDirsPath; $this->view->watched_dirs = $watchedDirsPath;
} }
public function dispatchMetadataAction($md, $mode, $dry_run=false) public function dispatchMetadataAction($md, $mode, $dry_run=false)
{ {
// Replace this compound result in a hash with proper error handling later on // Replace this compound result in a hash with proper error handling later on
$return_hash = array(); $return_hash = array();
if ( $dry_run ) { // for debugging we return garbage not to screw around with the db if ( $dry_run ) { // for debugging we return garbage not to screw around with the db
@ -550,7 +540,7 @@ class ApiController extends Zend_Controller_Action
} }
$return_hash['fileid'] = $file->getId(); $return_hash['fileid'] = $file->getId();
return $return_hash; return $return_hash;
} }
public function reloadMetadataGroupAction() public function reloadMetadataGroupAction()
{ {
@ -595,7 +585,7 @@ class ApiController extends Zend_Controller_Action
$response['key'] = $k; $response['key'] = $k;
array_push($responses, $response); array_push($responses, $response);
// On recorded show requests we do some extra work here. Not sure what it actually is and it // On recorded show requests we do some extra work here. Not sure what it actually is and it
// was usually called from the python api client. Now we just call it straight from the controller to // was usually called from the python api client. Now we just call it straight from the controller to
// save the http roundtrip // save the http roundtrip
if( $info_json['is_record'] and !array_key_exists('error', $response) ) { if( $info_json['is_record'] and !array_key_exists('error', $response) ) {
$this->uploadRecordedActionParam($info_json['showinstanceid'],$info_json['fileid'],$dry_run=$dry); $this->uploadRecordedActionParam($info_json['showinstanceid'],$info_json['fileid'],$dry_run=$dry);

View File

@ -51,14 +51,18 @@ class AudiopreviewController extends Zend_Controller_Action
if ($type == "audioclip") { if ($type == "audioclip") {
$uri = "/api/get-media/file/".$audioFileID; $uri = "/api/get-media/file/".$audioFileID;
$media = Application_Model_StoredFile::Recall($audioFileID);
$mime = $media->getPropelOrm()->getDbMime();
} else if ($type == "stream") { } else if ($type == "stream") {
$webstream = CcWebstreamQuery::create()->findPk($audioFileID); $webstream = CcWebstreamQuery::create()->findPk($audioFileID);
$uri = $webstream->getDbUrl(); $uri = $webstream->getDbUrl();
$mime = $webstream->getDbMime();
} else { } else {
throw new Exception("Unknown type for audio preview!"); throw new Exception("Unknown type for audio preview!");
} }
$this->view->uri = $uri; $this->view->uri = $uri;
$this->view->mime = $mime;
$this->view->audioFileID = $audioFileID; $this->view->audioFileID = $audioFileID;
$this->view->audioFileArtist = $audioFileArtist; $this->view->audioFileArtist = $audioFileArtist;
$this->view->audioFileTitle = $audioFileTitle; $this->view->audioFileTitle = $audioFileTitle;

View File

@ -76,7 +76,7 @@ class LibraryController extends Zend_Controller_Action
$obj = new Application_Model_Playlist($id); $obj = new Application_Model_Playlist($id);
} else { } else {
$obj = new Application_Model_Block($id); $obj = new Application_Model_Block($id);
if (!$obj->isStatic()){ if (!$obj->isStatic()) {
unset($menu["play"]); unset($menu["play"]);
} }
if (($isAdminOrPM || $obj->getCreatorId() == $user->getId()) && $screen == "playlist") { if (($isAdminOrPM || $obj->getCreatorId() == $user->getId()) && $screen == "playlist") {
@ -96,7 +96,8 @@ class LibraryController extends Zend_Controller_Action
} }
} else if ($type == "stream") { } else if ($type == "stream") {
$obj = new Application_Model_Webstream($id); $webstream = CcWebstreamQuery::create()->findPK($id);
$obj = new Application_Model_Webstream($webstream);
if (isset($this->obj_sess->id) && $screen == "playlist") { if (isset($this->obj_sess->id) && $screen == "playlist") {
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) { if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
if ($this->obj_sess->type === "playlist") { if ($this->obj_sess->type === "playlist") {
@ -108,8 +109,6 @@ class LibraryController extends Zend_Controller_Action
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete"); $menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete");
$menu["edit"] = array("name"=> "Edit", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}"); $menu["edit"] = array("name"=> "Edit", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
} }
} }
//SOUNDCLOUD MENU OPTIONS //SOUNDCLOUD MENU OPTIONS
@ -136,6 +135,10 @@ class LibraryController extends Zend_Controller_Action
$menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => "/library/upload-file-soundcloud/id/{$id}"); $menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => "/library/upload-file-soundcloud/id/{$id}");
} }
if (empty($menu)) {
$menu["noaction"] = array("name"=>"No action available");
}
$this->view->items = $menu; $this->view->items = $menu;
} }
@ -265,7 +268,7 @@ class LibraryController extends Zend_Controller_Action
Logging::log($data['MDATA_KEY_FILEPATH']); Logging::log($data['MDATA_KEY_FILEPATH']);
Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data); Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data);
$this->_redirect('playlist/index'); $this->_redirect('Playlist');
} }
} }
@ -330,9 +333,10 @@ class LibraryController extends Zend_Controller_Action
} }
$this->view->block = $block; $this->view->block = $block;
} else if ($type == "stream") { } else if ($type == "stream") {
$file = new Application_Model_Webstream($id); $webstream = CcWebstreamQuery::create()->findPK($id);
$ws = new Application_Model_Webstream($webstream);
$md = $file->getMetadata(); $md = $ws->getMetadata();
$this->view->md = $md; $this->view->md = $md;
$this->view->type = $type; $this->view->type = $type;

View File

@ -15,19 +15,19 @@ class WebstreamController extends Zend_Controller_Action
public function newAction() public function newAction()
{ {
$this->view->ws = new Application_Model_Webstream();
$webstream = new CcWebstream();
//we're not saving this primary key in the DB so it's OK
$webstream->setDbId(-1);
$webstream->setDbName("Untitled Webstream");
$webstream->setDbDescription("");
$webstream->setDbUrl("http://");
$webstream->setDbLength("00:00:00");
$webstream->setDbName("Untitled Webstream");
$this->view->ws = new Application_Model_Webstream($webstream);
$this->view->html = $this->view->render('webstream/webstream.phtml'); $this->view->html = $this->view->render('webstream/webstream.phtml');
/*
$pl_sess = $this->pl_sess;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$pl = new Application_Model_Playlist();
$pl->setName("Untitled Playlist");
$pl->setPLMetaData('dc:creator', $userInfo->id);
$this->changePlaylist($pl->getId());
$this->createFullResponse($pl);
*/
} }
public function editAction() public function editAction()
@ -39,7 +39,8 @@ class WebstreamController extends Zend_Controller_Action
throw new Exception("Missing parameter 'id'"); throw new Exception("Missing parameter 'id'");
} }
$this->view->ws = new Application_Model_Webstream($id); $webstream = CcWebstreamQuery::create()->findPK($id);
$this->view->ws = new Application_Model_Webstream($webstream);
$this->view->html = $this->view->render('webstream/webstream.phtml'); $this->view->html = $this->view->render('webstream/webstream.phtml');
} }
@ -52,13 +53,15 @@ class WebstreamController extends Zend_Controller_Action
$hasPermission = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST)); $hasPermission = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST));
$id = $request->getParam("id"); $id = $request->getParam("id");
if ($id == -1) { $parameters = array();
$webstream = new CcWebstream(); $parameters['id'] = trim($request->getParam("id"));
} else { $parameters['length'] = trim($request->getParam("length"));
$webstream = CcWebstreamQuery::create()->findPK($id); $parameters['name'] = trim($request->getParam("name"));
} $parameters['description'] = trim($request->getParam("description"));
$parameters['url'] = trim($request->getParam("url"));
if ($id != -1) {
if ($parameters['id'] != -1) {
$webstream = CcWebstreamQuery::create()->findPK($parameters['id']);
//we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission. //we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission.
$user = Application_Model_User::getCurrentUser(); $user = Application_Model_User::getCurrentUser();
if ($webstream->getDbCreatorId() != $user->getId()) { if ($webstream->getDbCreatorId() != $user->getId()) {
@ -72,12 +75,16 @@ class WebstreamController extends Zend_Controller_Action
return; return;
} }
$analysis = Application_Model_Webstream::analyzeFormData($request); $analysis = Application_Model_Webstream::analyzeFormData($parameters);
try {
if (Application_Model_Webstream::isValid($analysis)) { if (Application_Model_Webstream::isValid($analysis)) {
Application_Model_Webstream::save($request, $webstream); Application_Model_Webstream::save($parameters);
$this->view->statusMessage = "<div class='success'>Webstream saved.</div>"; $this->view->statusMessage = "<div class='success'>Webstream saved.</div>";
} else { } else {
throw new Exception();
}
} catch (Exception $e) {
Logging::log($e);
$this->view->statusMessage = "<div class='errors'>Invalid form values.</div>"; $this->view->statusMessage = "<div class='errors'>Invalid form values.</div>";
$this->view->analysis = $analysis; $this->view->analysis = $analysis;
} }

View File

@ -42,7 +42,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
"album_title" => "s", "album_title" => "s",
"artist_name" => "s", "artist_name" => "s",
"bit_rate" => "n", "bit_rate" => "n",
"bpm" => "n", "bpm" => "s",
"comments" => "s", "comments" => "s",
"composer" => "s", "composer" => "s",
"conductor" => "s", "conductor" => "s",

View File

@ -275,12 +275,24 @@ EOT;
if ($modifier == "items") { if ($modifier == "items") {
$length = $value." ".$modifier; $length = $value." ".$modifier;
} else { } else {
$value = str_pad($value, 2, "0", STR_PAD_LEFT); $hour = "00";
if ($modifier == "minutes") { if ($modifier == "minutes") {
$length = "00:".$value.":00"; if ($value >59) {
$hour = intval($value/60);
$value = $value%60;
}
} else if ($modifier == "hours") { } else if ($modifier == "hours") {
$length = $value.":00:00"; $mins = $value * 60;
if ($mins >59) {
$hour = intval($mins/60);
$hour = str_pad($hour, 2, "0", STR_PAD_LEFT);
$value = $mins%60;
}
} }
$hour = str_pad($hour, 2, "0", STR_PAD_LEFT);
$value = str_pad($value, 2, "0", STR_PAD_LEFT);
$length = $hour.":".$value.":00";
} }
return $length; return $length;
} }
@ -976,7 +988,7 @@ EOT;
$column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']]); $column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$d['sp_criteria_field']]);
// validation on type of column // validation on type of column
if ($d['sp_criteria_field'] == 'length') { if ($d['sp_criteria_field'] == 'length') {
if (!preg_match("/(\d{2}):(\d{2}):(\d{2})/", $d['sp_criteria_value'])) { if (!preg_match("/^(\d{2}):(\d{2}):(\d{2})$/", $d['sp_criteria_value'])) {
$error[] = "'Length' should be in '00:00:00' format"; $error[] = "'Length' should be in '00:00:00' format";
} }
} else if ($column->getType() == PropelColumnTypes::TIMESTAMP) { } else if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
@ -1104,6 +1116,9 @@ EOT;
} }
} else { } else {
$length = $this->getStaticLength(); $length = $this->getStaticLength();
if (!$length) {
$length = "00:00:00";
}
$this->setLength($length); $this->setLength($length);
} }
$output['blockLength'] = $this->getFormattedLength(); $output['blockLength'] = $this->getFormattedLength();
@ -1298,9 +1313,20 @@ EOT;
foreach ($crit as $criteria) { foreach ($crit as $criteria) {
$spCriteriaPhpName = self::$criteria2PeerMap[$criteria['criteria']]; $spCriteriaPhpName = self::$criteria2PeerMap[$criteria['criteria']];
$spCriteria = $criteria['criteria']; $spCriteria = $criteria['criteria'];
$spCriteriaModifier = $criteria['modifier']; $spCriteriaModifier = $criteria['modifier'];
$spCriteriaValue = $criteria['value'];
$column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$spCriteria]);
// if the column is timestamp, convert it into UTC
if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
$spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($criteria['value']);
} else if($spCriteria == "bit_rate") {
// multiply 1000 because we store only number value
// e.g 192kps is stored as 192000
$spCriteriaValue = $criteria['value']*1000;
} else {
$spCriteriaValue = $criteria['value'];
}
if ($spCriteriaModifier == "starts with") { if ($spCriteriaModifier == "starts with") {
$spCriteriaValue = "$spCriteriaValue%"; $spCriteriaValue = "$spCriteriaValue%";
} else if ($spCriteriaModifier == "ends with") { } else if ($spCriteriaModifier == "ends with") {

View File

@ -157,7 +157,7 @@ class Application_Model_Playlist
$files = array(); $files = array();
$sql = <<<SQL $sql = <<<SQL
(SELECT * SELECT *
FROM ( FROM (
(SELECT pc.id AS id, (SELECT pc.id AS id,
pc.type, pc.type,
@ -212,11 +212,11 @@ class Application_Model_Playlist
JOIN cc_subjs AS sbj ON bl.creator_id=sbj.id JOIN cc_subjs AS sbj ON bl.creator_id=sbj.id
WHERE pc.playlist_id = {$this->id} WHERE pc.playlist_id = {$this->id}
AND pc.TYPE = 2)) AS temp AND pc.TYPE = 2)) AS temp
ORDER BY temp.position); ORDER BY temp.position;
SQL; SQL;
$con = Propel::getConnection(); $con = Propel::getConnection();
$rows = $con->query($sql)->fetchAll(); $rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
$offset = 0; $offset = 0;
foreach ($rows as &$row) { foreach ($rows as &$row) {

View File

@ -1902,7 +1902,7 @@ class Application_Model_Show
} }
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin //TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends" $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends FROM"
." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id" ." WHERE si.show_id = s.id"
." AND si.starts >= TIMESTAMP '$timeStart'" ." AND si.starts >= TIMESTAMP '$timeStart'"

View File

@ -4,22 +4,14 @@ class Application_Model_Webstream{
private $id; private $id;
public function __construct($id=-1) public function __construct($webstream)
{ {
if ($id == -1) { $this->webstream = $webstream;
$this->webstream = new CcWebstream(); }
//We're not saving this object in the database, so -1 ID is OK. public function getOrm()
$this->webstream->setDbId(-1); {
$this->webstream->setDbName("Untitled Webstream"); return $this->webstream;
$this->webstream->setDbDescription("");
$this->webstream->setDbUrl("http://");
$this->webstream->setDbLength("00:00:00");
$this->webstream->setDbName("Untitled Webstream");
} else {
$this->id = $id;
$this->webstream = CcWebstreamQuery::create()->findPK($this->id);
}
} }
public function getName() public function getName()
@ -61,8 +53,7 @@ class Application_Model_Webstream{
public function getMetadata() public function getMetadata()
{ {
$webstream = CcWebstreamQuery::create()->findPK($this->id); $subjs = CcSubjsQuery::create()->findPK($this->webstream->getDbCreatorId());
$subjs = CcSubjsQuery::create()->findPK($webstream->getDbCreatorId());
$username = $subjs->getDbLogin(); $username = $subjs->getDbLogin();
return array( return array(
@ -98,16 +89,15 @@ class Application_Model_Webstream{
$leftOvers = array_diff($p_ids, $ownedStreams); $leftOvers = array_diff($p_ids, $ownedStreams);
return $leftOvers; return $leftOvers;
} }
public static function analyzeFormData($request) public static function analyzeFormData($parameters)
{ {
$valid = array("length" => array(true, ''), $valid = array("length" => array(true, ''),
"url" => array(true, ''), "url" => array(true, ''),
"name" => array(true, '')); "name" => array(true, ''));
$length = trim($request->getParam("length")); $length = $parameters["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) {
$valid['length'][0] = false; $valid['length'][0] = false;
@ -115,10 +105,11 @@ class Application_Model_Webstream{
} }
$url = trim($request->getParam("url")); $url = $parameters["url"];
//simple validator that checks to make sure that the url starts with http(s), //simple validator that checks to make sure that the url starts with
//and that the domain is at least 1 letter long followed by a period. //http(s),
$result = preg_match("/^(http|https):\/\/.+\./", $url, $matches); //and that the domain is at least 1 letter long
$result = preg_match("/^(http|https):\/\/.+/", $url, $matches);
if ($result == 0) { if ($result == 0) {
$valid['url'][0] = false; $valid['url'][0] = false;
@ -126,13 +117,13 @@ class Application_Model_Webstream{
} }
$name = trim($request->getParam("name")); $name = $parameters["name"];
if (strlen($name) == 0) { if (strlen($name) == 0) {
$valid['name'][0] = false; $valid['name'][0] = false;
$valid['name'][1] = 'Webstream name cannot be empty'; $valid['name'][1] = 'Webstream name cannot be empty';
} }
$id = trim($request->getParam("id")); $id = $parameters["id"];
if (!is_null($id)) { if (!is_null($id)) {
// user has performed a create stream action instead of edit // user has performed a create stream action instead of edit
@ -143,15 +134,13 @@ class Application_Model_Webstream{
Logging::log("EDIT"); Logging::log("EDIT");
} }
return $valid; return $valid;
} }
public static function isValid($analysis) public static function isValid($analysis)
{ {
foreach ($analysis as $k => $v) { foreach ($analysis as $k => $v) {
if ($v[0] == false) { if ($v[0] === false) {
return false; return false;
} }
} }
@ -159,11 +148,38 @@ class Application_Model_Webstream{
return true; return true;
} }
public static function save($request, $webstream) /*
* This function is a callback used by curl to let us work
* with the contents returned from an http request. We don't
* actually want to work with the contents however (we just want
* the response headers), so immediately return a -1 in this function
* which tells curl not to download the response body at all.
*/
private function writefn($ch, $chunk)
{
return -1;
}
private function discoverStreamMime()
{
Logging::log($this->webstream->getDbUrl());
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->webstream->getDbUrl());
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, array($this, 'writefn'));
$result = curl_exec($ch);
$mime = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
Logging::log($mime);
return $mime;
}
public static function save($parameters)
{ {
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$length = trim($request->getParam("length")); $length = $parameters["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) {
@ -177,15 +193,24 @@ class Application_Model_Webstream{
throw new Exception("Invalid date format: $length"); throw new Exception("Invalid date format: $length");
} }
$webstream = new CcWebstream();
$webstream->setDbName($request->getParam("name")); $webstream->setDbName($parameters["name"]);
$webstream->setDbDescription($request->getParam("description")); $webstream->setDbDescription($parameters["description"]);
$webstream->setDbUrl($request->getParam("url")); $webstream->setDbUrl($parameters["url"]);
$webstream->setDbLength($dblength); $webstream->setDbLength($dblength);
$webstream->setDbCreatorId($userInfo->id); $webstream->setDbCreatorId($userInfo->id);
$webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC'))); $webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC')));
$webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC'))); $webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC')));
$ws = new Application_Model_Webstream($webstream);
$mime = $ws->discoverStreamMime();
if ($mime !== false) {
$webstream->setDbMime($mime);
} else {
throw new Exception("Couldn't get MIME type!");
}
$webstream->save(); $webstream->save();
} }
} }

View File

@ -46,6 +46,7 @@ class CcWebstreamTableMap extends TableMap {
$this->addColumn('CREATOR_ID', 'DbCreatorId', 'INTEGER', true, null, null); $this->addColumn('CREATOR_ID', 'DbCreatorId', 'INTEGER', true, null, null);
$this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', true, 6, null); $this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', true, 6, null);
$this->addColumn('UTIME', 'DbUtime', 'TIMESTAMP', true, 6, null); $this->addColumn('UTIME', 'DbUtime', 'TIMESTAMP', true, 6, null);
$this->addColumn('MIME', 'DbMime', 'VARCHAR', false, 255, null);
// validators // validators
} // initialize() } // initialize()

View File

@ -73,6 +73,12 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
*/ */
protected $utime; protected $utime;
/**
* The value for the mime field.
* @var string
*/
protected $mime;
/** /**
* @var array CcSchedule[] Collection to store aggregation of CcSchedule objects. * @var array CcSchedule[] Collection to store aggregation of CcSchedule objects.
*/ */
@ -239,6 +245,16 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
} }
} }
/**
* Get the [mime] column value.
*
* @return string
*/
public function getDbMime()
{
return $this->mime;
}
/** /**
* Set the value of [id] column. * Set the value of [id] column.
* *
@ -457,6 +473,26 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
return $this; return $this;
} // setDbUtime() } // setDbUtime()
/**
* Set the value of [mime] column.
*
* @param string $v new value
* @return CcWebstream The current object (for fluent API support)
*/
public function setDbMime($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->mime !== $v) {
$this->mime = $v;
$this->modifiedColumns[] = CcWebstreamPeer::MIME;
}
return $this;
} // setDbMime()
/** /**
* Indicates whether the columns in this object are only set to default values. * Indicates whether the columns in this object are only set to default values.
* *
@ -501,6 +537,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$this->creator_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; $this->creator_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
$this->mtime = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; $this->mtime = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
$this->utime = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; $this->utime = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->mime = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
$this->resetModified(); $this->resetModified();
$this->setNew(false); $this->setNew(false);
@ -509,7 +546,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$this->ensureConsistency(); $this->ensureConsistency();
} }
return $startcol + 8; // 8 = CcWebstreamPeer::NUM_COLUMNS - CcWebstreamPeer::NUM_LAZY_LOAD_COLUMNS). return $startcol + 9; // 9 = CcWebstreamPeer::NUM_COLUMNS - CcWebstreamPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) { } catch (Exception $e) {
throw new PropelException("Error populating CcWebstream object", $e); throw new PropelException("Error populating CcWebstream object", $e);
@ -850,6 +887,9 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
case 7: case 7:
return $this->getDbUtime(); return $this->getDbUtime();
break; break;
case 8:
return $this->getDbMime();
break;
default: default:
return null; return null;
break; break;
@ -881,6 +921,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$keys[5] => $this->getDbCreatorId(), $keys[5] => $this->getDbCreatorId(),
$keys[6] => $this->getDbMtime(), $keys[6] => $this->getDbMtime(),
$keys[7] => $this->getDbUtime(), $keys[7] => $this->getDbUtime(),
$keys[8] => $this->getDbMime(),
); );
return $result; return $result;
} }
@ -936,6 +977,9 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
case 7: case 7:
$this->setDbUtime($value); $this->setDbUtime($value);
break; break;
case 8:
$this->setDbMime($value);
break;
} // switch() } // switch()
} }
@ -968,6 +1012,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
if (array_key_exists($keys[5], $arr)) $this->setDbCreatorId($arr[$keys[5]]); if (array_key_exists($keys[5], $arr)) $this->setDbCreatorId($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbMtime($arr[$keys[6]]); if (array_key_exists($keys[6], $arr)) $this->setDbMtime($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbUtime($arr[$keys[7]]); if (array_key_exists($keys[7], $arr)) $this->setDbUtime($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setDbMime($arr[$keys[8]]);
} }
/** /**
@ -987,6 +1032,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
if ($this->isColumnModified(CcWebstreamPeer::CREATOR_ID)) $criteria->add(CcWebstreamPeer::CREATOR_ID, $this->creator_id); if ($this->isColumnModified(CcWebstreamPeer::CREATOR_ID)) $criteria->add(CcWebstreamPeer::CREATOR_ID, $this->creator_id);
if ($this->isColumnModified(CcWebstreamPeer::MTIME)) $criteria->add(CcWebstreamPeer::MTIME, $this->mtime); if ($this->isColumnModified(CcWebstreamPeer::MTIME)) $criteria->add(CcWebstreamPeer::MTIME, $this->mtime);
if ($this->isColumnModified(CcWebstreamPeer::UTIME)) $criteria->add(CcWebstreamPeer::UTIME, $this->utime); if ($this->isColumnModified(CcWebstreamPeer::UTIME)) $criteria->add(CcWebstreamPeer::UTIME, $this->utime);
if ($this->isColumnModified(CcWebstreamPeer::MIME)) $criteria->add(CcWebstreamPeer::MIME, $this->mime);
return $criteria; return $criteria;
} }
@ -1055,6 +1101,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$copyObj->setDbCreatorId($this->creator_id); $copyObj->setDbCreatorId($this->creator_id);
$copyObj->setDbMtime($this->mtime); $copyObj->setDbMtime($this->mtime);
$copyObj->setDbUtime($this->utime); $copyObj->setDbUtime($this->utime);
$copyObj->setDbMime($this->mime);
if ($deepCopy) { if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of // important: temporarily setNew(false) because this affects the behavior of
@ -1284,6 +1331,7 @@ abstract class BaseCcWebstream extends BaseObject implements Persistent
$this->creator_id = null; $this->creator_id = null;
$this->mtime = null; $this->mtime = null;
$this->utime = null; $this->utime = null;
$this->mime = null;
$this->alreadyInSave = false; $this->alreadyInSave = false;
$this->alreadyInValidation = false; $this->alreadyInValidation = false;
$this->clearAllReferences(); $this->clearAllReferences();

View File

@ -26,7 +26,7 @@ abstract class BaseCcWebstreamPeer {
const TM_CLASS = 'CcWebstreamTableMap'; const TM_CLASS = 'CcWebstreamTableMap';
/** The total number of columns. */ /** The total number of columns. */
const NUM_COLUMNS = 8; const NUM_COLUMNS = 9;
/** The number of lazy-loaded columns. */ /** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0; const NUM_LAZY_LOAD_COLUMNS = 0;
@ -55,6 +55,9 @@ abstract class BaseCcWebstreamPeer {
/** the column name for the UTIME field */ /** the column name for the UTIME field */
const UTIME = 'cc_webstream.UTIME'; const UTIME = 'cc_webstream.UTIME';
/** the column name for the MIME field */
const MIME = 'cc_webstream.MIME';
/** /**
* An identiy map to hold any loaded instances of CcWebstream objects. * An identiy map to hold any loaded instances of CcWebstream objects.
* This must be public so that other peer classes can access this when hydrating from JOIN * This must be public so that other peer classes can access this when hydrating from JOIN
@ -71,12 +74,12 @@ abstract class BaseCcWebstreamPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/ */
private static $fieldNames = array ( private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbDescription', 'DbUrl', 'DbLength', 'DbCreatorId', 'DbMtime', 'DbUtime', ), BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbDescription', 'DbUrl', 'DbLength', 'DbCreatorId', 'DbMtime', 'DbUtime', 'DbMime', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbDescription', 'dbUrl', 'dbLength', 'dbCreatorId', 'dbMtime', 'dbUtime', ), BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbDescription', 'dbUrl', 'dbLength', 'dbCreatorId', 'dbMtime', 'dbUtime', 'dbMime', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::DESCRIPTION, self::URL, self::LENGTH, self::CREATOR_ID, self::MTIME, self::UTIME, ), BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::DESCRIPTION, self::URL, self::LENGTH, self::CREATOR_ID, self::MTIME, self::UTIME, self::MIME, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'DESCRIPTION', 'URL', 'LENGTH', 'CREATOR_ID', 'MTIME', 'UTIME', ), BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'DESCRIPTION', 'URL', 'LENGTH', 'CREATOR_ID', 'MTIME', 'UTIME', 'MIME', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'description', 'url', 'length', 'creator_id', 'mtime', 'utime', ), BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'description', 'url', 'length', 'creator_id', 'mtime', 'utime', 'mime', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
); );
/** /**
@ -86,12 +89,12 @@ abstract class BaseCcWebstreamPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/ */
private static $fieldKeys = array ( private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbDescription' => 2, 'DbUrl' => 3, 'DbLength' => 4, 'DbCreatorId' => 5, 'DbMtime' => 6, 'DbUtime' => 7, ), BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbDescription' => 2, 'DbUrl' => 3, 'DbLength' => 4, 'DbCreatorId' => 5, 'DbMtime' => 6, 'DbUtime' => 7, 'DbMime' => 8, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbDescription' => 2, 'dbUrl' => 3, 'dbLength' => 4, 'dbCreatorId' => 5, 'dbMtime' => 6, 'dbUtime' => 7, ), BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbDescription' => 2, 'dbUrl' => 3, 'dbLength' => 4, 'dbCreatorId' => 5, 'dbMtime' => 6, 'dbUtime' => 7, 'dbMime' => 8, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::DESCRIPTION => 2, self::URL => 3, self::LENGTH => 4, self::CREATOR_ID => 5, self::MTIME => 6, self::UTIME => 7, ), BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::DESCRIPTION => 2, self::URL => 3, self::LENGTH => 4, self::CREATOR_ID => 5, self::MTIME => 6, self::UTIME => 7, self::MIME => 8, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'DESCRIPTION' => 2, 'URL' => 3, 'LENGTH' => 4, 'CREATOR_ID' => 5, 'MTIME' => 6, 'UTIME' => 7, ), BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'DESCRIPTION' => 2, 'URL' => 3, 'LENGTH' => 4, 'CREATOR_ID' => 5, 'MTIME' => 6, 'UTIME' => 7, 'MIME' => 8, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'description' => 2, 'url' => 3, 'length' => 4, 'creator_id' => 5, 'mtime' => 6, 'utime' => 7, ), BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'description' => 2, 'url' => 3, 'length' => 4, 'creator_id' => 5, 'mtime' => 6, 'utime' => 7, 'mime' => 8, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
); );
/** /**
@ -171,6 +174,7 @@ abstract class BaseCcWebstreamPeer {
$criteria->addSelectColumn(CcWebstreamPeer::CREATOR_ID); $criteria->addSelectColumn(CcWebstreamPeer::CREATOR_ID);
$criteria->addSelectColumn(CcWebstreamPeer::MTIME); $criteria->addSelectColumn(CcWebstreamPeer::MTIME);
$criteria->addSelectColumn(CcWebstreamPeer::UTIME); $criteria->addSelectColumn(CcWebstreamPeer::UTIME);
$criteria->addSelectColumn(CcWebstreamPeer::MIME);
} else { } else {
$criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.NAME');
@ -180,6 +184,7 @@ abstract class BaseCcWebstreamPeer {
$criteria->addSelectColumn($alias . '.CREATOR_ID'); $criteria->addSelectColumn($alias . '.CREATOR_ID');
$criteria->addSelectColumn($alias . '.MTIME'); $criteria->addSelectColumn($alias . '.MTIME');
$criteria->addSelectColumn($alias . '.UTIME'); $criteria->addSelectColumn($alias . '.UTIME');
$criteria->addSelectColumn($alias . '.MIME');
} }
} }

View File

@ -14,6 +14,7 @@
* @method CcWebstreamQuery orderByDbCreatorId($order = Criteria::ASC) Order by the creator_id column * @method CcWebstreamQuery orderByDbCreatorId($order = Criteria::ASC) Order by the creator_id column
* @method CcWebstreamQuery orderByDbMtime($order = Criteria::ASC) Order by the mtime column * @method CcWebstreamQuery orderByDbMtime($order = Criteria::ASC) Order by the mtime column
* @method CcWebstreamQuery orderByDbUtime($order = Criteria::ASC) Order by the utime column * @method CcWebstreamQuery orderByDbUtime($order = Criteria::ASC) Order by the utime column
* @method CcWebstreamQuery orderByDbMime($order = Criteria::ASC) Order by the mime column
* *
* @method CcWebstreamQuery groupByDbId() Group by the id column * @method CcWebstreamQuery groupByDbId() Group by the id column
* @method CcWebstreamQuery groupByDbName() Group by the name column * @method CcWebstreamQuery groupByDbName() Group by the name column
@ -23,6 +24,7 @@
* @method CcWebstreamQuery groupByDbCreatorId() Group by the creator_id column * @method CcWebstreamQuery groupByDbCreatorId() Group by the creator_id column
* @method CcWebstreamQuery groupByDbMtime() Group by the mtime column * @method CcWebstreamQuery groupByDbMtime() Group by the mtime column
* @method CcWebstreamQuery groupByDbUtime() Group by the utime column * @method CcWebstreamQuery groupByDbUtime() Group by the utime column
* @method CcWebstreamQuery groupByDbMime() Group by the mime column
* *
* @method CcWebstreamQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcWebstreamQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcWebstreamQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method CcWebstreamQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -43,6 +45,7 @@
* @method CcWebstream findOneByDbCreatorId(int $creator_id) Return the first CcWebstream filtered by the creator_id column * @method CcWebstream findOneByDbCreatorId(int $creator_id) Return the first CcWebstream filtered by the creator_id column
* @method CcWebstream findOneByDbMtime(string $mtime) Return the first CcWebstream filtered by the mtime column * @method CcWebstream findOneByDbMtime(string $mtime) Return the first CcWebstream filtered by the mtime column
* @method CcWebstream findOneByDbUtime(string $utime) Return the first CcWebstream filtered by the utime column * @method CcWebstream findOneByDbUtime(string $utime) Return the first CcWebstream filtered by the utime column
* @method CcWebstream findOneByDbMime(string $mime) Return the first CcWebstream filtered by the mime column
* *
* @method array findByDbId(int $id) Return CcWebstream objects filtered by the id column * @method array findByDbId(int $id) Return CcWebstream objects filtered by the id column
* @method array findByDbName(string $name) Return CcWebstream objects filtered by the name column * @method array findByDbName(string $name) Return CcWebstream objects filtered by the name column
@ -52,6 +55,7 @@
* @method array findByDbCreatorId(int $creator_id) Return CcWebstream objects filtered by the creator_id column * @method array findByDbCreatorId(int $creator_id) Return CcWebstream objects filtered by the creator_id column
* @method array findByDbMtime(string $mtime) Return CcWebstream objects filtered by the mtime column * @method array findByDbMtime(string $mtime) Return CcWebstream objects filtered by the mtime column
* @method array findByDbUtime(string $utime) Return CcWebstream objects filtered by the utime column * @method array findByDbUtime(string $utime) Return CcWebstream objects filtered by the utime column
* @method array findByDbMime(string $mime) Return CcWebstream objects filtered by the mime column
* *
* @package propel.generator.airtime.om * @package propel.generator.airtime.om
*/ */
@ -359,6 +363,28 @@ abstract class BaseCcWebstreamQuery extends ModelCriteria
return $this->addUsingAlias(CcWebstreamPeer::UTIME, $dbUtime, $comparison); return $this->addUsingAlias(CcWebstreamPeer::UTIME, $dbUtime, $comparison);
} }
/**
* Filter the query on the mime column
*
* @param string $dbMime The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcWebstreamQuery The current query, for fluid interface
*/
public function filterByDbMime($dbMime = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbMime)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbMime)) {
$dbMime = str_replace('*', '%', $dbMime);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcWebstreamPeer::MIME, $dbMime, $comparison);
}
/** /**
* Filter the query by a related CcSchedule object * Filter the query by a related CcSchedule object
* *

View File

@ -8,6 +8,7 @@
<span class='blockIndex'><?php echo "$this->blockIndex" ?></span> <span class='blockIndex'><?php echo "$this->blockIndex" ?></span>
<?php elseif (isset($this->uri)): ?> <?php elseif (isset($this->uri)): ?>
<span class='audioUri'><?php echo "$this->uri" ?></span> <span class='audioUri'><?php echo "$this->uri" ?></span>
<span class='audioMime'><?php echo "$this->mime" ?></span>
<span class='audioFileTitle'><?php echo "$this->audioFileTitle" ?></span> <span class='audioFileTitle'><?php echo "$this->audioFileTitle" ?></span>
<span class='audioFileArtist'><?php echo "$this->audioFileArtist" ?></span> <span class='audioFileArtist'><?php echo "$this->audioFileArtist" ?></span>
<?php elseif (isset($this->showID)): ?> <?php elseif (isset($this->showID)): ?>

View File

@ -16,14 +16,14 @@ if ($item['type'] == 2) {
<div class="big_play" audioFile="<?php echo $item["id"]; ?>"> <div class="big_play" audioFile="<?php echo $item["id"]; ?>">
<span class="ui-icon ui-icon-play"></span> <span class="ui-icon ui-icon-play"></span>
</div> </div>
<?php elseif ($item['type'] == 1 && $item['exists']): ?>
<div class="big_play">
<span class="ui-icon ui-icon-play"></span>
</div>
<?php elseif ($item['type'] == 2 && $item['exists']): ?> <?php elseif ($item['type'] == 2 && $item['exists']): ?>
<div class="big_play ui-state-hover" blockId="<?php echo $item["item_id"]; ?>"> <div class="big_play ui-state-hover" blockId="<?php echo $item["item_id"]; ?>">
<span class="ui-icon ui-icon-alert"></span> <span class="ui-icon ui-icon-alert"></span>
</div> </div>
<?php else: ?>
<div class="big_play ui-state-hover">
<span class="ui-icon ui-icon-alert"></span>
</div>
<?php endif; ?> <?php endif; ?>
<div class="text-row top"> <div class="text-row top">
<span class="spl_playlength"><?php echo $item["length"] ?></span> <span class="spl_playlength"><?php echo $item["length"] ?></span>

View File

@ -422,5 +422,6 @@
<column name="creator_id" phpName="DbCreatorId" type="INTEGER" required="true" /> <column name="creator_id" phpName="DbCreatorId" type="INTEGER" required="true" />
<column name="mtime" phpName="DbMtime" type="TIMESTAMP" size="6" required="true" /> <column name="mtime" phpName="DbMtime" type="TIMESTAMP" size="6" required="true" />
<column name="utime" phpName="DbUtime" type="TIMESTAMP" size="6" required="true" /> <column name="utime" phpName="DbUtime" type="TIMESTAMP" size="6" required="true" />
<column name="mime" phpName="DbMime" type="VARCHAR" />
</table> </table>
</database> </database>

View File

@ -638,6 +638,7 @@ CREATE TABLE "cc_webstream"
"creator_id" INTEGER NOT NULL, "creator_id" INTEGER NOT NULL,
"mtime" TIMESTAMP(6) NOT NULL, "mtime" TIMESTAMP(6) NOT NULL,
"utime" TIMESTAMP(6) NOT NULL, "utime" TIMESTAMP(6) NOT NULL,
"mime" VARCHAR(255),
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );

View File

@ -36,6 +36,7 @@ $(document).ready(function(){
$.jPlayer.timeFormat.showHour = true; $.jPlayer.timeFormat.showHour = true;
var audioUri = $('.audioUri').text(); var audioUri = $('.audioUri').text();
var audioMime = $('.audioMime').text();
//var audioFileID = $('.audioFileID').text(); //var audioFileID = $('.audioFileID').text();
var playlistID = $('.playlistID').text(); var playlistID = $('.playlistID').text();
var playlistIndex = $('.playlistIndex').text(); var playlistIndex = $('.playlistIndex').text();
@ -49,7 +50,7 @@ $(document).ready(function(){
if (playlistID != "" && playlistID !== ""){ if (playlistID != "" && playlistID !== ""){
playAllPlaylist(playlistID, playlistIndex); playAllPlaylist(playlistID, playlistIndex);
}else if (audioUri != "") { }else if (audioUri != "") {
playOne(audioUri); playOne(audioUri, audioMime);
}else if (showID != "") { }else if (showID != "") {
playAllShow(showID, showIndex); playAllShow(showID, showIndex);
}else if(blockId != "" && blockIndex != ""){ }else if(blockId != "" && blockIndex != ""){
@ -188,20 +189,21 @@ function play(p_playlistIndex){
* Playing one audio track occurs from the library. This function will create the media, setup * Playing one audio track occurs from the library. This function will create the media, setup
* jplayer and play the track. * jplayer and play the track.
*/ */
function playOne(uri) { function playOne(uri, mime) {
var playlist = new Array(); var playlist = new Array();
var fileExtension = uri.split('.').pop();
if (fileExtension.toLowerCase() === 'mp3') { if (mime.search(/mp3/i) > 0 || mime.search(/mpeg/i) > 0) {
media = {title: $('.audioFileTitle').text() !== 'null' ?$('.audioFileTitle').text():"", media = {title: $('.audioFileTitle').text() !== 'null' ?$('.audioFileTitle').text():"",
artist: $('.audioFileArtist').text() !== 'null' ?$('.audioFileArtist').text():"", artist: $('.audioFileArtist').text() !== 'null' ?$('.audioFileArtist').text():"",
mp3:uri mp3:uri
}; };
} else if (fileExtension.toLowerCase() === 'ogg' ) { } else if (mime.search(/og(g|a)/i) > 0 || mime.search(/vorbis/i) > 0) {
media = {title: $('.audioFileTitle').text() != 'null' ?$('.audioFileTitle').text():"", media = {title: $('.audioFileTitle').text() != 'null' ?$('.audioFileTitle').text():"",
artist: $('.audioFileArtist').text() != 'null' ?$('.audioFileArtist').text():"", artist: $('.audioFileArtist').text() != 'null' ?$('.audioFileArtist').text():"",
oga:uri oga:uri
}; };
} }
_playlist_jplayer.option("autoPlay", true); _playlist_jplayer.option("autoPlay", true);
playlist[0] = media; playlist[0] = media;
//_playlist_jplayer.setPlaylist(playlist); --if I use this the player will call _init on the setPlaylist and on the ready //_playlist_jplayer.setPlaylist(playlist); --if I use this the player will call _init on the setPlaylist and on the ready

View File

@ -568,7 +568,7 @@ var criteriaTypes = {
"album_title" : "s", "album_title" : "s",
"artist_name" : "s", "artist_name" : "s",
"bit_rate" : "n", "bit_rate" : "n",
"bpm" : "n", "bpm" : "s",
"comments" : "s", "comments" : "s",
"composer" : "s", "composer" : "s",
"conductor" : "s", "conductor" : "s",

View File

@ -17,7 +17,7 @@ if (substr($sapi_type, 0, 3) == 'cli') {
$status = AirtimeCheck::GetStatus($baseUrl, $base_port, $apiKey); $status = AirtimeCheck::GetStatus($baseUrl, $base_port, $apiKey);
AirtimeCheck::PrintStatus($baseUrl, $status); AirtimeCheck::PrintStatus($baseUrl, $base_port, $status);
} }
class AirtimeCheck { class AirtimeCheck {
@ -92,8 +92,9 @@ class AirtimeCheck {
return $os_string." ".$machine; return $os_string." ".$machine;
} }
public static function GetServerType($p_baseUrl){ public static function GetServerType($p_baseUrl, $p_basePort)
$headerInfo = get_headers("http://$p_baseUrl",1); {
$headerInfo = get_headers("http://$p_baseUrl:$p_basePort",1);
if (!isset($headerInfo['Server'][0])) if (!isset($headerInfo['Server'][0]))
return self::UNKNOWN; return self::UNKNOWN;
@ -120,7 +121,7 @@ class AirtimeCheck {
return $data; return $data;
} }
public static function PrintStatus($p_baseUrl, $p_status){ public static function PrintStatus($p_baseUrl, $p_basePort, $p_status){
if ($p_status === false){ if ($p_status === false){
self::output_status("AIRTIME_SERVER_RESPONDING", "FAILED"); self::output_status("AIRTIME_SERVER_RESPONDING", "FAILED");
@ -150,7 +151,7 @@ class AirtimeCheck {
} }
self::output_status("OS", self::CheckOsTypeVersion()); self::output_status("OS", self::CheckOsTypeVersion());
self::output_status("CPU", self::GetCpuInfo()); self::output_status("CPU", self::GetCpuInfo());
self::output_status("WEB_SERVER", self::GetServerType($p_baseUrl)); self::output_status("WEB_SERVER", self::GetServerType($p_baseUrl, $p_basePort));
if (isset($data->services)) { if (isset($data->services)) {
$services = $data->services; $services = $data->services;