]> _ Git - cubist_cms-back.git/commitdiff
#2757
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 12 Jul 2019 13:07:00 +0000 (15:07 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 12 Jul 2019 13:07:00 +0000 (15:07 +0200)
composer.json
src/app/Http/Controllers/CubistPageController.php
src/app/Magic/BunchOfFields.php
src/app/Magic/Menu/Item.php
src/app/Magic/Models/CMSPage.php
src/app/Magic/Models/CubistMagicAbstractModel.php

index 5a6c5c6a25b07b5c7f404245c1825f348f0bbecc..24deb9eaf5a264ebe1da1e42f3ccc66d02c8fd60 100644 (file)
@@ -35,7 +35,8 @@
         "gaspertrix/laravel-backpack-dropzone-field": "^1.0",
         "cviebrock/eloquent-sluggable": "^4.8",
         "cocur/slugify": "^3.2",
-        "lavary/laravel-menu": "^1.7"
+        "lavary/laravel-menu": "^1.7",
+        "graham-campbell/markdown": "^11.0"
     },
     "require-dev": {
         "filp/whoops": "^2.3",
index 5ea27544d31b9c5acedd072d699efbe380a94e9d..6d48186dc9f849fbfb503781d8fe1d396bbe28cb 100644 (file)
@@ -5,7 +5,6 @@ namespace Cubist\Backpack\app\Http\Controllers;
 use Cubist\Backpack\app\Magic\Menu\Menu;
 use Cubist\Backpack\app\Magic\Models\CMSPage;
 use Illuminate\Support\Str;
-use Illuminate\View\View;
 
 class CubistPageController extends CubistFrontController
 {
@@ -27,7 +26,7 @@ class CubistPageController extends CubistFrontController
         // Page templates can modify/inject data before it is passed to the view
         $page->getUsedTemplate()->setData($this->data);
 
-        return view('pages.' . $page->template, $this->data);
+        return view('pages.' . $page->getAttributeValue('template'), $this->data);
     }
 
     public function catchall($main = '', $subs = '')
@@ -38,7 +37,7 @@ class CubistPageController extends CubistFrontController
             $path = 'home';
         }
         $nav = Menu::getNavigation();
-        $item = $nav->findOneByHref($path);
+        $item = $nav->findItemWithURL($path);
         if (null === $item) {
             $this->_404();
         }
index d7b053b7b3fb5b56acd44bd291cbf24eea62b4cd..6bfc00c027b00b3e55342a8f24f1a2541932d0e0 100644 (file)
@@ -47,6 +47,9 @@ trait BunchOfFields
     public function addFakeField(array $attributes)
     {
         $attributes['fake'] = true;
+        if (!isset($attributes['store_in'])) {
+            $attributes['store_in'] = 'extras';
+        }
         return $this->addField($attributes);
     }
 
index b9859c70f5ab3fc43207c6519111e9802ef93fc0..de32d594ff7e79d8ff9debe1968607ca86abdf8d 100644 (file)
@@ -144,6 +144,33 @@ class Item
         return $this->findOneBy('href', $href);
     }
 
+    public function findAllBy($param, $search)
+    {
+        $res = [];
+        if ($this->get($param) == $search) {
+            $res[] = $this;
+        }
+        foreach ($this->getChildren() as $child) {
+            $res = array_merge($res, $child->findAllBy($param, $search));
+        }
+
+        return $res;
+    }
+
+    public function findItemWithURL($href)
+    {
+        foreach ($this->findAllBy('href', $href) as $item) {
+            if (!($item instanceof PageItem)) {
+                return $item;
+            }
+            /** @var $item PageItem */
+            if (stristr($item->getPage()->template, 'redirection')) {
+                continue;
+            }
+            return $item;
+        }
+    }
+
     /**
      * @return string
      */
@@ -236,6 +263,7 @@ class Item
         return $href;
     }
 
+
     /**
      * @param string $href
      */
index db46adcc257f385123c24b1a12fee358376957ac..365752adb176bfb71ffba44f2d1437a5c457538c 100644 (file)
@@ -4,8 +4,6 @@
 namespace Cubist\Backpack\app\Magic\Models;
 
 use Cubist\Backpack\app\Magic\Controllers\CubistMagicController;
-use Cubist\Backpack\app\Template\Navigation;
-use Cubist\Backpack\app\Template\Redirection;
 use Cubist\Backpack\app\Template\TemplateAbstract;
 use Cubist\Util\Json;
 use Doctrine\DBAL\Schema\Schema;
index 5c587f6f63e6170c982faee717c64f1892c0102f..dc0e906c832596db396dddb963af89d93c186013 100644 (file)
@@ -17,7 +17,6 @@ use Doctrine\DBAL\Schema\Schema;
 use Doctrine\DBAL\Schema\Table;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Str;
-use mysql_xdevapi\Exception;
 use Spatie\MediaLibrary\HasMedia\HasMedia;
 use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
 use Spatie\MediaLibrary\Models\Media;
@@ -326,7 +325,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
 
         $this->fakeColumns = array_unique($this->fakeColumns);
         foreach ($this->fakeColumns as $fakeColumn) {
-            $table->addColumn($fakeColumn, 'text');
+            $table->addColumn($fakeColumn, 'text', ['notnull' => false]);
         }
 
         if ($this->timestamps) {
@@ -454,7 +453,17 @@ class CubistMagicAbstractModel extends Model implements HasMedia
 
     protected function _prepareData($attributes)
     {
-        return $attributes;
+        $res = [];
+        foreach ($attributes as $k => $attribute) {
+            if (stristr($k, '___')) {
+                continue;
+            }
+            if (stristr($k, 'bunchmultiple_')) {
+                continue;
+            }
+            $res[$k] = $attribute;
+        }
+        return $res;
     }
 
     public function update(array $attributes = [], array $options = [])