public function testCurrentURL() { $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['REQUEST_URI'] = '/deeds/0000b26c-76e8-0b20-9ebf-b9bb1776eae5'; $url = new \Picturae\Genealogy\URL(); $this->assertEquals('http://example.com/deeds/0000b26c-76e8-0b20-9ebf-b9bb1776eae5', $url->getCurrentURL()); }
<?php require_once 'vendor/autoload.php'; $url = new Picturae\Genealogy\URL(); $link = $url->getCurrentURL(); // Change to your API key $apiKey = '509544d0-1c67-11e4-9016-c788dee409dc'; // Your base url for the genealogy application (note the deeds at the end is to link directly to the deed) // your application would be installed under http://demo.webservices.picturae.pro/genealogie/ $baseURL = 'http://demo.webservices.picturae.pro/genealogie/deeds/'; $client = new Picturae\Genealogy\Client($apiKey); // This part should be cached to avoid the extra request $deedsCount = 100; $result = $client->getDeeds(['rows' => $deedsCount]); $pages = $result->metadata->pagination->pages; $currentPage = null; if (isset($_GET['page'])) { $currentPage = (int) $_GET['page']; } $collection = new \Sitemap\Collection(); if ($currentPage) { // Render the sitemap for the current page $result = $client->getDeeds(['rows' => $deedsCount, 'page' => $currentPage]); foreach ($result->deeds as $deed) { $basic = new \Sitemap\Sitemap\SitemapEntry($baseURL . $deed->id); $collection->addSitemap($basic); } } else { // Render the sitemap with all other sitemap for ($index = 0; $index < $pages; $index++) { $basic = new \Sitemap\Sitemap\SitemapEntry($url->getCurrentURL() . '?page=' . ($index + 1));