コード例 #1
0
$dropdown = new DropDown('routeID', Route::GetAllRoutes());
$form = new Form();
$form->Add($dropdown);
$form->Add(new SubmitButton());
echo $form->ToString();
if (isset($_POST['routeID'])) {
    /* adding a direction */
    echo '<hr />';
    $route_id = $_POST['routeID'];
    $dir = $_POST['direction'];
    $descr = $_POST['description'];
    $stops = explode(',', $_POST['stops']);
    echo 'adding direction ' . $descr . ' to route ' . $route_id;
    $new_dir = new Direction($route_id, $dir, $descr);
    $new_dir->WriteToDatabase();
    echo '<p>route direction created as ID ' . $new_dir->GetID() . ', adding stops... ';
    $sequence = 0;
    foreach ($stops as $stopValue) {
        $stop = trim($stopValue);
        $new_dir->AddStop($stop, $sequence);
        $sequence++;
    }
    echo $sequence . ' stops added.</p>';
    echo '<hr/>';
}
if (isset($_GET['routeID'])) {
    $route = new Route(false, false, $_GET['routeID']);
    echo '<p>Route: ' . $route->short_name . ' ' . $route->long_name;
    $route_directions = $route->GetDirections();
    if (count($route_directions) > 0) {
        echo '<blockquote><p>Existing directions (editing not currently supported)';