Esempio n. 1
0
 /**
  * Get events from a given date range
  * @since Version 3.9
  * @param \DateTime $dateFrom
  * @param \DateTime $dateTo
  * @return \Railpage\Chronicle\Entry
  * @yield \Railpage\Chronicle\Entry
  */
 public function getEventsForDates($dateFrom = null, $dateTo = null)
 {
     $events = array();
     $Railcams = new Module_Railcams();
     if (!$dateFrom instanceof DateTime) {
         throw new Exception("dateFrom is not an instance of \\DateTime");
     }
     if (!$dateTo instanceof DateTime) {
         throw new Exception("dateTo is not an instance of \\DateTime");
     }
     foreach ($Railcams->getTaggedPhotos() as $photo) {
         $Camera = new Camera($photo['railcam_id']);
         $Photo = $Camera->getPhoto($photo['photo_id']);
         if ($dateFrom instanceof DateTime && $Photo->dates['taken'] >= $dateFrom && $dateTo instanceof DateTime && $Photo->dates['taken'] <= $dateTo) {
             $Loco = new Locomotive($photo['loco_id']);
             $events[] = array("provider" => self::PROVIDER_NAME, "id" => $photo['id'], "title" => sprintf("Railcam sighting: %s at %s", $Loco->number, $Camera->name), "date" => new DateTime(sprintf("@%s", substr($photo['id'], 0, 10))), "url" => $Photo->url->getURLs());
         }
     }
     return $events;
 }
Esempio n. 2
0
 /**
  * Constructor
  * @since Version 3.9
  * @param int|bool $id The ID of the photo from the provider
  * @param object|bool $Provider The provider of the image, using the \Railpage\Railcams\Provider interface
  */
 public function __construct($id = false, $Provider = false)
 {
     parent::__construct();
     if ($Provider) {
         $this->setProvider($Provider);
     }
     if (filter_var($id, FILTER_VALIDATE_INT)) {
         $this->id = $id;
         if (is_object($this->Provider)) {
             $this->load();
         }
     }
 }
Esempio n. 3
0
 /**
  * Constructor
  * @since Version 3.4
  * @param int $id
  */
 public function __construct($id = null)
 {
     parent::__construct();
     $this->GuzzleClient = new Client();
     if ($id != null) {
         $this->id = $id;
         // Fetch Railcam data
         $this->load();
     }
 }
Esempio n. 4
0
 /**
  * Constructor
  * @since Version 3.4
  * @param int $id
  */
 public function __construct($id = false)
 {
     parent::__construct();
     if ($id) {
         $this->id = $id;
         // Fetch Railcam data
         try {
             $this->load();
         } catch (Exception $e) {
             throw new Exception($e->getMessage());
         }
     }
 }