Merge branch 'dev' into cwbs_template
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
/resources/views/modules
|
||||
/public/modules
|
||||
/resources/views/vendor
|
||||
/public/assets
|
||||
|
||||
# directories with custom templates
|
||||
**/views/**/custom/*
|
||||
|
||||
@@ -21,7 +21,6 @@ class TemplateRegistrator
|
||||
protected $namespace;
|
||||
/**
|
||||
* @var string absolute path to currently registered directory
|
||||
*
|
||||
* This variable is set in register() method as $baseDirectory/$path
|
||||
*/
|
||||
protected $registeredPath;
|
||||
@@ -78,7 +77,6 @@ class TemplateRegistrator
|
||||
|
||||
/**
|
||||
* Registers new template path.
|
||||
*
|
||||
* This method registeres given path itself with all subdirectories
|
||||
*
|
||||
* @param string $path path relatively to root of the project
|
||||
@@ -140,7 +138,13 @@ class TemplateRegistrator
|
||||
{
|
||||
// skip custom directories (contains updated templates only)
|
||||
$dirName = basename($path);
|
||||
if ($dirName == Template::EDITED_TEMPLATES_DIRECTORY) {
|
||||
$ignoredDirectories = [
|
||||
Template::EDITED_TEMPLATES_DIRECTORY,
|
||||
Template::ASSETS_DIRECTORY,
|
||||
Template::MODULES_DIRECTORY
|
||||
];
|
||||
|
||||
if (in_array($dirName, $ignoredDirectories)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,7 +160,6 @@ class TemplateRegistrator
|
||||
|
||||
/**
|
||||
* Registers all templates
|
||||
*
|
||||
* This method takes all templates in given directory and registers them into database. Templates registered in
|
||||
* this way may be used for further manipulation.
|
||||
*
|
||||
@@ -259,7 +262,6 @@ class TemplateRegistrator
|
||||
|
||||
/**
|
||||
* Get template name
|
||||
*
|
||||
* Converts path to template to corresponding name
|
||||
*
|
||||
* @param $template
|
||||
|
||||
@@ -21,6 +21,9 @@ class Template extends Model
|
||||
protected $guarded = [];
|
||||
protected $pathModel = null;
|
||||
const EDITED_TEMPLATES_DIRECTORY = 'custom';
|
||||
const ASSETS_DIRECTORY = 'assets';
|
||||
const MODULES_DIRECTORY = 'modules';
|
||||
|
||||
const TEMPLATE_SUFFIX = '.blade.php';
|
||||
const CUSTOM_EDIT_DIRECTORY = 1;
|
||||
const ORIGINAL_DIRECTORY = 2;
|
||||
|
||||
@@ -10,21 +10,24 @@ use App\Handlers\Search\Content;
|
||||
use App\Handlers\Search\Files;
|
||||
use App\Handlers\Search\Presenters\AdminContent as AdminContentPresenter;
|
||||
use App\Handlers\Search\Presenters\AdminFiles;
|
||||
use App\Models\Template;
|
||||
use App\Widgets\HtmlCode\HtmlCode;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// ignore running from artisan
|
||||
if (App::runningInConsole()) {
|
||||
$this->publishViewResources();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +39,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
@@ -118,4 +120,45 @@ class AppServiceProvider extends ServiceProvider
|
||||
$registrator->register(new Content(), new AdminContentPresenter());
|
||||
$registrator->register(new Files(), new AdminFiles());
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish all public assets from all themes
|
||||
*/
|
||||
private function publishViewResources()
|
||||
{
|
||||
$themes = File::directories(resource_path('views/visitor'));
|
||||
|
||||
$assets = [];
|
||||
foreach ($themes as $theme) {
|
||||
$themeName = basename($theme);
|
||||
|
||||
if (is_dir($theme . '/'.Template::ASSETS_DIRECTORY)) {
|
||||
$assets[$theme . '/'.Template::ASSETS_DIRECTORY] = public_path('assets/' . $themeName);
|
||||
}
|
||||
|
||||
if (is_dir($theme . '/'.Template::MODULES_DIRECTORY)) {
|
||||
$this->publishModuleViews($theme . '/'.Template::MODULES_DIRECTORY, $themeName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($assets)) {
|
||||
$this->publishes($assets, 'public-assets');
|
||||
}
|
||||
}
|
||||
|
||||
private function publishModuleViews($themeModules, $themeName)
|
||||
{
|
||||
$modules = File::directories($themeModules);
|
||||
|
||||
$moduleViews = [];
|
||||
foreach ($modules as $module) {
|
||||
$moduleName = strtolower(basename($module));
|
||||
|
||||
$moduleViews[$module] = resource_path('views/modules/' . $moduleName . '/visitor/' . $themeName);
|
||||
}
|
||||
|
||||
if (!empty($moduleViews)) {
|
||||
$this->publishes($moduleViews, 'module-views');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
@extends('visitor.layout')
|
||||
|
||||
@section('pageName', @trans('admin/userManagement.detail', ['name' => $user->name, 'email' => $user->email]))
|
||||
@extendVisitor('layout')
|
||||
|
||||
@section('content')
|
||||
{!! $page->content !!}
|
||||
|
||||
Reference in New Issue
Block a user