getRequest()->getControllerName());
if ($currentController == "schedule") {
$userIsOnCalendarPage = true;
}
if ($currentController == "plupload") {
$userIsOnAddMediaPage = true;
}
}
if (self::zeroFilesUploaded()) {
if ($userIsOnAddMediaPage) {
return _("Upload some tracks below to add them to your library!");
} else {
return sprintf(_("It looks like you haven't uploaded any audio files yet. %sUpload a file now%s."),
"",
"");
}
} else if (!self::isFutureOrCurrentShowScheduled()) {
if ($userIsOnCalendarPage) {
return _("Click the 'New Show' button and fill out the required fields.");
} else {
return sprintf(_("It looks like you don't have any shows scheduled. %sCreate a show now%s."),
"",
"");
}
} else if (self::isCurrentShowEmpty()) {
// If the current show is linked users cannot add content to it so we have to provide a different message.
if (self::isCurrentShowLinked()) {
if ($userIsOnCalendarPage) {
return _("To start broadcasting, cancel the current linked show by clicking on it and selecting 'Cancel Show'.");
} else {
return sprintf(_("Linked shows need to be filled with tracks before it starts. To start broadcasting cancel the current linked show and schedule an unlinked show.
%sCreate an unlinked show now%s."), "", "");
}
} else {
if ($userIsOnCalendarPage) {
return _("To start broadcasting, click on the current show and select 'Schedule Tracks'");
} else {
return sprintf(_("It looks like the current show needs more tracks. %sAdd tracks to your show now%s."),
"",
"");
}
}
} else if (!self::getCurrentShow() && self::isNextShowEmpty()) {
if ($userIsOnCalendarPage) {
return _("Click on the show starting next and select 'Schedule Tracks'");
} else {
return sprintf(_("It looks like the next show is empty. %sAdd tracks to your show now%s."),
"",
"");
}
} else {
return "";
}
}
/**
* Returns true if no files have been uploaded.
*/
private static function zeroFilesUploaded()
{
$fileCount = CcFilesQuery::create()
->filterByDbFileExists(true)
->filterByDbHidden(false)
->count();
if ($fileCount == 0) {
return true;
} else {
return false;
}
}
/**
* Returns true if there is at least one show currently scheduled
* or in the future.
*/
private static function isFutureOrCurrentShowScheduled()
{
$futureShow = self::getNextFutureShow();
$currentShow = self::getCurrentShow();
if (is_null($futureShow) && is_null($currentShow)) {
return false;
} else {
return true;
}
}
private static function isCurrentShowEmpty()
{
$currentShow = self::getCurrentShow();
if (is_null($currentShow)) {
return false;
} else {
$now = new DateTime("now", new DateTimeZone("UTC"));
$scheduledTracks = CcScheduleQuery::create()
->filterByDbInstanceId($currentShow->getDbId())
->filterByDbEnds($now, Criteria::GREATER_EQUAL)
->find();
if ($scheduledTracks->count() == 0) {
return true;
} else {
return false;
}
}
}
private static function isNextShowEmpty()
{
$futureShow = self::getNextFutureShow();
if (is_null($futureShow)) {
return false;
} else {
$now = new DateTime("now", new DateTimeZone("UTC"));
$scheduledTracks = CcScheduleQuery::create()
->filterByDbInstanceId($futureShow->getDbId())
->filterByDbStarts($now, Criteria::GREATER_EQUAL)
->find();
if ($scheduledTracks->count() == 0) {
return true;
} else {
return false;
}
}
}
private static function getCurrentShow()
{
$now = new DateTime("now", new DateTimeZone("UTC"));
return CcShowInstancesQuery::create()
->filterByDbStarts($now, Criteria::LESS_THAN)
->filterByDbEnds($now, Criteria::GREATER_THAN)
->filterByDbModifiedInstance(false)
->findOne();
}
private static function getNextFutureShow()
{
$now = new DateTime("now", new DateTimeZone("UTC"));
return CcShowInstancesQuery::create()
->filterByDbStarts($now, Criteria::GREATER_THAN)
->filterByDbModifiedInstance(false)
->orderByDbStarts()
->findOne();
}
private static function isCurrentShowLinked()
{
$currentShow = self::getCurrentShow();
if (!is_null($currentShow)) {
$show = CcShowQuery::create()
->filterByDbId($currentShow->getDbShowId())
->findOne();
if ($show->isLinked()) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}