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
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@ class Application_Model_Datatables
|
|||
} else {
|
||||
$input1 = $term;
|
||||
}
|
||||
|
||||
|
||||
if ($isRange) {
|
||||
$sub = array();
|
||||
if ($input1 != null) {
|
||||
|
@ -33,6 +33,7 @@ class Application_Model_Datatables
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode(" AND ", $where);
|
||||
}
|
||||
/*
|
||||
|
@ -41,7 +42,7 @@ class Application_Model_Datatables
|
|||
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
|
||||
{
|
||||
$librarySetting = Application_Model_Preference::getCurrentLibraryTableSetting();
|
||||
|
||||
|
||||
// map that maps original column position to db name
|
||||
$current2dbname = array();
|
||||
// array of search terms
|
||||
|
@ -50,22 +51,22 @@ class Application_Model_Datatables
|
|||
if (strstr($key, "mDataProp_")) {
|
||||
list($dump, $index) = explode("_", $key);
|
||||
$current2dbname[$index] = $d;
|
||||
} else if (strstr($key, "sSearch_")) {
|
||||
list($dump, $index) = explode("_", $key);
|
||||
} elseif (strstr($key, "sSearch_")) {
|
||||
list($dump, $index) = explode("_", $key);
|
||||
$orig2searchTerm[$index] = $d;
|
||||
}
|
||||
}
|
||||
// map that maps current column position to original position
|
||||
$current2orig = $librarySetting['ColReorder'];
|
||||
|
||||
|
||||
// map that maps dbname to searchTerm
|
||||
$dbname2searchTerm = array();
|
||||
foreach ($current2dbname as $currentPos=>$dbname) {
|
||||
$dbname2searchTerm[$dbname] = $orig2searchTerm[$current2orig[$currentPos]];
|
||||
}
|
||||
|
||||
|
||||
$where = array();
|
||||
|
||||
|
||||
$advancedWhere = self::buildWhereClauseForAdvancedSearch($dbname2searchTerm);
|
||||
if ($advancedWhere != "") {
|
||||
$where[] = $advancedWhere;
|
||||
|
@ -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';
|
||||
|
|
|
@ -26,7 +26,7 @@ class Application_Model_Email
|
|||
if ($mailServerRequiresAuth) {
|
||||
$username = Application_Model_Preference::GetMailServerEmailAddress();
|
||||
$password = Application_Model_Preference::GetMailServerPassword();
|
||||
|
||||
|
||||
$config = array(
|
||||
'auth' => 'login',
|
||||
'ssl' => 'ssl',
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
<?php
|
||||
|
||||
class Application_Model_Library
|
||||
class Application_Model_Library
|
||||
{
|
||||
|
||||
public static function getObjInfo($p_type)
|
||||
{
|
||||
$info = array();
|
||||
|
||||
|
||||
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'");
|
||||
}
|
||||
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ SQL;
|
|||
$clipSec = Application_Common_DateHelper::playlistTimeToSeconds($row['length']);
|
||||
$offset += $clipSec;
|
||||
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
|
||||
|
||||
|
||||
//format the length for UI.
|
||||
if ($row['type'] == 2) {
|
||||
$bl = new Application_Model_Block($row['item_id']);
|
||||
|
@ -235,15 +235,15 @@ SQL;
|
|||
$formatter = new LengthFormatter($row['length']);
|
||||
}
|
||||
$row['length'] = $formatter->format();
|
||||
|
||||
|
||||
$formatter = new LengthFormatter($offset_cliplength);
|
||||
$row['offset'] = $formatter->format();
|
||||
|
||||
|
||||
//format the fades in format 00(.000000)
|
||||
$fades = $this->getFadeInfo($row['position']);
|
||||
$row['fadein'] = $fades[0];
|
||||
$row['fadeout'] = $fades[1];
|
||||
|
||||
|
||||
//format original length
|
||||
$formatter = new LengthFormatter($row['orig_length']);
|
||||
$row['orig_length'] = $formatter->format();
|
||||
|
@ -261,7 +261,7 @@ SQL;
|
|||
{
|
||||
//First get rid of the first six characters 00:00: which will be added back later for db update
|
||||
$fade = substr($fade, 6);
|
||||
|
||||
|
||||
//Second add .000000 if the fade does't have milliseconds format already
|
||||
$dbFadeStrPos = strpos( $fade, '.' );
|
||||
if ($dbFadeStrPos === false) {
|
||||
|
@ -275,9 +275,10 @@ SQL;
|
|||
//done, just need to set back the formated values
|
||||
return $fade;
|
||||
}
|
||||
|
||||
|
||||
// returns true/false and ids of dynamic blocks
|
||||
public function hasDynamicBlock(){
|
||||
public function hasDynamicBlock()
|
||||
{
|
||||
$ids = $this->getIdsOfDynamicBlocks();
|
||||
if (count($ids) > 0) {
|
||||
return true;
|
||||
|
@ -285,29 +286,32 @@ SQL;
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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.");
|
||||
|
@ -430,7 +435,7 @@ SQL;
|
|||
|
||||
Logging::info("Adding to playlist");
|
||||
Logging::info("at position {$pos}");
|
||||
|
||||
|
||||
foreach ($p_items as $ac) {
|
||||
$res = $this->insertPlaylistElement($this->buildEntry($ac, $pos));
|
||||
$pos = $pos + 1;
|
||||
|
@ -575,15 +580,16 @@ SQL;
|
|||
->filterByDbPlaylistId($this->id)
|
||||
->filterByDbPosition($pos)
|
||||
->findOne();
|
||||
|
||||
|
||||
if (!$row) {
|
||||
return NULL;
|
||||
}
|
||||
#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
|
||||
|
@ -877,7 +883,7 @@ SQL;
|
|||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
|
||||
|
||||
if (!$isAdminOrPM) {
|
||||
$leftOver = self::playlistsNotOwnedByUser($p_ids, $p_userId);
|
||||
if (count($leftOver) == 0) {
|
||||
|
@ -889,9 +895,10 @@ SQL;
|
|||
CcPlaylistQuery::create()->findPKs($p_ids)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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();
|
||||
|
@ -900,11 +907,12 @@ SQL;
|
|||
$ownedPls[] = $pl->getDbId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$leftOvers = array_diff($selectedPls, $ownedPls);
|
||||
|
||||
return $leftOvers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all files from playlist
|
||||
* @param int $p_playlistId
|
||||
|
|
|
@ -1089,12 +1089,12 @@ class Application_Model_Preference
|
|||
{
|
||||
return self::getValue("mail_server_port");
|
||||
}
|
||||
|
||||
|
||||
public static function SetMailServerRequiresAuth($value)
|
||||
{
|
||||
self::setValue("mail_server_requires_auth", $value, false);
|
||||
}
|
||||
|
||||
|
||||
public static function GetMailServerRequiresAuth()
|
||||
{
|
||||
return self::getValue("mail_server_requires_auth");
|
||||
|
@ -1109,8 +1109,9 @@ class Application_Model_Preference
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -75,40 +76,40 @@ class Application_Model_Schedule
|
|||
|
||||
global $CC_CONFIG;
|
||||
$con = Propel::getConnection();
|
||||
$sql = "SELECT %%columns%% st.starts as starts, st.ends as ends,
|
||||
$sql = "SELECT %%columns%% st.starts as starts, st.ends as ends,
|
||||
st.media_item_played as media_item_played, si.ends as show_ends
|
||||
%%tables%% WHERE ";
|
||||
|
||||
|
||||
$fileColumns = "ft.artist_name, ft.track_title, ";
|
||||
$fileJoin = "FROM cc_schedule st JOIN cc_files ft ON st.file_id = ft.id
|
||||
LEFT JOIN cc_show_instances si ON st.instance_id = si.id";
|
||||
|
||||
|
||||
$streamColumns = "ws.name AS artist_name, wm.liquidsoap_data AS track_title, ";
|
||||
$streamJoin = "FROM cc_schedule AS st JOIN cc_webstream ws ON st.stream_id = ws.id
|
||||
LEFT JOIN cc_show_instances AS si ON st.instance_id = si.id
|
||||
LEFT JOIN cc_subjs AS sub on sub.id = ws.creator_id
|
||||
LEFT JOIN (SELECT * FROM cc_webstream_metadata ORDER BY start_time DESC LIMIT 1) AS wm on st.id = wm.instance_id";
|
||||
|
||||
$predicateArr = array();
|
||||
|
||||
$predicateArr = array();
|
||||
if (isset($p_previousShowID)) {
|
||||
$predicateArr[] = 'st.instance_id = '.$p_previousShowID;
|
||||
}
|
||||
}
|
||||
if (isset($p_currentShowID)) {
|
||||
$predicateArr[] = 'st.instance_id = '.$p_currentShowID;
|
||||
}
|
||||
}
|
||||
if (isset($p_nextShowID)) {
|
||||
$predicateArr[] = 'st.instance_id = '.$p_nextShowID;
|
||||
}
|
||||
|
||||
|
||||
$sql .= " (".implode(" OR ", $predicateArr).") ";
|
||||
$sql .= ' AND st.playout_status > 0 ORDER BY st.starts';
|
||||
|
||||
|
||||
$filesSql = str_replace("%%columns%%", $fileColumns, $sql);
|
||||
$filesSql = str_replace("%%tables%%", $fileJoin, $filesSql);
|
||||
|
||||
|
||||
$streamSql = str_replace("%%columns%%", $streamColumns, $sql);
|
||||
$streamSql = str_replace("%%tables%%", $streamJoin, $streamSql);
|
||||
|
||||
|
||||
$sql = "SELECT * FROM (($filesSql) UNION ($streamSql)) AS unioned ORDER BY starts";
|
||||
|
||||
$rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
@ -119,13 +120,12 @@ class Application_Model_Schedule
|
|||
$results['next'] = null;
|
||||
|
||||
$timeNowAsMillis = strtotime($p_timeNow);
|
||||
for ($i = 0; $i < $numberOfRows; ++$i) {
|
||||
for ($i = 0; $i < $numberOfRows; ++$i) {
|
||||
// if the show is overbooked, then update the track end time to the end of the show time.
|
||||
if ($rows[$i]['ends'] > $rows[$i]["show_ends"]) {
|
||||
$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"],
|
||||
|
@ -140,7 +140,7 @@ class Application_Model_Schedule
|
|||
"record"=>0,
|
||||
"type"=>'track');
|
||||
if (isset($rows[$i+1])) {
|
||||
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
||||
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
||||
"starts"=>$rows[$i+1]["starts"],
|
||||
"ends"=>$rows[$i+1]["ends"],
|
||||
"type"=>'track');
|
||||
|
@ -192,7 +192,6 @@ class Application_Model_Schedule
|
|||
return $row;
|
||||
}
|
||||
|
||||
|
||||
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
@ -266,7 +265,7 @@ SELECT DISTINCT sched.starts AS sched_starts,
|
|||
sched.fade_out AS fade_out,
|
||||
sched.playout_status AS playout_status,
|
||||
sched.instance_id AS sched_instance_id,
|
||||
|
||||
|
||||
%%columns%%
|
||||
FROM (%%join%%)
|
||||
SQL;
|
||||
|
@ -284,11 +283,11 @@ SQL;
|
|||
SQL;
|
||||
|
||||
|
||||
$filesSql = str_replace("%%columns%%",
|
||||
$filesColumns,
|
||||
$filesSql = str_replace("%%columns%%",
|
||||
$filesColumns,
|
||||
$templateSql);
|
||||
$filesSql= str_replace("%%join%%",
|
||||
$filesJoin,
|
||||
$filesSql= str_replace("%%join%%",
|
||||
$filesJoin,
|
||||
$filesSql);
|
||||
|
||||
$streamColumns = <<<SQL
|
||||
|
@ -304,11 +303,11 @@ SQL;
|
|||
LEFT JOIN cc_subjs AS sub ON (ws.creator_id = sub.id)
|
||||
SQL;
|
||||
|
||||
$streamSql = str_replace("%%columns%%",
|
||||
$streamColumns,
|
||||
$streamSql = str_replace("%%columns%%",
|
||||
$streamColumns,
|
||||
$templateSql);
|
||||
$streamSql = str_replace("%%join%%",
|
||||
$streamJoin,
|
||||
$streamSql = str_replace("%%join%%",
|
||||
$streamJoin,
|
||||
$streamSql);
|
||||
|
||||
|
||||
|
@ -332,7 +331,7 @@ SELECT showt.name AS show_name,
|
|||
si.last_scheduled AS si_last_scheduled,
|
||||
si.file_id AS si_file_id,
|
||||
*
|
||||
FROM (($filesSql) UNION ($streamSql)) as temp
|
||||
FROM (($filesSql) UNION ($streamSql)) as temp
|
||||
RIGHT JOIN cc_show_instances AS si ON (si.id = sched_instance_id)
|
||||
JOIN cc_show AS showt ON (showt.id = si.show_id)
|
||||
WHERE si.modified_instance = FALSE
|
||||
|
@ -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'];
|
||||
|
@ -720,7 +720,7 @@ SQL;
|
|||
//time of this event is the "end" time of the stream minus 1 second.
|
||||
$dt = new DateTime($item["end"], new DateTimeZone('UTC'));
|
||||
$dt->sub(new DateInterval("PT1S"));
|
||||
|
||||
|
||||
//make sure the webstream doesn't play past the end time of the show
|
||||
if ($dt->getTimestamp() > $showEndDateTime->getTimestamp()) {
|
||||
$dt = $showEndDateTime;
|
||||
|
@ -1094,10 +1094,11 @@ SQL;
|
|||
|
||||
return $overlapping;
|
||||
}
|
||||
|
||||
|
||||
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){
|
||||
|
||||
foreach ($contents as $plItem) {
|
||||
if ($plItem['type'] == 0) {
|
||||
$data["id"] = $plItem['item_id'];
|
||||
$data["cliplength"] = $plItem['length'];
|
||||
$data["cuein"] = $plItem['cuein'];
|
||||
|
@ -159,29 +159,29 @@ class Application_Model_Scheduler
|
|||
$data["fadein"] = $plItem['fadein'];
|
||||
$data["fadeout"] = $plItem['fadeout'];
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
} else if ($plItem['type'] == 2) {
|
||||
$files[] = $data;
|
||||
} elseif ($plItem['type'] == 2) {
|
||||
// if it's a block
|
||||
$bl = new Application_Model_Block($plItem['item_id']);
|
||||
if ($bl->isStatic()) {
|
||||
$bl = new Application_Model_Block($plItem['item_id']);
|
||||
if ($bl->isStatic()) {
|
||||
foreach ($bl->getContents() as $track) {
|
||||
$data["id"] = $track['item_id'];
|
||||
$data["cliplength"] = $track['length'];
|
||||
$data["cuein"] = $track['cuein'];
|
||||
$data["cueout"] = $track['cueout'];
|
||||
$data["fadein"] = $track['fadein'];
|
||||
$data["id"] = $track['item_id'];
|
||||
$data["cliplength"] = $track['length'];
|
||||
$data["cuein"] = $track['cuein'];
|
||||
$data["cueout"] = $track['cueout'];
|
||||
$data["fadein"] = $track['fadein'];
|
||||
$data["fadeout"] = $track['fadeout'];
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
}
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
}
|
||||
} else {
|
||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
||||
foreach ($dynamicFiles as $fileId=>$f) {
|
||||
$file = CcFilesQuery::create()->findPk($fileId);
|
||||
if (isset($file) && $file->getDbFileExists()) {
|
||||
$data["id"] = $file->getDbId();
|
||||
$data["cliplength"] = $file->getDbLength();
|
||||
$data["cuein"] = "00:00:00";
|
||||
if (isset($file) && $file->getDbFileExists()) {
|
||||
$data["id"] = $file->getDbId();
|
||||
$data["cliplength"] = $file->getDbLength();
|
||||
$data["cuein"] = "00:00:00";
|
||||
$data["cueout"] = $file->getDbLength();
|
||||
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
||||
if (isset($defaultFade)) {
|
||||
|
@ -190,13 +190,13 @@ class Application_Model_Scheduler
|
|||
$data["fadeout"] = $defaultFade;
|
||||
}
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
$files[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($type == "stream") {
|
||||
} elseif ($type == "stream") {
|
||||
//need to return
|
||||
$stream = CcWebstreamQuery::create()->findPK($id, $this->con);
|
||||
|
||||
|
@ -218,40 +218,41 @@ class Application_Model_Scheduler
|
|||
|
||||
$files[] = $data;
|
||||
}
|
||||
} else if ($type == "block") {
|
||||
$bl = new Application_Model_Block($id);
|
||||
if ($bl->isStatic()) {
|
||||
foreach ($bl->getContents() as $track) {
|
||||
$data["id"] = $track['item_id'];
|
||||
$data["cliplength"] = $track['length'];
|
||||
$data["cuein"] = $track['cuein'];
|
||||
$data["cueout"] = $track['cueout'];
|
||||
$data["fadein"] = $track['fadein'];
|
||||
$data["fadeout"] = $track['fadeout'];
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
}
|
||||
} else {
|
||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
||||
foreach ($dynamicFiles as $fileId=>$f) {
|
||||
$file = CcFilesQuery::create()->findPk($fileId);
|
||||
if (isset($file) && $file->getDbFileExists()) {
|
||||
$data["id"] = $file->getDbId();
|
||||
$data["cliplength"] = $file->getDbLength();
|
||||
$data["cuein"] = "00:00:00";
|
||||
$data["cueout"] = $file->getDbLength();
|
||||
} elseif ($type == "block") {
|
||||
$bl = new Application_Model_Block($id);
|
||||
if ($bl->isStatic()) {
|
||||
foreach ($bl->getContents() as $track) {
|
||||
$data["id"] = $track['item_id'];
|
||||
$data["cliplength"] = $track['length'];
|
||||
$data["cuein"] = $track['cuein'];
|
||||
$data["cueout"] = $track['cueout'];
|
||||
$data["fadein"] = $track['fadein'];
|
||||
$data["fadeout"] = $track['fadeout'];
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
}
|
||||
} else {
|
||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
||||
foreach ($dynamicFiles as $fileId=>$f) {
|
||||
$file = CcFilesQuery::create()->findPk($fileId);
|
||||
if (isset($file) && $file->getDbFileExists()) {
|
||||
$data["id"] = $file->getDbId();
|
||||
$data["cliplength"] = $file->getDbLength();
|
||||
$data["cuein"] = "00:00:00";
|
||||
$data["cueout"] = $file->getDbLength();
|
||||
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
||||
if (isset($defaultFade)) {
|
||||
//fade is in format SS.uuuuuu
|
||||
$data["fadein"] = $defaultFade;
|
||||
$data["fadeout"] = $defaultFade;
|
||||
}
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data["type"] = 0;
|
||||
$files[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
|
@ -425,8 +426,8 @@ class Application_Model_Scheduler
|
|||
->setDbFadeOut($file['fadeout'])
|
||||
->setDbClipLength($file['cliplength'])
|
||||
->setDbInstanceId($instance->getDbId());
|
||||
|
||||
switch ($file["type"]){
|
||||
|
||||
switch ($file["type"]) {
|
||||
case 0:
|
||||
$sched->setDbFileId($file['id']);
|
||||
break;
|
||||
|
@ -435,7 +436,7 @@ class Application_Model_Scheduler
|
|||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
$sched->save($this->con);
|
||||
|
||||
$nextStartDT = $endTimeDT;
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
<?php
|
||||
class Application_Model_ServiceRegister
|
||||
class Application_Model_ServiceRegister
|
||||
{
|
||||
public static function GetRemoteIpAddr()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -172,32 +172,32 @@ class Application_Model_Show
|
|||
if ($deltaDay > 0) {
|
||||
return "Shows can have a max length of 24 hours.";
|
||||
}
|
||||
|
||||
|
||||
$showInstances = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($this->_showId)
|
||||
->find($con);
|
||||
|
||||
|
||||
/* Check if the show being resized and any of its repeats
|
||||
* overlap with other scheduled shows
|
||||
*/
|
||||
foreach ($showInstances as $si) {
|
||||
$startsDateTime = new DateTime($si->getDbStarts(), new DateTimeZone("UTC"));
|
||||
$endsDateTime = new DateTime($si->getDbEnds(), new DateTimeZone("UTC"));
|
||||
|
||||
|
||||
/* The user is moving the show on the calendar from the perspective of local time.
|
||||
* incase a show is moved across a time change border offsets should be added to the local
|
||||
* timestamp and then converted back to UTC to avoid show time changes
|
||||
*/
|
||||
*/
|
||||
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
|
||||
$newStartsDateTime = Application_Model_ShowInstance::addDeltas($startsDateTime, $deltaDay, $deltaMin);
|
||||
$newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin);
|
||||
|
||||
|
||||
//convert our new starts/ends to UTC.
|
||||
$newStartsDateTime->setTimezone(new DateTimeZone("UTC"));
|
||||
$newEndsDateTime->setTimezone(new DateTimeZone("UTC"));
|
||||
|
||||
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows($newStartsDateTime,
|
||||
$newEndsDateTime, true, $si->getDbId());
|
||||
if ($overlapping) {
|
||||
|
@ -1583,6 +1583,7 @@ class Application_Model_Show
|
|||
}
|
||||
|
||||
$result = $con->query($sql)->fetchAll();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -1662,13 +1663,13 @@ class Application_Model_Show
|
|||
}
|
||||
$startsDT = DateTime::createFromFormat("Y-m-d G:i:s", $show["starts"], new DateTimeZone("UTC"));
|
||||
$endsDT = DateTime::createFromFormat("Y-m-d G:i:s", $show["ends"], new DateTimeZone("UTC"));
|
||||
|
||||
|
||||
$startsEpochStr = $startsDT->format("U");
|
||||
$endsEpochStr = $endsDT->format("U");
|
||||
|
||||
|
||||
$startsEpoch = intval($startsEpochStr);
|
||||
$endsEpoch = intval($endsEpochStr);
|
||||
|
||||
|
||||
$startsDT->setTimezone(new DateTimeZone($timezone));
|
||||
$endsDT->setTimezone(new DateTimeZone($timezone));
|
||||
|
||||
|
@ -1679,7 +1680,7 @@ class Application_Model_Show
|
|||
} elseif ($p_editable && $nowEpoch < $endsEpoch) {
|
||||
$options["editable"] = true;
|
||||
}
|
||||
|
||||
|
||||
$showInstance = new Application_Model_ShowInstance($show["instance_id"]);
|
||||
$showContent = $showInstance->getShowListContent();
|
||||
if (empty($showContent)) {
|
||||
|
@ -1687,7 +1688,7 @@ class Application_Model_Show
|
|||
} else {
|
||||
$options["show_empty"] = 0;
|
||||
}
|
||||
|
||||
|
||||
$events[] = &self::makeFullCalendarEvent($show, $options, $startsDT, $endsDT, $startsEpochStr, $endsEpochStr);
|
||||
}
|
||||
|
||||
|
@ -1727,15 +1728,15 @@ class Application_Model_Show
|
|||
if ($show["color"] != "") {
|
||||
$event["textColor"] = "#".$show["color"];
|
||||
}
|
||||
|
||||
|
||||
if ($show["background_color"] != "") {
|
||||
$event["color"] = "#".$show["background_color"];
|
||||
}
|
||||
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
$event[$key] = $value;
|
||||
}
|
||||
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class Application_Model_StoredFile
|
|||
{
|
||||
$this->_file->setDbFtype($p_format);
|
||||
}
|
||||
|
||||
|
||||
/* This function is only called after liquidsoap
|
||||
* has notified that a track has started playing.
|
||||
*/
|
||||
|
@ -83,7 +83,7 @@ class Application_Model_StoredFile
|
|||
{
|
||||
$this->_file->setDbLPtime($p_now);
|
||||
/* Normally we would only call save after all columns have been set
|
||||
* like in setDbColMetadata(). But since we are only setting one
|
||||
* like in setDbColMetadata(). But since we are only setting one
|
||||
* column in this case it is OK.
|
||||
*/
|
||||
$this->_file->save();
|
||||
|
@ -151,9 +151,9 @@ 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 MDATA_OWNER_ID is not set then we default to the
|
||||
// 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 MDATA_OWNER_ID is not set then we default to the
|
||||
// first admin user we find
|
||||
if (!array_key_exists('owner_id', $p_md)) {
|
||||
//$admins = Application_Model_User::getUsers(array('A'));
|
||||
|
@ -170,10 +170,9 @@ class Application_Model_StoredFile
|
|||
$owner = $user;
|
||||
}
|
||||
}
|
||||
if ($owner) {
|
||||
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,9 +492,9 @@ 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']) ) {
|
||||
return null;
|
||||
}
|
||||
if ( !isset($md['MDATA_KEY_FILEPATH']) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$file = new CcFiles();
|
||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||
|
@ -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;
|
||||
|
@ -745,7 +746,7 @@ class Application_Model_StoredFile
|
|||
$formatter = new BitrateFormatter($row['bit_rate']);
|
||||
$row['bit_rate'] = $formatter->format();
|
||||
}
|
||||
|
||||
|
||||
//convert mtime and utime to localtime
|
||||
$row['mtime'] = new DateTime($row['mtime'], new DateTimeZone('UTC'));
|
||||
$row['mtime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
@ -753,7 +754,7 @@ class Application_Model_StoredFile
|
|||
$row['utime'] = new DateTime($row['utime'], new DateTimeZone('UTC'));
|
||||
$row['utime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
||||
$row['utime'] = $row['utime']->format('Y-m-d H:i:s');
|
||||
|
||||
|
||||
// add checkbox row
|
||||
$row['checkbox'] = "<input type='checkbox' name='cb_".$row['id']."'>";
|
||||
|
||||
|
@ -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" => "
|
||||
|
@ -1044,8 +1047,9 @@ class Application_Model_StoredFile
|
|||
if (!is_null($limit) && is_int($limit)) {
|
||||
$sql .= " LIMIT $limit";
|
||||
}
|
||||
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
throw new Exception();
|
||||
}
|
||||
} else {
|
||||
$this->webstream = $webstream;
|
||||
$this->webstream = $webstream;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -87,7 +90,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
throw new Exception("Invalid user permissions");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This function returns that are not owen by $p_user_id among $p_ids
|
||||
private static function streamsNotOwnedByUser($p_ids, $p_userId)
|
||||
{
|
||||
|
@ -98,14 +101,15 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
$ownedStreams[] = $pl->getDbId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$leftOvers = array_diff($p_ids, $ownedStreams);
|
||||
|
||||
return $leftOvers;
|
||||
}
|
||||
|
||||
public static function analyzeFormData($parameters)
|
||||
{
|
||||
$valid = array("length" => array(true, ''),
|
||||
$valid = array("length" => array(true, ''),
|
||||
"url" => array(true, ''),
|
||||
"name" => array(true, ''));
|
||||
|
||||
|
@ -117,16 +121,14 @@ 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) {
|
||||
if (!$invalid_date_interval) {
|
||||
|
||||
//Due to the way our Regular Expression is set up, we could have $minutes or $hours
|
||||
//not set. Do simple test here
|
||||
|
@ -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,9 +157,8 @@ 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
|
||||
//simple validator that checks to make sure that the url starts with
|
||||
//http(s),
|
||||
//and that the domain is at least 1 letter long
|
||||
$result = preg_match("/^(http|https):\/\/.+/", $url, $matches);
|
||||
|
@ -196,7 +195,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
|
||||
$id = $parameters["id"];
|
||||
|
||||
return array($valid, $mime, $mediaUrl, $di);
|
||||
return array($valid, $mime, $mediaUrl, $di);
|
||||
}
|
||||
|
||||
public static function isValid($analysis)
|
||||
|
@ -210,16 +209,14 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
return true;
|
||||
}
|
||||
|
||||
public function setMetadata($key, $val)
|
||||
public function setMetadata($key, $val)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setName($name)
|
||||
public function setName($name)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static function getXspfUrl($url)
|
||||
|
@ -270,7 +267,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
$delim = "\n";
|
||||
if (strpos($content, "\r\n") !== false) {
|
||||
$delim = "\r\n";
|
||||
}
|
||||
}
|
||||
$lines = explode("$delim", $content);
|
||||
#$lines = preg_split('/$\R?^/m', $content);
|
||||
|
||||
|
@ -282,23 +279,23 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
}
|
||||
|
||||
private static function getMediaUrl($url, $mime, $content_length_found)
|
||||
{
|
||||
{
|
||||
|
||||
if (preg_match("/x-mpegurl/", $mime)) {
|
||||
$media_url = self::getM3uUrl($url);
|
||||
} else if (preg_match("/xspf\+xml/", $mime)) {
|
||||
$media_url = self::getXspfUrl($url);
|
||||
} else if (preg_match("/(mpeg|ogg)/", $mime)) {
|
||||
$media_url = self::getM3uUrl($url);
|
||||
} elseif (preg_match("/xspf\+xml/", $mime)) {
|
||||
$media_url = self::getXspfUrl($url);
|
||||
} elseif (preg_match("/(mpeg|ogg)/", $mime)) {
|
||||
if ($content_length_found) {
|
||||
throw new Exception("Invalid webstream - This appears to be a file download.");
|
||||
}
|
||||
}
|
||||
$media_url = $url;
|
||||
} else {
|
||||
throw new Exception("Unrecognized stream type: $mime");
|
||||
}
|
||||
|
||||
return $media_url;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static function discoverStreamMime($url)
|
||||
|
@ -315,11 +312,10 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
if (preg_match("/^content-length:/i", $h)) {
|
||||
$content_length_found = true;
|
||||
//if content-length appears, this is not a web stream!!!!
|
||||
//Aborting the save process.
|
||||
//Aborting the save process.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return array($mime, $content_length_found);
|
||||
}
|
||||
|
||||
|
@ -338,14 +334,14 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
|
|||
$webstream->setDbDescription($parameters["description"]);
|
||||
$webstream->setDbUrl($mediaUrl);
|
||||
|
||||
$dblength = $di->format("%H:%I");
|
||||
$dblength = $di->format("%H:%I");
|
||||
$webstream->setDbLength($dblength);
|
||||
$webstream->setDbCreatorId($userInfo->id);
|
||||
$webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC')));
|
||||
$webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC')));
|
||||
|
||||
$ws = new Application_Model_Webstream($webstream);
|
||||
|
||||
|
||||
$webstream->setDbMime($mime);
|
||||
$webstream->save();
|
||||
|
||||
|
|
|
@ -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,15 +46,13 @@ 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);
|
||||
}
|
||||
|
||||
return $time;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class SamplerateFormatter {
|
||||
|
||||
class SamplerateFormatter
|
||||
{
|
||||
/**
|
||||
* @string sample rate
|
||||
*/
|
||||
|
@ -21,4 +21,4 @@ class SamplerateFormatter {
|
|||
|
||||
return "{$kHz} kHz";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class TimeFilledFormatter {
|
||||
|
||||
class TimeFilledFormatter
|
||||
{
|
||||
/**
|
||||
* @string seconds
|
||||
*/
|
||||
|
@ -51,4 +51,4 @@ class TimeFilledFormatter {
|
|||
|
||||
return $formatted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue