public function GET_view_2($date, $class)
 {
     $model = new ReplacementsRepository();
     $replacements = $model->getByClassAndDate($class, $date);
     if ($replacements == null) {
         header('HTTP/1.0 404 Not Found');
         include '404.html';
     } else {
         $template = $this->includeTemplate('dashboard/replacements_view');
         $template->replacements = $replacements;
         $template->render();
     }
 }
Example #2
0
 private function updateReplacements($dom)
 {
     $model = new ReplacementsRepository();
     $parser = new ReplacementsParser();
     $remoteList = $parser->getReplacements($dom);
     $this->logErrors('ReplacementsParser', $parser->getErrors());
     if ($remoteList !== null) {
         foreach ($remoteList as $remote) {
             $local = $model->getByClassAndDate($remote->class, $remote->date);
             if ($local === null || $remote->value !== $local->value) {
                 $model->setValue($remote->class, $remote->date, $remote->value);
                 echo "updated replacements/{$remote->date}/{$remote->class}\n";
             }
         }
     }
 }
 /**
  * @param string $date in format yyyy-mm-dd
  * @param int $lastModified
  * @return News
  */
 public function getNews($date, $lastModified)
 {
     $now = time();
     $replacements = new ReplacementsRepository();
     $luckyNumbers = new LuckyNumberRepository();
     $timetables = new TimetableRepository();
     $bells = new BellsRepository();
     $settings = new SettingRepository();
     $news = new News();
     $news->timestamp = $now;
     $news->replacements = $replacements->getByDateAndLastModified($date, $lastModified);
     $news->luckyNumbers = $luckyNumbers->getByDateAndLastModified($date, $lastModified);
     $news->timetables = $timetables->getByLastModified($lastModified);
     $news->bells = $bells->getByLastModified($lastModified);
     $news->version = (int) $settings->get('version');
     return $news;
 }
 public function GET_replacements_2($date, $class)
 {
     $repo = new ReplacementsRepository();
     $result = $repo->getByClassAndDate($class, $date);
     if ($result !== null) {
         Json::OK($result);
     } else {
         Json::notFound();
     }
 }