openURI('php://output'); $xmlWriter->startDocument('1.0', 'UTF-8'); $xmlWriter->setIndent(true); { $xmlWriter->startElement('urlset'); { $xmlWriter->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); foreach ($this->iterateTables() as $entry) { $xmlWriter->startElement('url'); $xmlWriter->writeElement('loc', $entry->url); if (isset($entry->priority)) { $xmlWriter->writeElement('priority', $entry->priority); } if (isset($entry->changefreq)) { $xmlWriter->writeElement('changefreq', $entry->changefreq); } if (isset($entry->lastmodified)) { $xmlWriter->writeElement('lastmod', $entry->lastmodified->format(\DateTime::W3C)); } $xmlWriter->endElement(); } } $xmlWriter->endElement(); } $xmlWriter->endDocument(); } private function iterateTables() { $prio_info = .9; $prio_user = .8; $prio_table = .6; $prio_table_rev = .5; $prio_misc = .5; yield (object)[ 'url' => route('dash'), 'priority' => 1, ]; yield (object)[ 'url' => route('terms'), 'priority' => $prio_info, ]; yield (object)[ 'url' => route('faq'), 'priority' => $prio_info, ]; yield (object)[ 'url' => route('donate'), 'priority' => $prio_info, ]; yield (object)[ 'url' => route('privacy'), 'priority' => $prio_info, ]; yield (object)[ 'url' => route('login'), 'priority' => $prio_misc, ]; yield (object)[ 'url' => route('register'), 'priority' => $prio_misc, ]; foreach (User::all() as $user) { yield (object)[ 'url' => route('profile.view', $user->name), 'lastmodified' => $user->updated_at, 'priority' => $prio_user, ]; } foreach (Table::all() as $table) { yield (object)[ 'url' => $table->viewRoute, 'lastmodified' => $table->updated_at, 'priority' => $prio_table, ]; yield (object)[ 'url' => $table->revisionsRoute, 'lastmodified' => $table->updated_at, 'priority' => $prio_table_rev, ]; } } }