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

This commit is contained in:
Naomi Aro 2012-09-17 16:28:36 -07:00
commit f50fccaf5f
15 changed files with 320 additions and 280 deletions

View file

@ -77,8 +77,21 @@ class Application_Model_Datatables
// map that maps dbname to searchTerm
$dbname2searchTerm = array();
foreach ($current2dbname as $currentPos => $dbname) {
$dbname2searchTerm[$dbname] =
$orig2searchTerm[$librarySetting($currentPos)];
$new_index = $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();

View file

@ -1101,7 +1101,7 @@ class Application_Model_Preference
} else {
$ds = unserialize($v);
return function ($x) use ($ds) {
if ( in_array($x, $ds['ColReorder'] ) ) {
if ( array_key_exists($x, $ds['ColReorder'] ) ) {
return $ds['ColReorder'][$x];
} else {
Logging::warn("Index $x does not exist preferences");

View file

@ -2060,8 +2060,6 @@ SQL;
// been specified
if ($timeEnd == "") {
$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
@ -2083,12 +2081,24 @@ WHERE si.show_id = s.id
AND si.starts < :timeEnd::timestamp
AND modified_instance != TRUE
ORDER BY si.starts
LIMIT :lim
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,
':timeEnd' => $timeEnd,
':lim' => $limit), 'all');
':lim' => $limit);
} else {
$params = array(
':timeStart' => $timeStart,
':timeEnd' => $timeEnd);
}
return Application_Common_Database::prepareAndExecute( $sql, $params, 'all');
}
/**

View file

@ -23,26 +23,26 @@ class Application_Model_ShowBuilder
private $showInstances = array();
private $defaultRowArray = array(
"header" => false,
"footer" => false,
"empty" => false,
"allowed" => false,
"id" => 0,
"instance" => "",
"starts" => "",
"ends" => "",
"runtime" => "",
"title" => "",
"creator" => "",
"album" => "",
"timestamp" => null,
"cuein" => "",
"cueout" => "",
"fadein" => "",
"fadeout" => "",
"image" => false,
"color" => "", //in hex without the '#' sign.
"backgroundColor"=> "", //in hex without the '#' sign.
"header" => false,
"footer" => false,
"empty" => false,
"allowed" => false,
"id" => 0,
"instance" => "",
"starts" => "",
"ends" => "",
"runtime" => "",
"title" => "",
"creator" => "",
"album" => "",
"timestamp" => null,
"cuein" => "",
"cueout" => "",
"fadein" => "",
"fadeout" => "",
"image" => false,
"color" => "", //in hex without the '#' sign.
"backgroundColor" => "", //in hex without the '#' sign.
);
/*
@ -51,12 +51,12 @@ class Application_Model_ShowBuilder
*/
public function __construct($p_startDT, $p_endDT, $p_opts)
{
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->user = Application_Model_User::getCurrentUser();
$this->opts = $p_opts;
$this->epoch_now = floatval(microtime(true));
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->user = Application_Model_User::getCurrentUser();
$this->opts = $p_opts;
$this->epoch_now = floatval(microtime(true));
$this->currentShow = false;
}
@ -91,7 +91,7 @@ class Application_Model_ShowBuilder
private function getItemColor($p_item, &$row)
{
$defaultColor = "ffffff";
$defaultColor = "ffffff";
$defaultBackground = "3366cc";
$color = $p_item["show_color"];
@ -103,7 +103,7 @@ class Application_Model_ShowBuilder
$backgroundColor = $defaultBackground;
}
$row["color"] = $color;
$row["color"] = $color;
$row["backgroundColor"] = $backgroundColor;
}
@ -129,6 +129,7 @@ class Application_Model_ShowBuilder
* 0 = past
* 1 = current
* 2 = future
* TODO : change all of the above to real constants -- RG
*/
private function getScheduledStatus($p_epochItemStart, $p_epochItemEnd, &$row)
{
@ -157,6 +158,14 @@ class Application_Model_ShowBuilder
//item is in the future.
else if ($this->epoch_now < $p_epochItemStart) {
$row["scheduled"] = 2;
} else {
Logging::warn("No-op? is this what should happen...printing
debug just in case");
$d = array(
'$p_epochItemStart' => $p_epochItemStart,
'$p_epochItemEnd' => $p_epochItemEnd,
'$row' => $row);
Logging::warn($d);
}
}
@ -189,10 +198,13 @@ class Application_Model_ShowBuilder
$row["record"] = true;
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)) {
$sid = $file->getSoundCloudId();
$row["soundcloud_id"] = $sid;
$row['soundcloud_id'] = $sid;
}
}
}
@ -204,18 +216,18 @@ class Application_Model_ShowBuilder
$this->currentShow = false;
}
$row["header"] = true;
$row["starts"] = $showStartDT->format("Y-m-d H:i");
$row["header"] = true;
$row["starts"] = $showStartDT->format("Y-m-d H:i");
$row["startDate"] = $showStartDT->format("Y-m-d");
$row["startTime"] = $showStartDT->format("H:i");
$row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now;
$row["ends"] = $showEndDT->format("Y-m-d H:i");
$row["endDate"] = $showEndDT->format("Y-m-d");
$row["endTime"] = $showEndDT->format("H:i");
$row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u"));
$row["title"] = $p_item["show_name"];
$row["instance"] = intval($p_item["si_id"]);
$row["image"] = '';
$row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now;
$row["ends"] = $showEndDT->format("Y-m-d H:i");
$row["endDate"] = $showEndDT->format("Y-m-d");
$row["endTime"] = $showEndDT->format("H:i");
$row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u"));
$row["title"] = $p_item["show_name"];
$row["instance"] = intval($p_item["si_id"]);
$row["image"] = '';
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
@ -238,50 +250,50 @@ class Application_Model_ShowBuilder
$this->getItemStatus($p_item, $row);
$startsEpoch = floatval($schedStartDT->format("U.u"));
$endsEpoch = floatval($schedEndDT->format("U.u"));
$startsEpoch = floatval($schedStartDT->format("U.u"));
$endsEpoch = floatval($schedEndDT->format("U.u"));
$showEndEpoch = floatval($showEndDT->format("U.u"));
//don't want an overbooked item to stay marked as current.
$this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row);
$row["id"] = intval($p_item["sched_id"]);
$row["image"] = $p_item["file_exists"];
$row["id"] = intval($p_item["sched_id"]);
$row["image"] = $p_item["file_exists"];
$row["instance"] = intval($p_item["si_id"]);
$row["starts"] = $schedStartDT->format("H:i:s");
$row["ends"] = $schedEndDT->format("H:i:s");
$row["starts"] = $schedStartDT->format("H:i:s");
$row["ends"] = $schedEndDT->format("H:i:s");
$formatter = new LengthFormatter($p_item['file_length']);
$row['runtime'] = $formatter->format();
$formatter = new LengthFormatter($p_item['file_length']);
$row['runtime'] = $formatter->format();
$row["title"] = $p_item["file_track_title"];
$row["creator"] = $p_item["file_artist_name"];
$row["album"] = $p_item["file_album_title"];
$row["title"] = $p_item["file_track_title"];
$row["creator"] = $p_item["file_artist_name"];
$row["album"] = $p_item["file_album_title"];
$row["cuein"] = $p_item["cue_in"];
$row["cueout"] = $p_item["cue_out"];
$row["fadein"] = round(substr($p_item["fade_in"], 6), 6);
$row["fadeout"] = round(substr($p_item["fade_out"], 6), 6);
$row["cuein"] = $p_item["cue_in"];
$row["cueout"] = $p_item["cue_out"];
$row["fadein"] = round(substr($p_item["fade_in"], 6), 6);
$row["fadeout"] = round(substr($p_item["fade_out"], 6), 6);
$row["pos"] = $this->pos++;
$row["pos"] = $this->pos++;
$this->contentDT = $schedEndDT;
}
//show is empty or is a special kind of show (recording etc)
else if (intval($p_item["si_record"]) === 1) {
$row["record"] = true;
$row["record"] = true;
$row["instance"] = intval($p_item["si_id"]);
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$startsEpoch = floatval($showStartDT->format("U.u"));
$endsEpoch = floatval($showEndDT->format("U.u"));
$startsEpoch = floatval($showStartDT->format("U.u"));
$endsEpoch = floatval($showEndDT->format("U.u"));
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
} else {
$row["empty"] = true;
$row["id"] = 0 ;
$row["empty"] = true;
$row["id"] = 0 ;
$row["instance"] = intval($p_item["si_id"]);
}
@ -444,9 +456,12 @@ class Application_Model_ShowBuilder
//make the last footer if there were any scheduled items.
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);
}
}

View file

@ -407,11 +407,12 @@ SQL;
*/
public function getFileExtension()
{
return "";
// TODO : what's the point of having this function? Can we not just use
// the extension from the file_path column from cc_files?
$mime = $this->_file->getDbMime();
if ($mime == "audio/vorbis" || $mime == "application/ogg") {
if ($mime == "audio/ogg" || $mime == "application/ogg") {
return "ogg";
} elseif ($mime == "audio/mp3" || $mime == "audio/mpeg") {
return "mp3";
@ -505,8 +506,6 @@ SQL;
*/
public function getRelativeFileUrl($baseUrl)
{
Logging::info("getting media!");
return $baseUrl."/api/get-media/file/".$this->getId().".".$this->getFileExtension();
}

View file

@ -106,12 +106,12 @@ class Application_Model_StreamSetting
public static function getStreamData($p_streamId)
{
$con = Propel::getConnection();
$streamId = pg_escape_string($p_streamId);
$sql = "SELECT * "
."FROM cc_stream_setting "
."WHERE keyname LIKE :stream_id";
."WHERE keyname LIKE '{$streamId}_%'";
$stmt = $con->prepare($sql);
$stmt->bindParam(':stream_id', "${p_streamId}_%");
if ($stmt->execute()) {
$rows = $stmt->fetchAll();

View file

@ -14,82 +14,82 @@
* @package propel.generator.airtime
*/
class CcBlockcontents extends BaseCcBlockcontents {
/**
* 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
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbFadein($format = "s.u")
{
return parent::getDbFadein($format);
}
/**
* 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
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbFadeout($format = "s.u")
{
return parent::getDbFadeout($format);
}
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
*
* @return CcBlockcontents The current object (for fluent API support)
*/
public function setDbFadein($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
$dt = DateTime::createFromFormat("s.u", $v);
}
else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
$this->fadein = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEIN;
return $this;
} // setDbFadein()
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
*
* @return CcBlockcontents The current object (for fluent API support)
*/
public function setDbFadeout($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
$dt = DateTime::createFromFormat("s.u", $v);
}
else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
$this->fadeout = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEOUT;
return $this;
/**
* 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
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbFadein($format = "s.u")
{
return parent::getDbFadein($format);
}
/**
* 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
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbFadeout($format = "s.u")
{
return parent::getDbFadeout($format);
}
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
*
* @return CcBlockcontents The current object (for fluent API support)
*/
public function setDbFadein($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
$dt = DateTime::createFromFormat("s.u", $v);
}
else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
$this->fadein = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEIN;
return $this;
} // setDbFadein()
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
*
* @return CcBlockcontents The current object (for fluent API support)
*/
public function setDbFadeout($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
$dt = DateTime::createFromFormat("s.u", $v);
}
else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
$this->fadeout = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEOUT;
return $this;
} // setDbFadeout()
} // CcBlockcontents

View file

@ -139,40 +139,40 @@ class CcShowInstances extends BaseCcShowInstances {
$this->save($con);
}
/**
* Computes the value of the aggregate column time_filled
*
* @param PropelPDO $con A connection object
*
* @return mixed The scalar result from the aggregate query
*/
public function computeDbTimeFilled(PropelPDO $con)
{
$stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1');
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
/**
* Updates the aggregate column time_filled
*
* @param PropelPDO $con A connection object
*/
public function updateDbTimeFilled(PropelPDO $con)
/**
* Computes the value of the aggregate column time_filled
*
* @param PropelPDO $con A connection object
*
* @return mixed The scalar result from the aggregate query
*/
public function computeDbTimeFilled(PropelPDO $con)
{
$stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1');
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
/**
* Updates the aggregate column time_filled
*
* @param PropelPDO $con A connection object
*/
public function updateDbTimeFilled(PropelPDO $con)
{
$timefilled = $this->computeDbTimeFilled($con);
if(is_null($timefilled)){
$timefilled = "00:00:00";
}
$this->setDbTimeFilled($timefilled);
$this->save($con);
}
$this->setDbTimeFilled($timefilled);
$this->save($con);
}
public function preInsert(PropelPDO $con = null) {
$now = new DateTime("now", new DateTimeZone("UTC"));
$this->setDbCreated($now);
return true;
$now = new DateTime("now", new DateTimeZone("UTC"));
$this->setDbCreated($now);
return true;
}
} // CcShowInstances