From: maxious Date: Tue, 22 Mar 2011 14:33:47 +0000 Subject: Move open transit data experiments to labs X-Git-Url: http://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=37ba9fdaf50586223bf0d1da787573c0ea67ca8a --- Move open transit data experiments to labs --- --- /dev/null +++ b/labs/myway_api.json.php @@ -1,1 +1,125 @@ + "SRNO", + "DOBmonth" => "month", + "DOBday" => "day", + "DOByear" => "year", + "secret_answer" => "pwrd", + "button" => "button" +); +foreach (Array( + "card_number", + "DOBday", + "DOBmonth", + "DOByear" +) as $field_name) { + if (isset($_REQUEST[$field_name])) { + $fields[$field_name] = filter_var($_REQUEST[$field_name], FILTER_SANITIZE_NUMBER_INT); + } + else { + $return["error"][] = $field_name. " parameter invalid or unspecified"; + } +} +if (isset($_REQUEST['secret_answer'])) { + $fields['secret_answer'] = filter_var($_REQUEST['secret_answer'], FILTER_SANITIZE_STRING, Array( + FILTER_FLAG_NO_ENCODE_QUOTES, + FILTER_FLAG_STRIP_HIGH, + FILTER_FLAG_STRIP_LOW + )); +} +else { + $return["error"][] = "secret_answer parameter invalid or unspecified"; +} +$fields['button'] = 'Submit'; +$fields_string = ""; +//url-ify the data for the POST +foreach ($fields as $key => $value) { + if (sizeof($value) === 0) $return['error'][] = $key . " parameter invalid or unspecified"; + $fields_string.= $field_mapping[$key] . '=' . $value . '&'; +} +$fields_string = rtrim($fields_string, '&'); +if (!isset($return['error'])) { + //open connection + $ch = curl_init(); + //set the url, number of POST vars, POST data + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, count($fields)); + curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + //execute post + $pageHTML = curl_exec($ch); + if (curl_errno($ch)) $return["error"][] = "Network error " . curl_errno($ch) . " " . curl_error($ch) . " " . $url . $fields_string; + //close connection + curl_close($ch); +} +if (!isset($return['error'])) { + include_once ('simple_html_dom.php'); + $page = str_get_html($pageHTML); + $pageAlerts = $page->find(".smartCardAlert"); + if (sizeof($pageAlerts) > 0) { + $return['error'][] = $pageAlerts[0]->plaintext; + } + if (!isset($return['error'])) { + $tableNum = 0; + $tableName = Array( + 1 => "myway_carddetails", + 2 => "myway_transactions" + ); + foreach ($page->find("table") as $table) { + $tableNum++; + $tableColumns = Array(); + $tableColumnNum = 0; + foreach ($table->find("th") as $th) { + $tableColumns[$tableColumnNum] = cleanString($th->plaintext); + $tableColumnNum++; + } + $tableRowNum = 0; + foreach ($table->find("tr") as $tr) { + $tableColumnNum = 0; + foreach ($tr->find("td") as $td) { + if ($tableNum == 1) $return[$tableName[$tableNum]][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext); + else $return[$tableName[$tableNum]][$tableRowNum][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext); + $tableColumnNum++; + } + $tableRowNum++; + } + } + } +} +if (sizeof($return) == 0) { +$return['error'][] = "No data extracted from MyWay website - API may be out of date"; +} + +header('Content-Type: text/javascript; charset=utf8'); +// header('Access-Control-Allow-Origin: http://bus.lambdacomplex.org/'); +header('Access-Control-Max-Age: 3628800'); +header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE'); +if (isset($_GET['callback'])) { + $json = '(' . json_encode($return) . ');'; //must wrap in parens and end with semicolon + print_r($_GET['callback'] . $json); //callback is prepended for json-p + +} +else echo json_encode($return); +?> + --- /dev/null +++ b/labs/mywaybalance.php @@ -1,1 +1,64 @@ +" . var_dump($return['error']) . ""; + } else { + echo "

Balance: " . $return['myway_carddetails']['Card Balance'] . "

"; + echo '"; + } +} +if (isset($_REQUEST['card_number']) && isset($_REQUEST['date']) && isset($_REQUEST['secret_answer'])) { + $cardNumber = $_REQUEST['card_number']; + $date = explode("/", $_REQUEST['date']); + $pwrd = $_REQUEST['secret_answer']; + if ($_REQUEST['remember'] == true) { + $_COOKIE['card_number'] = $cardNumber; + $_COOKIE['date'] = $date; + $_COOKIE['secret_answer'] = $pwrd; + } + printBalance($cardNumber, $date, $pwrd); +} +else if (isset($_COOKIE['card_number']) && isset($_COOKIE['date']) && isset($_COOKIE['secret_answer'])) { + $cardNumber = $_COOKIE['card_number']; + $date = explode("/", $_COOKIE['date']); + $pwrd = $_COOKIE['secret_answer']; + printBalance($cardNumber, $date, $pwrd); +} +else { + $date = (isset($_REQUEST['date']) ? filter_var($_REQUEST['date'], FILTER_SANITIZE_STRING) : date("m/d/Y")); + echo '
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
'; +} +include_footer(); +?> --- /dev/null +++ b/labs/stop.pdf.php @@ -1,1 +1,196 @@ +

'; +$url = $APIurl . "/json/stoproutes?stop=" . $stopid . "&time=" . midnight_seconds() . "&service_period=" . service_period(); +$routes = json_decode(getPage($url)); +foreach ($routes as $route) { + $html.= '
' . $route[1] . ' - ' . $route[2] . ''; + $viaPoints = viaPointNames($route[3], $stopid); + if ($viaPoints != "") $html.= '
Via: ' . $viaPoints . ''; + $html.= "
"; +} +$html.= '' . staticmap(Array( + 0 => Array( + $stop[2], + $stop[3] + ) +) , 0, "iconb", false) . ""; +$url = $APIurl . "/json/stoptrips?stop=" . $stopid . "&time=" . midnight_seconds() . "&service_period=" . service_period(); +$trips = json_decode(getPage($url)); +$html.= "

"; +$html.= ""; +debug(print_r($trips, true)); +foreach ($trips as $row) { + $html.= '"; + $html.= ''; + $html.= ''; +} +$html.= '
RouteTime
' . $row[1][1] . "' . midnight_seconds_to_time($row[0]) . '
'; +if (sizeof($trips) == 0) $html.= "
No trips in the near future.
"; +require_once ('lib/tcpdf/config/lang/eng.php'); +require_once ('lib/tcpdf/tcpdf.php'); +// create new PDF document +class Custom_TCPDF extends TCPDF +{ + var $QRCodeURL; + function set_QRCodeURL($url) + { + $this->QRCodeURL = $url; + } + /** + * This method is used to render the page header. + * It is automatically called by AddPage() and could be overwritten in your own inherited class. + * @public + */ + public function Header() + { + if ($this->header_xobjid < 0) { + // start a new XObject Template + $this->header_xobjid = $this->startTemplate($this->w, $this->tMargin + 10); + $headerfont = $this->getHeaderFont(); + $headerdata = $this->getHeaderData(); + $this->y = $this->header_margin; + if ($this->rtl) { + $this->x = $this->w - $this->original_rMargin; + } + else { + $this->x = $this->original_lMargin - 10; + } + if (isset($this->QRCodeURL)) { + // QRCODE,H : QR-CODE Best error correction + $style = array( + 'border' => 1, + 'padding' => 0, + 'fgcolor' => array( + 0, + 0, + 0 + ) , + 'bgcolor' => false, //array(255,255,255) + 'module_width' => 1, // width of a single module in points + 'module_height' => 1 + // height of a single module in points + + ); + $this->write2DBarcode($this->QRCodeURL, 'QRCODE,H', '', '', 25, 25, $style, 'T'); + $imgy = 50 + 20; + } + elseif (($headerdata['logo']) AND ($headerdata['logo'] != K_BLANK_IMAGE)) { + $imgtype = $this->getImageFileType(K_PATH_IMAGES . $headerdata['logo']); + if (($imgtype == 'eps') OR ($imgtype == 'ai')) { + $this->ImageEps(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); + } + elseif ($imgtype == 'svg') { + $this->ImageSVG(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); + } + else { + $this->Image(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); + } + $imgy = $this->getImageRBY(); + } + else { + $imgy = $this->y; + } + $cell_height = round(($this->cell_height_ratio * $headerfont[2]) / $this->k, 2); + // set starting margin for text data cell + if ($this->getRTL()) { + $header_x = $this->original_rMargin + ($headerdata['logo_width'] * 1.1); + } + else { + $header_x = $this->original_lMargin + ($headerdata['logo_width'] * 1.1); + } + $cw = $this->w - $this->original_lMargin - $this->original_rMargin - ($headerdata['logo_width'] * 1.1); + $this->SetTextColor(0, 0, 0); + // header title + $this->SetFont($headerfont[0], 'B', $headerfont[2] + 1); + $this->SetX($header_x); + $this->Cell($cw, $cell_height, $headerdata['title'], 0, 1, '', 0, '', 0); + // header string + $this->SetFont($headerfont[0], $headerfont[1], $headerfont[2]); + $this->SetX($header_x); + $this->MultiCell($cw, $cell_height, $headerdata['string'], 0, '', 0, 1, '', '', true, 0, false); + // print an ending header line + //$this->SetLineStyle(array('width' => 0.85 / $this->k, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); + //$this->SetY((2.835 / $this->k) + max($imgy, $this->y)); + if ($this->rtl) { + $this->SetX($this->original_rMargin); + } + else { + $this->SetX($this->original_lMargin); + } + //$this->Cell(($this->w - $this->original_lMargin - $this->original_rMargin), 0, '', 'T', 0, 'C'); + $this->endTemplate(); + } + // print header template + $x = 0; + $dx = 0; + if ($this->booklet AND (($this->page % 2) == 0)) { + // adjust margins for booklet mode + $dx = ($this->original_lMargin - $this->original_rMargin); + } + if ($this->rtl) { + $x = $this->w + $dx; + } + else { + $x = 0 + $dx; + } + $this->printTemplate($this->header_xobjid, $x, 0, 0, 0, '', '', false); + } +} +$pdf = new Custom_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); +// set document information +$pdf->SetCreator(PDF_CREATOR); +$pdf->SetAuthor('bus.lambdacomplex.org'); +$pdf->SetTitle($stop[1]); +// set default header data +$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $stop[1] . " Timetable", "Some description of customization like Weekdays, 9am-10am"); +$pdf->set_QRCodeURL(curPageURL() . "stop.php?stopid=" . $_REQUEST['stopid']); +// set header and footer fonts +$pdf->setHeaderFont(Array( + PDF_FONT_NAME_MAIN, + '', + PDF_FONT_SIZE_MAIN +)); +$pdf->setFooterFont(Array( + PDF_FONT_NAME_DATA, + '', + PDF_FONT_SIZE_DATA +)); +// set default monospaced font +$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); +//set margins +$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); +$pdf->SetHeaderMargin(PDF_MARGIN_HEADER); +$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); +//set auto page breaks +$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); +//set image scale factor +$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); +//set some language-dependent strings +$pdf->setLanguageArray($l); +// --------------------------------------------------------- +// set default font subsetting mode +$pdf->setFontSubsetting(true); +// Set font +// dejavusans is a UTF-8 Unicode font, if you only need to +// print standard ASCII chars, you can use core fonts like +// helvetica or times to reduce file size. +$pdf->SetFont('helvetica', '', 14, '', true); +// Add a page +// This method has several options, check the source code documentation for more information. +$pdf->AddPage(); +// Print text using writeHTMLCell() +$pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true); +// --------------------------------------------------------- +// Close and output PDF document +// This method has several options, check the source code documentation for more information. +$pdf->Output('example_001.pdf', 'I'); +//============================================================+ +// END OF FILE +//============================================================+ +?> + --- /dev/null +++ b/labs/tripPlannerTester.php @@ -1,1 +1,88 @@ + Array( + "startlat" => - 35.1828, + "startlon" => 149.0295, + "finishlat" => - 35.2630, + "finishlon" => 149.1045, + ) , + "north gungahlin civic" => Array( + "startlat" => - 35.2652, + "startlon" => 149.1045, + "finishlat" => -35.2955, + "finishlon" => 149.1559, + ) , + "west duffy" => Array( + "startlat" => - 35.3252, + "startlon" => 149.0240, + "finishlat" => - 35.3997, + "finishlon" => 149.0676, + ) , + "central south" => Array( + "startlat" => - 35.3042, + "startlon" => 149.0762, + "finishlat" => - 35.3370, + "finishlon" => 149.1806, + ) , + "south" => Array( + "startlat" => - 35.3403, + "startlon" => 149.0714, + "finishlat" => - 35.4607, + "finishlon" => 149.1243, + ) + +); +$latdeltasize = 0.025; +$londeltasize = 0.025; +$from = "Barry Drive"; +$fromPlace = (startsWith($from, "-") ? $from : geocode($from, false)); +$startTime = "9:00 am"; +$startDate = "21/03/2011"; +$counter = 0; +$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; +echo "
";
+echo "lat,lon,time,latdeltasize, londeltasize, region key name\n";
 
+foreach ($boundingBoxes as $key => $boundingBox) {
+	for ($i = $boundingBox['startlat']; $i >= $boundingBox['finishlat']; $i-= $latdeltasize) {
+		for ($j = $boundingBox['startlon']; $j <= $boundingBox['finishlon']; $j+= $londeltasize) {
+			$url = $otpAPIurl . "ws/plan?date=" . urlencode($startDate) . "&time=" . urlencode($startTime) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=" . $i . "," . $j . "&fromPlace=$fromPlace&intermediatePlaces=";
+			$ch = curl_init($url);
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+			curl_setopt($ch, CURLOPT_HEADER, 0);
+			curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+				"Accept: application/json"
+			));
+			curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+			$page = curl_exec($ch);
+			if (curl_errno($ch)) {
+				echo "Trip planner temporarily unavailable: " . curl_errno($ch) . " " . curl_error($ch);
+			}
+			else {
+				$tripplan = json_decode($page);
+				if (isset($tripplan->error)) var_dump($tripplan->error);
+				$times = Array();
+				if (is_array($tripplan->plan->itineraries->itinerary)) {
+					
+					foreach ($tripplan->plan->itineraries->itinerary as $itineraryNumber => $itinerary) {
+						$times[] = floor($itinerary->duration / 60000);
+					}
+
+				}
+				else {
+					$times[] = floor($tripplan->plan->itineraries->itinerary->duration / 60000);
+				}
+				echo "$i,$j," . min($times) . ",$latdeltasize, $londeltasize,$key\n";
+			}
+			flush();
+			ob_flush();
+			curl_close($ch);
+		}
+	}
+}
+echo "
"; +?> + --- a/myway_api.json.php +++ /dev/null @@ -1,125 +1,1 @@ - "SRNO", - "DOBmonth" => "month", - "DOBday" => "day", - "DOByear" => "year", - "secret_answer" => "pwrd", - "button" => "button" -); -foreach (Array( - "card_number", - "DOBday", - "DOBmonth", - "DOByear" -) as $field_name) { - if (isset($_REQUEST[$field_name])) { - $fields[$field_name] = filter_var($_REQUEST[$field_name], FILTER_SANITIZE_NUMBER_INT); - } - else { - $return["error"][] = $field_name. " parameter invalid or unspecified"; - } -} -if (isset($_REQUEST['secret_answer'])) { - $fields['secret_answer'] = filter_var($_REQUEST['secret_answer'], FILTER_SANITIZE_STRING, Array( - FILTER_FLAG_NO_ENCODE_QUOTES, - FILTER_FLAG_STRIP_HIGH, - FILTER_FLAG_STRIP_LOW - )); -} -else { - $return["error"][] = "secret_answer parameter invalid or unspecified"; -} -$fields['button'] = 'Submit'; -$fields_string = ""; -//url-ify the data for the POST -foreach ($fields as $key => $value) { - if (sizeof($value) === 0) $return['error'][] = $key . " parameter invalid or unspecified"; - $fields_string.= $field_mapping[$key] . '=' . $value . '&'; -} -$fields_string = rtrim($fields_string, '&'); -if (!isset($return['error'])) { - //open connection - $ch = curl_init(); - //set the url, number of POST vars, POST data - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_POST, count($fields)); - curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); - //execute post - $pageHTML = curl_exec($ch); - if (curl_errno($ch)) $return["error"][] = "Network error " . curl_errno($ch) . " " . curl_error($ch) . " " . $url . $fields_string; - //close connection - curl_close($ch); -} -if (!isset($return['error'])) { - include_once ('simple_html_dom.php'); - $page = str_get_html($pageHTML); - $pageAlerts = $page->find(".smartCardAlert"); - if (sizeof($pageAlerts) > 0) { - $return['error'][] = $pageAlerts[0]->plaintext; - } - if (!isset($return['error'])) { - $tableNum = 0; - $tableName = Array( - 1 => "myway_carddetails", - 2 => "myway_transactions" - ); - foreach ($page->find("table") as $table) { - $tableNum++; - $tableColumns = Array(); - $tableColumnNum = 0; - foreach ($table->find("th") as $th) { - $tableColumns[$tableColumnNum] = cleanString($th->plaintext); - $tableColumnNum++; - } - $tableRowNum = 0; - foreach ($table->find("tr") as $tr) { - $tableColumnNum = 0; - foreach ($tr->find("td") as $td) { - if ($tableNum == 1) $return[$tableName[$tableNum]][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext); - else $return[$tableName[$tableNum]][$tableRowNum][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext); - $tableColumnNum++; - } - $tableRowNum++; - } - } - } -} -if (sizeof($return) == 0) { -$return['error'][] = "No data extracted from MyWay website - API may be out of date"; -} - -header('Content-Type: text/javascript; charset=utf8'); -// header('Access-Control-Allow-Origin: http://bus.lambdacomplex.org/'); -header('Access-Control-Max-Age: 3628800'); -header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE'); -if (isset($_GET['callback'])) { - $json = '(' . json_encode($return) . ');'; //must wrap in parens and end with semicolon - print_r($_GET['callback'] . $json); //callback is prepended for json-p - -} -else echo json_encode($return); -?> - --- a/mywaybalance.php +++ /dev/null @@ -1,64 +1,1 @@ -" . var_dump($return['error']) . ""; - } else { - echo "

Balance: " . $return['myway_carddetails']['Card Balance'] . "

"; - echo '"; - } -} -if (isset($_REQUEST['card_number']) && isset($_REQUEST['date']) && isset($_REQUEST['secret_answer'])) { - $cardNumber = $_REQUEST['card_number']; - $date = explode("/", $_REQUEST['date']); - $pwrd = $_REQUEST['secret_answer']; - if ($_REQUEST['remember'] == true) { - $_COOKIE['card_number'] = $cardNumber; - $_COOKIE['date'] = $date; - $_COOKIE['secret_answer'] = $pwrd; - } - printBalance($cardNumber, $date, $pwrd); -} -else if (isset($_COOKIE['card_number']) && isset($_COOKIE['date']) && isset($_COOKIE['secret_answer'])) { - $cardNumber = $_COOKIE['card_number']; - $date = explode("/", $_COOKIE['date']); - $pwrd = $_COOKIE['secret_answer']; - printBalance($cardNumber, $date, $pwrd); -} -else { - $date = (isset($_REQUEST['date']) ? filter_var($_REQUEST['date'], FILTER_SANITIZE_STRING) : date("m/d/Y")); - echo '
-
- - -
-
- - -
-
- - -
-
- - -
-
'; -} -include_footer(); -?> --- a/stop.pdf.php +++ /dev/null @@ -1,196 +1,1 @@ -

'; -$url = $APIurl . "/json/stoproutes?stop=" . $stopid . "&time=" . midnight_seconds() . "&service_period=" . service_period(); -$routes = json_decode(getPage($url)); -foreach ($routes as $route) { - $html.= '
' . $route[1] . ' - ' . $route[2] . ''; - $viaPoints = viaPointNames($route[3], $stopid); - if ($viaPoints != "") $html.= '
Via: ' . $viaPoints . ''; - $html.= "
"; -} -$html.= '' . staticmap(Array( - 0 => Array( - $stop[2], - $stop[3] - ) -) , 0, "iconb", false) . ""; -$url = $APIurl . "/json/stoptrips?stop=" . $stopid . "&time=" . midnight_seconds() . "&service_period=" . service_period(); -$trips = json_decode(getPage($url)); -$html.= "

"; -$html.= ""; -debug(print_r($trips, true)); -foreach ($trips as $row) { - $html.= '"; - $html.= ''; - $html.= ''; -} -$html.= '
RouteTime
' . $row[1][1] . "' . midnight_seconds_to_time($row[0]) . '
'; -if (sizeof($trips) == 0) $html.= "
No trips in the near future.
"; -require_once ('lib/tcpdf/config/lang/eng.php'); -require_once ('lib/tcpdf/tcpdf.php'); -// create new PDF document -class Custom_TCPDF extends TCPDF -{ - var $QRCodeURL; - function set_QRCodeURL($url) - { - $this->QRCodeURL = $url; - } - /** - * This method is used to render the page header. - * It is automatically called by AddPage() and could be overwritten in your own inherited class. - * @public - */ - public function Header() - { - if ($this->header_xobjid < 0) { - // start a new XObject Template - $this->header_xobjid = $this->startTemplate($this->w, $this->tMargin + 10); - $headerfont = $this->getHeaderFont(); - $headerdata = $this->getHeaderData(); - $this->y = $this->header_margin; - if ($this->rtl) { - $this->x = $this->w - $this->original_rMargin; - } - else { - $this->x = $this->original_lMargin - 10; - } - if (isset($this->QRCodeURL)) { - // QRCODE,H : QR-CODE Best error correction - $style = array( - 'border' => 1, - 'padding' => 0, - 'fgcolor' => array( - 0, - 0, - 0 - ) , - 'bgcolor' => false, //array(255,255,255) - 'module_width' => 1, // width of a single module in points - 'module_height' => 1 - // height of a single module in points - - ); - $this->write2DBarcode($this->QRCodeURL, 'QRCODE,H', '', '', 25, 25, $style, 'T'); - $imgy = 50 + 20; - } - elseif (($headerdata['logo']) AND ($headerdata['logo'] != K_BLANK_IMAGE)) { - $imgtype = $this->getImageFileType(K_PATH_IMAGES . $headerdata['logo']); - if (($imgtype == 'eps') OR ($imgtype == 'ai')) { - $this->ImageEps(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); - } - elseif ($imgtype == 'svg') { - $this->ImageSVG(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); - } - else { - $this->Image(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); - } - $imgy = $this->getImageRBY(); - } - else { - $imgy = $this->y; - } - $cell_height = round(($this->cell_height_ratio * $headerfont[2]) / $this->k, 2); - // set starting margin for text data cell - if ($this->getRTL()) { - $header_x = $this->original_rMargin + ($headerdata['logo_width'] * 1.1); - } - else { - $header_x = $this->original_lMargin + ($headerdata['logo_width'] * 1.1); - } - $cw = $this->w - $this->original_lMargin - $this->original_rMargin - ($headerdata['logo_width'] * 1.1); - $this->SetTextColor(0, 0, 0); - // header title - $this->SetFont($headerfont[0], 'B', $headerfont[2] + 1); - $this->SetX($header_x); - $this->Cell($cw, $cell_height, $headerdata['title'], 0, 1, '', 0, '', 0); - // header string - $this->SetFont($headerfont[0], $headerfont[1], $headerfont[2]); - $this->SetX($header_x); - $this->MultiCell($cw, $cell_height, $headerdata['string'], 0, '', 0, 1, '', '', true, 0, false); - // print an ending header line - //$this->SetLineStyle(array('width' => 0.85 / $this->k, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); - //$this->SetY((2.835 / $this->k) + max($imgy, $this->y)); - if ($this->rtl) { - $this->SetX($this->original_rMargin); - } - else { - $this->SetX($this->original_lMargin); - } - //$this->Cell(($this->w - $this->original_lMargin - $this->original_rMargin), 0, '', 'T', 0, 'C'); - $this->endTemplate(); - } - // print header template - $x = 0; - $dx = 0; - if ($this->booklet AND (($this->page % 2) == 0)) { - // adjust margins for booklet mode - $dx = ($this->original_lMargin - $this->original_rMargin); - } - if ($this->rtl) { - $x = $this->w + $dx; - } - else { - $x = 0 + $dx; - } - $this->printTemplate($this->header_xobjid, $x, 0, 0, 0, '', '', false); - } -} -$pdf = new Custom_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); -// set document information -$pdf->SetCreator(PDF_CREATOR); -$pdf->SetAuthor('bus.lambdacomplex.org'); -$pdf->SetTitle($stop[1]); -// set default header data -$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $stop[1] . " Timetable", "Some description of customization like Weekdays, 9am-10am"); -$pdf->set_QRCodeURL(curPageURL() . "stop.php?stopid=" . $_REQUEST['stopid']); -// set header and footer fonts -$pdf->setHeaderFont(Array( - PDF_FONT_NAME_MAIN, - '', - PDF_FONT_SIZE_MAIN -)); -$pdf->setFooterFont(Array( - PDF_FONT_NAME_DATA, - '', - PDF_FONT_SIZE_DATA -)); -// set default monospaced font -$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); -//set margins -$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); -$pdf->SetHeaderMargin(PDF_MARGIN_HEADER); -$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); -//set auto page breaks -$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); -//set image scale factor -$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); -//set some language-dependent strings -$pdf->setLanguageArray($l); -// --------------------------------------------------------- -// set default font subsetting mode -$pdf->setFontSubsetting(true); -// Set font -// dejavusans is a UTF-8 Unicode font, if you only need to -// print standard ASCII chars, you can use core fonts like -// helvetica or times to reduce file size. -$pdf->SetFont('helvetica', '', 14, '', true); -// Add a page -// This method has several options, check the source code documentation for more information. -$pdf->AddPage(); -// Print text using writeHTMLCell() -$pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true); -// --------------------------------------------------------- -// Close and output PDF document -// This method has several options, check the source code documentation for more information. -$pdf->Output('example_001.pdf', 'I'); -//============================================================+ -// END OF FILE -//============================================================+ -?> -