From: Vincent Vanwaelscappel Date: Thu, 19 Mar 2020 16:15:59 +0000 (+0100) Subject: fix #3514 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=0ac6353e6ac8157d279ac186635541f5697daeec;p=cubist_cms-back.git fix #3514 @0.5 --- diff --git a/src/app/Http/Controllers/CubistSEOController.php b/src/app/Http/Controllers/CubistSEOController.php index 973ae3e..d871549 100644 --- a/src/app/Http/Controllers/CubistSEOController.php +++ b/src/app/Http/Controllers/CubistSEOController.php @@ -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 = '' . "\n"; $res .= '' . "\n"; - if ($this->isRobotsEnabled()) { + if (self::isRobotsEnabled()) { $pages = Menu::getAllNavigablePages(); foreach ($pages as $url => $page) { if ($page instanceof PageItem && !$page->isRobots()) { diff --git a/src/app/Magic/PageData.php b/src/app/Magic/PageData.php index ef1334a..120bc11 100644 --- a/src/app/Magic/PageData.php +++ b/src/app/Magic/PageData.php @@ -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'; } }