CC-3174 : showbuilder

fixing times in CcPlaylistContents
This commit is contained in:
Naomi Aro 2012-02-06 18:46:53 +01:00
parent 613006e69c
commit d9947b622a
5 changed files with 239 additions and 25 deletions

View file

@ -32,8 +32,8 @@ class Application_Model_Playlist {
"cliplength" => "", "cliplength" => "",
"cuein" => "00:00:00", "cuein" => "00:00:00",
"cueout" => "00:00:00", "cueout" => "00:00:00",
"fadein" => "00:00:00", "fadein" => "0.0",
"fadeout" => "00:00:00", "fadeout" => "0.0",
); );
//using propel's phpNames. //using propel's phpNames.
@ -50,7 +50,7 @@ class Application_Model_Playlist {
if (isset($id)) { if (isset($id)) {
$this->pl = CcPlaylistQuery::create()->findPK($id); $this->pl = CcPlaylistQuery::create()->findPK($id);
if (is_null($this->pl)){ if (is_null($this->pl)) {
throw new PlaylistNotFoundException(); throw new PlaylistNotFoundException();
} }
} }
@ -63,9 +63,9 @@ class Application_Model_Playlist {
$defaultFade = Application_Model_Preference::GetDefaultFade(); $defaultFade = Application_Model_Preference::GetDefaultFade();
if ($defaultFade !== "") { if ($defaultFade !== "") {
//fade is in format SS.uuuuuu //fade is in format SS.uuuuuu
$fade = DateTime::createFromFormat("s.u", $defaultFade, new DateTimeZone("UTC"));
$this->plItem["fadein"] = $fade->format("H:i:s.u"); $this->plItem["fadein"] = $defaultFade;
$this->plItem["fadeout"] = $fade->format("H:i:s.u"); $this->plItem["fadeout"] = $defaultFade;
} }
$this->con = isset($con) ? $con : Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); $this->con = isset($con) ? $con : Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
@ -145,15 +145,14 @@ class Application_Model_Playlist {
$files[$i] = $row->toArray(BasePeer::TYPE_FIELDNAME, true, true); $files[$i] = $row->toArray(BasePeer::TYPE_FIELDNAME, true, true);
// display only upto 1 decimal place by calling secondsToPlaylistTime // display only upto 1 decimal place by calling secondsToPlaylistTime
$clipSec = Application_Model_Playlist::playlistTimeToSeconds($files[$i]['cliplength']); $clipSec = Application_Model_Playlist::playlistTimeToSeconds($files[$i]['cliplength']);
$files[$i]['cliplength'] = Application_Model_Playlist::secondsToPlaylistTime($clipSec); //$files[$i]['cliplength'] = Application_Model_Playlist::secondsToPlaylistTime($clipSec);
$offset += $clipSec; $offset += $clipSec;
$files[$i]['offset'] = Application_Model_Playlist::secondsToPlaylistTime($offset); $files[$i]['offset'] = Application_Model_Playlist::secondsToPlaylistTime($offset);
#For issue CC-2065 - update fade in and out values between playlst elements //Propel has been modified to only return SS.uuuuuu, might want this normalize
#modified from the db default format of 00:00:00 to the more practical //feature to instead strip useless zeroes.
#00.000000 format which is for only seconds. //$files[$i]['fadein'] = $this->normalizeFade($files[$i]['fadein']);
$files[$i]['fadein'] = $this->normalizeFade($files[$i]['fadein']); //$files[$i]['fadeout'] = $this->normalizeFade($files[$i]['fadeout']);
$files[$i]['fadeout'] = $this->normalizeFade($files[$i]['fadeout']);
$i++; $i++;
} }
@ -429,11 +428,9 @@ class Application_Model_Playlist {
->filterByDbPosition($pos) ->filterByDbPosition($pos)
->findOne(); ->findOne();
#For issue CC-2065, fade in and out values are for the Playlist itself and must be #Propel returns values in form 00.000000 format which is for only seconds.
#modified from the db default format of 00:00:00 to the more practical $fadeIn = $row->getDbFadein();
#00.000000 format which is for only seconds. $fadeOut = $row->getDbFadeout();
$fadeIn = $this->normalizeFade($row->getDbFadein());
$fadeOut = $this->normalizeFade($row->getDbFadeout());
return array($fadeIn, $fadeOut); return array($fadeIn, $fadeOut);
} }
@ -489,7 +486,12 @@ class Application_Model_Playlist {
$row->setDbFadeout($fadeOut); $row->setDbFadeout($fadeOut);
} }
$row->save(); try {
$row->save();
}
catch (Exception $e) {
Logging::log($e->getMessage());
}
return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut); return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
} }

View file

@ -1,7 +1,5 @@
<?php <?php
require_once('Common.php');
/** /**
* Skeleton subclass for representing a row from the 'cc_playlistcontents' table. * Skeleton subclass for representing a row from the 'cc_playlistcontents' table.
* *
@ -15,5 +13,219 @@ require_once('Common.php');
*/ */
class CcPlaylistcontents extends BaseCcPlaylistcontents { class CcPlaylistcontents extends BaseCcPlaylistcontents {
/**
* 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()
{
if ($this->fadein === null) {
return null;
}
try {
$dt = new DateTime($this->fadein);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->fadein, true), $x);
}
return $dt->format("s.u");
}
/**
* 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()
{
if ($this->fadeout === null) {
return null;
}
try {
$dt = new DateTime($this->fadeout);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->fadein, true), $x);
}
return $dt->format("s.u");
}
/**
* Just changing the default format to return subseconds
*
* @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 getDbCuein($format = 'H:i:s.u')
{
return parent::getDbCuein($format);
}
/**
* Just changing the default format to return subseconds
*
* @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 getDbCueout($format = 'H:i:s.u')
{
return parent::getDbCueout($format);
}
/**
* Just changing the default format to return subseconds
*
* @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 getDbCliplength($format = 'H:i:s.u')
{
return parent::getDbCliplength($format);
}
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
*
* @return CcPlaylistcontents The current object (for fluent API support)
*/
public function setDbFadein($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-5][0-9](\.\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 ? $dt->format('H:i:s.u') : null);
$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
return $this;
} // setDbFadein()
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
*
* @return CcPlaylistcontents The current object (for fluent API support)
*/
public function setDbFadeout($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-5][0-9](\.\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 ? $dt->format('H:i:s.u') : null);
$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
return $this;
} // setDbFadeout()
/**
* Sets the value of [cuein] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcPlaylistcontents The current object (for fluent API support)
*/
public function setDbCuein($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else {
try {
$dt = new DateTime($v);
}
catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
$this->cuein = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN;
return $this;
} // setDbCuein()
/**
* Sets the value of [cueout] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcPlaylistcontents The current object (for fluent API support)
*/
public function setDbCueout($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else {
try {
$dt = new DateTime($v);
}
catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
$this->cueout = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT;
return $this;
} // setDbCueout()
/**
* Sets the value of [cliplength] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcPlaylistcontents The current object (for fluent API support)
*/
public function setDbCliplength($v)
{
if ($v instanceof DateTime) {
$dt = $v;
}
else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
$this->cliplength = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH;
return $this;
} // setDbCliplength()
} // CcPlaylistcontents } // CcPlaylistcontents

View file

@ -35,10 +35,10 @@
<div id="crossfade_main" class="crossfade-main clearfix" style="display:none;"> <div id="crossfade_main" class="crossfade-main clearfix" style="display:none;">
<span class="ui-icon ui-icon-closethick"></span> <span class="ui-icon ui-icon-closethick"></span>
<dl id="spl_editor-main" class="inline-list"> <dl id="spl_editor-main" class="inline-list">
<dt>Fade in:</dt> <dt>Fade in (s):</dt>
<dd id="spl_fade_in_main"><span contenteditable="true" class="spl_text_input">00</span></dd> <dd id="spl_fade_in_main"><span contenteditable="true" class="spl_text_input">00</span></dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>
<dt>Fade out:</dt> <dt>Fade out (s):</dt>
<dd id="spl_fade_out_main"><span contenteditable="true" class="spl_text_input">00/span></dd> <dd id="spl_fade_out_main"><span contenteditable="true" class="spl_text_input">00/span></dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>
</dl> </dl>

View file

@ -1,10 +1,10 @@
<dl id="spl_editor" class="inline-list"> <dl id="spl_editor" class="inline-list">
<dt>Fade out:</dt> <dt>Fade out (s):</dt>
<dd id="spl_fade_out_<?php echo $this->item1; ?>" class="spl_fade_out"> <dd id="spl_fade_out_<?php echo $this->item1; ?>" class="spl_fade_out">
<span contenteditable="true" class="spl_text_input"><?php echo $this->fadeOut; ?></span> <span contenteditable="true" class="spl_text_input"><?php echo $this->fadeOut; ?></span>
</dd> </dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>
<dt>Fade in:</dt> <dt>Fade in (s):</dt>
<dd id="spl_fade_in_<?php echo $this->item2; ?>" class="spl_fade_in"> <dd id="spl_fade_in_<?php echo $this->item2; ?>" class="spl_fade_in">
<span contenteditable="true" class="spl_text_input"><?php echo $this->fadeIn; ?></span> <span contenteditable="true" class="spl_text_input"><?php echo $this->fadeIn; ?></span>
</dd> </dd>

View file

@ -14,7 +14,7 @@ var AIRTIME = (function(AIRTIME){
} }
function isFadeValid(fade) { function isFadeValid(fade) {
var regExpr = new RegExp("^\\d{2}([.]\\d{1,6})?$"); var regExpr = new RegExp("^\\d{1}(\\d{1})?([.]\\d{1,6})?$");
return regExpr.test(fade); return regExpr.test(fade);
} }