$l .= '<li><a href="/vacation/' . $app->escape($loc->area) . '/' . $app->escape($loc->slug) . '/">' . $app->escape($loc->title) . '</a></li> '; } return Page::display('Destinations found: <ul>' . $l . '</ul>'); }); // ... definitions $app->get('/vacation/{cont}/', function (App $app, $cont) { $locs = Location::where('area', $cont)->get(); $l = 'Destinations in this area: '; foreach ($locs as $loc) { $l .= '<li><a href="/vacation/' . $app->escape($loc->area) . '/' . $app->escape($loc->slug) . '/">' . $app->escape($loc->title) . '</a></li> '; } return Page::display('Destinations in this area: <ul>' . $l . '</ul> '); }); // ... definitions $app->get('/vacation/{cont}/{slug}/', function (App $app, $cont, $slug) { $loc = Location::where('slug', $slug)->where('area', $cont)->first(); $out = 'No such area found.'; if (null !== $loc) { assert((bool) $loc->title); $d = new DOMDocument(); $mock = new DOMDocument(); $d->loadHTML(file_get_contents(WWW . 'vacation/' . $cont . '/' . $slug . '.html')); $body = $d->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child) { $mock->appendChild($mock->importNode($child, true)); } $out = $mock->saveHTML(); } return Page::display(Page::additions() . $out); }); $app->run();
}); // ... definitions $app->get('/destinations/{cont}/{slug}/', function (App $app, $cont, $slug) { $loc = Location::where('slug', $slug)->where('area', $cont)->first(); $out = 'No such area found.'; if (null !== $loc) { assert((bool) $loc->title); $out = ' <div class="area"> <p>' . $loc->intro . '</p> <h1>' . $loc->title . '</h1> <img src="' . $loc->loc_image . '" class="loc-image" style="float:right;margin:0.7em;"> <p>' . $loc->description . '</p> <div> <div class="hotels"><i> List of hotels here </i> </div> <div class="map"> <i> Map here </i> </div> </div> <p>' . $loc->outro . '</p> </div> '; } return Page::display($out); }); $app->run();