Пример #1
0
 protected function fetchData(Request $request)
 {
     $country = strtoupper($request->getCountry());
     $lang = strtoupper($request->getLang());
     $stations = array();
     $count = 0;
     $pre = "";
     //yes, I hate this dirty hack. It's here to provide for the iRail client as well as for the API.
     //It needs to disapear if we rewrite the mobile client
     if (sizeof(explode("api", $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"])) > 1) {
         $pre = "../";
     }
     $file = $pre . "stationlists/" . $country . ".csv";
     if (!file_exists($file)) {
         $file = $pre . "stationlists/" . $country . "_EN.csv";
     }
     if (($handle = fopen($file, "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
             if (isset($data[4])) {
                 $stations[$count] = new Station($data[1], $data[3], $data[2], $data[0], $data[4]);
             } else {
                 $stations[$count] = new Station($data[1], $data[3], $data[2], $data[0]);
             }
             $count++;
         }
         fclose($handle);
     }
     return $stations;
 }
Пример #2
0
 /**
  * This function serves as a factory method
  * It provides something with an input
  * @return Input
  */
 public function getInput()
 {
     if (parent::getCountry() == "nl") {
         return new NSConnectionInput();
     } else {
         if (parent::getCountry() == "be") {
             return new BRailConnectionInput();
         } else {
             return new NSConnectionInput();
         }
     }
 }
Пример #3
0
 /**
  * This function serves as a factory method
  * It provides something with an input
  * @return Input
  */
 public function getInput()
 {
     if (parent::getCountry() == "nl") {
         return new NSLiveboardInput();
     } else {
         if (parent::getCountry() == "be") {
             return new BRailLiveBoardInput();
         } else {
             return new NSLiveboardInput();
         }
     }
 }