public function testAdd() { $Url = new Url("/test/blah"); $this->assertInstanceOf("Railpage\\Url", $Url); $this->assertEquals("/test/blah", $Url->url); $this->assertEquals("http://www.railpage.com.au/test/blah", $Url->canonical); $_SERVER['debug'] = true; $Url = new Url("/test/blah2"); $this->assertEquals("/test/blah2", $Url->url); $this->assertTrue(count($Url->getURLs()) >= 1); }
/** * Get path of this route * @since Version 3.9 * @return array */ public function getPath() { $mckey = sprintf("railpage:gtfs.path;provider=%s;route=%s", $this->Provider->getProviderName(), $this->short_name); $Memcached = AppCore::GetMemcached(); if ($path = $Memcached->fetch($mckey)) { return $path; } $query = sprintf("SELECT id, service_id, trip_id, trip_headsign, shape_id, meta FROM %s_trips WHERE route_id = '%s' LIMIT 1", $this->Provider->getDbPrefix(), $this->short_name); $result = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE); if ($result) { foreach ($result as $row) { $trip = $row->getArrayCopy(); } } if (!isset($trip)) { return false; } $query = "SELECT t.id, t.arrival_time, t.departure_time, t.stop_id, t.stop_sequence, t.pickup_type, t.drop_off_type, t.timepoint, t.meta AS time_meta, \r\n s.stop_code, s.stop_name, s.stop_lat, s.stop_lon, s.location_type, s.wheelchair_boarding, s.platform_code, s.meta AS stop_meta\r\n FROM %s_stop_times AS t LEFT JOIN %s_stops AS s ON t.stop_id = s.stop_id\r\n WHERE t.trip_id = %d ORDER BY t.stop_sequence"; $query = sprintf($query, $this->Provider->getDbPrefix(), $this->Provider->getDbPrefix(), $trip['trip_id']); $result = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE); $path = array(); if ($result) { foreach ($result as $row) { $url = new Url(sprintf("/timetables?mode=stop&provider=%s&id=%d", $this->Provider->getProviderName(), $row['stop_id'])); $row = $row->getArrayCopy(); $row['stop_meta'] = json_decode($row['stop_meta'], true); $row['time_meta'] = json_decode($row['time_meta'], true); $row['url'] = $url->getURLs(); $path[] = $row; } } $Memcached->save($mckey, $path, strtotime("+1 month")); return $path; }
/** * Get this job as an associative array * @since Versio 3.9.1 * @return array */ public function getArray() { $return = array("id" => $this->id, "title" => $this->title, "reference_id" => $this->reference_id, "description" => $this->desc, "added" => array("absolute" => $this->Open->format("Y-m-d H:i:s")), "expiry" => array("absolute" => $this->expiry->format("Y-m-d H:i:s")), "location" => array("id" => $this->Location->id, "name" => $this->Location->name), "organisation" => array("id" => $this->Organisation->id, "name" => $this->Organisation->name), "classification" => array("id" => $this->Classification->id, "name" => $this->Classification->name), "url" => $this->url->getURLs()); return $return; }