Format code using php-cs-fixer

This commit is contained in:
jo 2021-10-11 16:10:47 +02:00
parent 43d7dc92cd
commit d52c6184b9
352 changed files with 17473 additions and 17041 deletions

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_access' 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.airtime
*/
class CcAccess extends BaseCcAccess {
class CcAccess extends BaseCcAccess
{
} // CcAccess

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_access' 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.airtime
*/
class CcAccessPeer extends BaseCcAccessPeer {
class CcAccessPeer extends BaseCcAccessPeer
{
} // CcAccessPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_access' 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.airtime
*/
class CcAccessQuery extends BaseCcAccessQuery {
class CcAccessQuery extends BaseCcAccessQuery
{
} // CcAccessQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_backup' 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.airtime
*/
class CcBackup extends BaseCcBackup {
class CcBackup extends BaseCcBackup
{
} // CcBackup

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_backup' 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.airtime
*/
class CcBackupPeer extends BaseCcBackupPeer {
class CcBackupPeer extends BaseCcBackupPeer
{
} // CcBackupPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_backup' 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.airtime
*/
class CcBackupQuery extends BaseCcBackupQuery {
class CcBackupQuery extends BaseCcBackupQuery
{
} // CcBackupQuery

View file

@ -1,27 +1,23 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_block' 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.airtime
*/
class CcBlock extends BaseCcBlock {
/**
class CcBlock extends BaseCcBlock
{
/**
* Get the [optionally formatted] temporal [utime] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbUtime($format = 'Y-m-d H:i:s')
{
@ -30,29 +26,31 @@ class CcBlock extends BaseCcBlock {
}
try {
$dt = new DateTime($this->utime, new DateTimeZone("UTC"));
$dt = new DateTime($this->utime, new DateTimeZone('UTC'));
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x);
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->utime, 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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($format);
}
/**
* Get the [optionally formatted] temporal [mtime] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbMtime($format = 'Y-m-d H:i:s')
{
@ -61,19 +59,20 @@ class CcBlock extends BaseCcBlock {
}
try {
$dt = new DateTime($this->mtime, new DateTimeZone("UTC"));
$dt = new DateTime($this->mtime, new DateTimeZone('UTC'));
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->mtime, true), $x);
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->mtime, 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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($format);
}
/**
@ -86,7 +85,7 @@ class CcBlock extends BaseCcBlock {
*/
public function computeDbLength(PropelPDO $con)
{
$sql = <<<SQL
$sql = <<<'SQL'
SELECT SUM(cliplength) FROM cc_blockcontents as bc
JOIN cc_files as f ON bc.file_id = f.id
WHERE BLOCK_ID = :b1
@ -98,7 +97,7 @@ SQL;
$length = $stmt->fetchColumn();
if (is_null($length)) {
$length = "00:00:00";
$length = '00:00:00';
}
return $length;

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_block' 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.airtime
*/
class CcBlockPeer extends BaseCcBlockPeer {
class CcBlockPeer extends BaseCcBlockPeer
{
} // CcBlockPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_block' 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.airtime
*/
class CcBlockQuery extends BaseCcBlockQuery {
class CcBlockQuery extends BaseCcBlockQuery
{
} // CcBlockQuery

View file

@ -1,44 +1,45 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_blockcontents' 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.airtime
*/
class CcBlockcontents extends BaseCcBlockcontents {
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.
* @param mixed $format
*
* @throws propelException - if unable to parse/validate the date/time value
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbFadein($format = "s.u")
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.
* @param mixed $format
*
* @throws propelException - if unable to parse/validate the date/time value
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbFadeout($format = "s.u")
public function getDbFadeout($format = 's.u')
{
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.
* @param mixed $v
*
* @return CcBlockcontents The current object (for fluent API support)
*/
@ -47,35 +48,33 @@ class CcBlockcontents extends BaseCcBlockcontents {
$microsecond = 0;
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
} elseif (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
// in php 5.3.2 createFromFormat() with "u" is not supported(bug)
// Hence we need to do parsing.
$info = explode('.', $v);
$microsecond = $info[1];
$dt = DateTime::createFromFormat("s", $info[0]);
}
else {
$dt = DateTime::createFromFormat('s', $info[0]);
} else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ($microsecond == 0) {
$this->fadein = $dt->format('H:i:s.u');
} else {
$this->fadein = $dt->format('H:i:s').".".$microsecond;
$this->fadein = $dt->format('H:i:s') . '.' . $microsecond;
}
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEIN;
return $this;
} // setDbFadein()
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
* @param string in format SS.uuuuuu, Datetime, or DateTime accepted string.
* @param mixed $v
*
* @return CcBlockcontents The current object (for fluent API support)
*/
@ -84,15 +83,13 @@ class CcBlockcontents extends BaseCcBlockcontents {
$microsecond = 0;
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
} elseif (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
// in php 5.3.2 createFromFormat() with "u" is not supported(bug)
// Hence we need to do parsing.
$info = explode('.', $v);
$microsecond = $info[1];
$dt = DateTime::createFromFormat("s", $info[0]);
}
else {
$dt = DateTime::createFromFormat('s', $info[0]);
} else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
@ -103,11 +100,10 @@ class CcBlockcontents extends BaseCcBlockcontents {
if ($microsecond == 0) {
$this->fadeout = $dt->format('H:i:s.u');
} else {
$this->fadeout = $dt->format('H:i:s').".".$microsecond;
$this->fadeout = $dt->format('H:i:s') . '.' . $microsecond;
}
$this->modifiedColumns[] = CcBlockcontentsPeer::FADEOUT;
return $this;
} // setDbFadeout()
} // CcBlockcontents

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_blockcontents' 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.airtime
*/
class CcBlockcontentsPeer extends BaseCcBlockcontentsPeer {
class CcBlockcontentsPeer extends BaseCcBlockcontentsPeer
{
} // CcBlockcontentsPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_blockcontents' 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.airtime
*/
class CcBlockcontentsQuery extends BaseCcBlockcontentsQuery {
class CcBlockcontentsQuery extends BaseCcBlockcontentsQuery
{
} // CcBlockcontentsQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_blockcriteria' 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.airtime
*/
class CcBlockcriteria extends BaseCcBlockcriteria {
class CcBlockcriteria extends BaseCcBlockcriteria
{
} // CcBlockcriteria

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_blockcriteria' 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.airtime
*/
class CcBlockcriteriaPeer extends BaseCcBlockcriteriaPeer {
class CcBlockcriteriaPeer extends BaseCcBlockcriteriaPeer
{
} // CcBlockcriteriaPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_blockcriteria' 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.airtime
*/
class CcBlockcriteriaQuery extends BaseCcBlockcriteriaQuery {
class CcBlockcriteriaQuery extends BaseCcBlockcriteriaQuery
{
} // CcBlockcriteriaQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_country' 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.airtime
*/
class CcCountry extends BaseCcCountry {
class CcCountry extends BaseCcCountry
{
} // CcCountry

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_country' 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.airtime
*/
class CcCountryPeer extends BaseCcCountryPeer {
class CcCountryPeer extends BaseCcCountryPeer
{
} // CcCountryPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_country' 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.airtime
*/
class CcCountryQuery extends BaseCcCountryQuery {
class CcCountryQuery extends BaseCcCountryQuery
{
} // CcCountryQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_file_tag' 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.airtime
*/
class CcFileTag extends BaseCcFileTag {
class CcFileTag extends BaseCcFileTag
{
} // CcFileTag

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_file_tag' 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.airtime
*/
class CcFileTagPeer extends BaseCcFileTagPeer {
class CcFileTagPeer extends BaseCcFileTagPeer
{
} // CcFileTagPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_file_tag' 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.airtime
*/
class CcFileTagQuery extends BaseCcFileTagQuery {
class CcFileTagQuery extends BaseCcFileTagQuery
{
} // CcFileTagQuery

View file

@ -3,15 +3,10 @@
/**
* 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 InvalidMetadataException extends Exception
{
}
@ -22,20 +17,18 @@ class LibreTimeFileNotFoundException extends Exception
class OverDiskQuotaException extends Exception
{
}
class CcFiles extends BaseCcFiles {
const MUSIC_DIRS_STOR_PK = 1;
const IMPORT_STATUS_SUCCESS = 0;
const IMPORT_STATUS_PENDING = 1;
const IMPORT_STATUS_FAILED = 2;
class CcFiles extends BaseCcFiles
{
public const MUSIC_DIRS_STOR_PK = 1;
public const IMPORT_STATUS_SUCCESS = 0;
public const IMPORT_STATUS_PENDING = 1;
public const IMPORT_STATUS_FAILED = 2;
//fields that are not modifiable via our RESTful API
private static $blackList = array(
private static $blackList = [
'id',
'directory',
'filepath',
@ -45,19 +38,20 @@ class CcFiles extends BaseCcFiles {
'lptime',
'silan_check',
'is_scheduled',
'is_playlist'
);
'is_playlist',
];
//fields we should never expose through our RESTful API
private static $privateFields = array(
private static $privateFields = [
'file_exists',
'silan_check',
'is_scheduled',
'is_playlist'
);
'is_playlist',
];
/**
* Retrieve a sanitized version of the file metadata, suitable for public access.
*
* @param $fileId
*/
public static function getSanitizedFileById($fileId)
@ -65,17 +59,19 @@ class CcFiles extends BaseCcFiles {
$file = CcFilesQuery::create()->findPk($fileId);
if ($file) {
return CcFiles::sanitizeResponse($file);
} else {
throw new LibreTimeFileNotFoundException();
}
throw new LibreTimeFileNotFoundException();
}
/** Used to create a CcFiles object from an array containing metadata and a file uploaded by POST.
* This is used by our Media REST API!
* @param $fileArray An array containing metadata for a CcFiles object.
*
* @param $fileArray An array containing metadata for a CcFiles object
*
* @throws Exception
*
* @return object the sanitized response
* @throws Exception
*/
public static function createFromUpload($fileArray)
{
@ -100,6 +96,7 @@ class CcFiles extends BaseCcFiles {
if (file_exists($tempFilePath)) {
unlink($tempFilePath);
}
throw $e;
}
}
@ -107,38 +104,43 @@ class CcFiles extends BaseCcFiles {
/** Import a music file to the library from a local file on disk (something pre-existing).
* This function allows you to copy a file rather than move it, which is useful for importing
* static music files (like sample tracks).
* @param string $filePath The full path to the audio file to import.
* @param bool $copyFile True if you want to just copy the false, false if you want to move it (default false)
*
* @param string $filePath the full path to the audio file to import
* @param bool $copyFile True if you want to just copy the false, false if you want to move it (default false)
* @param mixed $fileArray
*
* @throws Exception
*/
public static function createFromLocalFile($fileArray, $filePath, $copyFile=false)
public static function createFromLocalFile($fileArray, $filePath, $copyFile = false)
{
$info = pathinfo($filePath);
$fileName = basename($filePath).'.'.$info['extension'];
$fileName = basename($filePath) . '.' . $info['extension'];
self::createAndImport($fileArray, $filePath, $fileName, $copyFile);
}
/** Create a new CcFiles object/row and import a file for it.
* You shouldn't call this directly. Either use createFromUpload() or createFromLocalFile().
* @param array $fileArray Any metadata to pre-fill for the audio file
* @param string $filePath The full path to the audio file to import
*
* @param array $fileArray Any metadata to pre-fill for the audio file
* @param string $filePath The full path to the audio file to import
* @param string $originalFilename
* @param bool $copyFile
* @return mixed
* @param bool $copyFile
*
* @throws Exception
* @throws PropelException
*
* @return mixed
*/
private static function createAndImport($fileArray, $filePath, $originalFilename, $copyFile=false)
private static function createAndImport($fileArray, $filePath, $originalFilename, $copyFile = false)
{
$file = new CcFiles();
try
{
try {
//Only accept files with a file extension that we support.
// Let the analyzer do the heavy lifting in terms of mime verification and playability
$fileExtension = pathinfo($originalFilename, PATHINFO_EXTENSION);
if (!in_array(strtolower($fileExtension), array_values(FileDataHelper::getAudioMimeTypeArray()))) {
throw new Exception("Bad file extension.");
throw new Exception('Bad file extension.');
}
$fileArray = self::removeBlacklistedFields($fileArray);
@ -146,14 +148,14 @@ class CcFiles extends BaseCcFiles {
self::validateFileArray($fileArray);
$storDir = Application_Model_MusicDir::getStorDir();
$importedStorageDir = $storDir->getDirectory() . "imported/" . self::getOwnerId() . "/";
$importedDbPath = "imported/" . self::getOwnerId() . "/";
$importedStorageDir = $storDir->getDirectory() . 'imported/' . self::getOwnerId() . '/';
$importedDbPath = 'imported/' . self::getOwnerId() . '/';
$artwork = FileDataHelper::saveArtworkData($filePath, $originalFilename, $importedStorageDir, $importedDbPath);
$trackType = FileDataHelper::saveTrackType();
$file->fromArray($fileArray);
$file->setDbOwnerId(self::getOwnerId());
$now = new DateTime("now", new DateTimeZone("UTC"));
$now = new DateTime('now', new DateTimeZone('UTC'));
$file->setDbTrackTitle($originalFilename);
$file->setDbArtwork($artwork);
$file->setDbTrackType($trackType);
@ -161,28 +163,35 @@ class CcFiles extends BaseCcFiles {
$file->setDbHidden(true);
$file->save();
$callbackUrl = Application_Common_HTTPHelper::getStationUrl() . "/rest/media/" . $file->getPrimaryKey();
$callbackUrl = Application_Common_HTTPHelper::getStationUrl() . '/rest/media/' . $file->getPrimaryKey();
Application_Service_MediaService::importFileToLibrary($callbackUrl, $filePath,
$originalFilename, self::getOwnerId(), $copyFile);
Application_Service_MediaService::importFileToLibrary(
$callbackUrl,
$filePath,
$originalFilename,
self::getOwnerId(),
$copyFile
);
return CcFiles::sanitizeResponse($file);
} catch (Exception $e) {
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED);
$file->setDbHidden(true);
$file->save();
throw $e;
}
}
/** Update a file with metadata specified in an array.
* @param $fileId string The ID of the file to update in the DB.
* @param $fileId string The ID of the file to update in the DB
* @param $fileArray array An associative array containing metadata. Replaces those fields if they exist.
* @return array A sanitized version of the file metadata array.
*
* @throws Exception
* @throws LibreTimeFileNotFoundException
* @throws PropelException
*
* @return array a sanitized version of the file metadata array
*/
public static function updateFromArray($fileId, $fileArray)
{
@ -192,29 +201,26 @@ class CcFiles extends BaseCcFiles {
$fileArray = self::stripTimeStampFromYearTag($fileArray);
try {
self::validateFileArray($fileArray);
if ($file && isset($fileArray["resource_id"])) {
if ($file && isset($fileArray['resource_id'])) {
$file->fromArray($fileArray, BasePeer::TYPE_FIELDNAME);
//store the original filename
$file->setDbFilepath($fileArray["filename"]);
$file->setDbFilepath($fileArray['filename']);
$fileSizeBytes = $fileArray["filesize"];
$fileSizeBytes = $fileArray['filesize'];
if (!isset($fileSizeBytes) || $fileSizeBytes === false) {
throw new LibreTimeFileNotFoundException("Invalid filesize for $fileId");
throw new LibreTimeFileNotFoundException("Invalid filesize for {$fileId}");
}
$cloudFile = new CloudFile();
$cloudFile->setStorageBackend($fileArray["storage_backend"]);
$cloudFile->setResourceId($fileArray["resource_id"]);
$cloudFile->setStorageBackend($fileArray['storage_backend']);
$cloudFile->setResourceId($fileArray['resource_id']);
$cloudFile->setCcFiles($file);
$cloudFile->save();
Application_Model_Preference::updateDiskUsage($fileSizeBytes);
} else if ($file) {
} elseif ($file) {
// Since we check for this value when deleting files, set it first
$file->setDbDirectory(self::MUSIC_DIRS_STOR_PK);
@ -223,18 +229,18 @@ class CcFiles extends BaseCcFiles {
//Our RESTful API takes "full_path" as a field, which we then split and translate to match
//our internal schema. Internally, file path is stored relative to a directory, with the directory
//as a foreign key to cc_music_dirs.
if (isset($fileArray["full_path"])) {
$fileSizeBytes = filesize($fileArray["full_path"]);
if (isset($fileArray['full_path'])) {
$fileSizeBytes = filesize($fileArray['full_path']);
if (!isset($fileSizeBytes) || $fileSizeBytes === false) {
throw new LibreTimeFileNotFoundException("Invalid filesize for $fileId");
throw new LibreTimeFileNotFoundException("Invalid filesize for {$fileId}");
}
Application_Model_Preference::updateDiskUsage($fileSizeBytes);
$fullPath = $fileArray["full_path"];
$fullPath = $fileArray['full_path'];
$storDir = Application_Model_MusicDir::getStorDir()->getDirectory();
$pos = strpos($fullPath, $storDir);
if ($pos !== FALSE) {
if ($pos !== false) {
assert($pos == 0); //Path must start with the stor directory path
$filePathRelativeToStor = substr($fullPath, strlen($storDir));
@ -245,15 +251,14 @@ class CcFiles extends BaseCcFiles {
throw new LibreTimeFileNotFoundException();
}
$now = new DateTime("now", new DateTimeZone("UTC"));
$now = new DateTime('now', new DateTimeZone('UTC'));
$file->setDbMtime($now);
$file->save();
}
catch (LibreTimeFileNotFoundException $e)
{
} catch (LibreTimeFileNotFoundException $e) {
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED);
$file->setDbHidden(true);
$file->save();
throw $e;
}
@ -262,6 +267,7 @@ class CcFiles extends BaseCcFiles {
/** Delete a file from the database and disk (or cloud).
* @param $id The file ID
*
* @throws DeleteScheduledFileException
* @throws Exception
* @throws FileNoPermissionException
@ -278,10 +284,8 @@ class CcFiles extends BaseCcFiles {
} else {
throw new LibreTimeFileNotFoundException();
}
}
private static function validateFileArray(&$fileArray)
{
// Sanitize any wildly incorrect metadata before it goes to be validated
@ -298,7 +302,7 @@ class CcFiles extends BaseCcFiles {
* genre is more than 64 chars, for example, we don't want to reject
* tracks for that reason
*/
foreach($fileArray as $tag => &$value) {
foreach ($fileArray as $tag => &$value) {
if ($fileForm->getElement($tag)) {
$stringLengthValidator = $fileForm->getElement($tag)->getValidator('StringLength');
//$stringLengthValidator will be false if the StringLength validator doesn't exist on the current element
@ -315,56 +319,55 @@ class CcFiles extends BaseCcFiles {
$errors = $fileForm->getErrors();
$messages = $fileForm->getMessages();
Logging::error($messages);
throw new Exception("Data validation failed: $errors - $messages");
throw new Exception("Data validation failed: {$errors} - {$messages}");
}
return true;
}
public function getCueLength()
{
$cuein = $this->getDbCuein();
$cueout = $this->getDbCueout();
{
$cuein = $this->getDbCuein();
$cueout = $this->getDbCueout();
$cueinSec = Application_Common_DateHelper::calculateLengthInSeconds($cuein);
$cueoutSec = Application_Common_DateHelper::calculateLengthInSeconds($cueout);
$lengthSec = bcsub($cueoutSec, $cueinSec, 6);
$cueinSec = Application_Common_DateHelper::calculateLengthInSeconds($cuein);
$cueoutSec = Application_Common_DateHelper::calculateLengthInSeconds($cueout);
$lengthSec = bcsub($cueoutSec, $cueinSec, 6);
$length = Application_Common_DateHelper::secondsToPlaylistTime($lengthSec);
return $length;
}
return Application_Common_DateHelper::secondsToPlaylistTime($lengthSec);
}
public function setDbTrackNumber($v)
{
$max = pow(2, 31)-1;
$max = pow(2, 31) - 1;
$v = ($v > $max) ? $max : $v;
return parent::setDbTrackNumber($v);
}
// returns true if the file exists and is not hidden
public function visible() {
public function visible()
{
return $this->getDbFileExists() && !$this->getDbHidden();
}
public function reassignTo($user)
{
$this->setDbOwnerId( $user->getDbId() );
$this->setDbOwnerId($user->getDbId());
$this->save();
}
/**
*
* Strips out the private fields we do not want to send back in API responses
* Strips out the private fields we do not want to send back in API responses.
*
* @param CcFiles $file a CcFiles object
*
* @return array
*/
//TODO: rename this function?
public static function sanitizeResponse($file) {
public static function sanitizeResponse($file)
{
$response = $file->toArray(BasePeer::TYPE_FIELDNAME);
foreach (self::$privateFields as $key) {
@ -398,7 +401,7 @@ class CcFiles extends BaseCcFiles {
*/
public function getURLsForTrackPreviewOrDownload()
{
return array($this->getAbsoluteFilePath());
return [$this->getAbsoluteFilePath()];
}
/**
@ -408,10 +411,11 @@ class CcFiles extends BaseCcFiles {
{
$music_dir = Application_Model_MusicDir::getDirByPK($this->getDbDirectory());
if (!$music_dir) {
throw new Exception("Invalid music_dir for file " . $this->getDbId() . " in database.");
throw new Exception('Invalid music_dir for file ' . $this->getDbId() . ' in database.');
}
$directory = $music_dir->getDirectory();
$filepath = $this->getDbFilepath();
$filepath = $this->getDbFilepath();
return Application_Common_OsPath::join($directory, $filepath);
}
@ -422,18 +426,18 @@ class CcFiles extends BaseCcFiles {
{
$music_dir = Application_Model_MusicDir::getDirByPK($this->getDbDirectory());
if (!$music_dir) {
throw new Exception("Invalid music_dir for file " . $this->getDbId() . " in database.");
throw new Exception('Invalid music_dir for file ' . $this->getDbId() . ' in database.');
}
$directory = $music_dir->getDirectory();
$filepath = $this->getDbArtwork();
$filepath = $this->getDbArtwork();
return Application_Common_OsPath::join($directory, $filepath);
}
/**
*
* Strips out fields from incoming request data that should never be modified
* from outside of Airtime
* from outside of Airtime.
*
* @param array $data
*/
private static function removeBlacklistedFields($data)
@ -445,29 +449,31 @@ class CcFiles extends BaseCcFiles {
return $data;
}
private static function getOwnerId()
{
try {
if (Zend_Auth::getInstance()->hasIdentity()) {
$service_user = new Application_Service_UserService();
return $service_user->getCurrentUser()->getDbId();
} else {
$defaultOwner = CcSubjsQuery::create()
->filterByDbType('A')
->orderByDbId()
->findOne();
if (!$defaultOwner) {
// what to do if there is no admin user?
// should we handle this case?
return null;
}
return $defaultOwner->getDbId();
}
} catch(Exception $e) {
$defaultOwner = CcSubjsQuery::create()
->filterByDbType('A')
->orderByDbId()
->findOne()
;
if (!$defaultOwner) {
// what to do if there is no admin user?
// should we handle this case?
return null;
}
return $defaultOwner->getDbId();
} catch (Exception $e) {
Logging::info($e->getMessage());
}
}
/*
* It's possible that the year tag will be a timestamp but Airtime doesn't support this.
* The year field in cc_files can only be 16 chars max.
@ -476,11 +482,12 @@ class CcFiles extends BaseCcFiles {
*/
private static function stripTimeStampFromYearTag($metadata)
{
if (isset($metadata["year"])) {
if (preg_match("/^(\d{4})-(\d{2})-(\d{2})(?:\s+(\d{2}):(\d{2}):(\d{2}))?$/", $metadata["year"])) {
$metadata["year"] = substr($metadata["year"], 0, 4);
if (isset($metadata['year'])) {
if (preg_match("/^(\d{4})-(\d{2})-(\d{2})(?:\s+(\d{2}):(\d{2}):(\d{2}))?$/", $metadata['year'])) {
$metadata['year'] = substr($metadata['year'], 0, 4);
}
}
return $metadata;
}
@ -488,28 +495,29 @@ class CcFiles extends BaseCcFiles {
{
//Remove invalid UTF-8 characters
//reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ?
$string = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'.
'|[\x00-\x7F][\x80-\xBF]+'.
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'.
$string = preg_replace(
'/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' .
'|[\x00-\x7F][\x80-\xBF]+' .
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' .
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' .
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S',
'?', $string );
'?',
$string
);
//reject overly long 3 byte sequences and UTF-16 surrogates and replace with ?
$string = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'.
'|\xED[\xA0-\xBF][\x80-\xBF]/S','?', $string );
$string = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' .
'|\xED[\xA0-\xBF][\x80-\xBF]/S', '?', $string);
//Do a final encoding conversion to
$string = mb_convert_encoding($string, 'UTF-8', 'UTF-8');
return $string;
return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
}
private function removeEmptySubFolders($path)
{
exec("find $path -empty -type d -delete");
exec("find {$path} -empty -type d -delete");
}
/**
* Checks if the file is a regular file that can be previewed and downloaded.
*/
@ -519,7 +527,6 @@ class CcFiles extends BaseCcFiles {
}
/**
*
* Deletes the file from the stor directory on disk.
*/
public function deletePhysicalFile()
@ -529,17 +536,16 @@ class CcFiles extends BaseCcFiles {
if (file_exists($filepath)) {
unlink($filepath);
// also delete related images (dataURI and jpeg files)
foreach (glob("$artworkpath*", GLOB_NOSORT) as $filename) {
foreach (glob("{$artworkpath}*", GLOB_NOSORT) as $filename) {
unlink($filename);
}
unlink($artworkpath);
} else {
throw new Exception("Could not locate file ".$filepath);
throw new Exception('Could not locate file ' . $filepath);
}
}
/**
*
* This function refers to the file's Amazon S3 resource id.
* Returns null because cc_files are stored on local disk.
*/
@ -552,5 +558,4 @@ class CcFiles extends BaseCcFiles {
{
return $this->id;
}
} // CcFiles

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on 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.airtime
*/
class CcFilesPeer extends BaseCcFilesPeer {
class CcFilesPeer extends BaseCcFilesPeer
{
} // CcFilesPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on 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.airtime
*/
class CcFilesQuery extends BaseCcFilesQuery {
class CcFilesQuery extends BaseCcFilesQuery
{
} // CcFilesQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_listener_count' 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.airtime
*/
class CcListenerCount extends BaseCcListenerCount {
class CcListenerCount extends BaseCcListenerCount
{
} // CcListenerCount

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_listener_count' 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.airtime
*/
class CcListenerCountPeer extends BaseCcListenerCountPeer {
class CcListenerCountPeer extends BaseCcListenerCountPeer
{
} // CcListenerCountPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_listener_count' 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.airtime
*/
class CcListenerCountQuery extends BaseCcListenerCountQuery {
class CcListenerCountQuery extends BaseCcListenerCountQuery
{
} // CcListenerCountQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_live_log' 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.airtime
*/
class CcLiveLog extends BaseCcLiveLog {
class CcLiveLog extends BaseCcLiveLog
{
} // CcLiveLog

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_live_log' 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.airtime
*/
class CcLiveLogPeer extends BaseCcLiveLogPeer {
class CcLiveLogPeer extends BaseCcLiveLogPeer
{
} // CcLiveLogPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_live_log' 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.airtime
*/
class CcLiveLogQuery extends BaseCcLiveLogQuery {
class CcLiveLogQuery extends BaseCcLiveLogQuery
{
} // CcLiveLogQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_locale' 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.airtime
*/
class CcLocale extends BaseCcLocale {
class CcLocale extends BaseCcLocale
{
} // CcLocale

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_locale' 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.airtime
*/
class CcLocalePeer extends BaseCcLocalePeer {
class CcLocalePeer extends BaseCcLocalePeer
{
} // CcLocalePeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_locale' 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.airtime
*/
class CcLocaleQuery extends BaseCcLocaleQuery {
class CcLocaleQuery extends BaseCcLocaleQuery
{
} // CcLocaleQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_login_attempts' 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.airtime
*/
class CcLoginAttempts extends BaseCcLoginAttempts {
class CcLoginAttempts extends BaseCcLoginAttempts
{
} // CcLoginAttempts

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_login_attempts' 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.airtime
*/
class CcLoginAttemptsPeer extends BaseCcLoginAttemptsPeer {
class CcLoginAttemptsPeer extends BaseCcLoginAttemptsPeer
{
} // CcLoginAttemptsPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_login_attempts' 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.airtime
*/
class CcLoginAttemptsQuery extends BaseCcLoginAttemptsQuery {
class CcLoginAttemptsQuery extends BaseCcLoginAttemptsQuery
{
} // CcLoginAttemptsQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_mount_name' 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.airtime
*/
class CcMountName extends BaseCcMountName {
class CcMountName extends BaseCcMountName
{
} // CcMountName

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_mount_name' 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.airtime
*/
class CcMountNamePeer extends BaseCcMountNamePeer {
class CcMountNamePeer extends BaseCcMountNamePeer
{
} // CcMountNamePeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_mount_name' 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.airtime
*/
class CcMountNameQuery extends BaseCcMountNameQuery {
class CcMountNameQuery extends BaseCcMountNameQuery
{
} // CcMountNameQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_music_dirs' 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.airtime
*/
class CcMusicDirs extends BaseCcMusicDirs {
class CcMusicDirs extends BaseCcMusicDirs
{
} // CcMusicDirs

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_music_dirs' 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.airtime
*/
class CcMusicDirsPeer extends BaseCcMusicDirsPeer {
class CcMusicDirsPeer extends BaseCcMusicDirsPeer
{
} // CcMusicDirsPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_music_dirs' 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.airtime
*/
class CcMusicDirsQuery extends BaseCcMusicDirsQuery {
class CcMusicDirsQuery extends BaseCcMusicDirsQuery
{
} // CcMusicDirsQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_perms' 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.airtime
*/
class CcPerms extends BaseCcPerms {
class CcPerms extends BaseCcPerms
{
} // CcPerms

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_perms' 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.airtime
*/
class CcPermsPeer extends BaseCcPermsPeer {
class CcPermsPeer extends BaseCcPermsPeer
{
} // CcPermsPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_perms' 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.airtime
*/
class CcPermsQuery extends BaseCcPermsQuery {
class CcPermsQuery extends BaseCcPermsQuery
{
} // CcPermsQuery

View file

@ -1,28 +1,23 @@
<?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 {
class CcPlaylist extends BaseCcPlaylist
{
/**
* Get the [optionally formatted] temporal [utime] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbUtime($format = 'Y-m-d H:i:s')
{
@ -31,29 +26,31 @@ class CcPlaylist extends BaseCcPlaylist {
}
try {
$dt = new DateTime($this->utime, new DateTimeZone("UTC"));
$dt = new DateTime($this->utime, new DateTimeZone('UTC'));
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x);
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->utime, 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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($format);
}
/**
* Get the [optionally formatted] temporal [mtime] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbMtime($format = 'Y-m-d H:i:s')
{
@ -62,19 +59,20 @@ class CcPlaylist extends BaseCcPlaylist {
}
try {
$dt = new DateTime($this->mtime, new DateTimeZone("UTC"));
$dt = new DateTime($this->mtime, new DateTimeZone('UTC'));
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->mtime, true), $x);
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->mtime, 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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($format);
}
/**
@ -87,7 +85,7 @@ class CcPlaylist extends BaseCcPlaylist {
*/
public function computeDbLength(PropelPDO $con)
{
$sql = <<<SQL
$sql = <<<'SQL'
SELECT SUM(cliplength) FROM cc_playlistcontents as pc
LEFT JOIN cc_files as f ON pc.file_id = f.id
WHERE PLAYLIST_ID = :p1
@ -98,10 +96,9 @@ SQL;
$stmt->execute();
$length = $stmt->fetchColumn();
if (is_null($length)) {
$length = "00:00:00";
$length = '00:00:00';
}
return $length;
}
} // CcPlaylist

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on 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.airtime
*/
class CcPlaylistPeer extends BaseCcPlaylistPeer {
class CcPlaylistPeer extends BaseCcPlaylistPeer
{
} // CcPlaylistPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on 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.airtime
*/
class CcPlaylistQuery extends BaseCcPlaylistQuery {
class CcPlaylistQuery extends BaseCcPlaylistQuery
{
} // CcPlaylistQuery

View file

@ -3,23 +3,22 @@
/**
* 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 {
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.
* @param mixed $format
*
* @throws propelException - if unable to parse/validate the date/time value
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbFadein($format = "s.u")
public function getDbFadein($format = 's.u')
{
return parent::getDbFadein($format);
}
@ -27,17 +26,20 @@ 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.
* @param mixed $format
*
* @throws propelException - if unable to parse/validate the date/time value
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
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.
* @param mixed $v
*
* @return CcPlaylistcontents The current object (for fluent API support)
*/
@ -46,15 +48,13 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
$microsecond = 0;
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
} elseif (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
// in php 5.3.2 createFromFormat() with "u" is not supported(bug)
// Hence we need to do parsing.
$info = explode('.', $v);
$microsecond = $info[1];
$dt = DateTime::createFromFormat("s", $info[0]);
}
else {
$dt = DateTime::createFromFormat('s', $info[0]);
} else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
@ -65,7 +65,7 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
if ($microsecond == 0) {
$this->fadein = $dt->format('H:i:s.u');
} else {
$this->fadein = $dt->format('H:i:s').".".$microsecond;
$this->fadein = $dt->format('H:i:s') . '.' . $microsecond;
}
$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
$this->save();
@ -76,25 +76,23 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
} // setDbFadein()
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
*
* @return CcPlaylistcontents The current object (for fluent API support)
*/
* @param string in format SS.uuuuuu, Datetime, or DateTime accepted string.
* @param mixed $v
*
* @return CcPlaylistcontents The current object (for fluent API support)
*/
public function setDbFadeout($v)
{
$microsecond = 0;
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
} elseif (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
// in php 5.3.2 createFromFormat() with "u" is not supported(bug)
// Hence we need to do parsing.
$info = explode('.', $v);
$microsecond = $info[1];
$dt = DateTime::createFromFormat("s", $info[0]);
}
else {
$dt = DateTime::createFromFormat('s', $info[0]);
} else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
@ -105,14 +103,13 @@ class CcPlaylistcontents extends BaseCcPlaylistcontents {
if ($microsecond == 0) {
$this->fadeout = $dt->format('H:i:s.u');
} else {
$this->fadeout = $dt->format('H:i:s').".".$microsecond;
$this->fadeout = $dt->format('H:i:s') . '.' . $microsecond;
}
$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
$this->save();
//FIXME(XXX): Propel silently drops the milliseconds from our fadeout time. :(
return $this;
} // setDbFadeout()
} // CcPlaylistcontents

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on 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.airtime
*/
class CcPlaylistcontentsPeer extends BaseCcPlaylistcontentsPeer {
class CcPlaylistcontentsPeer extends BaseCcPlaylistcontentsPeer
{
} // CcPlaylistcontentsPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on 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.airtime
*/
class CcPlaylistcontentsQuery extends BaseCcPlaylistcontentsQuery {
class CcPlaylistcontentsQuery extends BaseCcPlaylistcontentsQuery
{
} // CcPlaylistcontentsQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playlistcriteria' 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.airtime
*/
class CcPlaylistcriteria extends BaseCcPlaylistcriteria {
class CcPlaylistcriteria extends BaseCcPlaylistcriteria
{
} // CcPlaylistcriteria

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlistcriteria' 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.airtime
*/
class CcPlaylistcriteriaPeer extends BaseCcPlaylistcriteriaPeer {
class CcPlaylistcriteriaPeer extends BaseCcPlaylistcriteriaPeer
{
} // CcPlaylistcriteriaPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playlistcriteria' 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.airtime
*/
class CcPlaylistcriteriaQuery extends BaseCcPlaylistcriteriaQuery {
class CcPlaylistcriteriaQuery extends BaseCcPlaylistcriteriaQuery
{
} // CcPlaylistcriteriaQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playout_history' 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.airtime
*/
class CcPlayoutHistory extends BaseCcPlayoutHistory {
class CcPlayoutHistory extends BaseCcPlayoutHistory
{
} // CcPlayoutHistory

View file

@ -1,34 +1,28 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playout_history_metadata' 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.airtime
*/
class CcPlayoutHistoryMetaData extends BaseCcPlayoutHistoryMetaData {
/**
* Set the value of [value] column.
*
* @param string $v new value
* @return CcPlayoutHistoryMetaData The current object (for fluent API support)
*/
public function setDbValue($v)
{
//make sure the metadata isn't longer than the DB field.
$v = substr($v, 0, 128);
parent::setDbValue($v);
return $this;
} // setDbValue()
class CcPlayoutHistoryMetaData extends BaseCcPlayoutHistoryMetaData
{
/**
* Set the value of [value] column.
*
* @param string $v new value
*
* @return CcPlayoutHistoryMetaData The current object (for fluent API support)
*/
public function setDbValue($v)
{
//make sure the metadata isn't longer than the DB field.
$v = substr($v, 0, 128);
parent::setDbValue($v);
return $this;
} // setDbValue()
} // CcPlayoutHistoryMetaData

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history_metadata' 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.airtime
*/
class CcPlayoutHistoryMetaDataPeer extends BaseCcPlayoutHistoryMetaDataPeer {
class CcPlayoutHistoryMetaDataPeer extends BaseCcPlayoutHistoryMetaDataPeer
{
} // CcPlayoutHistoryMetaDataPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history_metadata' 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.airtime
*/
class CcPlayoutHistoryMetaDataQuery extends BaseCcPlayoutHistoryMetaDataQuery {
class CcPlayoutHistoryMetaDataQuery extends BaseCcPlayoutHistoryMetaDataQuery
{
} // CcPlayoutHistoryMetaDataQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history' 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.airtime
*/
class CcPlayoutHistoryPeer extends BaseCcPlayoutHistoryPeer {
class CcPlayoutHistoryPeer extends BaseCcPlayoutHistoryPeer
{
} // CcPlayoutHistoryPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history' 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.airtime
*/
class CcPlayoutHistoryQuery extends BaseCcPlayoutHistoryQuery {
class CcPlayoutHistoryQuery extends BaseCcPlayoutHistoryQuery
{
} // CcPlayoutHistoryQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playout_history_template' 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.airtime
*/
class CcPlayoutHistoryTemplate extends BaseCcPlayoutHistoryTemplate {
class CcPlayoutHistoryTemplate extends BaseCcPlayoutHistoryTemplate
{
} // CcPlayoutHistoryTemplate

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playout_history_template_field' 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.airtime
*/
class CcPlayoutHistoryTemplateField extends BaseCcPlayoutHistoryTemplateField {
class CcPlayoutHistoryTemplateField extends BaseCcPlayoutHistoryTemplateField
{
} // CcPlayoutHistoryTemplateField

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history_template_field' 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.airtime
*/
class CcPlayoutHistoryTemplateFieldPeer extends BaseCcPlayoutHistoryTemplateFieldPeer {
class CcPlayoutHistoryTemplateFieldPeer extends BaseCcPlayoutHistoryTemplateFieldPeer
{
} // CcPlayoutHistoryTemplateFieldPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history_template_field' 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.airtime
*/
class CcPlayoutHistoryTemplateFieldQuery extends BaseCcPlayoutHistoryTemplateFieldQuery {
class CcPlayoutHistoryTemplateFieldQuery extends BaseCcPlayoutHistoryTemplateFieldQuery
{
} // CcPlayoutHistoryTemplateFieldQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history_template' 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.airtime
*/
class CcPlayoutHistoryTemplatePeer extends BaseCcPlayoutHistoryTemplatePeer {
class CcPlayoutHistoryTemplatePeer extends BaseCcPlayoutHistoryTemplatePeer
{
} // CcPlayoutHistoryTemplatePeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history_template' 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.airtime
*/
class CcPlayoutHistoryTemplateQuery extends BaseCcPlayoutHistoryTemplateQuery {
class CcPlayoutHistoryTemplateQuery extends BaseCcPlayoutHistoryTemplateQuery
{
} // CcPlayoutHistoryTemplateQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_pref' 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.airtime
*/
class CcPref extends BaseCcPref {
class CcPref extends BaseCcPref
{
} // CcPref

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_pref' 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.airtime
*/
class CcPrefPeer extends BaseCcPrefPeer {
class CcPrefPeer extends BaseCcPrefPeer
{
} // CcPrefPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_pref' 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.airtime
*/
class CcPrefQuery extends BaseCcPrefQuery {
class CcPrefQuery extends BaseCcPrefQuery
{
} // CcPrefQuery

View file

@ -1,28 +1,23 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_schedule' 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.airtime
*/
class CcSchedule extends BaseCcSchedule {
class CcSchedule extends BaseCcSchedule
{
/**
* Get the [optionally formatted] temporal [starts] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbStarts($format = 'Y-m-d H:i:s.u')
{
@ -31,29 +26,31 @@ class CcSchedule extends BaseCcSchedule {
}
try {
$dt = new DateTime($this->starts, new DateTimeZone("UTC"));
$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);
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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($format);
}
/**
* Get the [optionally formatted] temporal [ends] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbEnds($format = 'Y-m-d H:i:s.u')
{
@ -62,28 +59,32 @@ class CcSchedule extends BaseCcSchedule {
}
try {
$dt = new DateTime($this->ends, new DateTimeZone("UTC"));
$dt = new DateTime($this->ends, new DateTimeZone('UTC'));
} 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('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->ends, 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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($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.
* @param mixed $format
*
* @throws propelException - if unable to parse/validate the date/time value
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbFadeIn($format = "s.u")
public function getDbFadeIn($format = 's.u')
{
return parent::getDbFadein($format);
}
@ -91,17 +92,20 @@ class CcSchedule extends BaseCcSchedule {
/**
* 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.
* @param mixed $format
*
* @throws propelException - if unable to parse/validate the date/time value
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbFadeOut($format = "s.u")
public function getDbFadeOut($format = 's.u')
{
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.
* @param mixed $v
*
* @return CcPlaylistcontents The current object (for fluent API support)
*/
@ -110,15 +114,13 @@ class CcSchedule extends BaseCcSchedule {
$microsecond = 0;
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
} elseif (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
// in php 5.3.2 createFromFormat() with "u" is not supported(bug)
// Hence we need to do parsing.
$info = explode('.', $v);
$microsecond = $info[1];
$dt = DateTime::createFromFormat("s", $info[0]);
}
else {
$dt = DateTime::createFromFormat('s', $info[0]);
} else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
@ -129,7 +131,7 @@ class CcSchedule extends BaseCcSchedule {
if ($microsecond == 0) {
$this->fade_in = $dt->format('H:i:s.u');
} else {
$this->fade_in = $dt->format('H:i:s').".".$microsecond;
$this->fade_in = $dt->format('H:i:s') . '.' . $microsecond;
}
$this->modifiedColumns[] = CcSchedulePeer::FADE_IN;
@ -137,25 +139,23 @@ class CcSchedule extends BaseCcSchedule {
} // setDbFadein()
/**
*
* @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
*
* @return CcPlaylistcontents The current object (for fluent API support)
*/
* @param string in format SS.uuuuuu, Datetime, or DateTime accepted string.
* @param mixed $v
*
* @return CcPlaylistcontents The current object (for fluent API support)
*/
public function setDbFadeOut($v)
{
$microsecond = 0;
if ($v instanceof DateTime) {
$dt = $v;
}
else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
} elseif (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
// in php 5.3.2 createFromFormat() with "u" is not supported(bug)
// Hence we need to do parsing.
$info = explode('.', $v);
$microsecond = $info[1];
$dt = DateTime::createFromFormat("s", $info[0]);
}
else {
$dt = DateTime::createFromFormat('s', $info[0]);
} else {
try {
$dt = new DateTime($v);
} catch (Exception $x) {
@ -166,7 +166,7 @@ class CcSchedule extends BaseCcSchedule {
if ($microsecond == 0) {
$this->fade_out = $dt->format('H:i:s.u');
} else {
$this->fade_out = $dt->format('H:i:s').".".$microsecond;
$this->fade_out = $dt->format('H:i:s') . '.' . $microsecond;
}
$this->modifiedColumns[] = CcSchedulePeer::FADE_OUT;
@ -176,15 +176,16 @@ class CcSchedule extends BaseCcSchedule {
/**
* Sets the value of [starts] 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 CcSchedule The current object (for fluent API support)
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
*
* @return CcSchedule The current object (for fluent API support)
*/
public function setDbStarts($v)
{
$utcTimeZone = new DateTimeZone('UTC');
if ($v instanceof DateTime) {
if ($v instanceof DateTime) {
$dt = $v;
$dt->setTimezone($utcTimeZone);
} else {
@ -192,8 +193,7 @@ class CcSchedule extends BaseCcSchedule {
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, $utcTimeZone);
$dt = new DateTime('@' . $v, $utcTimeZone);
} else {
$dt = new DateTime($v, $utcTimeZone);
}
@ -211,14 +211,15 @@ class CcSchedule extends BaseCcSchedule {
/**
* Sets the value of [ends] 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 CcSchedule The current object (for fluent API support)
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
*
* @return CcSchedule The current object (for fluent API support)
*/
public function setDbEnds($v)
{
$utcTimeZone = new DateTimeZone('UTC');
$utcTimeZone = new DateTimeZone('UTC');
if ($v instanceof DateTime) {
$dt = $v;
$dt->setTimezone($utcTimeZone);
@ -227,8 +228,7 @@ class CcSchedule extends BaseCcSchedule {
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, $utcTimeZone);
$dt = new DateTime('@' . $v, $utcTimeZone);
} else {
$dt = new DateTime($v, $utcTimeZone);
}
@ -242,21 +242,20 @@ class CcSchedule extends BaseCcSchedule {
return $this;
} // setDbEnds()
public function isCurrentItem($epochNow = null) {
public function isCurrentItem($epochNow = null)
{
if (is_null($epochNow)) {
$epochNow = microtime(true);
}
$epochStart = floatval($this->getDbStarts('U.u'));
$epochEnd = floatval($this->getDbEnds('U.u'));
if ($epochStart < $epochNow && $epochEnd > $epochNow) {
return true;
}
return false;
}
} // CcSchedule

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_schedule' 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.airtime
*/
class CcSchedulePeer extends BaseCcSchedulePeer {
class CcSchedulePeer extends BaseCcSchedulePeer
{
} // CcSchedulePeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_schedule' 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.airtime
*/
class CcScheduleQuery extends BaseCcScheduleQuery {
class CcScheduleQuery extends BaseCcScheduleQuery
{
} // CcScheduleQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_service_register' 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.airtime
*/
class CcServiceRegister extends BaseCcServiceRegister {
class CcServiceRegister extends BaseCcServiceRegister
{
} // CcServiceRegister

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_service_register' 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.airtime
*/
class CcServiceRegisterPeer extends BaseCcServiceRegisterPeer {
class CcServiceRegisterPeer extends BaseCcServiceRegisterPeer
{
} // CcServiceRegisterPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_service_register' 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.airtime
*/
class CcServiceRegisterQuery extends BaseCcServiceRegisterQuery {
class CcServiceRegisterQuery extends BaseCcServiceRegisterQuery
{
} // CcServiceRegisterQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_sess' 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.airtime
*/
class CcSess extends BaseCcSess {
class CcSess extends BaseCcSess
{
} // CcSess

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_sess' 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.airtime
*/
class CcSessPeer extends BaseCcSessPeer {
class CcSessPeer extends BaseCcSessPeer
{
} // CcSessPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_sess' 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.airtime
*/
class CcSessQuery extends BaseCcSessQuery {
class CcSessQuery extends BaseCcSessQuery
{
} // CcSessQuery

View file

@ -1,20 +1,14 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show' 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.airtime
*/
class CcShow extends BaseCcShow {
class CcShow extends BaseCcShow
{
/*
* Returns all cc_show_day rules that belong to a cc_show and that are
* repeating.
@ -24,11 +18,13 @@ class CcShow extends BaseCcShow {
* So when the entire cc_show is updated after that, the single edited
* instance can remain separate from the rest of the instances
*/
public function getRepeatingCcShowDays(){
public function getRepeatingCcShowDays()
{
return CcShowDaysQuery::create()
->filterByDbShowId($this->id)
->filterByDbRepeatType(-1, Criteria::NOT_EQUAL)
->find();
->find()
;
}
/**
@ -40,17 +36,19 @@ class CcShow extends BaseCcShow {
* If this CcShow is new, it will return
* an empty collection or the current collection; the criteria is ignored on a new object.
*
* @param Criteria $criteria optional Criteria object to narrow the query
* @param PropelPDO $con optional connection object
* @return PropelCollection|array CcShowDays[] List of CcShowDays objects
* @throws PropelException
* @param Criteria $criteria optional Criteria object to narrow the query
* @param PropelPDO $con optional connection object
*
* @throws PropelException
*
* @return array|PropelCollection CcShowDays[] List of CcShowDays objects
*/
public function getFirstCcShowDay($criteria = null, PropelPDO $con = null)
{
/*CcShowPeer::clearInstancePool();
CcShowPeer::clearRelatedInstancePool();*/
if(null === $this->collCcShowDayss || null !== $criteria) {
if (null === $this->collCcShowDayss || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowDayss) {
// return empty collection
$this->initCcShowDayss();
@ -59,22 +57,23 @@ class CcShow extends BaseCcShow {
->filterByCcShow($this)
->orderByDbFirstShow()
->limit(1)
->find($con);
->find($con)
;
if (null !== $criteria) {
return $collCcShowDayss;
}
$this->collCcShowDayss = $collCcShowDayss;
}
}
return $this->collCcShowDayss[0];
}
/**
*
* A repeating show may have a rule in cc_show_days with a repeat type
* of -1 (not repeating). This happens when a single instances was edited
* from the repeating sequence.
*
*
* When the repeating show gets edited in this case, we want to exclude all
* the edited instances from the update. We do this by not returning any of
* the cc_show_day rules with a -1 repeat type.
@ -85,16 +84,16 @@ class CcShow extends BaseCcShow {
->filterByDbShowId($this->id)
->filterByDbRepeatType(-1, Criteria::NOT_EQUAL)
->orderByDbFirstShow()
->findOne();
->findOne()
;
}
/**
*
* In order to determine if a show is repeating we need to check each
* cc_show_day entry and check if there are any non -1 repeat types.
* Because editing a single instances creates a new cc_show_day rule
* with a -1 (non repeating) repeat type we need to check all cc_show_day
* entries
* entries.
*/
public function isRepeating()
{
@ -102,7 +101,8 @@ class CcShow extends BaseCcShow {
$ccShowDays = CcShowDaysQuery::create()
->filterByDbShowId($this->id)
->filterByDbRepeatType(0, Criteria::GREATER_EQUAL)
->find();
->find()
;
if (!$ccShowDays->isEmpty()) {
return true;
@ -113,7 +113,7 @@ class CcShow extends BaseCcShow {
/**
* Returns all cc_show_instances that have been edited out of
* a repeating sequence
* a repeating sequence.
*/
public function getEditedRepeatingInstanceIds()
{
@ -121,27 +121,29 @@ class CcShow extends BaseCcShow {
$ccShowDays = CcShowDaysQuery::create()
->filterByDbShowId($this->id)
->filterByDbRepeatType(-1)
->find();
->find()
;
$startsUTC = array();
$startsUTC = [];
$utc = new DateTimeZone("UTC");
$utc = new DateTimeZone('UTC');
foreach ($ccShowDays as $day) {
//convert to UTC
$starts = new DateTime(
$day->getDbFirstShow()." ".$day->getDbStartTime(),
$day->getDbFirstShow() . ' ' . $day->getDbStartTime(),
new DateTimeZone($day->getDbTimezone())
);
$starts->setTimezone($utc);
array_push($startsUTC, $starts->format("Y-m-d H:i:s"));
array_push($startsUTC, $starts->format('Y-m-d H:i:s'));
}
$excludeInstances = CcShowInstancesQuery::create()
->filterByDbShowId($this->id)
->filterByDbStarts($startsUTC, criteria::IN)
->find();
->find()
;
$excludeIds = array();
$excludeIds = [];
foreach ($excludeInstances as $instance) {
array_push($excludeIds, $instance->getDbId());
}
@ -158,29 +160,33 @@ class CcShow extends BaseCcShow {
* If this CcShow is new, it will return
* an empty collection or the current collection; the criteria is ignored on a new object.
*
* @param Criteria $criteria optional Criteria object to narrow the query
* @param PropelPDO $con optional connection object
* @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects
* @throws PropelException
* @param Criteria $criteria optional Criteria object to narrow the query
* @param PropelPDO $con optional connection object
*
* @throws PropelException
*
* @return array|PropelCollection CcShowInstances[] List of CcShowInstances objects
*/
public function getFutureCcShowInstancess($criteria = null, PropelPDO $con = null)
{
if(null === $this->collCcShowInstancess || null !== $criteria) {
if (null === $this->collCcShowInstancess || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowInstancess) {
// return empty collection
$this->initCcShowInstancess();
} else {
$collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria)
->filterByCcShow($this)
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
->filterByDbStarts(gmdate('Y-m-d H:i:s'), Criteria::GREATER_THAN)
->filterByDbModifiedInstance(false)
->find($con);
->find($con)
;
if (null !== $criteria) {
return $collCcShowInstancess;
}
$this->collCcShowInstancess = $collCcShowInstancess;
}
}
return $this->collCcShowInstancess;
}
@ -189,18 +195,20 @@ class CcShow extends BaseCcShow {
$ccShowDay = CcShowDaysQuery::create()
->filterByDbShowId($this->getDbId())
->filterByDbRecord(1)
->findOne();
->findOne()
;
return (!is_null($ccShowDay));
return !is_null($ccShowDay);
}
public function isRebroadcast()
{
$ccShowRebroadcast = CcShowRebroadcastQuery::create()
->filterByDbShowId($this->getDbId())
->findOne();
->findOne()
;
return (!is_null($ccShowRebroadcast));
return !is_null($ccShowRebroadcast);
}
public function getRebroadcastsRelative()
@ -208,7 +216,8 @@ class CcShow extends BaseCcShow {
return CcShowRebroadcastQuery::create()
->filterByDbShowId($this->getDbId())
->orderByDbDayOffset()
->find();
->find()
;
}
public function getRebroadcastsAbsolute()
@ -218,7 +227,8 @@ class CcShow extends BaseCcShow {
->filterByDbRebroadcast(1)
->filterByDbModifiedInstance(false)
->orderByDbStarts()
->find();
->find()
;
}
public function isLinked()
@ -240,18 +250,21 @@ class CcShow extends BaseCcShow {
* If this CcShow is new, it will return
* an empty collection or the current collection; the criteria is ignored on a new object.
*
* @param Criteria $criteria optional Criteria object to narrow the query
* @param PropelPDO $con optional connection object
* @return PropelCollection|array CcShowInstances[] List of CcShowInstances objects
* @throws PropelException
* @param Criteria $criteria optional Criteria object to narrow the query
* @param PropelPDO $con optional connection object
*
* @throws PropelException
*
* @return array|PropelCollection CcShowInstances[] List of CcShowInstances objects
*/
public function getCcShowInstancess($criteria = null, PropelPDO $con = null)
{
return CcShowInstancesQuery::create(null, $criteria)
->filterByCcShow($this)
->filterByDbModifiedInstance(false)
->orderByDbId()
->find($con);
->filterByCcShow($this)
->filterByDbModifiedInstance(false)
->orderByDbId()
->find($con)
;
/*if(null === $this->collCcShowInstancess || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowInstancess) {
@ -273,26 +286,30 @@ class CcShow extends BaseCcShow {
return $this->collCcShowInstancess;*/
}
public function getInstanceIds() {
$instanceIds = array();
public function getInstanceIds()
{
$instanceIds = [];
foreach ($this->getCcShowInstancess() as $ccShowInstance) {
$instanceIds[] = $ccShowInstance->getDbId();
}
return $instanceIds;
}
/*
* Returns cc_show_instance ids where the start time is greater than
* the current time
*
* If a Criteria object is passed in Propel will always fetch the
*
* If a Criteria object is passed in Propel will always fetch the
* results from the database and not return a cached collection
*/
public function getFutureInstanceIds($criteria = null) {
$instanceIds = array();
public function getFutureInstanceIds($criteria = null)
{
$instanceIds = [];
foreach ($this->getFutureCcShowInstancess($criteria) as $ccShowInstance) {
$instanceIds[] = $ccShowInstance->getDbId();
}
return $instanceIds;
}
@ -302,28 +319,28 @@ class CcShow extends BaseCcShow {
return CcShowInstancesQuery::create()
->filterByCcShow($this)
->filterByDbId($instanceId, Criteria::NOT_EQUAL)
->find();
->find()
;
}
public function getShowInfo()
{
$info = array();
$info = [];
if ($this->getDbId() == null) {
return $info;
} else {
$info['name'] = $this->getDbName();
$info['id'] = $this->getDbId();
$info['url'] = $this->getDbUrl();
$info['genre'] = $this->getDbGenre();
$info['description'] = $this->getDbDescription();
$info['color'] = $this->getDbColor();
$info['background_color'] = $this->getDbBackgroundColor();
$info['linked'] = $this->getDbLinked();
$info['has_autoplaylist'] = $this->getDbHasAutoPlaylist();
$info['autoplaylist_id'] = $this->getDbAutoPlaylistId();
$info['autoplaylist_repeat'] = $this->getDbAutoPlaylistRepeat();
return $info;
}
$info['name'] = $this->getDbName();
$info['id'] = $this->getDbId();
$info['url'] = $this->getDbUrl();
$info['genre'] = $this->getDbGenre();
$info['description'] = $this->getDbDescription();
$info['color'] = $this->getDbColor();
$info['background_color'] = $this->getDbBackgroundColor();
$info['linked'] = $this->getDbLinked();
$info['has_autoplaylist'] = $this->getDbHasAutoPlaylist();
$info['autoplaylist_id'] = $this->getDbAutoPlaylistId();
$info['autoplaylist_repeat'] = $this->getDbAutoPlaylistRepeat();
return $info;
}
} // CcShow

View file

@ -1,20 +1,14 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_days' 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.airtime
*/
class CcShowDays extends BaseCcShowDays {
class CcShowDays extends BaseCcShowDays
{
public function isRepeating()
{
return $this->getDbRepeatType() != -1;
@ -26,7 +20,7 @@ class CcShowDays extends BaseCcShowDays {
"{$this->getDbFirstShow()} {$this->getDbStartTime()}",
new DateTimeZone($this->getDbTimezone())
);
$dt->setTimezone(new DateTimeZone("UTC"));
$dt->setTimezone(new DateTimeZone('UTC'));
return $dt;
}
@ -34,38 +28,37 @@ class CcShowDays extends BaseCcShowDays {
// Returns the start of a show in the timezone it was created in
public function getLocalStartDateAndTime()
{
$dt = new DateTime(
return new DateTime(
"{$this->getDbFirstShow()} {$this->getDbStartTime()}",
new DateTimeZone($this->getDbTimezone())
);
//set timezone to that of the show
//$dt->setTimezone(new DateTimeZone($this->getDbTimezone()));
return $dt;
}
/**
*
* Returns the end of a show in the timezone it was created in
* Returns the end of a show in the timezone it was created in.
*
* @param DateTime $startDateTime first show in show's local time
*/
public function getLocalEndDateAndTime()
{
$startDateTime = $this->getLocalStartDateAndTime();
$duration = explode(":", $this->getDbDuration());
$duration = explode(':', $this->getDbDuration());
return $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M'));
return $startDateTime->add(new DateInterval('PT' . $duration[0] . 'H' . $duration[1] . 'M'));
}
public function isShowStartInPast()
{
return $this->getUTCStartDateAndTime()->format("Y-m-d H:i:s") < gmdate("Y-m-d H:i:s");
return $this->getUTCStartDateAndTime()->format('Y-m-d H:i:s') < gmdate('Y-m-d H:i:s');
}
public function formatDuration()
{
$info = explode(':',$this->getDbDuration());
$info = explode(':', $this->getDbDuration());
return str_pad(intval($info[0]),2,'0',STR_PAD_LEFT).'h '.str_pad(intval($info[1]),2,'0',STR_PAD_LEFT).'m';
return str_pad(intval($info[0]), 2, '0', STR_PAD_LEFT) . 'h ' . str_pad(intval($info[1]), 2, '0', STR_PAD_LEFT) . 'm';
}
} // CcShowDays

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_days' 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.airtime
*/
class CcShowDaysPeer extends BaseCcShowDaysPeer {
class CcShowDaysPeer extends BaseCcShowDaysPeer
{
} // CcShowDaysPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_days' 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.airtime
*/
class CcShowDaysQuery extends BaseCcShowDaysQuery {
class CcShowDaysQuery extends BaseCcShowDaysQuery
{
} // CcShowDaysQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_hosts' 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.airtime
*/
class CcShowHosts extends BaseCcShowHosts {
class CcShowHosts extends BaseCcShowHosts
{
} // CcShowHosts

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_hosts' 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.airtime
*/
class CcShowHostsPeer extends BaseCcShowHostsPeer {
class CcShowHostsPeer extends BaseCcShowHostsPeer
{
} // CcShowHostsPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_hosts' 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.airtime
*/
class CcShowHostsQuery extends BaseCcShowHostsQuery {
class CcShowHostsQuery extends BaseCcShowHostsQuery
{
} // CcShowHostsQuery

View file

@ -1,28 +1,23 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_instances' 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.airtime
*/
class CcShowInstances extends BaseCcShowInstances {
/**
class CcShowInstances extends BaseCcShowInstances
{
/**
* Get the [optionally formatted] temporal [starts] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbStarts($format = 'Y-m-d H:i:s')
{
@ -31,29 +26,31 @@ class CcShowInstances extends BaseCcShowInstances {
}
try {
$dt = new DateTime($this->starts, new DateTimeZone("UTC"));
$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);
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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($format);
}
/**
* Get the [optionally formatted] temporal [ends] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbEnds($format = 'Y-m-d H:i:s')
{
@ -62,29 +59,31 @@ class CcShowInstances extends BaseCcShowInstances {
}
try {
$dt = new DateTime($this->ends, new DateTimeZone("UTC"));
$dt = new DateTime($this->ends, new DateTimeZone('UTC'));
} 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('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->ends, 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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($format);
}
/**
* Get the [optionally formatted] temporal [last_scheduled] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @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
*
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
*/
public function getDbLastScheduled($format = 'Y-m-d H:i:s')
{
@ -93,24 +92,25 @@ class CcShowInstances extends BaseCcShowInstances {
}
try {
$dt = new DateTime($this->last_scheduled, new DateTimeZone("UTC"));
$dt = new DateTime($this->last_scheduled, new DateTimeZone('UTC'));
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_scheduled, true), $x);
throw new PropelException('Internally stored date/time/timestamp value could not be converted to DateTime: ' . var_export($this->last_scheduled, 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);
}
if (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
}
return $dt->format($format);
}
//post save hook to update the cc_schedule status column for the tracks in the show.
public function updateScheduleStatus(PropelPDO $con) {
public function updateScheduleStatus(PropelPDO $con)
{
$this->updateDbTimeFilled($con);
//scheduled track is in the show
@ -118,7 +118,8 @@ class CcShowInstances extends BaseCcShowInstances {
->filterByDbInstanceId($this->id)
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
->filterByDbEnds($this->ends, Criteria::LESS_EQUAL)
->update(array('DbPlayoutStatus' => 1), $con);
->update(['DbPlayoutStatus' => 1], $con)
;
//scheduled track is a boundary track
CcScheduleQuery::create()
@ -126,24 +127,25 @@ class CcShowInstances extends BaseCcShowInstances {
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
->filterByDbStarts($this->ends, Criteria::LESS_THAN)
->filterByDbEnds($this->ends, Criteria::GREATER_THAN)
->update(array('DbPlayoutStatus' => 2), $con);
->update(['DbPlayoutStatus' => 2], $con)
;
//scheduled track is overbooked.
CcScheduleQuery::create()
->filterByDbInstanceId($this->id)
->filterByDbPlayoutStatus(0, Criteria::GREATER_EQUAL)
->filterByDbStarts($this->ends, Criteria::GREATER_THAN)
->update(array('DbPlayoutStatus' => 0), $con);
$this->setDbLastScheduled(gmdate("Y-m-d H:i:s"));
->update(['DbPlayoutStatus' => 0], $con)
;
$this->setDbLastScheduled(gmdate('Y-m-d H:i:s'));
$this->save($con);
}
/**
*
* This function resets the cc_schedule table's position numbers so that
* tracks for each cc_show_instances start at position 1
*
* tracks for each cc_show_instances start at position 1.
*
* The position numbers can become out of sync when the user deletes items
* from linekd shows filled with dyanmic smart blocks, where each instance
* has a different amount of scheduled items
@ -153,17 +155,18 @@ class CcShowInstances extends BaseCcShowInstances {
$schedule = CcScheduleQuery::create()
->filterByDbInstanceId($this->id)
->orderByDbStarts()
->find();
->find()
;
$pos = 0;
foreach ($schedule as $item) {
$item->setDbPosition($pos)->save();
$pos++;
++$pos;
}
}
/**
* Computes the value of the aggregate column time_filled
* Computes the value of the aggregate column time_filled.
*
* @param PropelPDO $con A connection object
*
@ -174,27 +177,30 @@ class CcShowInstances extends BaseCcShowInstances {
$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
* 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";
if (is_null($timefilled)) {
$timefilled = '00:00:00';
}
$this->setDbTimeFilled($timefilled);
$this->save($con);
}
public function preInsert(PropelPDO $con = null) {
$now = new DateTime("now", new DateTimeZone("UTC"));
public function preInsert(PropelPDO $con = null)
{
$now = new DateTime('now', new DateTimeZone('UTC'));
$this->setDbCreated($now);
return true;
}
@ -211,7 +217,7 @@ class CcShowInstances extends BaseCcShowInstances {
public function getLocalStartDateTime()
{
$startDT = $this->getDbStarts(null);
return $startDT->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone()));
}
} // CcShowInstances

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_instances' 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.airtime
*/
class CcShowInstancesPeer extends BaseCcShowInstancesPeer {
class CcShowInstancesPeer extends BaseCcShowInstancesPeer
{
} // CcShowInstancesPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_instances' 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.airtime
*/
class CcShowInstancesQuery extends BaseCcShowInstancesQuery {
class CcShowInstancesQuery extends BaseCcShowInstancesQuery
{
} // CcShowInstancesQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show' 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.airtime
*/
class CcShowPeer extends BaseCcShowPeer {
class CcShowPeer extends BaseCcShowPeer
{
} // CcShowPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show' 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.airtime
*/
class CcShowQuery extends BaseCcShowQuery {
class CcShowQuery extends BaseCcShowQuery
{
} // CcShowQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_rebroadcast' 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.airtime
*/
class CcShowRebroadcast extends BaseCcShowRebroadcast {
class CcShowRebroadcast extends BaseCcShowRebroadcast
{
} // CcShowRebroadcast

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_rebroadcast' 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.airtime
*/
class CcShowRebroadcastPeer extends BaseCcShowRebroadcastPeer {
class CcShowRebroadcastPeer extends BaseCcShowRebroadcastPeer
{
} // CcShowRebroadcastPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_rebroadcast' 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.airtime
*/
class CcShowRebroadcastQuery extends BaseCcShowRebroadcastQuery {
class CcShowRebroadcastQuery extends BaseCcShowRebroadcastQuery
{
} // CcShowRebroadcastQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_show_schedule' 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.airtime
*/
class CcShowSchedule extends BaseCcShowSchedule {
class CcShowSchedule extends BaseCcShowSchedule
{
} // CcShowSchedule

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_schedule' 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.airtime
*/
class CcShowSchedulePeer extends BaseCcShowSchedulePeer {
class CcShowSchedulePeer extends BaseCcShowSchedulePeer
{
} // CcShowSchedulePeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_show_schedule' 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.airtime
*/
class CcShowScheduleQuery extends BaseCcShowScheduleQuery {
class CcShowScheduleQuery extends BaseCcShowScheduleQuery
{
} // CcShowScheduleQuery

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_stream_setting' 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.airtime
*/
class CcStreamSetting extends BaseCcStreamSetting {
class CcStreamSetting extends BaseCcStreamSetting
{
} // CcStreamSetting

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_stream_setting' 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.airtime
*/
class CcStreamSettingPeer extends BaseCcStreamSettingPeer {
class CcStreamSettingPeer extends BaseCcStreamSettingPeer
{
} // CcStreamSettingPeer

View file

@ -1,18 +1,12 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_stream_setting' 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.airtime
*/
class CcStreamSettingQuery extends BaseCcStreamSettingQuery {
class CcStreamSettingQuery extends BaseCcStreamSettingQuery
{
} // CcStreamSettingQuery

View file

@ -3,16 +3,12 @@
/**
* Skeleton subclass for representing a row from the 'cc_subjs' 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.airtime
*/
class CcSubjs extends BaseCcSubjs {
class CcSubjs extends BaseCcSubjs
{
public function isAdminOrPM()
{
return $this->type === UTYPE_SUPERADMIN || $this->type === UTYPE_ADMIN || $this->type === UTYPE_PROGRAM_MANAGER;
@ -34,11 +30,12 @@ class CcSubjs extends BaseCcSubjs {
public function isHostOfShowInstance($instanceId)
{
$showInstance = CcShowInstancesQuery::create()
->findPk($instanceId);
->findPk($instanceId)
;
return CcShowHostsQuery::create()
->filterByDbShow($showInstance->getDbShowId())
->filterByDbHost($this->getDbId())
->count() > 0;
->filterByDbShow($showInstance->getDbShowId())
->filterByDbHost($this->getDbId())
->count() > 0;
}
} // CcSubjs

Some files were not shown because too many files have changed in this diff Show more