1 | <?php |
||
9 | class Translation { |
||
10 | public $db; |
||
11 | public function __construct($dbc = null) { |
||
12 | $Connection = new Connection($dbc); |
||
13 | $this->db = $Connection->db(); |
||
14 | } |
||
15 | |||
16 | |||
17 | /** |
||
18 | * Change IATA to ICAO value for ident |
||
19 | * |
||
20 | * @param String $ident ident |
||
21 | * @return String the icao |
||
22 | */ |
||
23 | public function ident2icao($ident) { |
||
24 | $Spotter = new Spotter(); |
||
25 | if (!is_numeric(substr($ident, 0, 3))) { |
||
26 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
||
27 | $airline_icao = substr($ident, 0, 2); |
||
28 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
||
29 | //$airline_icao = substr($ident, 0, 3); |
||
30 | return $ident; |
||
31 | } else return $ident; |
||
32 | } else return $ident; |
||
33 | if ($airline_icao == 'AF') { |
||
34 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
||
35 | else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
||
36 | } else { |
||
37 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
||
38 | if (isset($identicao[0])) { |
||
39 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
||
40 | } else $icao = $ident; |
||
41 | } |
||
42 | return $icao; |
||
43 | } |
||
44 | |||
45 | public function getOperator($ident) { |
||
46 | $query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1"; |
||
47 | $query_values = array(':ident' => $ident); |
||
48 | try { |
||
49 | $sth = $this->db->prepare($query); |
||
50 | $sth->execute($query_values); |
||
51 | } catch(PDOException $e) { |
||
52 | return "error : ".$e->getMessage(); |
||
53 | } |
||
54 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
||
55 | $sth->closeCursor(); |
||
56 | if (count($row) > 0) { |
||
57 | return $row['operator_correct']; |
||
58 | } else return $ident; |
||
59 | } |
||
60 | |||
61 | public function addOperator($ident,$correct_ident,$source) { |
||
71 | |||
72 | public function updateOperator($ident,$correct_ident,$source) { |
||
82 | |||
83 | public function checkTranslation($ident,$web = false) { |
||
|
|||
84 | global $globalTranslationSources, $globalTranslationFetch; |
||
113 | |||
114 | /* |
||
115 | function fromPlanefinder($icao) { |
||
116 | $url = 'http://planefinder.net/data/endpoints/search_ajax.php?searchText='.$icao; |
||
117 | $Common = new Common(); |
||
118 | $json = $Common->getData($url); |
||
119 | $parsed_json = json_decode($json); |
||
120 | if (isset($parsed_json->flights[0]->title) && isset($parsed_json->flights[0]->subtitle) && $parsed_json->flights[0]->subtitle == $icao) return $parsed_json->flights[0]->title; |
||
121 | else return ''; |
||
122 | } |
||
123 | */ |
||
124 | } |
||
125 | //echo Translation->checkTranslation('EZY268X'); |
||
127 | ?> |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.