function toString()
 {
     $result = parent::toString();
     $use_index_hint = '';
     $force_index_hint = '';
     $ignore_index_hint = '';
     foreach ($this->index_hints_list as $index_hint) {
         $index_hint_type = $index_hint->getIndexHintType();
         if ($index_hint_type == 'USE') {
             $use_index_hint .= $index_hint->getIndexName() . ', ';
         } else {
             if ($index_hint_type == 'FORCE') {
                 $force_index_hint .= $index_hint->getIndexName() . ', ';
             } else {
                 if ($index_hint_type == 'IGNORE') {
                     $ignore_index_hint .= $index_hint->getIndexName() . ', ';
                 }
             }
         }
     }
     if ($use_index_hint != '') {
         $result .= ' USE INDEX (' . substr($use_index_hint, 0, -2) . ') ';
     }
     if ($force_index_hint != '') {
         $result .= ' FORCE INDEX (' . substr($force_index_hint, 0, -2) . ') ';
     }
     if ($ignore_index_hint != '') {
         $result .= ' IGNORE INDEX (' . substr($ignore_index_hint, 0, -2) . ') ';
     }
     return $result;
 }
 function toString()
 {
     $result = parent::toString();
     $index_hint_string = '';
     $indexTypeList = array('USE' => 1, 'FORCE' => 1);
     foreach ($this->index_hints_list as $index_hint) {
         $index_hint_type = $index_hint->getIndexHintType();
         if (isset($indexTypeList[$index_hint_type])) {
             $index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
         }
     }
     if ($index_hint_string != '') {
         $result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
     }
     return $result;
 }
Example #3
0
                 } else {
                     $l = $_GET['l'];
                 }
             }
             $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", "<b>Directions</b>"));
             $header_row->addCell(new Cell("header_cell", ""));
             $choices_row = new Row(null, "stationRow");
             $directions_table->addRow($choices_row);
             $choices_row->addCell(new Cell("choice", "<a href=\"javascript:void(0)\" onclick=\"return _gd('to', '{$l}')\"><img src=\"images/{$start_marker_img}\"/> To {$l}</a>"));
             //$choices_row = new Row(null, "stationRowHighlight");
             //$directions_table->addRow($choices_row);
             $choices_row->addCell(new Cell("choice", "<a href=\"javascript:void(0)\" onclick=\"return _gd('from', '{$l}')\"><img src=\"images/{$end_marker_img}\"/> From {$l}</a>"));
             echo $directions_table->toString();
             #echo "Directions: [<a href=\"javascript:void(0)\" onclick=\"return _gd('to', '$l')\">To Here</a>] [<a href=\"javascript:void(0)\" onclick=\"return _gd('from', '$l')\">From Here</a>]\n";
         } else {
             echo "Sorry. Address could not be found. Make sure that it is a valid postal address, not a vanity address.<br/>\n";
         }
     }
 } else {
     if ($type == 'dir' || $type == 'dir_alt') {
         if (count($starts) == 1 && count($ends) == 1) {
             echo "Start Address:<br/>\n";
             $loc = $starts[0];
             $start_loc = $loc->name;
             //printAddress($loc, $saddr, $start_marker_img);
             printAddress2($loc, $start_marker_img);
             echo "<br/>\n";
             echo "End Address:<br/>\n";
/**
    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";
    }
}
Example #5
0
 /**
  * @param string $delimiter
  * @param int $colSize
  * @return string
  */
 public function toStringWithHeader($delimiter = "\t", $colSize = 0)
 {
     $string = "";
     foreach ($this->header as $name) {
         $string .= str_pad($name, $colSize) . $delimiter;
     }
     $string .= "\n";
     return $string . parent::toString($delimiter, $colSize);
 }
Example #6
0
 public function testToString()
 {
     $this->assertEquals('"xe_member" as "m"', $this->object->toString());
 }