Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $basic = new \Sitemap\Sitemap\SitemapEntry('http://magehero.com/');
     $basic->setLastMod(time());
     $collection = new \Sitemap\Collection();
     $collection->addSitemap($basic);
     // Add User Profiles
     $select = $this->_getContainer()->User()->selectAll();
     $userRows = $this->_getContainer()->LocalConfig()->database()->fetchAll($select);
     foreach ($userRows as $userRow) {
         $userModel = $this->_getContainer()->User()->setData($userRow);
         $userEntry = new \Sitemap\Sitemap\SitemapEntry($userModel->getUrl());
         $userEntry->setLastMod($userModel->getUpdatedAt());
         $userEntry->setChangeFreq(\Sitemap\Sitemap\SitemapEntry::CHANGEFREQ_DAILY);
         $collection->addSitemap($userEntry);
     }
     // Add Posts
     $select = $this->_getContainer()->Post()->selectAll()->where('posts.is_active = 1');
     $postRows = $this->_getContainer()->LocalConfig()->database()->fetchAll($select);
     foreach ($postRows as $postRow) {
         $postModel = $this->_getContainer()->Post()->setData($postRow);
         $postEntry = new \Sitemap\Sitemap\SitemapEntry($postModel->getUrl());
         $postEntry->setLastMod($postModel->getUpdatedAt());
         $postEntry->setChangeFreq(\Sitemap\Sitemap\SitemapEntry::CHANGEFREQ_WEEKLY);
         $collection->addSitemap($postEntry);
     }
     // There's some different formatters available.
     $collection->setFormatter(new \Sitemap\Formatter\XML\URLSet());
     file_put_contents('sitemap.xml', $collection->output());
 }
Example #2
0
$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());
 /**
  * Returns scanned url links in sitemap xml standard.
  * @return mixed
  */
 public function getSitemapContent()
 {
     $urls = $this->getFoundUrls();
     $collection = new \Sitemap\Collection();
     foreach ($urls as $url) {
         $entry = new \Sitemap\Sitemap\SitemapEntry();
         $entry->setLocation($url);
         //$entry->setLastMod(time());
         $collection->addSitemap($entry);
     }
     // There's some different formatters available.
     $collection->setFormatter(new \Sitemap\Formatter\XML\URLSet());
     return $collection->output();
 }