CC-4090: Make code style PSR compliant
-run psr-cs-fixer
This commit is contained in:
parent
5661872034
commit
794cf2c845
40 changed files with 2017 additions and 1874 deletions
|
@ -3,8 +3,8 @@
|
|||
require_once 'formatters/LengthFormatter.php';
|
||||
require_once 'formatters/TimeFilledFormatter.php';
|
||||
|
||||
class Application_Model_ShowBuilder {
|
||||
|
||||
class Application_Model_ShowBuilder
|
||||
{
|
||||
private $timezone;
|
||||
|
||||
//in UTC timezone
|
||||
|
@ -49,8 +49,8 @@ class Application_Model_ShowBuilder {
|
|||
* @param DateTime $p_startsDT
|
||||
* @param DateTime $p_endsDT
|
||||
*/
|
||||
public function __construct($p_startDT, $p_endDT, $p_opts) {
|
||||
|
||||
public function __construct($p_startDT, $p_endDT, $p_opts)
|
||||
{
|
||||
$this->startDT = $p_startDT;
|
||||
$this->endDT = $p_endDT;
|
||||
$this->timezone = date_default_timezone_get();
|
||||
|
@ -60,25 +60,25 @@ class Application_Model_ShowBuilder {
|
|||
$this->currentShow = false;
|
||||
}
|
||||
|
||||
private function getUsersShows() {
|
||||
|
||||
private function getUsersShows()
|
||||
{
|
||||
$shows = array();
|
||||
|
||||
$host_shows = CcShowHostsQuery::create()
|
||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||
->filterByDbHost($this->user->getId())
|
||||
->find();
|
||||
|
||||
foreach ($host_shows as $host_show) {
|
||||
$shows[] = $host_show->getDbShow();
|
||||
$host_shows = CcShowHostsQuery::create()
|
||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||
->filterByDbHost($this->user->getId())
|
||||
->find();
|
||||
|
||||
foreach ($host_shows as $host_show) {
|
||||
$shows[] = $host_show->getDbShow();
|
||||
}
|
||||
|
||||
return $shows;
|
||||
}
|
||||
|
||||
//check to see if this row should be editable by the user.
|
||||
private function isAllowed($p_item, &$row) {
|
||||
|
||||
private function isAllowed($p_item, &$row)
|
||||
{
|
||||
//cannot schedule in a recorded show.
|
||||
if (intval($p_item["si_record"]) === 1) {
|
||||
return;
|
||||
|
@ -89,7 +89,8 @@ class Application_Model_ShowBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private function getItemColor($p_item, &$row) {
|
||||
private function getItemColor($p_item, &$row)
|
||||
{
|
||||
$defaultColor = "ffffff";
|
||||
$defaultBackground = "3366cc";
|
||||
|
||||
|
@ -107,17 +108,16 @@ class Application_Model_ShowBuilder {
|
|||
}
|
||||
|
||||
//information about whether a track is inside|boundary|outside a show.
|
||||
private function getItemStatus($p_item, &$row) {
|
||||
|
||||
private function getItemStatus($p_item, &$row)
|
||||
{
|
||||
$row["status"] = intval($p_item["playout_status"]);
|
||||
}
|
||||
|
||||
private function getRowTimestamp($p_item, &$row) {
|
||||
|
||||
private function getRowTimestamp($p_item, &$row)
|
||||
{
|
||||
if (is_null($p_item["si_last_scheduled"])) {
|
||||
$ts = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$dt = new DateTime($p_item["si_last_scheduled"], new DateTimeZone("UTC"));
|
||||
$ts = intval($dt->format("U"));
|
||||
}
|
||||
|
@ -130,41 +130,38 @@ class Application_Model_ShowBuilder {
|
|||
* 1 = current
|
||||
* 2 = future
|
||||
*/
|
||||
private function getScheduledStatus($p_epochItemStart, $p_epochItemEnd, &$row) {
|
||||
|
||||
private function getScheduledStatus($p_epochItemStart, $p_epochItemEnd, &$row)
|
||||
{
|
||||
if ($row["footer"] === true && $this->epoch_now > $p_epochItemStart && $this->epoch_now > $p_epochItemEnd) {
|
||||
$row["scheduled"] = 0;
|
||||
}
|
||||
else if ($row["footer"] === true && $this->epoch_now < $p_epochItemEnd) {
|
||||
$row["scheduled"] = 2;
|
||||
}
|
||||
else if ($row["header"] === true && $this->epoch_now >= $p_epochItemStart) {
|
||||
} elseif ($row["footer"] === true && $this->epoch_now < $p_epochItemEnd) {
|
||||
$row["scheduled"] = 2;
|
||||
} elseif ($row["header"] === true && $this->epoch_now >= $p_epochItemStart) {
|
||||
$row["scheduled"] = 0;
|
||||
}
|
||||
else if ($row["header"] === true && $this->epoch_now < $p_epochItemEnd) {
|
||||
$row["scheduled"] = 2;
|
||||
} elseif ($row["header"] === true && $this->epoch_now < $p_epochItemEnd) {
|
||||
$row["scheduled"] = 2;
|
||||
}
|
||||
|
||||
//item is in the past.
|
||||
else if ($this->epoch_now > $p_epochItemEnd) {
|
||||
$row["scheduled"] = 0;
|
||||
}
|
||||
|
||||
//item is the currently scheduled item.
|
||||
else if ($this->epoch_now >= $p_epochItemStart && $this->epoch_now < $p_epochItemEnd) {
|
||||
$row["scheduled"] = 1;
|
||||
//how many seconds the view should wait to redraw itself.
|
||||
$row["refresh"] = $p_epochItemEnd - $this->epoch_now;
|
||||
else if ($this->epoch_now > $p_epochItemEnd) {
|
||||
$row["scheduled"] = 0;
|
||||
}
|
||||
|
||||
//item is in the future.
|
||||
else if ($this->epoch_now < $p_epochItemStart) {
|
||||
$row["scheduled"] = 2;
|
||||
}
|
||||
//item is the currently scheduled item.
|
||||
else if ($this->epoch_now >= $p_epochItemStart && $this->epoch_now < $p_epochItemEnd) {
|
||||
$row["scheduled"] = 1;
|
||||
//how many seconds the view should wait to redraw itself.
|
||||
$row["refresh"] = $p_epochItemEnd - $this->epoch_now;
|
||||
}
|
||||
|
||||
//item is in the future.
|
||||
else if ($this->epoch_now < $p_epochItemStart) {
|
||||
$row["scheduled"] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
private function makeHeaderRow($p_item) {
|
||||
|
||||
private function makeHeaderRow($p_item)
|
||||
{
|
||||
$row = $this->defaultRowArray;
|
||||
$this->isAllowed($p_item, $row);
|
||||
$this->getRowTimestamp($p_item, $row);
|
||||
|
@ -177,8 +174,8 @@ class Application_Model_ShowBuilder {
|
|||
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
|
||||
$endsEpoch = floatval($showEndDT->format("U.u"));
|
||||
|
||||
//is a rebroadcast show
|
||||
if (intval($p_item["si_rebroadcast"]) === 1) {
|
||||
//is a rebroadcast show
|
||||
if (intval($p_item["si_rebroadcast"]) === 1) {
|
||||
$row["rebroadcast"] = true;
|
||||
|
||||
$parentInstance = CcShowInstancesQuery::create()->findPk($p_item["parent_show"]);
|
||||
|
@ -187,15 +184,14 @@ class Application_Model_ShowBuilder {
|
|||
$dt->setTimezone(new DateTimeZone($this->timezone));
|
||||
$time = $dt->format("Y-m-d H:i");
|
||||
|
||||
$row["rebroadcast_title"] = "Rebroadcast of {$name} from {$time}";
|
||||
}
|
||||
else if (intval($p_item["si_record"]) === 1) {
|
||||
$row["rebroadcast_title"] = "Rebroadcast of {$name} from {$time}";
|
||||
} elseif (intval($p_item["si_record"]) === 1) {
|
||||
$row["record"] = true;
|
||||
|
||||
if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
|
||||
$file = Application_Model_StoredFile::Recall($p_item["si_file_id"]);
|
||||
if (isset($file)) {
|
||||
$sid = $file->getSoundCloudId();
|
||||
$sid = $file->getSoundCloudId();
|
||||
$row["soundcloud_id"] = $sid;
|
||||
}
|
||||
}
|
||||
|
@ -204,8 +200,7 @@ class Application_Model_ShowBuilder {
|
|||
if ($startsEpoch < $this->epoch_now && $endsEpoch > $this->epoch_now) {
|
||||
$row["currentShow"] = true;
|
||||
$this->currentShow = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->currentShow = false;
|
||||
}
|
||||
|
||||
|
@ -229,7 +224,8 @@ class Application_Model_ShowBuilder {
|
|||
return $row;
|
||||
}
|
||||
|
||||
private function makeScheduledItemRow($p_item) {
|
||||
private function makeScheduledItemRow($p_item)
|
||||
{
|
||||
$row = $this->defaultRowArray;
|
||||
|
||||
if (isset($p_item["sched_starts"])) {
|
||||
|
@ -279,34 +275,33 @@ class Application_Model_ShowBuilder {
|
|||
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
||||
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
|
||||
|
||||
$startsEpoch = floatval($showStartDT->format("U.u"));
|
||||
$startsEpoch = floatval($showStartDT->format("U.u"));
|
||||
$endsEpoch = floatval($showEndDT->format("U.u"));
|
||||
|
||||
|
||||
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$row["empty"] = true;
|
||||
$row["id"] = 0 ;
|
||||
$row["instance"] = intval($p_item["si_id"]);
|
||||
}
|
||||
|
||||
if (intval($p_item["si_rebroadcast"]) === 1) {
|
||||
$row["rebroadcast"] = true;
|
||||
if (intval($p_item["si_rebroadcast"]) === 1) {
|
||||
$row["rebroadcast"] = true;
|
||||
}
|
||||
|
||||
|
||||
if ($this->currentShow === true) {
|
||||
$row["currentShow"] = true;
|
||||
}
|
||||
|
||||
$this->getItemColor($p_item, $row);
|
||||
$this->getRowTimestamp($p_item, $row);
|
||||
|
||||
$this->getItemColor($p_item, $row);
|
||||
$this->getRowTimestamp($p_item, $row);
|
||||
$this->isAllowed($p_item, $row);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function makeFooterRow($p_item) {
|
||||
|
||||
private function makeFooterRow($p_item)
|
||||
{
|
||||
$row = $this->defaultRowArray;
|
||||
$row["footer"] = true;
|
||||
$row["instance"] = intval($p_item["si_id"]);
|
||||
|
@ -321,21 +316,21 @@ class Application_Model_ShowBuilder {
|
|||
$timeFilled = new TimeFilledFormatter($runtime);
|
||||
$row["fRuntime"] = $timeFilled->format();
|
||||
|
||||
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
||||
$showStartDT->setTimezone(new DateTimeZone($this->timezone));
|
||||
$startsEpoch = floatval($showStartDT->format("U.u"));
|
||||
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
|
||||
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
|
||||
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
|
||||
$showStartDT->setTimezone(new DateTimeZone($this->timezone));
|
||||
$startsEpoch = floatval($showStartDT->format("U.u"));
|
||||
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
|
||||
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
|
||||
$endsEpoch = floatval($showEndDT->format("U.u"));
|
||||
|
||||
$row["refresh"] = floatval($showEndDT->format("U.u")) - $this->epoch_now;
|
||||
$row["refresh"] = floatval($showEndDT->format("U.u")) - $this->epoch_now;
|
||||
|
||||
if ($this->currentShow === true) {
|
||||
$row["currentShow"] = true;
|
||||
if ($this->currentShow === true) {
|
||||
$row["currentShow"] = true;
|
||||
}
|
||||
|
||||
|
||||
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
|
||||
$this->isAllowed($p_item, $row);
|
||||
$this->isAllowed($p_item, $row);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
@ -346,14 +341,14 @@ class Application_Model_ShowBuilder {
|
|||
* @return boolean whether the schedule in the show builder's range has been updated.
|
||||
*
|
||||
*/
|
||||
public function hasBeenUpdatedSince($timestamp, $instances) {
|
||||
public function hasBeenUpdatedSince($timestamp, $instances)
|
||||
{
|
||||
$outdated = false;
|
||||
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
|
||||
|
||||
if ($this->opts["showFilter"] !== 0) {
|
||||
$include[] = $this->opts["showFilter"];
|
||||
}
|
||||
else if ($this->opts["myShows"] === 1) {
|
||||
} elseif ($this->opts["myShows"] === 1) {
|
||||
|
||||
$include = $this->getUsersShows();
|
||||
}
|
||||
|
@ -368,17 +363,16 @@ class Application_Model_ShowBuilder {
|
|||
|
||||
if (isset($show["last_scheduled"])) {
|
||||
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$dt = new DateTime($show["created"], new DateTimeZone("UTC"));
|
||||
}
|
||||
|
||||
//check if any of the shows have a more recent timestamp.
|
||||
$showTimeStamp = intval($dt->format("U"));
|
||||
$showTimeStamp = intval($dt->format("U"));
|
||||
if ($timestamp < $showTimeStamp) {
|
||||
Logging::debug("timestamp is {$timestamp} show timestamp is {$showTimeStamp}");
|
||||
$outdated = true;
|
||||
break;
|
||||
Logging::debug("timestamp is {$timestamp} show timestamp is {$showTimeStamp}");
|
||||
$outdated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -392,8 +386,8 @@ class Application_Model_ShowBuilder {
|
|||
return $outdated;
|
||||
}
|
||||
|
||||
public function GetItems() {
|
||||
|
||||
public function GetItems()
|
||||
{
|
||||
$current_id = -1;
|
||||
$display_items = array();
|
||||
|
||||
|
@ -401,8 +395,7 @@ class Application_Model_ShowBuilder {
|
|||
if ($this->opts["myShows"] === 1) {
|
||||
|
||||
$shows = $this->getUsersShows();
|
||||
}
|
||||
else if ($this->opts["showFilter"] !== 0) {
|
||||
} elseif ($this->opts["showFilter"] !== 0) {
|
||||
$shows[] = $this->opts["showFilter"];
|
||||
}
|
||||
|
||||
|
@ -439,9 +432,9 @@ class Application_Model_ShowBuilder {
|
|||
if (isset($row)) {
|
||||
$display_items[] = $row;
|
||||
}
|
||||
|
||||
if ($current_id !== -1 && !in_array($current_id, $this->showInstances)) {
|
||||
$this->showInstances[] = $current_id;
|
||||
|
||||
if ($current_id !== -1 && !in_array($current_id, $this->showInstances)) {
|
||||
$this->showInstances[] = $current_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue