From: Vincent Vanwaelscappel Date: Fri, 13 Dec 2019 17:13:35 +0000 (+0100) Subject: wip #3262 @0.75 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=37cde048387f80db2ee95e9b68921d36bcc6cb08;p=cubist_cms-back.git wip #3262 @0.75 --- diff --git a/src/app/Console/Commands/LocaleSlugReset.php b/src/app/Console/Commands/LocaleSlugReset.php index 8cf3c14..31cb732 100644 --- a/src/app/Console/Commands/LocaleSlugReset.php +++ b/src/app/Console/Commands/LocaleSlugReset.php @@ -23,7 +23,7 @@ class LocaleSlugReset extends CubistCommand public function handle() { - //$this->call('backup:run'); + $this->call('backup:run'); $this->_handleMagicFolder([$this, '_resetSlug']); $this->call('cache:clear'); } @@ -38,9 +38,6 @@ class LocaleSlugReset extends CubistCommand } $class = get_class($model); $all = $class::all(); - if ($class !== 'App\Models\Page') { - return; - } $locale = $this->argument('locale'); foreach ($all as $instance) { $instance->setLocale($locale); diff --git a/src/app/Http/Controllers/CubistSEOController.php b/src/app/Http/Controllers/CubistSEOController.php index dcdec4d..8e06aea 100644 --- a/src/app/Http/Controllers/CubistSEOController.php +++ b/src/app/Http/Controllers/CubistSEOController.php @@ -6,6 +6,7 @@ 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 Illuminate\Http\Request; class CubistSEOController extends CubistFrontController @@ -25,14 +26,28 @@ class CubistSEOController extends CubistFrontController public function sitemap(Request $request) { - $res = ''; - if (config('cubist.seo_robots', true)) { + $locales = Locale::getEnabledLocalesCodes(); + + $res = '' . "\n"; + $res .= '' . "\n"; + if (true || config('cubist.seo_robots', true)) { $pages = Menu::getAllNavigablePages(); foreach ($pages as $url => $page) { if ($page instanceof PageItem && !$page->isRobots()) { continue; } - $res .= '' . $url . ''; + $res .= "\t" . '' . "\n"; + $res .= "\t\t" . '' . $url . '' . "\n"; + if (count($locales) > 1) { + foreach ($locales as $locale) { + $translated = $page->getTranslatedPage($locale); + if (null === $translated || !$translated->isRobots()) { + continue; + } + $res .= "\t\t" . '' . "\n"; + } + } + $res .= "\t" . '' . "\n"; } } $res .= ''; diff --git a/src/app/Magic/Models/Locale.php b/src/app/Magic/Models/Locale.php index 5ac91d0..af2f966 100644 --- a/src/app/Magic/Models/Locale.php +++ b/src/app/Magic/Models/Locale.php @@ -88,6 +88,10 @@ class Locale extends CubistMagicAbstractModel return array_keys(self::getLocales()); } + public static function getEnabledLocalesCodes(){ + return array_keys(self::getLocalesDataForFront()['enabled']); + } + /** * @return string */