Beispiel #1
0
 /**
  * @param $zip
  * @param $i
  */
 public function saveCollection(\ZipArchive $zip, &$i)
 {
     $this->currentNum = 0;
     $file = "sitemap-{$i}.xml";
     $this->index[] = $file;
     $this->currentCollection->setFormatter(new URLSet());
     $zip->addFromString($file, $this->currentCollection->output());
     $this->currentCollection = new Collection();
     $i++;
 }
Beispiel #2
0
// your application would be installed under http://demo.webservices.picturae.pro/mediabank/
$baseURL = 'http://demo.webservices.picturae.pro/mediabank/detail/';
$client = new Client($apiKey);
// This part should be cached to avoid the extra request
$rows = 100;
$result = $client->search(['rows' => $rows]);
$pages = $result->metadata->pagination->pages;
$currentPage = null;
if (isset($_GET['page'])) {
    $currentPage = (int) $_GET['page'];
}
$collection = new Collection();
if ($currentPage) {
    // Render the sitemap for the current page
    $result = $client->search(['rows' => $rows, 'page' => $currentPage]);
    foreach ($result->media as $media) {
        $basic = new SitemapEntry($baseURL . $media->id);
        $collection->addSitemap($basic);
    }
} else {
    // Render the sitemap with all other sitemap
    for ($index = 0; $index < $pages; $index++) {
        $basic = new SitemapEntry($url->getCurrentURL() . '?page=' . ($index + 1));
        $collection->addSitemap($basic);
    }
}
$collection->setFormatter(new URLSet());
$collection->setFormatter(new SitemapIndex());
header("Content-type: text/xml; charset=utf-8");
echo $collection->output();