Ejemplo n.º 1
0
 public static function GetNextItem($p_timeNow)
 {
     //get previous show and previous item in the schedule table.
     //Compare the two and if the last show was recorded and started
     //after the last item in the schedule table, then return the show's
     //name. Else return the last item from the schedule.
     $showInstance = Application_Model_ShowInstance::GetNextShowInstance($p_timeNow);
     $row = Application_Model_Schedule::GetNextScheduleItem($p_timeNow);
     if (is_null($showInstance)) {
         if (count($row) == 0) {
             return null;
         } else {
             return array("name" => $row[0]["artist_name"] . " - " . $row[0]["track_title"], "starts" => $row[0]["starts"], "ends" => $row[0]["ends"]);
         }
     } else {
         if (count($row) == 0) {
             if ($showInstance->isRecorded()) {
                 //last item is a show instance
                 return array("name" => $showInstance->getName(), "starts" => $showInstance->getShowInstanceStart(), "ends" => $showInstance->getShowInstanceEnd());
             } else {
                 return null;
             }
         } else {
             //return the one that starts sooner.
             if ($row[0]["starts"] <= $showInstance->getShowInstanceStart()) {
                 return array("name" => $row[0]["artist_name"] . " - " . $row[0]["track_title"], "starts" => $row[0]["starts"], "ends" => $row[0]["ends"]);
             } else {
                 return array("name" => $showInstance->getName(), "starts" => $showInstance->getShowInstanceStart(), "ends" => $showInstance->getShowInstanceEnd());
             }
         }
     }
 }