CC-3174 : showbuilder

overriding some propel setter/getters to support subseconds
or using fades in ss.uuuuuu time as a default.
This commit is contained in:
Naomi Aro 2012-02-07 13:29:50 +01:00
parent d9947b622a
commit f651024a6e
8 changed files with 244 additions and 300 deletions

View file

@ -1,7 +1,5 @@
<?php
require_once('Common.php');
/**
* Skeleton subclass for representing a row from the 'cc_files' table.
*
@ -15,16 +13,31 @@ require_once('Common.php');
*/
class CcFiles extends BaseCcFiles {
public function getDbLength()
public function getDbLength($format = "H:i:s.u")
{
return $this->length;
return parent::getDbCliplength($format);
}
public function setDbLength($time)
public function setDbLength($v)
{
$this->length = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::LENGTH;
return Common::setTimeInSub($this, 'LENGTH', $time);
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->length = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcFilesPeer::LENGTH;
return $this;
}

View file

@ -19,19 +19,9 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
* @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()
public function getDbFadein($format = "s.u")
{
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");
parent::getDbFadein($format);
}
/**
@ -40,19 +30,9 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
* @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()
public function getDbFadeout($format = "s.u")
{
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");
parent::getDbFadeout($format);
}
/**
@ -110,7 +90,7 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
}
}
$this->fadein = ($dt ? $dt->format('H:i:s.u') : null);
$this->fadein = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
return $this;
@ -138,7 +118,7 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
}
}
$this->fadeout = ($dt ? $dt->format('H:i:s.u') : null);
$this->fadeout = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
return $this;

View file

@ -17,24 +17,7 @@ class CcSchedule extends BaseCcSchedule {
public function getDbClipLength($format = 'H:i:s.u')
{
if ($this->clip_length === null) {
return null;
}
try {
$dt = new DateTime($this->clip_length);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->clip_length, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
return parent::getDbClipLength($format);
}
/**
@ -46,26 +29,9 @@ class CcSchedule extends BaseCcSchedule {
* @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 getDbStarts($format = 'Y-m-d H:i:s')
public function getDbStarts($format = 'Y-m-d H:i:s.u')
{
if ($this->starts === null) {
return null;
}
try {
$dt = new DateTime($this->starts, new DateTimeZone("UTC"));
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->starts, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
return parent::getDbStarts($format);
}
/**
@ -77,26 +43,192 @@ class CcSchedule extends BaseCcSchedule {
* @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 getDbEnds($format = 'Y-m-d H:i:s')
public function getDbEnds($format = 'Y-m-d H:i:s.u')
{
if ($this->ends === null) {
return null;
return parent::getDbEnds($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 getDbFadeIn($format = "s.u")
{
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")
{
parent::getDbFadeout($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 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);
}
/**
*
* @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->fade_in = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcSchedulePeer::FADE_IN;
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->fadeIout = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADE_OUT;
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->cue_in = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUE_IN;
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->cue_out = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUE_OUT;
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($this->ends, new DateTimeZone("UTC"));
$dt = new DateTime($v);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ends, true), $x);
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
}
$this->clip_length = $dt->format('H:i:s.u');
$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIP_LENGTH;
return $this;
} // setDbCliplength()
} // CcSchedule

View file

@ -289,8 +289,6 @@ abstract class BaseCcPlaylistcontents extends BaseObject implements Persistent
return null;
}
try {
$dt = new DateTime($this->fadein);
} catch (Exception $x) {

View file

@ -1,31 +0,0 @@
<?php
require_once('Common.php');
/**
* Skeleton subclass for representing a row from the 'cc_files' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcFiles extends BaseCcFiles {
public function getDbLength()
{
return $this->length;
}
public function setDbLength($time)
{
$this->length = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::LENGTH;
return Common::setTimeInSub($this, 'LENGTH', $time);
}
} // CcFiles

View file

@ -1,48 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playlist' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylist extends BaseCcPlaylist {
public function computeLastPosition()
{
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$sql = 'SELECT MAX('.CcPlaylistcontentsPeer::POSITION.') AS pos'
. ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME
. ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
public function computeLength()
{
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$sql = 'SELECT SUM('.CcPlaylistcontentsPeer::CLIPLENGTH.') AS length'
. ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME
. ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
} // CcPlaylist

View file

@ -1,81 +0,0 @@
<?php
require_once('Common.php');
/**
* Skeleton subclass for representing a row from the 'cc_playlistcontents' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.campcaster
*/
class CcPlaylistcontents extends BaseCcPlaylistcontents {
public function getDbFadein()
{
return $this->fadein;
}
public function setDbFadein($time)
{
$this->fadein = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
Common::setTimeInSub($this, 'FADEIN', $time);
}
public function getDbFadeout()
{
return $this->fadeout;
}
public function setDbFadeout($time)
{
$this->fadeout = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
Common::setTimeInSub($this, 'FADEOUT', $time);
}
public function getDbCuein()
{
return $this->cuein;
}
public function setDbCuein($time)
{
$this->cuein = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN;
Common::setTimeInSub($this, 'CUEIN', $time);
}
public function getDbCueout()
{
return $this->cueout;
}
public function setDbCueout($time)
{
$this->cueout = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT;
Common::setTimeInSub($this, 'CUEOUT', $time);
}
public function getDbCliplength()
{
return $this->cliplength;
}
public function setDbCliplength($time)
{
$this->cliplength = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH;
Common::setTimeInSub($this, 'CLIPLENGTH', $time);
}
} // CcPlaylistcontents

View file

@ -1,19 +0,0 @@
<?php
class Common {
public static function setTimeInSub($row, $col, $time)
{
$class = get_class($row).'Peer';
$con = Propel::getConnection($class::DATABASE_NAME);
$sql = 'UPDATE '.$class::TABLE_NAME
. ' SET '.$col.' = :f1'
. ' WHERE ' .$class::ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':f1', $time);
$stmt->bindValue(':p1', $row->getDbId());
$stmt->execute();
}
}