62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Gallery;
|
|
|
|
use App\Album;
|
|
use App\Facade\Theme;
|
|
use App\Facade\UserConfig;
|
|
use App\Helpers\DbHelper;
|
|
use App\Http\Controllers\Controller;
|
|
use App\VisitorHit;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class DefaultController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$albums = DbHelper::getAlbumsForCurrentUser(0);
|
|
$resetStatus = $request->session()->get('status');
|
|
|
|
// Record the visit to the index (no album or photo to record a hit against though)
|
|
if (UserConfig::get('enable_visitor_hits'))
|
|
{
|
|
DB::transaction(function () use ($request)
|
|
{
|
|
VisitorHit::fromRequest($request);
|
|
});
|
|
}
|
|
|
|
return Theme::render('gallery.index', [
|
|
'albums' => $albums,
|
|
'info' => $request->session()->get('info'),
|
|
'success' => $resetStatus
|
|
]);
|
|
}
|
|
|
|
public function sitemapXml()
|
|
{
|
|
$xml = new \DOMDocument('1.0', 'UTF-8');
|
|
$xml->preserveWhiteSpace = true;
|
|
$xml->formatOutput = true;
|
|
|
|
$root = $xml->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');
|
|
$xml->appendChild($root);
|
|
|
|
// Root URL
|
|
$this->createSitemapNode($xml, $root, route('home'));
|
|
|
|
return response($xml->saveXML(), 200, ['Content-Type' => 'text/xml']);
|
|
}
|
|
|
|
private function createSitemapNode(\DOMDocument $document, \DOMElement $parentElement, $url)
|
|
{
|
|
$urlElement = $document->createElement('url');
|
|
$urlLocElement = $document->createElement('loc', $url);
|
|
$urlElement->appendChild($urlLocElement);
|
|
$parentElement->appendChild($urlElement);
|
|
|
|
return $urlElement;
|
|
}
|
|
} |