Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
df476d9cb6
|
@ -366,56 +366,56 @@ class Application_Common_DateHelper
|
||||||
return $retVal;
|
return $retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used for calculations! Don't modify for display purposes!
|
* This function is used for calculations! Don't modify for display purposes!
|
||||||
*
|
*
|
||||||
* Convert playlist time value to float seconds
|
* Convert playlist time value to float seconds
|
||||||
*
|
*
|
||||||
* @param string $plt
|
* @param string $plt
|
||||||
* playlist interval value (HH:mm:ss.dddddd)
|
* playlist interval value (HH:mm:ss.dddddd)
|
||||||
* @return int
|
* @return int
|
||||||
* seconds
|
* seconds
|
||||||
*/
|
*/
|
||||||
public static function playlistTimeToSeconds($plt)
|
public static function playlistTimeToSeconds($plt)
|
||||||
{
|
{
|
||||||
$arr = preg_split('/:/', $plt);
|
$arr = preg_split('/:/', $plt);
|
||||||
if (isset($arr[2])) {
|
if (isset($arr[2])) {
|
||||||
return (intval($arr[0])*60 + intval($arr[1]))*60 + floatval($arr[2]);
|
return (intval($arr[0])*60 + intval($arr[1]))*60 + floatval($arr[2]);
|
||||||
}
|
}
|
||||||
if (isset($arr[1])) {
|
if (isset($arr[1])) {
|
||||||
return intval($arr[0])*60 + floatval($arr[1]);
|
return intval($arr[0])*60 + floatval($arr[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return floatval($arr[0]);
|
return floatval($arr[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used for calculations! Don't modify for display purposes!
|
* This function is used for calculations! Don't modify for display purposes!
|
||||||
*
|
*
|
||||||
* Convert float seconds value to playlist time format
|
* Convert float seconds value to playlist time format
|
||||||
*
|
*
|
||||||
* @param float $seconds
|
* @param float $seconds
|
||||||
* @return string
|
* @return string
|
||||||
* interval in playlist time format (HH:mm:ss.d)
|
* interval in playlist time format (HH:mm:ss.d)
|
||||||
*/
|
*/
|
||||||
public static function secondsToPlaylistTime($p_seconds)
|
public static function secondsToPlaylistTime($p_seconds)
|
||||||
{
|
{
|
||||||
$info = explode('.', $p_seconds);
|
$info = explode('.', $p_seconds);
|
||||||
$seconds = $info[0];
|
$seconds = $info[0];
|
||||||
if (!isset($info[1])) {
|
if (!isset($info[1])) {
|
||||||
$milliStr = 0;
|
$milliStr = 0;
|
||||||
} else {
|
} else {
|
||||||
$milliStr = $info[1];
|
$milliStr = $info[1];
|
||||||
}
|
}
|
||||||
$hours = floor($seconds / 3600);
|
$hours = floor($seconds / 3600);
|
||||||
$seconds -= $hours * 3600;
|
$seconds -= $hours * 3600;
|
||||||
$minutes = floor($seconds / 60);
|
$minutes = floor($seconds / 60);
|
||||||
$seconds -= $minutes * 60;
|
$seconds -= $minutes * 60;
|
||||||
|
|
||||||
$res = sprintf("%02d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr);
|
$res = sprintf("%02d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,12 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->checkAuth();
|
$ignoreAuth = array("live-info", "week-info");
|
||||||
|
|
||||||
|
$params = $this->getRequest()->getParams();
|
||||||
|
if (!in_array($params['action'], $ignoreAuth)) {
|
||||||
|
$this->checkAuth();
|
||||||
|
}
|
||||||
/* Initialize action controller here */
|
/* Initialize action controller here */
|
||||||
$context = $this->_helper->getHelper('contextSwitch');
|
$context = $this->_helper->getHelper('contextSwitch');
|
||||||
$context->addActionContext('version' , 'json')
|
$context->addActionContext('version' , 'json')
|
||||||
|
@ -41,7 +46,6 @@ class ApiController extends Zend_Controller_Action
|
||||||
public function checkAuth()
|
public function checkAuth()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
|
||||||
$api_key = $this->_getParam('api_key');
|
$api_key = $this->_getParam('api_key');
|
||||||
|
|
||||||
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
|
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
|
||||||
|
@ -298,7 +302,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$result = array();
|
$result = array();
|
||||||
for ($i=0; $i<7; $i++) {
|
for ($i=0; $i<7; $i++) {
|
||||||
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
|
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
|
||||||
$shows = Application_Model_Show::getNextShows($utcDayStart, "0", $utcDayEnd);
|
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
|
||||||
$utcDayStart = $utcDayEnd;
|
$utcDayStart = $utcDayEnd;
|
||||||
|
|
||||||
Application_Model_Show::convertToLocalTimeZone($shows,
|
Application_Model_Show::convertToLocalTimeZone($shows,
|
||||||
|
@ -307,9 +311,10 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
$result[$dow[$i]] = $shows;
|
$result[$dow[$i]] = $shows;
|
||||||
}
|
}
|
||||||
$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.
|
|
||||||
|
//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;
|
||||||
header("Content-type: text/javascript");
|
header("Content-type: text/javascript");
|
||||||
Logging::info($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 {
|
||||||
|
@ -415,8 +420,9 @@ class ApiController extends Zend_Controller_Action
|
||||||
$this->uploadRecordedActionParam($show_instance_id, $file_id);
|
$this->uploadRecordedActionParam($show_instance_id, $file_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The paramterized version of the uploadRecordedAction controller. We want this controller's action
|
// The paramterized version of the uploadRecordedAction controller.
|
||||||
// to be invokable from other controllers instead being of only through http
|
// We want this controller's action to be invokable from other
|
||||||
|
// controllers instead being of only through http
|
||||||
public function uploadRecordedActionParam($show_instance_id, $file_id)
|
public function uploadRecordedActionParam($show_instance_id, $file_id)
|
||||||
{
|
{
|
||||||
$showCanceled = false;
|
$showCanceled = false;
|
||||||
|
@ -430,10 +436,10 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
//we've reached here probably because the show was
|
//we've reached here probably because the show was
|
||||||
//cancelled, and therefore the show instance does not
|
//cancelled, and therefore the show instance does not exist
|
||||||
//exist anymore (ShowInstance constructor threw this error).
|
//anymore (ShowInstance constructor threw this error). We've
|
||||||
//We've done all we can do (upload the file and put it in
|
//done all we can do (upload the file and put it in the
|
||||||
//the library), now lets just return.
|
//library), now lets just return.
|
||||||
$showCanceled = true;
|
$showCanceled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +450,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
if (!$showCanceled && Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud()) {
|
if (!$showCanceled && Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud()) {
|
||||||
$id = $file->getId();
|
$id = $file->getId();
|
||||||
$res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &");
|
Application_Model_Soundcloud::uploadSoundcloud($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,7 @@ class LibraryController extends Zend_Controller_Action
|
||||||
public function uploadFileSoundcloudAction()
|
public function uploadFileSoundcloudAction()
|
||||||
{
|
{
|
||||||
$id = $this->_getParam('id');
|
$id = $this->_getParam('id');
|
||||||
$res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &");
|
Application_Model_Soundcloud::uploadSoundcloud($id);
|
||||||
// we should die with ui info
|
// we should die with ui info
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$file = $show_inst->getRecordedFile();
|
$file = $show_inst->getRecordedFile();
|
||||||
$id = $file->getId();
|
$id = $file->getId();
|
||||||
$res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &");
|
Application_Model_Soundcloud::uploadSoundcloud($id);
|
||||||
// we should die with ui info
|
// we should die with ui info
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,21 @@ class Application_Model_Datatables
|
||||||
// map that maps dbname to searchTerm
|
// map that maps dbname to searchTerm
|
||||||
$dbname2searchTerm = array();
|
$dbname2searchTerm = array();
|
||||||
foreach ($current2dbname as $currentPos => $dbname) {
|
foreach ($current2dbname as $currentPos => $dbname) {
|
||||||
$dbname2searchTerm[$dbname] =
|
$new_index = $librarySetting($currentPos);
|
||||||
$orig2searchTerm[$librarySetting($currentPos)];
|
// TODO : Fix this retarded hack later. Just a band aid for
|
||||||
|
// now at least we print some warnings so that we don't
|
||||||
|
// forget about this -- cc-4462
|
||||||
|
if ( array_key_exists($new_index, $orig2searchTerm) ) {
|
||||||
|
$dbname2searchTerm[$dbname] = $orig2searchTerm[$new_index];
|
||||||
|
} else {
|
||||||
|
Logging::warn("Trying to reorder to unknown index
|
||||||
|
printing as much debugging as possible...");
|
||||||
|
$debug = array(
|
||||||
|
'$new_index' => $new_index,
|
||||||
|
'$currentPos' => $currentPos,
|
||||||
|
'$orig2searchTerm' => $orig2searchTerm);
|
||||||
|
Logging::warn($debug);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = array();
|
$where = array();
|
||||||
|
|
|
@ -1101,7 +1101,7 @@ class Application_Model_Preference
|
||||||
} else {
|
} else {
|
||||||
$ds = unserialize($v);
|
$ds = unserialize($v);
|
||||||
return function ($x) use ($ds) {
|
return function ($x) use ($ds) {
|
||||||
if ( in_array($x, $ds['ColReorder'] ) ) {
|
if ( array_key_exists($x, $ds['ColReorder'] ) ) {
|
||||||
return $ds['ColReorder'][$x];
|
return $ds['ColReorder'][$x];
|
||||||
} else {
|
} else {
|
||||||
Logging::warn("Index $x does not exist preferences");
|
Logging::warn("Index $x does not exist preferences");
|
||||||
|
|
|
@ -2060,8 +2060,6 @@ SQL;
|
||||||
// been specified
|
// been specified
|
||||||
if ($timeEnd == "") {
|
if ($timeEnd == "") {
|
||||||
$timeEnd = "'$timeStart' + INTERVAL '2 days'";
|
$timeEnd = "'$timeStart' + INTERVAL '2 days'";
|
||||||
} else {
|
|
||||||
$timeEnd = "'$timeEnd'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
||||||
|
@ -2083,12 +2081,24 @@ WHERE si.show_id = s.id
|
||||||
AND si.starts < :timeEnd::timestamp
|
AND si.starts < :timeEnd::timestamp
|
||||||
AND modified_instance != TRUE
|
AND modified_instance != TRUE
|
||||||
ORDER BY si.starts
|
ORDER BY si.starts
|
||||||
LIMIT :lim
|
|
||||||
SQL;
|
SQL;
|
||||||
return Application_Common_Database::prepareAndExecute( $sql, array(
|
|
||||||
|
//PDO won't accept "ALL" as a limit value (complains it is not an
|
||||||
|
//integer, and so we must completely remove the limit clause if we
|
||||||
|
//want to show all results - MK
|
||||||
|
if ($limit != "ALL") {
|
||||||
|
$sql .= PHP_EOL."LIMIT :lim";
|
||||||
|
$params = array(
|
||||||
':timeStart' => $timeStart,
|
':timeStart' => $timeStart,
|
||||||
':timeEnd' => $timeEnd,
|
':timeEnd' => $timeEnd,
|
||||||
':lim' => $limit), 'all');
|
':lim' => $limit);
|
||||||
|
} else {
|
||||||
|
$params = array(
|
||||||
|
':timeStart' => $timeStart,
|
||||||
|
':timeEnd' => $timeEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Application_Common_Database::prepareAndExecute( $sql, $params, 'all');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -189,10 +189,13 @@ class Application_Model_ShowBuilder
|
||||||
$row["record"] = true;
|
$row["record"] = true;
|
||||||
|
|
||||||
if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
|
if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
|
||||||
$file = Application_Model_StoredFile::Recall($p_item["si_file_id"]);
|
Logging::info('$p_item contains:');
|
||||||
|
Logging::info($p_item);
|
||||||
|
$file = Application_Model_StoredFile::Recall(
|
||||||
|
$p_item['si_file_id']);
|
||||||
if (isset($file)) {
|
if (isset($file)) {
|
||||||
$sid = $file->getSoundCloudId();
|
$sid = $file->getSoundCloudId();
|
||||||
$row["soundcloud_id"] = $sid;
|
$row['soundcloud_id'] = $sid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,18 +207,18 @@ class Application_Model_ShowBuilder
|
||||||
$this->currentShow = false;
|
$this->currentShow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$row["header"] = true;
|
$row["header"] = true;
|
||||||
$row["starts"] = $showStartDT->format("Y-m-d H:i");
|
$row["starts"] = $showStartDT->format("Y-m-d H:i");
|
||||||
$row["startDate"] = $showStartDT->format("Y-m-d");
|
$row["startDate"] = $showStartDT->format("Y-m-d");
|
||||||
$row["startTime"] = $showStartDT->format("H:i");
|
$row["startTime"] = $showStartDT->format("H:i");
|
||||||
$row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now;
|
$row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now;
|
||||||
$row["ends"] = $showEndDT->format("Y-m-d H:i");
|
$row["ends"] = $showEndDT->format("Y-m-d H:i");
|
||||||
$row["endDate"] = $showEndDT->format("Y-m-d");
|
$row["endDate"] = $showEndDT->format("Y-m-d");
|
||||||
$row["endTime"] = $showEndDT->format("H:i");
|
$row["endTime"] = $showEndDT->format("H:i");
|
||||||
$row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u"));
|
$row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u"));
|
||||||
$row["title"] = $p_item["show_name"];
|
$row["title"] = $p_item["show_name"];
|
||||||
$row["instance"] = intval($p_item["si_id"]);
|
$row["instance"] = intval($p_item["si_id"]);
|
||||||
$row["image"] = '';
|
$row["image"] = '';
|
||||||
|
|
||||||
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
|
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
|
||||||
|
|
||||||
|
@ -440,9 +443,12 @@ class Application_Model_ShowBuilder
|
||||||
|
|
||||||
//make the last footer if there were any scheduled items.
|
//make the last footer if there were any scheduled items.
|
||||||
if (count($scheduled_items) > 0) {
|
if (count($scheduled_items) > 0) {
|
||||||
$display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]);
|
$display_items[] = $this->makeFooterRow($scheduled_items[
|
||||||
|
count($scheduled_items)-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array("schedule" => $display_items, "showInstances" => $this->showInstances);
|
return array(
|
||||||
|
"schedule" => $display_items,
|
||||||
|
"showInstances" => $this->showInstances);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@ class Application_Model_Soundcloud
|
||||||
$downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1';
|
$downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1';
|
||||||
|
|
||||||
$track_data = array(
|
$track_data = array(
|
||||||
'track[sharing]' => 'private',
|
'track[sharing]' => 'private',
|
||||||
'track[title]' => $filename,
|
'track[title]' => $filename,
|
||||||
'track[asset_data]' => '@' . $filepath,
|
'track[asset_data]' => '@' . $filepath,
|
||||||
'track[tag_list]' => $tags,
|
'track[tag_list]' => $tags,
|
||||||
'track[description]' => $description,
|
'track[description]' => $description,
|
||||||
'track[downloadable]' => $downloadable,
|
'track[downloadable]' => $downloadable,
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -52,7 +52,6 @@ class Application_Model_Soundcloud
|
||||||
|
|
||||||
//YYYY-MM-DD-HH-mm-SS
|
//YYYY-MM-DD-HH-mm-SS
|
||||||
$release = explode("-", $release);
|
$release = explode("-", $release);
|
||||||
|
|
||||||
$track_data['track[release_year]'] = $release[0];
|
$track_data['track[release_year]'] = $release[0];
|
||||||
$track_data['track[release_month]'] = $release[1];
|
$track_data['track[release_month]'] = $release[1];
|
||||||
$track_data['track[release_day]'] = $release[2];
|
$track_data['track[release_day]'] = $release[2];
|
||||||
|
@ -87,6 +86,13 @@ class Application_Model_Soundcloud
|
||||||
throw new NoSoundCloundToken();
|
throw new NoSoundCloundToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function uploadSoundcloud($id)
|
||||||
|
{
|
||||||
|
$cmd = "/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &";
|
||||||
|
Logging::info("Uploading soundcloud with command: $cmd");
|
||||||
|
exec($cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NoSoundCloundToken extends Exception {}
|
class NoSoundCloundToken extends Exception {}
|
||||||
|
|
|
@ -407,11 +407,12 @@ SQL;
|
||||||
*/
|
*/
|
||||||
public function getFileExtension()
|
public function getFileExtension()
|
||||||
{
|
{
|
||||||
|
return "";
|
||||||
// TODO : what's the point of having this function? Can we not just use
|
// TODO : what's the point of having this function? Can we not just use
|
||||||
// the extension from the file_path column from cc_files?
|
// the extension from the file_path column from cc_files?
|
||||||
$mime = $this->_file->getDbMime();
|
$mime = $this->_file->getDbMime();
|
||||||
|
|
||||||
if ($mime == "audio/vorbis" || $mime == "application/ogg") {
|
if ($mime == "audio/ogg" || $mime == "application/ogg") {
|
||||||
return "ogg";
|
return "ogg";
|
||||||
} elseif ($mime == "audio/mp3" || $mime == "audio/mpeg") {
|
} elseif ($mime == "audio/mp3" || $mime == "audio/mpeg") {
|
||||||
return "mp3";
|
return "mp3";
|
||||||
|
@ -505,8 +506,6 @@ SQL;
|
||||||
*/
|
*/
|
||||||
public function getRelativeFileUrl($baseUrl)
|
public function getRelativeFileUrl($baseUrl)
|
||||||
{
|
{
|
||||||
Logging::info("getting media!");
|
|
||||||
|
|
||||||
return $baseUrl."/api/get-media/file/".$this->getId().".".$this->getFileExtension();
|
return $baseUrl."/api/get-media/file/".$this->getId().".".$this->getFileExtension();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,12 +106,12 @@ class Application_Model_StreamSetting
|
||||||
public static function getStreamData($p_streamId)
|
public static function getStreamData($p_streamId)
|
||||||
{
|
{
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
|
$streamId = pg_escape_string($p_streamId);
|
||||||
$sql = "SELECT * "
|
$sql = "SELECT * "
|
||||||
."FROM cc_stream_setting "
|
."FROM cc_stream_setting "
|
||||||
."WHERE keyname LIKE :stream_id";
|
."WHERE keyname LIKE '{$streamId}_%'";
|
||||||
|
|
||||||
$stmt = $con->prepare($sql);
|
$stmt = $con->prepare($sql);
|
||||||
$stmt->bindParam(':stream_id', "${p_streamId}_%");
|
|
||||||
|
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
$rows = $stmt->fetchAll();
|
$rows = $stmt->fetchAll();
|
||||||
|
|
|
@ -14,82 +14,82 @@
|
||||||
* @package propel.generator.airtime
|
* @package propel.generator.airtime
|
||||||
*/
|
*/
|
||||||
class CcBlockcontents extends BaseCcBlockcontents {
|
class CcBlockcontents extends BaseCcBlockcontents {
|
||||||
/**
|
/**
|
||||||
* Get the [optionally formatted] temporal [fadein] column value.
|
* Get the [optionally formatted] temporal [fadein] column value.
|
||||||
*
|
*
|
||||||
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
*/
|
*/
|
||||||
public function getDbFadein($format = "s.u")
|
public function getDbFadein($format = "s.u")
|
||||||
{
|
{
|
||||||
return parent::getDbFadein($format);
|
return parent::getDbFadein($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the [optionally formatted] temporal [fadein] column value.
|
* Get the [optionally formatted] temporal [fadein] column value.
|
||||||
*
|
*
|
||||||
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
*/
|
*/
|
||||||
public function getDbFadeout($format = "s.u")
|
public function getDbFadeout($format = "s.u")
|
||||||
{
|
{
|
||||||
return parent::getDbFadeout($format);
|
return parent::getDbFadeout($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
|
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
|
||||||
*
|
*
|
||||||
* @return CcBlockcontents The current object (for fluent API support)
|
* @return CcBlockcontents The current object (for fluent API support)
|
||||||
*/
|
*/
|
||||||
public function setDbFadein($v)
|
public function setDbFadein($v)
|
||||||
{
|
{
|
||||||
if ($v instanceof DateTime) {
|
if ($v instanceof DateTime) {
|
||||||
$dt = $v;
|
$dt = $v;
|
||||||
}
|
}
|
||||||
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
|
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
|
||||||
$dt = DateTime::createFromFormat("s.u", $v);
|
$dt = DateTime::createFromFormat("s.u", $v);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
$dt = new DateTime($v);
|
$dt = new DateTime($v);
|
||||||
} catch (Exception $x) {
|
} catch (Exception $x) {
|
||||||
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
|
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fadein = $dt->format('H:i:s.u');
|
$this->fadein = $dt->format('H:i:s.u');
|
||||||
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEIN;
|
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEIN;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
} // setDbFadein()
|
} // setDbFadein()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
|
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
|
||||||
*
|
*
|
||||||
* @return CcBlockcontents The current object (for fluent API support)
|
* @return CcBlockcontents The current object (for fluent API support)
|
||||||
*/
|
*/
|
||||||
public function setDbFadeout($v)
|
public function setDbFadeout($v)
|
||||||
{
|
{
|
||||||
if ($v instanceof DateTime) {
|
if ($v instanceof DateTime) {
|
||||||
$dt = $v;
|
$dt = $v;
|
||||||
}
|
}
|
||||||
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
|
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
|
||||||
$dt = DateTime::createFromFormat("s.u", $v);
|
$dt = DateTime::createFromFormat("s.u", $v);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
$dt = new DateTime($v);
|
$dt = new DateTime($v);
|
||||||
} catch (Exception $x) {
|
} catch (Exception $x) {
|
||||||
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
|
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fadeout = $dt->format('H:i:s.u');
|
$this->fadeout = $dt->format('H:i:s.u');
|
||||||
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEOUT;
|
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEOUT;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
} // setDbFadeout()
|
} // setDbFadeout()
|
||||||
|
|
||||||
} // CcBlockcontents
|
} // CcBlockcontents
|
||||||
|
|
|
@ -139,40 +139,40 @@ class CcShowInstances extends BaseCcShowInstances {
|
||||||
$this->save($con);
|
$this->save($con);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the value of the aggregate column time_filled
|
* Computes the value of the aggregate column time_filled
|
||||||
*
|
*
|
||||||
* @param PropelPDO $con A connection object
|
* @param PropelPDO $con A connection object
|
||||||
*
|
*
|
||||||
* @return mixed The scalar result from the aggregate query
|
* @return mixed The scalar result from the aggregate query
|
||||||
*/
|
*/
|
||||||
public function computeDbTimeFilled(PropelPDO $con)
|
public function computeDbTimeFilled(PropelPDO $con)
|
||||||
{
|
{
|
||||||
$stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1');
|
$stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1');
|
||||||
$stmt->bindValue(':p1', $this->getDbId());
|
$stmt->bindValue(':p1', $this->getDbId());
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
return $stmt->fetchColumn();
|
return $stmt->fetchColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the aggregate column time_filled
|
* Updates the aggregate column time_filled
|
||||||
*
|
*
|
||||||
* @param PropelPDO $con A connection object
|
* @param PropelPDO $con A connection object
|
||||||
*/
|
*/
|
||||||
public function updateDbTimeFilled(PropelPDO $con)
|
public function updateDbTimeFilled(PropelPDO $con)
|
||||||
{
|
{
|
||||||
$timefilled = $this->computeDbTimeFilled($con);
|
$timefilled = $this->computeDbTimeFilled($con);
|
||||||
if(is_null($timefilled)){
|
if(is_null($timefilled)){
|
||||||
$timefilled = "00:00:00";
|
$timefilled = "00:00:00";
|
||||||
}
|
}
|
||||||
$this->setDbTimeFilled($timefilled);
|
$this->setDbTimeFilled($timefilled);
|
||||||
$this->save($con);
|
$this->save($con);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preInsert(PropelPDO $con = null) {
|
public function preInsert(PropelPDO $con = null) {
|
||||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||||
$this->setDbCreated($now);
|
$this->setDbCreated($now);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // CcShowInstances
|
} // CcShowInstances
|
||||||
|
|
|
@ -85,7 +85,7 @@ if ($item['type'] == 2) {
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($item['type'] == 2) {?>
|
<?php if ($item['type'] == 2) {?>
|
||||||
<ul style='display:none' id="block_<?php echo $item["id"]?>_info" class="smart-block-info"></ul>
|
<ul style='display:none' id="block_<?php echo $item["id"]?>_info" class="smart-block-info expand-block-separate"></ul>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</li>
|
</li>
|
||||||
<?php $i = $i+1; ?>
|
<?php $i = $i+1; ?>
|
||||||
|
|
|
@ -572,4 +572,7 @@ li.spl_empty {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding-right: 6px;
|
padding-right: 6px;
|
||||||
|
}
|
||||||
|
.expand-block-separate {
|
||||||
|
border-top: 1px solid #5B5B5B;
|
||||||
}
|
}
|
|
@ -369,7 +369,6 @@ var AIRTIME = (function(AIRTIME){
|
||||||
$.each($(".big_play"), function(index, value){
|
$.each($(".big_play"), function(index, value){
|
||||||
if ($(value).attr('blockId') === undefined) {
|
if ($(value).attr('blockId') === undefined) {
|
||||||
var mime = $(value).attr("data-mime-type");
|
var mime = $(value).attr("data-mime-type");
|
||||||
console.log($(value));
|
|
||||||
if (isAudioSupported(mime)) {
|
if (isAudioSupported(mime)) {
|
||||||
$(value).bind("click", openAudioPreview);
|
$(value).bind("click", openAudioPreview);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -107,16 +107,16 @@ class AirtimeInstall
|
||||||
echo "done.\n";
|
echo "done.\n";
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo "Error!\n".$e->getMessage()."\n";
|
echo "Error!\n".$e->getMessage()."\n";
|
||||||
echo " SQL statement was:\n";
|
echo " SQL statement was:\n";
|
||||||
echo " ".$sql."\n\n";
|
echo " ".$sql."\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function DropSequence($p_sequenceName)
|
public static function DropSequence($p_sequenceName)
|
||||||
{
|
{
|
||||||
AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS $p_sequenceName");
|
AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS $p_sequenceName");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to connect to the database. Return true on success, false on failure.
|
* Try to connect to the database. Return true on success, false on failure.
|
||||||
|
@ -130,12 +130,12 @@ class AirtimeInstall
|
||||||
try {
|
try {
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage().PHP_EOL;
|
echo $e->getMessage().PHP_EOL;
|
||||||
echo "Database connection problem.".PHP_EOL;
|
echo "Database connection problem.".PHP_EOL;
|
||||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||||
" with corresponding permissions.".PHP_EOL;
|
" with corresponding permissions.".PHP_EOL;
|
||||||
if ($p_exitOnError) {
|
if ($p_exitOnError) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,15 @@ class AirtimeInstall
|
||||||
$database = $CC_CONFIG['dsn']['database'];
|
$database = $CC_CONFIG['dsn']['database'];
|
||||||
$username = $CC_CONFIG['dsn']['username'];
|
$username = $CC_CONFIG['dsn']['username'];
|
||||||
#$command = "echo \"CREATE DATABASE $database OWNER $username\" | su postgres -c psql 2>/dev/null";
|
#$command = "echo \"CREATE DATABASE $database OWNER $username\" | su postgres -c psql 2>/dev/null";
|
||||||
|
|
||||||
|
$command = "su postgres -c \"psql -l | cut -f2 -d' ' | grep -w 'airtime'\";";
|
||||||
|
exec($command, $output, $rv);
|
||||||
|
|
||||||
|
if ($rv == 0) {
|
||||||
|
//database already exists
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$command = "su postgres -c \"createdb $database --encoding UTF8 --owner $username\"";
|
$command = "su postgres -c \"createdb $database --encoding UTF8 --owner $username\"";
|
||||||
|
|
||||||
@exec($command, $output, $results);
|
@exec($command, $output, $results);
|
||||||
|
@ -305,7 +314,7 @@ class AirtimeInstall
|
||||||
|
|
||||||
public static function SetUniqueId()
|
public static function SetUniqueId()
|
||||||
{
|
{
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$uniqueId = md5(uniqid("", true));
|
$uniqueId = md5(uniqid("", true));
|
||||||
|
|
||||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
|
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
|
||||||
|
@ -319,8 +328,9 @@ class AirtimeInstall
|
||||||
public static function SetDefaultTimezone()
|
public static function SetDefaultTimezone()
|
||||||
{
|
{
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
// we need to run php as commandline because we want to get the timezone in cli php.ini file
|
// we need to run php as commandline because we want to get the timezone in cli php.ini file
|
||||||
$defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'");
|
//$defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'");
|
||||||
|
$defaultTimezone = exec("cat /etc/timezone");
|
||||||
$defaultTimezone = trim($defaultTimezone);
|
$defaultTimezone = trim($defaultTimezone);
|
||||||
if((!in_array($defaultTimezone, DateTimeZone::listIdentifiers()))){
|
if((!in_array($defaultTimezone, DateTimeZone::listIdentifiers()))){
|
||||||
$defaultTimezone = "UTC";
|
$defaultTimezone = "UTC";
|
||||||
|
@ -335,7 +345,7 @@ class AirtimeInstall
|
||||||
|
|
||||||
public static function SetImportTimestamp()
|
public static function SetImportTimestamp()
|
||||||
{
|
{
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')";
|
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')";
|
||||||
$result = $con->exec($sql);
|
$result = $con->exec($sql);
|
||||||
if ($result < 1) {
|
if ($result < 1) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ require_once(__DIR__.'/airtime-constants.php');
|
||||||
|
|
||||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||||
require_once 'propel/runtime/lib/Propel.php';
|
require_once 'propel/runtime/lib/Propel.php';
|
||||||
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
||||||
|
|
||||||
echo PHP_EOL."* Database Installation".PHP_EOL;
|
echo PHP_EOL."* Database Installation".PHP_EOL;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ set_include_path(implode(PATH_SEPARATOR, array(
|
||||||
require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php');
|
require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php');
|
||||||
require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php');
|
require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php');
|
||||||
require_once($CC_CONFIG['phpDir'].'/application/models/MusicDir.php');
|
require_once($CC_CONFIG['phpDir'].'/application/models/MusicDir.php');
|
||||||
|
require_once($CC_CONFIG['phpDir'].'/application/common/OsPath.php');
|
||||||
|
|
||||||
set_include_path($CC_CONFIG['phpDir'].'/library' . PATH_SEPARATOR . get_include_path());
|
set_include_path($CC_CONFIG['phpDir'].'/library' . PATH_SEPARATOR . get_include_path());
|
||||||
require_once($CC_CONFIG['phpDir'].'/application/models/Soundcloud.php');
|
require_once($CC_CONFIG['phpDir'].'/application/models/Soundcloud.php');
|
||||||
|
|
Loading…
Reference in New Issue