-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
55 lines (40 loc) · 1.62 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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));
$collection->addSitemap($basic);
}
}
$collection->setFormatter(new \Sitemap\Formatter\XML\URLSet);
$collection->setFormatter(new \Sitemap\Formatter\XML\SitemapIndex);
header("Content-type: text/xml; charset=utf-8");
echo $collection->output();