]> _ Git - cubist_cms-back.git/commitdiff
fix #3514 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 19 Mar 2020 16:15:59 +0000 (17:15 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 19 Mar 2020 16:15:59 +0000 (17:15 +0100)
src/app/Http/Controllers/CubistSEOController.php
src/app/Magic/PageData.php

index 973ae3e12a9da8aa965742497f794aceae71495c..d871549e6ff2f6ba4e603d0e94348d5442867ee9 100644 (file)
@@ -7,16 +7,17 @@ namespace Cubist\Backpack\app\Http\Controllers;
 use Cubist\Backpack\app\Magic\Menu\Menu;
 use Cubist\Backpack\app\Magic\Menu\PageItem;
 use Cubist\Backpack\app\Magic\Models\Locale;
+use Cubist\Backpack\app\Magic\Models\Settings;
 use Illuminate\Http\Request;
 
 class CubistSEOController extends CubistFrontController
 {
-    protected function isRobotsEnabled()
+    public static function isRobotsEnabled()
     {
         if (!config('cubist.seo_robots', true)) {
             return false;
         }
-        $robots = $this->data['global']->get('robots');
+        $robots = Settings::getData()->get('robots');
         if (null === $robots) {
             return false;
         }
@@ -27,7 +28,7 @@ class CubistSEOController extends CubistFrontController
     {
         $response = ['User-agent: *'];
 
-        if (!$this->isRobotsEnabled()) {
+        if (!self::isRobotsEnabled()) {
             $response[] = 'Disallow: /';
         } else {
             $response[] = 'Disallow: /admin/';
@@ -43,7 +44,7 @@ class CubistSEOController extends CubistFrontController
 
         $res = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $res .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">' . "\n";
-        if ($this->isRobotsEnabled()) {
+        if (self::isRobotsEnabled()) {
             $pages = Menu::getAllNavigablePages();
             foreach ($pages as $url => $page) {
                 if ($page instanceof PageItem && !$page->isRobots()) {
index ef1334a1c27901107af9b81621096d0597b3bc8f..120bc11a99baeddeaed6c6e986553c1466453e72 100644 (file)
@@ -3,6 +3,7 @@
 
 namespace Cubist\Backpack\app\Magic;
 
+use Cubist\Backpack\app\Http\Controllers\CubistSEOController;
 use Cubist\Backpack\app\Magic\Models\Settings;
 
 class PageData extends EntityData
@@ -32,7 +33,7 @@ class PageData extends EntityData
     public function getSocialImage()
     {
         $settings = Settings::getData();
-        $image = $this->getImageURL('social_image','', $settings->getImageURL('social_image'));
+        $image = $this->getImageURL('social_image', '', $settings->getImageURL('social_image'));
 
         if (!$image) {
             return null;
@@ -43,7 +44,7 @@ class PageData extends EntityData
 
     public function getRobots()
     {
-        return ($this->get('robots', true) && config('cubist.seo_robots', true))
+        return ($this->get('robots', true) && CubistSEOController::isRobotsEnabled())
             ? 'index,follow' : 'noindex,nofollow';
     }
 }