/** * * Receives a cc_show id and determines whether to create a * single show instance or repeating show instances */ public function delegateInstanceCreation($daysAdded = null, $end = null, $fillInstances = false) { $populateUntil = $this->getPopulateShowUntilDateTIme(); if (is_null($this->ccShow)) { $ccShowDays = $this->getShowDaysInRange($populateUntil, $end); } else { if ($this->ccShow->isRepeating()) { $ccShowDays = $this->ccShow->getRepeatingCcShowDays(); } else { $ccShowDays = $this->ccShow->getCcShowDayss(); } } if (!is_null($end)) { $populateUntil = $end; } /* In case the user is moving forward in the calendar and there are * linked shows in the schedule we need to keep track of each cc_show * so we know which shows need to be filled with content */ $ccShows = array(); foreach ($ccShowDays as $day) { $this->ccShow = $day->getCcShow(); $this->isRecorded = $this->ccShow->isRecorded(); $this->isRebroadcast = $this->ccShow->isRebroadcast(); if (!isset($ccShows[$day->getDbShowId()])) { $ccShows[$day->getDbShowId()] = $day->getccShow(); } switch ($day->getDbRepeatType()) { case NO_REPEAT: $this->createNonRepeatingInstance($day, $populateUntil); break; case REPEAT_WEEKLY: $this->createWeeklyRepeatInstances($day, $populateUntil, REPEAT_WEEKLY, new DateInterval("P7D"), $daysAdded); break; case REPEAT_BI_WEEKLY: $this->createWeeklyRepeatInstances($day, $populateUntil, REPEAT_BI_WEEKLY, new DateInterval("P14D"), $daysAdded); break; case REPEAT_TRI_WEEKLY: $this->createWeeklyRepeatInstances($day, $populateUntil, REPEAT_TRI_WEEKLY, new DateInterval("P21D"), $daysAdded); break; case REPEAT_QUAD_WEEKLY: $this->createWeeklyRepeatInstances($day, $populateUntil, REPEAT_QUAD_WEEKLY, new DateInterval("P28D"), $daysAdded); break; case REPEAT_MONTHLY_MONTHLY: $this->createMonthlyRepeatInstances($day, $populateUntil); break; case REPEAT_MONTHLY_WEEKLY: $this->createMonthlyRepeatInstances($day, $populateUntil); break; } } foreach ($ccShows as $ccShow) { if (($this->isUpdate || $fillInstances) && $ccShow->isLinked()) { Application_Service_SchedulerService::fillNewLinkedInstances($ccShow); } } if (isset($this->linkedShowContent)) { Application_Service_SchedulerService::fillPreservedLinkedShowContent($this->ccShow, $this->linkedShowContent); } return $this->ccShow; }