CC-4090: Make code style PSR compliant - part 4
-models dir
This commit is contained in:
parent
699a49a103
commit
4848717d4d
17 changed files with 439 additions and 404 deletions
|
@ -259,6 +259,7 @@ EOT;
|
|||
} else {
|
||||
$length = $this->getDynamicBlockLength();
|
||||
}
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
|
@ -276,6 +277,7 @@ EOT;
|
|||
}
|
||||
$formatter = new LengthFormatter($length);
|
||||
$length = $prepend.$formatter->format();
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
|
@ -304,6 +306,7 @@ EOT;
|
|||
$value = str_pad($value, 2, "0", STR_PAD_LEFT);
|
||||
$length = $hour.":".$value.":00";
|
||||
}
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
|
@ -313,14 +316,17 @@ EOT;
|
|||
->filterByDbCriteria('limit')->findOne();
|
||||
$modifier = $result->getDbModifier();
|
||||
$value = $result->getDbValue();
|
||||
|
||||
return array($value, $modifier);
|
||||
}
|
||||
|
||||
// this function returns sum of all track length under this block.
|
||||
public function getStaticLength(){
|
||||
public function getStaticLength()
|
||||
{
|
||||
$sql = "SELECT SUM(cliplength) as length FROM cc_blockcontents WHERE block_id={$this->id}";
|
||||
$r = $this->con->query($sql);
|
||||
$result = $r->fetchAll(PDO::FETCH_NUM);
|
||||
|
||||
return $result[0][0];
|
||||
}
|
||||
|
||||
|
@ -363,7 +369,8 @@ EOT;
|
|||
}
|
||||
}
|
||||
|
||||
public function isStatic(){
|
||||
public function isStatic()
|
||||
{
|
||||
if ($this->block->getDbType() == "static") {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -592,6 +599,7 @@ EOT;
|
|||
#Propel returns values in form 00.000000 format which is for only seconds.
|
||||
$fadeIn = $row->getDbFadein();
|
||||
$fadeOut = $row->getDbFadeout();
|
||||
|
||||
return array($fadeIn, $fadeOut);
|
||||
}
|
||||
|
||||
|
@ -914,6 +922,7 @@ EOT;
|
|||
}
|
||||
|
||||
$leftOvers = array_diff($selectedPls, $ownedPls);
|
||||
|
||||
return $leftOvers;
|
||||
}
|
||||
|
||||
|
@ -927,7 +936,8 @@ EOT;
|
|||
}
|
||||
|
||||
// smart block functions start
|
||||
public function shuffleSmartBlock(){
|
||||
public function shuffleSmartBlock()
|
||||
{
|
||||
// if it here that means it's static pl
|
||||
$this->saveType("static");
|
||||
$contents = CcBlockcontentsQuery::create()
|
||||
|
@ -940,6 +950,7 @@ EOT;
|
|||
$item->setDbPosition(array_shift($shuffledPos));
|
||||
$item->save();
|
||||
}
|
||||
|
||||
return array("result"=>0);
|
||||
}
|
||||
|
||||
|
@ -1045,6 +1056,7 @@ EOT;
|
|||
$this->addAudioClips(array_keys($insertList));
|
||||
// update length in playlist contents.
|
||||
$this->updateBlockLengthInAllPlaylist();
|
||||
|
||||
return array("result"=>0);
|
||||
}
|
||||
|
||||
|
@ -1091,6 +1103,7 @@ EOT;
|
|||
|
||||
$iterator->next();
|
||||
}
|
||||
|
||||
return $insertList;
|
||||
}
|
||||
|
||||
|
@ -1254,6 +1267,7 @@ EOT;
|
|||
}
|
||||
try {
|
||||
$out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
|
||||
|
||||
return array("files"=>$out, "limit"=>$limits, "count"=>$out->count());
|
||||
} catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
|
|
|
@ -33,6 +33,7 @@ class Application_Model_Datatables
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode(" AND ", $where);
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -277,7 +277,8 @@ SQL;
|
|||
}
|
||||
|
||||
// returns true/false and ids of dynamic blocks
|
||||
public function hasDynamicBlock(){
|
||||
public function hasDynamicBlock()
|
||||
{
|
||||
$ids = $this->getIdsOfDynamicBlocks();
|
||||
if (count($ids) > 0) {
|
||||
return true;
|
||||
|
@ -286,12 +287,14 @@ SQL;
|
|||
}
|
||||
}
|
||||
|
||||
public function getIdsOfDynamicBlocks() {
|
||||
public function getIdsOfDynamicBlocks()
|
||||
{
|
||||
$sql = "SELECT bl.id FROM cc_playlistcontents as pc
|
||||
JOIN cc_block as bl ON pc.type=2 AND pc.block_id=bl.id AND bl.type='dynamic'
|
||||
WHERE playlist_id={$this->id} AND pc.type=2";
|
||||
$r = $this->con->query($sql);
|
||||
$result = $r->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -308,6 +311,7 @@ SQL;
|
|||
}
|
||||
}
|
||||
$formatter = new LengthFormatter($length);
|
||||
|
||||
return "~".$formatter->format();
|
||||
} else {
|
||||
return $this->pl->getDbLength();
|
||||
|
@ -369,6 +373,7 @@ SQL;
|
|||
$entry["cueout"] = $obj->getDbLength();
|
||||
$entry["ftype"] = $objType;
|
||||
}
|
||||
|
||||
return $entry;
|
||||
} else {
|
||||
throw new Exception("trying to add a object that does not exist.");
|
||||
|
@ -582,6 +587,7 @@ SQL;
|
|||
#Propel returns values in form 00.000000 format which is for only seconds.
|
||||
$fadeIn = $row->getDbFadein();
|
||||
$fadeOut = $row->getDbFadeout();
|
||||
|
||||
return array($fadeIn, $fadeOut);
|
||||
}
|
||||
|
||||
|
@ -891,7 +897,8 @@ SQL;
|
|||
}
|
||||
|
||||
// This function returns that are not owen by $p_user_id among $p_ids
|
||||
private static function playlistsNotOwnedByUser($p_ids, $p_userId){
|
||||
private static function playlistsNotOwnedByUser($p_ids, $p_userId)
|
||||
{
|
||||
$ownedByUser = CcPlaylistQuery::create()->filterByDbCreatorId($p_userId)->find()->getData();
|
||||
$selectedPls = $p_ids;
|
||||
$ownedPls = array();
|
||||
|
@ -902,6 +909,7 @@ SQL;
|
|||
}
|
||||
|
||||
$leftOvers = array_diff($selectedPls, $ownedPls);
|
||||
|
||||
return $leftOvers;
|
||||
}
|
||||
|
||||
|
|
|
@ -1110,7 +1110,8 @@ class Application_Model_Preference
|
|||
}
|
||||
}
|
||||
|
||||
public static function getCurrentLibraryTableSetting(){
|
||||
public static function getCurrentLibraryTableSetting()
|
||||
{
|
||||
return unserialize(self::getValue("library_datatable"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ class Application_Model_Schedule
|
|||
if (!is_int($p_prev) || !is_int($p_next)) {
|
||||
//must enter integers to specify ranges
|
||||
Logging::info("Invalid range parameters: $p_prev or $p_next");
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,6 @@ class Application_Model_Schedule
|
|||
$rows[$i]['ends'] = $rows[$i]["show_ends"];
|
||||
}
|
||||
|
||||
|
||||
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)) {
|
||||
if ($i - 1 >= 0) {
|
||||
$results['previous'] = array("name"=>$rows[$i-1]["artist_name"]." - ".$rows[$i-1]["track_title"],
|
||||
|
@ -192,7 +192,6 @@ class Application_Model_Schedule
|
|||
return $row;
|
||||
}
|
||||
|
||||
|
||||
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
@ -348,6 +347,7 @@ ORDER BY si_starts,
|
|||
SQL;
|
||||
|
||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
@ -1098,6 +1098,7 @@ SQL;
|
|||
public static function GetFileId($p_scheduleId)
|
||||
{
|
||||
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
|
||||
|
||||
return $scheduledItem->getDbFileId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,6 +252,7 @@ class Application_Model_Scheduler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ class Application_Model_ServiceRegister
|
|||
} else {
|
||||
$ip=$_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
|
|
|
@ -1583,6 +1583,7 @@ class Application_Model_Show
|
|||
}
|
||||
|
||||
$result = $con->query($sql)->fetchAll();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -1806,6 +1807,7 @@ class Application_Model_Show
|
|||
|
||||
// Convert back to local timezone
|
||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
@ -1949,6 +1951,7 @@ class Application_Model_Show
|
|||
}
|
||||
|
||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
|
|
@ -172,8 +172,7 @@ class Application_Model_StoredFile
|
|||
}
|
||||
if ($owner) {
|
||||
$this->_file->setDbOwnerId( $owner->getDbId() );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Logging::info("Could not find suitable owner for file
|
||||
'".$p_md['MDATA_KEY_FILEPATH']."'");
|
||||
}
|
||||
|
@ -415,6 +414,7 @@ class Application_Model_StoredFile
|
|||
_file->getDbDirectory());
|
||||
$directory = $music_dir->getDirectory();
|
||||
$filepath = $this->_file->getDbFilepath();
|
||||
|
||||
return Application_Common_OsPath::join($directory, $filepath);
|
||||
}
|
||||
|
||||
|
@ -515,6 +515,7 @@ class Application_Model_StoredFile
|
|||
return null;
|
||||
}
|
||||
$storedFile->setMetadata($md);
|
||||
|
||||
return $storedFile;
|
||||
}
|
||||
|
||||
|
@ -917,6 +918,7 @@ class Application_Model_StoredFile
|
|||
// Check if we have enough space before copying
|
||||
if (!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
|
||||
$freeSpace = disk_free_space($stor);
|
||||
|
||||
return array("code" => 107,
|
||||
"message" => "The file was not uploaded, there is
|
||||
".$freeSpace."MB of disk space left and the file you are
|
||||
|
@ -958,6 +960,7 @@ class Application_Model_StoredFile
|
|||
//warn the user that the file wasn't uploaded and they should check if there is enough disk space.
|
||||
unlink($audio_file); //remove the file after failed rename
|
||||
unlink($id_file); // Also remove the identifier file
|
||||
|
||||
return array(
|
||||
"code" => 108,
|
||||
"message" => "
|
||||
|
@ -1046,6 +1049,7 @@ class Application_Model_StoredFile
|
|||
}
|
||||
|
||||
$rows = $con->query($sql, PDO::FETCH_ASSOC)->fetchAll();
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class Application_Model_User
|
|||
public function isHostOfShow($showId)
|
||||
{
|
||||
$userId = $this->_userInstance->getDbId();
|
||||
|
||||
return CcShowHostsQuery::create()
|
||||
->filterByDbShow($showId)
|
||||
->filterByDbHost($userId)->count() > 0;
|
||||
|
@ -238,15 +239,19 @@ class Application_Model_User
|
|||
return $user;
|
||||
}
|
||||
|
||||
public static function getUsersOfType($type) {
|
||||
public static function getUsersOfType($type)
|
||||
{
|
||||
return CcSubjsQuery::create()->filterByDbType($type)->find();
|
||||
}
|
||||
public static function getFirstAdminId() {
|
||||
public static function getFirstAdminId()
|
||||
{
|
||||
$admins = Application_Model_User::getUsersOfType('A');
|
||||
if (count($admins) > 0) { // found admin => pick first one
|
||||
|
||||
return $admins[0]->getDbId();
|
||||
} else {
|
||||
Logging::warn("Warning. no admins found in database");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -360,6 +365,7 @@ class Application_Model_User
|
|||
//we get here if $userinfo->id is defined, but doesn't exist
|
||||
//in the database anymore.
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,10 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
if (count($arr) == 3) {
|
||||
list($hours, $min, $sec) = $arr;
|
||||
$di = new DateInterval("PT{$hours}H{$min}M{$sec}S");
|
||||
|
||||
return $di->format("%Hh %Im");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -69,6 +71,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
$subjs = CcSubjsQuery::create()->findPK($this->webstream->getDbCreatorId());
|
||||
|
||||
$username = $subjs->getDbLogin();
|
||||
|
||||
return array(
|
||||
"name" => $this->webstream->getDbName(),
|
||||
"length" => $this->webstream->getDbLength(),
|
||||
|
@ -100,6 +103,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
}
|
||||
|
||||
$leftOvers = array_diff($p_ids, $ownedStreams);
|
||||
|
||||
return $leftOvers;
|
||||
}
|
||||
|
||||
|
@ -124,8 +128,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
$invalid_date_interval = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!$invalid_date_interval) {
|
||||
|
||||
//Due to the way our Regular Expression is set up, we could have $minutes or $hours
|
||||
|
@ -137,14 +139,12 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
$minutes = 0;
|
||||
}
|
||||
|
||||
|
||||
//minutes cannot be over 59. Need to convert anything > 59 minutes into hours.
|
||||
$hours += intval($minutes/60);
|
||||
$minutes = $minutes%60;
|
||||
|
||||
$di = new DateInterval("PT{$hours}H{$minutes}M");
|
||||
|
||||
|
||||
$totalMinutes = $di->h * 60 + $di->i;
|
||||
|
||||
if ($totalMinutes == 0) {
|
||||
|
@ -157,7 +157,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
$valid['length'][1] = 'Length should be of form "00h 00m"';
|
||||
}
|
||||
|
||||
|
||||
$url = $parameters["url"];
|
||||
//simple validator that checks to make sure that the url starts with
|
||||
//http(s),
|
||||
|
@ -215,11 +214,9 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
|
||||
}
|
||||
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static function getXspfUrl($url)
|
||||
|
@ -319,7 +316,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return array($mime, $content_length_found);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class BitrateFormatter {
|
||||
|
||||
class BitrateFormatter
|
||||
{
|
||||
/**
|
||||
* @string length
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class LengthFormatter {
|
||||
|
||||
class LengthFormatter
|
||||
{
|
||||
/**
|
||||
* @string length
|
||||
*/
|
||||
|
@ -15,7 +15,8 @@ class LengthFormatter {
|
|||
$this->_length = $length;
|
||||
}
|
||||
|
||||
public function format() {
|
||||
public function format()
|
||||
{
|
||||
if (!preg_match("/^[0-9]{2}:[0-9]{2}:[0-9]{2}/", $this->_length)) {
|
||||
return $this->_length;
|
||||
}
|
||||
|
@ -45,11 +46,9 @@ class LengthFormatter {
|
|||
|
||||
if (isset($hours) && isset($minutes) && isset($seconds)) {
|
||||
$time = sprintf("%d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr);
|
||||
}
|
||||
else if (isset($minutes) && isset($seconds)) {
|
||||
} elseif (isset($minutes) && isset($seconds)) {
|
||||
$time = sprintf("%d:%02d.%s", $minutes, $seconds, $milliStr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$time = sprintf("%d.%s", $seconds, $milliStr);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class SamplerateFormatter {
|
||||
|
||||
class SamplerateFormatter
|
||||
{
|
||||
/**
|
||||
* @string sample rate
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class TimeFilledFormatter {
|
||||
|
||||
class TimeFilledFormatter
|
||||
{
|
||||
/**
|
||||
* @string seconds
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue