/**
    @param $station<Station>
*/
function createStationTableRow($station, $marker_img, $class_name)
{
    global $website;
    $station_marker = $station->marker;
    $station_name = $station_marker->name;
    $marker_link = new MarkerLink($station_marker->getLat(), $station_marker->getLng(), new Image("images/{$marker_img}", 0));
    #echo $marker_link->toString() . "<br/>";
    $station_row = new Row($station_name, $class_name);
    //$station_cell = new Cell(null, null, null, $marker_link);
    #echo $station_cell->toString();
    #$station_row->addCell($station_cell);
    $station_row->addCell(new Cell(null, "stationMarkerLink", "text-align: center", $marker_link));
    $station_row->addCell(new Cell("stationName", $station_name));
    $lines_cell = new Cell("stationLines");
    $lines = $station_marker->getLines();
    foreach ($lines as $line) {
        foreach ($line->getConnections() as $connection) {
            if ($connection->type != "transfer") {
                $line_img = $line->img;
                $line_url = $website . $line->url;
                $link = new Link("javascript:void(0);", new Image(null, null, "images/{$line_img}", $line->name, null, 20), "window.open('{$line_url}');");
                //echo $link->toString();
                $lines_cell->addData($link);
                break;
            }
        }
    }
    $station_row->addCell($lines_cell);
    #echo "<!--" . $station_row->toString() . "-->";
    return $station_row;
}
 /**
  * Add cell
  */
 public function testAddCell()
 {
     $oRow = new Row();
     $element = $oRow->addCell();
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Cell', $element);
     $this->assertCount(1, $oRow->getCells());
 }
Пример #3
0
 public function addMatrix($arr)
 {
     foreach ($arr as $rowCtn) {
         $row = new Row();
         foreach ($rowCtn as $cellCtn) {
             $cell = new Cell($cellCtn);
             $row->addCell($cell);
         }
         $this->addRow($row);
     }
 }
Пример #4
0
$start_zoom = 12;
$location_marker = "mm_20_yellow.png";
$station_marker_img = "mm_20_blue.png";
$transfer_marker_img = "mm_20_orange.png";
$start_marker_img = "mm_20_green.png";
$end_marker_img = "mm_20_red.png";
$WALKING_SPEED = 2 / 3600;
$debug = false;
$logging = false;
$current_url = $_SERVER['PHP_SELF'];
$slogan = getSlogan();
$linksTable = new Table("linkstable");
$homeCell = new Cell("link", new Link("/", "home"));
$aboutCell = new Cell("link", new Link("/about.php", "about"));
$linksRow = new Row();
$linksRow->addCell($homeCell);
$linksRow->addCell($aboutCell);
$linksTable->addRow($linksRow);
$linksDiv = new Div("about", "noselect", null, $linksTable);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <meta name="Description" content="<?php 
echo $description;
?>
" />
    <meta name="Keywords" content="<?php 
echo $keywords;
?>
" />
Пример #5
0
/**
    Displays the station choices for choosing alternate stations when using direction finding.
    
    @param $url<String> the URL for the form
    @param $start_location<Location> the starting point for the search
    @param $end_location<Location> the ending point for the search
    @param $path_array[]<Segment> the path found in the original search
*/
function displayStationChoices($url, $start_location, $end_location, $path_array)
{
    global $website, $station_marker_img;
    $debug = false;
    if ($debug) {
        echo $start_location->desc . " to " . $end_location->desc . "<br/>";
    }
    // list alternate start stations
    $start_table = new Table(null, "choicetable");
    $div = new Div("alternate_choices", "<b>Start Station Choices</b><br/>\n");
    $div->addDataElement($start_table);
    $div->addDataElement("<br/>\n");
    $header_row = new Row(null, "header_row");
    $header_row->addCell(new Cell("header_cell", "Show"));
    $header_row->addCell(new Cell("header_cell", "Station Name"));
    $header_row->addCell(new Cell("header_cell", "Subway Lines"));
    $header_row->addCell(new Cell("header_cell"));
    $start_table->addRow($header_row);
    $start_stations = findNearestStations2($start_location);
    $start_station_marker = $path_array[0]->m2;
    if ($debug) {
        echo "start_station_marker->id = " . $start_station_marker->id . "<br/>";
    }
    $i = 0;
    foreach ($start_stations as $station) {
        $station_marker = $station->marker;
        $station_lng = $station_marker->getLng();
        $station_lat = $station_marker->getLat();
        if (isEven($i)) {
            $class_name = "rowHighlight";
        } else {
            $class_name = "row";
        }
        $station_row = new Row($station_marker->id, $class_name);
        // station marker link
        $station_row->addCell(new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$station_lat},{$station_lng}), map.getZoom());", new Image("images/{$station_marker_img}", "0"))));
        $station_row->addCell(new Cell("instruction", $station_marker->name));
        // build lines cell
        $lines = $station_marker->getLines();
        $lines_cell = new Cell("instruction");
        foreach ($lines as $line) {
            $line_img = $line->img;
            $line_url = $website . $line->url;
            $lines_cell->addData(new Link("javascript:void(0);", new Image(null, "images/{$line_img}", $line->name, null, "20"), "window.open('{$line_url}');"));
        }
        $station_row->addCell($lines_cell);
        if ($start_station_marker->id == $station_marker->id) {
            $cell_data = "<input type=\"radio\" name=\"start\" value=\"{$station_marker->id}\" checked=\"true\"/>";
        } else {
            $cell_data = "<input type=\"radio\" name=\"start\" value=\"{$station_marker->id}\" />";
        }
        $station_row->addCell(new Cell("step_cell", $cell_data));
        $start_table->addRow($station_row);
        $i++;
    }
    // list alternate end stations
    $div->addDataElement("<b>End Station Choices</b><br/>\n");
    $end_table = new Table(null, "choicetable");
    $div->addDataElement($end_table);
    $end_table->addRow($header_row);
    $end_stations = findNearestStations2($end_location);
    $end_station_marker = $path_array[count($path_array) - 1]->m1;
    if ($debug) {
        echo "end_station_marker->id = " . $end_station_marker->id . "<br/>";
    }
    $i = 0;
    foreach ($end_stations as $station) {
        $station_marker = $station->marker;
        $station_lng = $station_marker->getLng();
        $station_lat = $station_marker->getLat();
        if (isEven($i)) {
            $class_name = "rowHighlight";
        } else {
            $class_name = "row";
        }
        $station_row = new Row($station_marker->id, $class_name);
        // station marker link
        $station_row->addCell(new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$station_lat},{$station_lng}), map.getZoom());", new Image("images/{$station_marker_img}", "0"))));
        $station_row->addCell(new Cell("instruction", $station_marker->name));
        // build lines cell
        $lines = $station_marker->getLines();
        $lines_cell = new Cell("instruction");
        foreach ($lines as $line) {
            $line_img = $line->img;
            $line_url = $website . $line->url;
            $lines_cell->addData(new Link("javascript:void(0);", new Image(null, "images/{$line_img}", $line->name, null, "20"), "window.open('{$line_url}');"));
        }
        $station_row->addCell($lines_cell);
        if ($end_station_marker->id == $station_marker->id) {
            $cell_data = "<input type=\"radio\" name=\"end\" value=\"{$station_marker->id}\" checked=\"true\"/>";
        } else {
            $cell_data = "<input type=\"radio\" name=\"end\" value=\"{$station_marker->id}\" />";
        }
        $station_row->addCell(new Cell("step_cell", $cell_data));
        $end_table->addRow($station_row);
        $i++;
    }
    echo "<form id=\"form_pick\" action=\"{$url}\" method=\"get\">\n";
    echo $div->toString();
    echo "<input type=\"hidden\" name=\"type\" value=\"dir_alt\" />\n";
    echo "<input type=\"hidden\" name=\"sa\" value=\"" . $start_location->getAddressString() . "\" />\n";
    echo "<input type=\"hidden\" name=\"da\" value=\"" . $end_location->getAddressString() . "\" />\n";
    echo "<br/>\n";
    #echo "<input type=\"image\" name=\"submit\" src=\"images/usebutton.png\">\n";
    echo "<div id=\"usebutton\"><input class=\"btn\" type=\"submit\" id=\"submit\" value=\"Use\"></div>\n";
    echo "</form>";
}
/**
    This method displays the path instructions on the left side of the screen.
    
    @param $path<array[Segment]> the path found by the algorithm
*/
function printPath($path, $path_time)
{
    global $website;
    $debug = false;
    $count = count($path);
    if ($debug) {
        echo "[display_functions.php:printPath()]<br/>\n";
        echo "path count = {$count}<br/>\n";
        if ($count > 1) {
            print_r($path);
        } else {
            echo "path = {$path}<br/>";
        }
    }
    $old_lines = null;
    if ($count > 0) {
        // print consolidated path
        $directions_table = new Table(null, "info_table");
        $header_row = new Row(null, "header_row");
        $directions_table->addRow($header_row);
        $header_row->addCell(new Cell("header_cell", "Step"));
        $header_row->addCell(new Cell("header_cell", "Instructions"));
        $header_row->addCell(new Cell("header_cell", "Time"));
        for ($x = 0; $x < $count; $x++) {
            // create the row object
            if (isEven($x)) {
                $row_class = "rowHighlight";
            } else {
                $row_class = "row";
            }
            $row = new Row(null, $row_class);
            $y = $x + 1;
            // grab the segment and all its variables
            $segment = $path[$x];
            if ($debug) {
                echo $segment . "<br/>";
                echo "segment = " . $segment->toString() . "<br/>";
            }
            $marker = $segment->m1;
            $m1_name = $marker->name;
            $m1lat = $marker->getLat();
            $m1lng = $marker->getLng();
            $m2_name = $segment->m2->name;
            $connection = $segment->connection;
            $step_cell = new Cell("step_cell", new Link("javascript:focusOn(new GLatLng({$m1lat},{$m1lng}), map.getZoom());", "[ {$y} ]"));
            $instruction_cell = new Cell("instruction");
            $rawTime = $segment->t;
            $time_cell = new Cell("step_cell", getTimeString($rawTime));
            if ($connection == "walking") {
                $instruction_cell->addData("Walk from <b>{$m1_name}</b> to <b>{$m2_name}</b>.");
            } else {
                if ($connection == "transfer") {
                    $lines = $segment->lines;
                    $from_string = "";
                    $to_string = "";
                    for ($i = 0; $i < count($old_lines); $i++) {
                        $from_string .= "<img width=\"20\" src=\"images/" . $old_lines[$i]->img . "\"/>";
                    }
                    for ($i = 0; $i < count($lines); $i++) {
                        $to_string .= "<img width=\"20\" src=\"images/" . $lines[$i]->img . "\"/>";
                    }
                    $instruction_cell->addData("Transfer from <b>{$m1_name}</b> {$from_string} to <b>{$m2_name}</b> {$to_string}");
                } else {
                    // this is a regular segment
                    $output_string = "Take ";
                    $lines = $segment->lines;
                    for ($i = 0; $i < count($lines); $i++) {
                        $output_string .= "<a href=\"javascript:void(0);\" onclick=\"window.open('{$website}" . $lines[$i]->url . "');\"><img width=\"20\" src=\"images/" . $lines[$i]->img . "\"/></a>";
                    }
                    $output_string .= " from <b>{$m1_name}</b> to <b>{$m2_name}</b>.";
                    $instruction_cell->addData($output_string);
                    $old_lines = $lines;
                }
            }
            $row->addCell($step_cell);
            $row->addCell($instruction_cell);
            $row->addCell($time_cell);
            $directions_table->addRow($row);
        }
        $row = new Row(null, "total_row");
        $row->addCell(new Cell(null, ""));
        $row->addCell(new Cell("total", "Total Time:"));
        $row->addCell(new Cell("total_time", getTimeString($path_time)));
        $directions_table->addRow($row);
        echo $directions_table->toString();
    } else {
        echo "Sorry. No path found.<br/>\n";
    }
}
Пример #7
0
 /**
  * @param Row   $row
  * @param array $cells
  *
  * @return Row
  */
 public static function populateRow(Row $row, array $cells)
 {
     foreach ($cells as $name => $cell) {
         $name = is_numeric($name) ? null : $name;
         $cell = self::buildCell($cell, $name);
         $row->addCell($cell);
     }
     return $row;
 }