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
|
@ -254,11 +254,12 @@ EOT;
|
|||
public function getUnformatedLength()
|
||||
{
|
||||
$this->block->reload();
|
||||
if ($this->isStatic()){
|
||||
if ($this->isStatic()) {
|
||||
$length = $this->block->getDbLength();
|
||||
} else {
|
||||
$length = $this->getDynamicBlockLength();
|
||||
}
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
|
@ -266,7 +267,7 @@ EOT;
|
|||
{
|
||||
$this->block->reload();
|
||||
$prepend = "";
|
||||
if ($this->isStatic()){
|
||||
if ($this->isStatic()) {
|
||||
$length = $this->block->getDbLength();
|
||||
} else {
|
||||
$length = $this->getDynamicBlockLength();
|
||||
|
@ -276,6 +277,7 @@ EOT;
|
|||
}
|
||||
$formatter = new LengthFormatter($length);
|
||||
$length = $prepend.$formatter->format();
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
|
@ -292,7 +294,7 @@ EOT;
|
|||
$value = $value%60;
|
||||
|
||||
}
|
||||
} else if ($modifier == "hours") {
|
||||
} elseif ($modifier == "hours") {
|
||||
$mins = $value * 60;
|
||||
if ($mins >59) {
|
||||
$hour = intval($mins/60);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1180,7 +1193,7 @@ EOT;
|
|||
$spCriteriaExtra = substr($spCriteriaExtra, 0, 10);
|
||||
}
|
||||
}
|
||||
} else if ($spCriteria == "bit_rate" || $spCriteria == 'sample_rate') {
|
||||
} elseif ($spCriteria == "bit_rate" || $spCriteria == 'sample_rate') {
|
||||
// multiply 1000 because we store only number value
|
||||
// e.g 192kps is stored as 192000
|
||||
$spCriteriaValue = $criteria['value']*1000;
|
||||
|
@ -1193,7 +1206,7 @@ EOT;
|
|||
* user only sees the rounded version (i.e. 4:02.7 is 4:02.761625
|
||||
* in the database)
|
||||
*/
|
||||
} else if ($spCriteria == 'length' && $spCriteriaModifier == "is") {
|
||||
} elseif ($spCriteria == 'length' && $spCriteriaModifier == "is") {
|
||||
$spCriteriaModifier = "starts with";
|
||||
$spCriteria = $spCriteria.'::text';
|
||||
$spCriteriaValue = $criteria['value'];
|
||||
|
@ -1215,11 +1228,11 @@ EOT;
|
|||
|
||||
if ($spCriteriaModifier == "starts with") {
|
||||
$spCriteriaValue = "$spCriteriaValue%";
|
||||
} else if ($spCriteriaModifier == "ends with") {
|
||||
} elseif ($spCriteriaModifier == "ends with") {
|
||||
$spCriteriaValue = "%$spCriteriaValue";
|
||||
} else if ($spCriteriaModifier == "contains" || $spCriteriaModifier == "does not contain") {
|
||||
} elseif ($spCriteriaModifier == "contains" || $spCriteriaModifier == "does not contain") {
|
||||
$spCriteriaValue = "%$spCriteriaValue%";
|
||||
} else if ($spCriteriaModifier == "is in the range") {
|
||||
} elseif ($spCriteriaModifier == "is in the range") {
|
||||
$spCriteriaValue = "$spCriteria >= '$spCriteriaValue' AND $spCriteria <= '$spCriteriaExtra'";
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -1297,7 +1311,7 @@ EOT;
|
|||
if (in_array($fieldName, $fieldNames)) {
|
||||
$rowNum = intval(substr($ele['name'], $index+1));
|
||||
$output['criteria'][$critIndex][$lastChar][$fieldName] = trim($ele['value']);
|
||||
}else{
|
||||
} else {
|
||||
$output['etc'][$ele['name']] = $ele['value'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ class Application_Model_Datatables
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode(" AND ", $where);
|
||||
}
|
||||
/*
|
||||
|
@ -50,7 +51,7 @@ class Application_Model_Datatables
|
|||
if (strstr($key, "mDataProp_")) {
|
||||
list($dump, $index) = explode("_", $key);
|
||||
$current2dbname[$index] = $d;
|
||||
} else if (strstr($key, "sSearch_")) {
|
||||
} elseif (strstr($key, "sSearch_")) {
|
||||
list($dump, $index) = explode("_", $key);
|
||||
$orig2searchTerm[$index] = $d;
|
||||
}
|
||||
|
@ -158,7 +159,7 @@ class Application_Model_Datatables
|
|||
if ($r['ftype'] == 'playlist') {
|
||||
$pl = new Application_Model_Playlist($r['id']);
|
||||
$r['length'] = $pl->getLength();
|
||||
} else if ($r['ftype'] == "block") {
|
||||
} elseif ($r['ftype'] == "block") {
|
||||
$bl = new Application_Model_Block($r['id']);
|
||||
if ($bl->isStatic()) {
|
||||
$r['bl_type'] = 'static';
|
||||
|
|
|
@ -9,9 +9,9 @@ class Application_Model_Library
|
|||
|
||||
if (strcmp($p_type, 'playlist')==0) {
|
||||
$info['className'] = 'Application_Model_Playlist';
|
||||
} else if (strcmp($p_type, 'block')==0) {
|
||||
} elseif (strcmp($p_type, 'block')==0) {
|
||||
$info['className'] = 'Application_Model_Block';
|
||||
} else if (strcmp($p_type, 'stream')==0) {
|
||||
} elseif (strcmp($p_type, 'stream')==0) {
|
||||
$info['className'] = 'Application_Model_Webstream';
|
||||
} else {
|
||||
throw new Exception("Unknown object type: '$p_type'");
|
||||
|
|
|
@ -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,28 +287,31 @@ 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;
|
||||
}
|
||||
|
||||
//aggregate column on playlistcontents cliplength column.
|
||||
public function getLength()
|
||||
{
|
||||
if ($this->hasDynamicBlock()){
|
||||
if ($this->hasDynamicBlock()) {
|
||||
$ids = $this->getIdsOfDynamicBlocks();
|
||||
$length = $this->pl->getDbLength();
|
||||
foreach ($ids as $id){
|
||||
foreach ($ids as $id) {
|
||||
$bl = new Application_Model_Block($id['id']);
|
||||
if ($bl->hasItemLimit()) {
|
||||
return "N/A";
|
||||
}
|
||||
}
|
||||
$formatter = new LengthFormatter($length);
|
||||
|
||||
return "~".$formatter->format();
|
||||
} else {
|
||||
return $this->pl->getDbLength();
|
||||
|
@ -327,10 +331,10 @@ SQL;
|
|||
if ($info["ftype"] == "audioclip") {
|
||||
$row->setDbFileId($info["id"]);
|
||||
$type = 0;
|
||||
} else if ($info["ftype"] == "stream") {
|
||||
} elseif ($info["ftype"] == "stream") {
|
||||
$row->setDbStreamId($info["id"]);
|
||||
$type = 1;
|
||||
} else if ($info["ftype"] == "block") {
|
||||
} elseif ($info["ftype"] == "block") {
|
||||
$row->setDbBlockId($info["id"]);
|
||||
$type = 2;
|
||||
}
|
||||
|
@ -352,9 +356,9 @@ SQL;
|
|||
$objId = $p_item[0];
|
||||
if ($objType == 'audioclip') {
|
||||
$obj = CcFilesQuery::create()->findPK($objId, $this->con);
|
||||
} else if ($objType == "stream") {
|
||||
} elseif ($objType == "stream") {
|
||||
$obj = CcWebstreamQuery::create()->findPK($objId, $this->con);
|
||||
} else if ($objType == "block") {
|
||||
} elseif ($objType == "block") {
|
||||
$obj = CcBlockQuery::create()->findPK($objId, $this->con);
|
||||
} else {
|
||||
throw new Exception("Unknown file type");
|
||||
|
@ -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,8 +587,9 @@ SQL;
|
|||
#Propel returns values in form 00.000000 format which is for only seconds.
|
||||
$fadeIn = $row->getDbFadein();
|
||||
$fadeOut = $row->getDbFadeout();
|
||||
|
||||
return array($fadeIn, $fadeOut);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change fadeIn and fadeOut values for playlist Element
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -671,7 +671,7 @@ SQL;
|
|||
$uri = $storedFile->getFilePath();
|
||||
$type = "file";
|
||||
$independent_event = false;
|
||||
} else if (!is_null($item['stream_id'])) {
|
||||
} elseif (!is_null($item['stream_id'])) {
|
||||
//row is type "webstream"
|
||||
$media_id = $item['stream_id'];
|
||||
$uri = $item['url'];
|
||||
|
@ -1098,6 +1098,7 @@ SQL;
|
|||
public static function GetFileId($p_scheduleId)
|
||||
{
|
||||
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
|
||||
|
||||
return $scheduledItem->getDbFileId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,12 +146,12 @@ class Application_Model_Scheduler
|
|||
|
||||
$files[] = $data;
|
||||
}
|
||||
} else if ($type === "playlist") {
|
||||
} elseif ($type === "playlist") {
|
||||
$pl = new Application_Model_Playlist($id);
|
||||
$contents = $pl->getContents();
|
||||
|
||||
foreach ($contents as $plItem) {
|
||||
if ($plItem['type'] == 0){
|
||||
if ($plItem['type'] == 0) {
|
||||
$data["id"] = $plItem['item_id'];
|
||||
$data["cliplength"] = $plItem['length'];
|
||||
$data["cuein"] = $plItem['cuein'];
|
||||
|
@ -160,7 +160,7 @@ class Application_Model_Scheduler
|
|||
$data["fadeout"] = $plItem['fadeout'];
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
} else if ($plItem['type'] == 2) {
|
||||
} elseif ($plItem['type'] == 2) {
|
||||
// if it's a block
|
||||
$bl = new Application_Model_Block($plItem['item_id']);
|
||||
if ($bl->isStatic()) {
|
||||
|
@ -196,7 +196,7 @@ class Application_Model_Scheduler
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if ($type == "stream") {
|
||||
} elseif ($type == "stream") {
|
||||
//need to return
|
||||
$stream = CcWebstreamQuery::create()->findPK($id, $this->con);
|
||||
|
||||
|
@ -218,7 +218,7 @@ class Application_Model_Scheduler
|
|||
|
||||
$files[] = $data;
|
||||
}
|
||||
} else if ($type == "block") {
|
||||
} elseif ($type == "block") {
|
||||
$bl = new Application_Model_Block($id);
|
||||
if ($bl->isStatic()) {
|
||||
foreach ($bl->getContents() as $track) {
|
||||
|
@ -252,6 +252,7 @@ class Application_Model_Scheduler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
|
@ -426,7 +427,7 @@ class Application_Model_Scheduler
|
|||
->setDbClipLength($file['cliplength'])
|
||||
->setDbInstanceId($instance->getDbId());
|
||||
|
||||
switch ($file["type"]){
|
||||
switch ($file["type"]) {
|
||||
case 0:
|
||||
$sched->setDbFileId($file['id']);
|
||||
break;
|
||||
|
|
|
@ -6,12 +6,13 @@ class Application_Model_ServiceRegister
|
|||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
//check ip from share internet
|
||||
$ip=$_SERVER['HTTP_CLIENT_IP'];
|
||||
} else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
//to check ip is pass from proxy
|
||||
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ class Application_Model_StoredFile
|
|||
} else {
|
||||
$owner = $this->_file->getFkOwner();
|
||||
// if owner_id is already set we don't want to set it again.
|
||||
if(!$owner) { // no owner detected, we try to assign one.
|
||||
if (!$owner) { // no owner detected, we try to assign one.
|
||||
// if MDATA_OWNER_ID is not set then we default to the
|
||||
// first admin user we find
|
||||
if (!array_key_exists('owner_id', $p_md)) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -492,7 +492,7 @@ class Application_Model_StoredFile
|
|||
public static function Insert($md)
|
||||
{
|
||||
// save some work by checking if filepath is given right away
|
||||
if( !isset($md['MDATA_KEY_FILEPATH']) ) {
|
||||
if ( !isset($md['MDATA_KEY_FILEPATH']) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -515,6 +515,7 @@ class Application_Model_StoredFile
|
|||
return null;
|
||||
}
|
||||
$storedFile->setMetadata($md);
|
||||
|
||||
return $storedFile;
|
||||
}
|
||||
|
||||
|
@ -682,7 +683,7 @@ class Application_Model_StoredFile
|
|||
$blSelect[] = "NULL::int AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
$streamSelect[] = "NULL::int AS ".$key;
|
||||
} else if ($key === "filepath") {
|
||||
} elseif ($key === "filepath") {
|
||||
$plSelect[] = "NULL::VARCHAR AS ".$key;
|
||||
$blSelect[] = "NULL::VARCHAR AS ".$key;
|
||||
$fileSelect[] = $key;
|
||||
|
@ -768,12 +769,12 @@ class Application_Model_StoredFile
|
|||
if ($type == "au") {
|
||||
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
|
||||
$row['image'] = '<img title="Track preview" src="/css/images/icon_audioclip.png">';
|
||||
} else if ($type == "pl") {
|
||||
} elseif ($type == "pl") {
|
||||
$row['image'] = '<img title="Playlist preview" src="/css/images/icon_playlist.png">';
|
||||
} else if ($type == "st") {
|
||||
} elseif ($type == "st") {
|
||||
$row['audioFile'] = $row['id'];
|
||||
$row['image'] = '<img title="Webstream preview" src="/css/images/record_icon.png">';
|
||||
} else if ($type == "bl") {
|
||||
} elseif ($type == "bl") {
|
||||
$row['image'] = '<img title="Smart Block" src="/css/images/delete.png">';
|
||||
}
|
||||
}
|
||||
|
@ -915,8 +916,9 @@ class Application_Model_StoredFile
|
|||
}
|
||||
|
||||
// Check if we have enough space before copying
|
||||
if(!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
|
||||
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
|
||||
|
@ -924,7 +926,7 @@ class Application_Model_StoredFile
|
|||
}
|
||||
|
||||
// Check if liquidsoap can play this file
|
||||
if(!self::liquidsoapFilePlayabilityTest($audio_file)) {
|
||||
if (!self::liquidsoapFilePlayabilityTest($audio_file)) {
|
||||
return array(
|
||||
"code" => 110,
|
||||
"message" => "This file appears to be corrupted and will not
|
||||
|
@ -941,7 +943,7 @@ class Application_Model_StoredFile
|
|||
$uid = $user->getId();
|
||||
}
|
||||
$id_file = "$audio_stor.identifier";
|
||||
if (file_put_contents($id_file,$uid) === false) {
|
||||
if (file_put_contents($id_file,$uid) === false) {
|
||||
Logging::info("Could not write file to identify user: '$uid'");
|
||||
Logging::info("Id file path: '$id_file'");
|
||||
Logging::info("Defaulting to admin (no identification file was
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -117,15 +121,13 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
if ($result == 1 && count($matches) == 2) {
|
||||
$hours = $matches[1];
|
||||
$minutes = 0;
|
||||
} else if ($result == 1 && count($matches) == 3) {
|
||||
} elseif ($result == 1 && count($matches) == 3) {
|
||||
$hours = $matches[1];
|
||||
$minutes = $matches[2];
|
||||
} else {
|
||||
$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)
|
||||
|
@ -286,9 +283,9 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
|
||||
if (preg_match("/x-mpegurl/", $mime)) {
|
||||
$media_url = self::getM3uUrl($url);
|
||||
} else if (preg_match("/xspf\+xml/", $mime)) {
|
||||
} elseif (preg_match("/xspf\+xml/", $mime)) {
|
||||
$media_url = self::getXspfUrl($url);
|
||||
} else if (preg_match("/(mpeg|ogg)/", $mime)) {
|
||||
} elseif (preg_match("/(mpeg|ogg)/", $mime)) {
|
||||
if ($content_length_found) {
|
||||
throw new Exception("Invalid webstream - This appears to be a file download.");
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ class BitrateFormatter {
|
|||
{
|
||||
$Kbps = bcdiv($this->_bitrate, 1000, 0);
|
||||
|
||||
if($Kbps == 0) {
|
||||
if ($Kbps == 0) {
|
||||
return "";
|
||||
} else {
|
||||
return "{$Kbps} Kbps";
|
||||
|
|
|
@ -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