createFromUrl(GEORSS);
if (intval($_GET["test"]) == 1) {
echo "
";
echo "Read GeoRSS at: " . GEORSS . "
";
if (is_null($geoRss)) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct RSS class
$success = true;
echo "
";
echo "Class should be: " . CLASSNAME . "
";
echo "Class is: " . get_class($geoRss) . "
";
if (get_class($geoRss) !== CLASSNAME) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct title
$success = true;
echo "
";
echo "Title should be: " . TITLE . "
";
echo "Title is: " . $geoRss->channel_title . "
";
if ($geoRss->channel_title !== TITLE) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct description
$success = true;
echo "
";
echo "Description should be: " . DESCRIPTION . "
";
echo "Description is: " . $geoRss->channel_description . "
";
if ($geoRss->channel_description !== DESCRIPTION) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct URL
$success = true;
echo "
";
echo "URL should be: " . URL . "
";
echo "URL is: " . htmlentities($geoRss->channel_url, ENT_QUOTES, CHARSET) . "
";
if (htmlentities($geoRss->channel_url, ENT_QUOTES, CHARSET) !== URL) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct bbox
$success = true;
echo "
";
echo "Bounding box of item #3 should be: " . BBOX . "
";
$box = $geoRss->getItem(2)->getBbox();
$boxString =
$box->min->x . " " . $box->min->y . " " .
$box->max->x . " " . $box->max->y;
echo "Bounding box of item #3 is: " . $boxString . "
";
if ($boxString !== BBOX) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// create RSS at
$success = true;
echo "
";
$aSecondRssFactory = new RssFactory();
$randomRss = str_replace(".xml", "_" . rand() . ".xml", RANDOM_GEORSS);
echo "Create random GeoRSS at: " . $randomRss . "
";
$anotherRss = $aSecondRssFactory->createAt($randomRss);
if (is_null($anotherRss)) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// create RSS from URL
$success = true;
echo "
";
$yetAnotherRss = $someRssFactory->createFromUrl($randomRss);
echo "Random RSS should be of type: Rss
";
echo "Random RSS is of type: " . get_class($yetAnotherRss) . "
";
if (get_class($yetAnotherRss) !== "Rss") {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// create GeoRSS at
$success = true;
echo "
";
$anotherRssFactory = new GeoRssFactory();
$randomGeoRss = str_replace(".xml", "_" . rand() . ".xml", RANDOM_GEORSS);
echo "Create random GeoRSS at: " . $randomGeoRss . "
";
$anotherGeoRss = $anotherRssFactory->createAt($randomGeoRss);
if (is_null($anotherGeoRss)) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// create GeoRSS from URL
$success = true;
echo "
";
$yetAnotherGeoRss = $someRssFactory->createFromUrl($randomGeoRss);
echo "Random GeoRSS should be of type: GeoRss
";
echo "Random GeoRSS is of type: " . get_class($yetAnotherGeoRss) . "
";
if (get_class($yetAnotherGeoRss) !== "GeoRss") {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// append item to GeoRSS
$success = true;
echo "
";
echo "Save random GeoRSS
";
$yetAnotherGeoRss->setTitle("testTitel");
$yetAnotherGeoRss->setDescription("testDescription");
$yetAnotherGeoRss->setUrl("testUrl");
$item = $yetAnotherGeoRss->append();
$item->setBbox(new Mapbender_bbox(8,49,9,50,"EPSG:4326"));
$success = $yetAnotherGeoRss->saveAsFile();
if ($success) {
echo "OK :-)";
}
else {
$success = false;
echo "FAIL :-(";
die;
}
// reload random GeoRSS
$success = true;
echo "
";
echo "Reload random GeoRSS
";
$reloadedRss = $someRssFactory->createFromUrl($randomGeoRss);
if (is_null($reloadedRss)) {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct title
$success = true;
echo "
";
echo "Title should be: testTitel
";
echo "Title is: " . $reloadedRss->channel_title . "
";
if ($reloadedRss->channel_title !== "testTitel") {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct description
$success = true;
echo "
";
echo "Description should be: testDescription
";
echo "Description is: " . $reloadedRss->channel_description . "
";
if ($reloadedRss->channel_description !== "testDescription") {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct URL
$success = true;
echo "
";
echo "URL should be: testUrl
";
echo "URL is: " . htmlentities($reloadedRss->channel_url, ENT_QUOTES, CHARSET) . "
";
if (htmlentities($reloadedRss->channel_url, ENT_QUOTES, CHARSET) !== "testUrl") {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
// correct bbox
$success = true;
echo "
";
echo "Bounding box of item #3 should be: 8 49 9 50
";
$box = $reloadedRss->getItem(0)->getBbox();
$boxString =
$box->min->x . " " . $box->min->y . " " .
$box->max->x . " " . $box->max->y;
echo "Bounding box of item #3 is: " . $boxString . "
";
if ($boxString !== "8 49 9 50") {
$success = false;
echo "FAIL :-(";
die;
}
echo "OK :-)";
}
else {
header("Content-type:application/xml");
echo $geoRss;
}
?>