Beispiel #1
0
     }
 }
 // Register the file handlers
 if (Options::hasFeature('FILES')) {
     $app->routes->add('/files/preview/*', ['BearCMS\\Internal\\Controller', 'handleFilePreview']);
     $app->routes->add('/files/download/*', ['BearCMS\\Internal\\Controller', 'handleFileDownload']);
 }
 // Register some other pages
 $app->routes->add('/rss.xml', ['BearCMS\\Internal\\Controller', 'handleRSS']);
 $app->routes->add('/sitemap.xml', ['BearCMS\\Internal\\Controller', 'handleSitemap']);
 $app->routes->add('/robots.txt', ['BearCMS\\Internal\\Controller', 'handleRobots']);
 // Register the blog posts page handlers
 if (Options::hasFeature('BLOG')) {
     $app->routes->add(Options::$blogPagesPathPrefix . '?/', function () use($app) {
         $slug = (string) $app->request->path[1];
         $slugsList = InternalData\Blog::getSlugsList('published');
         $blogPostID = array_search($slug, $slugsList);
         if ($blogPostID === false && substr($slug, 0, 6) === 'draft-' && (Options::hasFeature('USERS') || Options::hasFeature('USERS_LOGIN_*')) && $app->bearCMS->currentUser->exists()) {
             $blogPost = $app->bearCMS->data->blog->getPost(substr($slug, 6));
             if ($blogPost !== null) {
                 $blogPostID = $blogPost['id'];
             }
         }
         if ($blogPostID !== false) {
             $blogPost = $app->bearCMS->data->blog->getPost($blogPostID);
             $content = '<div class="bearcms-blogpost-page-title-container"><h1 class="bearcms-blogpost-page-title">' . htmlspecialchars($blogPost['title']) . '</h1></div>';
             $content .= '<div class="bearcms-blogpost-page-date-container"><div class="bearcms-blogpost-page-date">' . ($blogPost['status'] === 'published' ? date('F j, Y', $blogPost['publishedTime']) : 'draft') . '</div></div>';
             $content .= '<div class="bearcms-blogpost-page-content"><component src="bearcms-elements" id="bearcms-blogpost-' . $blogPostID . '"/></div>';
             $response = new App\Response\HTML($content);
             $response->enableBearCMS = true;
             $response->applyBearCMSTheme = true;
 static function handleSitemap()
 {
     $app = App::$instance;
     $urls = [];
     $baseUrl = $app->request->base;
     $addUrl = function ($path) use(&$urls, $baseUrl) {
         $urls[] = '<url><loc>' . $baseUrl . $path . '</loc></url>';
     };
     $addUrl('/');
     $list = \BearCMS\Internal\Data\Pages::getPathsList('published');
     foreach ($list as $path) {
         $addUrl($path);
     }
     $list = \BearCMS\Internal\Data\Blog::getSlugsList('published');
     foreach ($list as $slug) {
         $addUrl(Options::$blogPagesPathPrefix . $slug . '/');
     }
     $response = new App\Response('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . implode('', $urls) . '</urlset>');
     $response->setContentType('text/xml');
     return $response;
 }