REFACTORING #1880 @4h30m: another ugly refactoring commit

This commit is contained in:
Michal Kváček
2016-10-25 16:50:04 +02:00
parent 28f67ffe3c
commit cc999dd24e
71 changed files with 827 additions and 608 deletions
@@ -21,12 +21,11 @@ interface AdvancedContentModifier {
* Reason why it is separated from createNew() method is simple - we need to save history of changes. * Reason why it is separated from createNew() method is simple - we need to save history of changes.
* *
* @param Content $content * @param Content $content
* @param Request $request * @param $request
* @param string $revisionId
* *
* @return mixed * @return mixed
*/ */
public static function edit(Content &$content, Request $request, $revisionId); public static function edit(Content $content, $request);
/** /**
* Method called right after content page is marked as deleted * Method called right after content page is marked as deleted
* *
+16 -4
View File
@@ -1,9 +1,21 @@
<?php <?php
namespace App\CMS\Contracts; namespace App\CMS\Contracts;
use App\Http\Requests\Request;
interface Interaction { interface Interaction {
public function handle(Request $request, $parameters); /**
public function getValidationRules($parameters); * Perform given action
*
* @param $data array input data
* @param $parameters array parameters
*
* @return mixed
*/
public function handle($data, $parameters);
/**
* @param $data array input data
*
* @return array
*/
public function getValidationRules($data = []);
} }
@@ -48,7 +48,7 @@ interface TemplateHandler extends BaseModuleHandler
* This way we can do almost whatever we want - even in template * This way we can do almost whatever we want - even in template
* *
* @param Content $content * @param Content $content
* @param Request $request * @param $request
*/ */
public static function beforeSave(Content & $content, Request $request); public static function beforeSave(Content & $content, $request);
} }
+5 -3
View File
@@ -4,8 +4,8 @@ namespace App\CMS\Contracts\Repositories;
use App\Models\Content\Content as ContentModel; use App\Models\Content\Content as ContentModel;
use App\Models\Module as ModuleModel; use App\Models\Module as ModuleModel;
interface Module extends BaseRepository { interface Module extends BaseRepository
{
public function getCreateContentTitle(ModuleModel $module); public function getCreateContentTitle(ModuleModel $module);
public function getUpdateContentTitle(ModuleModel $module, ContentModel $content = null); public function getUpdateContentTitle(ModuleModel $module, ContentModel $content = null);
@@ -14,5 +14,7 @@ interface Module extends BaseRepository {
public function getByHandler($handler); public function getByHandler($handler);
public function call(ModuleModel $module, $method, ...$parameters); public function call(ModuleModel $module, $method, $parameters = []);
public function callOnString($moduleHandler, $method, $parameters = []);
} }
+1 -1
View File
@@ -43,7 +43,7 @@ class History implements HistoryHandler
'to' => $statuses[$changeset->new_value] 'to' => $statuses[$changeset->new_value]
]); ]);
break; break;
case 'is_homepage': case 'isHomepage':
return trans('admin/history.setupAsHomepage'); return trans('admin/history.setupAsHomepage');
break; break;
default: default:
+15 -8
View File
@@ -3,30 +3,37 @@ namespace App\Cms\Handlers\Interactions;
use App\CMS\Contracts\Interaction as InteractionContract; use App\CMS\Contracts\Interaction as InteractionContract;
use App\CMS\Exceptions\Validation\ValidationFailedException; use App\CMS\Exceptions\Validation\ValidationFailedException;
use App\Http\Requests\Request; use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
class Interaction { class Interaction
{
/** /**
* Handle interaction with application * Handle interaction with application
* *
* @param Request $request * @param string $interactionClass
* @param InteractionContract $interaction * @param array $data
* @param array $parameters * @param array $extraParameters
* *
* @return mixed * @return mixed
* @throws ValidationFailedException * @throws ValidationFailedException
*/ */
public static function handle(Request $request, InteractionContract $interaction, ...$parameters) { public static function handle($interactionClass, $data, ...$extraParameters)
{
/**
* @var $interaction InteractionContract
*/
$interaction = App::make($interactionClass);
// validate interaction // validate interaction
$validator = Validator::make($request->all(), $interaction->getValidationRules($parameters)); $validator = Validator::make($data, $interaction->getValidationRules($extraParameters));
if ($validator->fails()) { if ($validator->fails()) {
throw new ValidationFailedException($validator); throw new ValidationFailedException($validator);
} }
// handle it // handle it
return $interaction->handle($request, $parameters);
return $interaction->handle($data, $extraParameters);
} }
} }
+72 -7
View File
@@ -1,12 +1,13 @@
<?php <?php
namespace App\CMS\Helpers; namespace App\CMS\Helpers;
use App\CMS\Contracts\Modules\TemplateHandler;
use App\Models\Content\Content;
use App\Models\Module; use App\Models\Module;
use DebugBar\Bridge\MonologCollector; use App\Models\User;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Monolog\Logger;
class CurrentTemplate class CurrentTemplate implements TemplateHandler
{ {
protected static $template; protected static $template;
protected static $initialized = false; protected static $initialized = false;
@@ -20,14 +21,14 @@ class CurrentTemplate
{ {
if (!self::$initialized) { if (!self::$initialized) {
try { try {
self::$template = Module::where('is_template', true) self::$template = Module::where('is_template', true)
->where('enabled', true) ->where('enabled', true)
->first(); ->first();
} catch (QueryException $e) { } catch (QueryException $e) {
throw new \ErrorException('DB not migrated, please, do so!'); throw new \ErrorException('DB not migrated, please, do so!');
} }
if (self::$template) { if (self::$template) {
self::$template->module_settings = json_decode(self::$template->module_settings); self::$template->moduleSettings = json_decode(self::$template->moduleSettings);
} }
self::$initialized = true; self::$initialized = true;
@@ -60,4 +61,68 @@ class CurrentTemplate
{ {
self::$initialized = false; self::$initialized = false;
} }
/**
* Register admin menu (or multiple ones)
*
* This cannot be in ServiceProvider because Session is started at middleware. And ServiceProvider is called before
* starting any middleware..
*
* @param User $user model of logged user
*/
public static function registerAdminMenu(User $user)
{
call_user_func_array([self::handler(), 'registerAdminMenu'], [$user]);
}
/**
* Get list of registered templates and supported modules.
*
* Returned array is expected to be array of arrays with following items: module, namespace and templateName.
* Example:
* return [
* ['module' => 'Article', 'templateName' => 'article::template.name']
* ];
*
* When no "namespace" is specified, value strtolower(module) is used instaed.
*
* @return array
*/
public static function getPublicTemplatePaths()
{
return call_user_func([self::handler(), 'getPublicTemplatePaths']);
}
/**
* Prepare Content object to be rendered using Blade template
*
* @param Content $content
*/
public static function beforeRender(Content & $content)
{
call_user_func_array([self::handler(), 'beforeRender'], [&$content]);
}
/**
* Modify input data into format which can be understood by edit template
*
* @param Content $content
*/
public static function beforePopulatingEditForm(Content & $content)
{
call_user_func_array([self::handler(), 'beforePopulatingEditForm'], [&$content]);
}
/**
* Slightly modify Content object before saving into database.
*
* This way we can do almost whatever we want - even in template
*
* @param Content $content
* @param $request
*/
public static function beforeSave(Content & $content, $request)
{
call_user_func_array([self::handler(), 'beforeSave'], [&$content, $request]);
}
} }
+2 -2
View File
@@ -24,7 +24,7 @@ class PageRenderer
public static function render(Content $page) public static function render(Content $page)
{ {
// decode module settings // decode module settings
$page->module_settings = json_decode($page->module_settings); $page->moduleSettings = json_decode($page->moduleSettings);
// do something template-specific // do something template-specific
$parameters = call_user_func_array([CurrentTemplate::handler(), 'beforeRender'], [&$page]); $parameters = call_user_func_array([CurrentTemplate::handler(), 'beforeRender'], [&$page]);
@@ -33,7 +33,7 @@ class PageRenderer
* @var $handler AppHandler * @var $handler AppHandler
*/ */
// get handler // get handler
$handler = new $page->module_handler; $handler = new $page->moduleHandler;
$page->content = Shortcode::compile($page->content); $page->content = Shortcode::compile($page->content);
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\CMS\Helpers\Traits;
use Carbon\Carbon;
/**
* Class Nullable
*
* @package App\CMS\Helpers\Traits
*/
trait Nullable {
/**
* Get null or parsed date
*
* @param $date
*
* @return null|string
*/
public function nullableDate($date) {
return empty($date) ? null : Carbon::parse($date)->toDateTimeString();
}
/**
* Get null or input value
*
* @param $string
*
* @return null
*/
public function nullable($string) {
return empty($string) ? null : $string;
}
}
+4
View File
@@ -27,4 +27,8 @@ function setting($key, $default = null) {
function asset_path($path) { function asset_path($path) {
return env('SITE_URL').'/assets/'.$path; return env('SITE_URL').'/assets/'.$path;
}
function template_name($name, $throwExceptions = true) {
return \App\CMS\Helpers\Template::name($name, $throwExceptions);
} }
@@ -0,0 +1,24 @@
<?php
namespace App\CMS\Interactions\Admin\Content;
use App\CMS\Contracts\Interaction;
use App\Http\Requests\Request;
class ChangeStatus implements Interaction {
public function handle(Request $data, $parameters)
{
$statuses = ContentStatuses::getWithTranslations();
// check if given status is valid
if (!isset($statuses[$status])) {
return redirect()
->route('content.overview')
->with('error', trans('admin/contents.invalidStatus'));
}
}
public function getValidationRules($parameters)
{
// TODO: Implement getValidationRules() method.
}
}
@@ -7,6 +7,8 @@ use App\CMS\Enumerations\ContentStatuses;
use App\CMS\Helpers\CurrentTemplate; use App\CMS\Helpers\CurrentTemplate;
use App\Events\EditContent as EditContentEvent; use App\Events\EditContent as EditContentEvent;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Models\Content\Content;
use App\Models\FileManager\File;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@@ -17,74 +19,59 @@ class EditContent implements Interaction
* @var Module * @var Module
*/ */
protected $module; protected $module;
/**
* @var File
*/
protected $file;
public function __construct() public function __construct()
{ {
$this->module = App::make(Module::class); $this->module = App::make(Module::class);
$this->file = App::make(File::class);
} }
public function handle(Request $request, $parameters) /**
* Edit page
*
* @param array $data
* @param array $parameters
*
* @return mixed|void
*/
public function handle($data, $parameters)
{ {
$page = $parameters[0]; /**
* @var $page Content
// upload file - if provided */
// todo use interaction list($page, $titlePhoto, $relatedFiles) = $parameters;
$file = $page->uploadTitlePhoto($request);
// let template to modify request and content page // let template to modify request and content page
call_user_func_array([CurrentTemplate::handler(), 'beforeSave'], [&$page, $request]); CurrentTemplate::beforeSave($page, $data);
$request->url = Str::slug($request->url); // upload file - if provided
$request->parentPage = $request->parentPage ? $request->parentPage : null; $data['titlePhoto'] = isset($data['existingTitlePhoto']) ? $data['existingTitlePhoto'] : null;
$request->publishedFrom = empty($request->publishedFrom) ? null : $request->publishedFrom;
$request->publishedTo = empty($request->publishedTo) ? null : $request->publishedTo;
if (!$file) { if (!is_null($titlePhoto)) {
$request->titlePhotoFilename = empty($request->existingTitlePhoto) ? null : $request->existingTitlePhoto; $file = $this->file->upload($titlePhoto);
} else { $data['titlePhoto'] = $file ? $file['filename'] : null;
$request->titlePhotoFilename = $file['filename'];
} }
// array of fields in database and fields from request $page->update($data);
$fields = [ $this->module->callOnString($page->moduleHandler, 'edit', [$page, $data]);
'title' => 'title',
'url' => 'url',
'template' => 'template',
'published_from' => 'publishedFrom',
'published_to' => 'publishedTo',
'meta_keywords' => 'metaKeywords',
'meta_description' => 'metaDescription',
'content' => 'pageContent',
'parent_id' => 'parentPage',
'status' => 'status',
'title_photo' => 'titlePhotoFilename',
'category_id' => 'category'
];
// save new values with history
// todo move this method out of the controller!
$data = \App\Http\Controllers\Admin\Contents\EditContent::getFields($request, array_values($fields));
// todo use Model Observer and model::original attributes
list($revision, $changedColumns) = $page->updateWithHistory($fields, $data);
$module = $this->module->getByHandler($page->module_handler);
$changedColumns += $this->module->call($module, 'edit', [&$page, $request, $revision]);
// move to interaction // move to interaction
$changedColumns += $page->uploadRelatedFiles($request, $revision); $keepAssigned = isset($data->keepAssigned) ? $data->keepAssigned : [];
$page->uploadRelatedFiles($relatedFiles, $keepAssigned);
if ($changedColumns > 0) {
Event::fire(new EditContentEvent($page, $revision));
}
return [$page, $revision, $changedColumns];
} }
public function getValidationRules($parameters) /**
* Validate this interaction
*
* @param array $parameters
*
* @return array
*/
public function getValidationRules($parameters = [])
{ {
$id = $parameters[0]->id; $id = $parameters[0]->id;
@@ -97,7 +84,7 @@ class EditContent implements Interaction
'url' => 'required|unique:contents,url,' . $id, 'url' => 'required|unique:contents,url,' . $id,
'publishedFrom' => 'date', 'publishedFrom' => 'date',
'publishedTo' => 'date', 'publishedTo' => 'date',
'title_photo' => 'exists:files,id', 'titlePhoto' => 'exists:files,id',
'status' => 'required|in:' . $statuses, 'status' => 'required|in:' . $statuses,
'parentPage' => 'exists:contents,id' 'parentPage' => 'exists:contents,id'
]; ];
@@ -2,10 +2,13 @@
namespace App\Cms\Interactions\Admin\Content; namespace App\Cms\Interactions\Admin\Content;
use App\CMS\Contracts\Interaction; use App\CMS\Contracts\Interaction;
use App\CMS\Contracts\Repositories\Content as ContentRepository;
use App\CMS\Contracts\Repositories\Module;
use App\CMS\Helpers\CurrentTemplate; use App\CMS\Helpers\CurrentTemplate;
use App\Events\CreateNewContent; use App\Events\CreateNewContent;
use App\Http\Requests\Request;
use App\Models\Content\Content; use App\Models\Content\Content;
use App\Models\FileManager\File;
use Carbon\Carbon;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@@ -13,73 +16,70 @@ use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
class NewContent implements Interaction class NewContent implements Interaction
{ {
/**
* @var ContentRepository
*/
protected $content; protected $content;
/**
* @var File
*/
protected $file;
/**
* @var Module
*/
protected $module;
public function __construct() public function __construct()
{ {
$this->content = App::make(\App\CMS\Contracts\Repositories\Content::class); $this->content = App::make(ContentRepository::class);
$this->module = App::make(Module::class);
$this->file = App::make(File::class);
} }
/** /**
* @param Request $request * Create new content page
*
* @param array $data
* @param $parameters * @param $parameters
* *
* @return Content * @return Content
*/ */
public function handle(Request $request, $parameters) public function handle($data, $parameters)
{ {
list($moduleHandler) = $parameters; list($moduleHandler, $titlePhoto, $relatedFiles) = $parameters;
// create new page
$page = new Content();
$page->template = $request->template;
// setup basic info
$page->user_id = \Auth::user()->id;
$page->language = LaravelLocalization::getCurrentLocale();
$page->title = $request->title;
$page->url = Str::slug($request->url);
$page->published_from = empty($request->publishedFrom) ? null : $request->publishedFrom;
$page->published_to = empty($request->publishedTo) ? null : $request->publishedTo;
$page->meta_keywords = $request->metaKeywords;
$page->meta_description = $request->metaDescription;
$page->content = $request->pageContent;
$page->status = $request->status;
$page->module_handler = $moduleHandler;
$page->category_id = (int)$request->category > 0 ? $request->category : null;
$page->parent_id = $request->parentPage ? $request->parentPage : null;
// upload file - if provided // upload file - if provided
$file = $page->uploadTitlePhoto($request); $file = !is_null($titlePhoto) ? $this->file->upload($titlePhoto) : null;
$page->title_photo = $file ? $file['filename'] : null; $data['userId'] = \Auth::user()->id;
$data['language'] = LaravelLocalization::getCurrentLocale();
$data['titlePhoto'] = $file ? $file['filename'] : null;
$data['moduleHandler'] = $moduleHandler;
$page = Content::create($data);
// save module-specific stuff // save module-specific stuff
call_user_func_array([$request->handler, 'createNew'], [&$page, $request]); $this->module->callOnString($moduleHandler, 'createNew', [&$page, $data]);
// let template to modify request and content page // let template to modify data and content page
call_user_func_array([CurrentTemplate::handler(), 'beforeSave'], [&$page, $request]); CurrentTemplate::beforeSave($page, $data);
// save content of page before (possible) uploading related files // save content of page before (possible) uploading related files
$page->save(); $page->save();
// upload files assigned to content page // upload files assigned to content page
$page->uploadRelatedFiles($request); $page->uploadRelatedFiles($relatedFiles);
Event::fire(new CreateNewContent($this));
return $page; return $page;
} }
public function getValidationRules($parameters) public function getValidationRules($parameters = [])
{ {
return [ return [
'titlePhoto' => 'image', 'titlePhoto' => 'image',
'title' => 'required', 'title' => 'required',
'url' => 'required|unique:contents,url', 'url' => 'required|unique:contents,url',
'status' => 'required|in:draft,protected,public', 'status' => 'required|in:draft,protected,public',
'title_photo' => 'exists:files,id',
'parentPage' => 'exists:contents,id', 'parentPage' => 'exists:contents,id',
'publishedFrom' => 'date', 'publishedFrom' => 'date',
'publishedTo' => 'date', 'publishedTo' => 'date',
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace App\CMS\Observers;
use App\Events\CreateNewContent;
use App\Models\Content\Content as ContentModel;
use App\Models\Content\ContentHistory;
use Illuminate\Support\Facades\Event;
class Content
{
protected $changeset;
public function __construct()
{
$this->changeset = uniqid();
}
/**
* @param ContentModel $content
*/
public function created(ContentModel $content)
{
Event::fire(new CreateNewContent($content));
}
/**
* Get all dirty changed from model.
*
* If user did not change moduleSettings column, return result from ContentModel::getDirty(). Otherwise append all
* changed columns from module settings.
*
* @param $changed
* @param $original
*
* @return array
*/
protected function getDirtyFields($changed, $original)
{
unset($changed['updated_at']);
$changes = $this->getNewAndOldValues(array_keys($changed), $changed, $original);
if (!isset($changed['moduleSettings']))
return $changes;
$moduleSettings = (array)json_decode($changed['moduleSettings']);
$originalSettings = (array)json_decode($original['moduleSettings']);
unset($changed['moduleSettings']);
$settingChanged = array_keys(array_diff_assoc($moduleSettings, $originalSettings));
$changesInSettings = $this->getNewAndOldValues($settingChanged, $moduleSettings, $originalSettings);
return array_merge($changes, $changesInSettings);
}
/**
*
*
* @param $fields
* @param $new
* @param $original
*
* @return array
*/
protected function getNewAndOldValues($fields, $new, $original) {
$changes = [];
foreach ($fields as $field) {
$changes[$field] = [
'new' => isset($new[$field]) ? $new[$field] : null,
'old' => isset($original[$field])? $original[$field] : null
];
}
return $changes;
}
public function updated(ContentModel $content)
{
$fields = $this->getDirtyFields($content->getDirty(), $content->getOriginal());
foreach ($fields as $field => $change) {
$history = [
'user_id' => \Auth::user()->id,
'content_id' => $content->id,
'edit_batch' => $this->changeset,
'column' => $field,
'old_value' => $change['old'],
'new_value' => $change['new']
];
// save history
ContentHistory::create($history);
}
}
/**
* @param ContentModel $content
*/
public function deleted(ContentModel $content)
{
}
}
+32 -23
View File
@@ -29,14 +29,14 @@ class Content extends Repository implements IContent
return ContentModel::where('status', '!=', IContent::STATUS_DRAFT) return ContentModel::where('status', '!=', IContent::STATUS_DRAFT)
->select('contents.*') ->select('contents.*')
->with('author') ->with('author')
->join('modules', 'modules.handler', '=', 'contents.module_handler') ->join('modules', 'modules.handler', '=', 'contents.moduleHandler')
->where(function ($query) { ->where(function ($query) {
$query->where('published_from', '<', Carbon::now()) $query->where('publishedFrom', '<=', Carbon::now())
->orWhereNull('published_from'); ->orWhereNull('publishedFrom');
}) })
->where(function ($query) { ->where(function ($query) {
$query->where('published_to', '>', Carbon::now()) $query->where('publishedTo', '>=', Carbon::now())
->orWhereNull('published_to'); ->orWhereNull('publishedTo');
}) })
->where('language', LaravelLocalization::getCurrentLocale()) ->where('language', LaravelLocalization::getCurrentLocale())
->whereNull('contents.deleted_at') ->whereNull('contents.deleted_at')
@@ -46,9 +46,14 @@ class Content extends Repository implements IContent
public function all() public function all()
{ {
return $this->getPageQuery() return $this->getPageQuery()
->get(); ->get();
} }
/**
* @param int $id
*
* @return mixed
*/
public function getOne($id = null) public function getOne($id = null)
{ {
if (is_null($id)) { if (is_null($id)) {
@@ -56,16 +61,9 @@ class Content extends Repository implements IContent
$page->user_id = \Auth::user()->id; $page->user_id = \Auth::user()->id;
$page->language = LaravelLocalization::getCurrentLocale(); $page->language = LaravelLocalization::getCurrentLocale();
$page->status = IContent::STATUS_DRAFT; $page->status = IContent::STATUS_DRAFT;
$page->module_settings = []; $page->moduleSettings = [];
} else { } else {
if (is_numeric($id)) {
$page = $this->model->findOrFail($id); $page = $this->model->findOrFail($id);
} else {
$page = $this->model->where('language', LaravelLocalization::getCurrentLocale())
->where('url', $id)
->firstOrFail();
}
$page->module_settings = json_decode($page->module_settings);
} }
return $page; return $page;
@@ -78,8 +76,9 @@ class Content extends Repository implements IContent
public function getHomepage() public function getHomepage()
{ {
return $this->getPageQuery() return $this->getPageQuery()
->where('is_homepage', 1) ->where('isHomepage', 1)
->first(); ->first();
} }
/** /**
@@ -91,9 +90,17 @@ class Content extends Repository implements IContent
*/ */
public function getByURL($url) public function getByURL($url)
{ {
return $this->getPageQuery() $page = $this->getPageQuery()
->where('url', $url) ->where('url', $url)
->first(); ->first();
if (is_null($page)) {
return null;
}
$page->moduleSettings = json_decode($page->moduleSettings);
return $page;
} }
/** /**
@@ -108,8 +115,8 @@ class Content extends Repository implements IContent
public function getOverview($handler = null, $statuses = null) public function getOverview($handler = null, $statuses = null)
{ {
$query = ContentModel::select('contents.*', 'modules.name AS module_name', 'modules.id AS module_id') $query = ContentModel::select('contents.*', 'modules.name AS module_name', 'modules.id AS module_id')
->join('modules', 'modules.handler', '=', 'contents.module_handler') ->join('modules', 'modules.handler', '=', 'contents.moduleHandler')
->join('users', 'users.id', '=', 'contents.user_id') ->join('users', 'users.id', '=', 'contents.userId')
->addSelect(DB::raw('COALESCE(users.name, users.email) AS author_name')) ->addSelect(DB::raw('COALESCE(users.name, users.email) AS author_name'))
->addSelect('users.email AS author_email') ->addSelect('users.email AS author_email')
->whereNull('contents.deleted_at') ->whereNull('contents.deleted_at')
@@ -119,7 +126,7 @@ class Content extends Repository implements IContent
// filter results using handler // filter results using handler
if (!is_null($handler)) { if (!is_null($handler)) {
$query = $query->where('contents.module_handler', $handler); $query = $query->where('contents.moduleHandler', $handler);
} }
// add filtering by status // add filtering by status
@@ -127,6 +134,8 @@ class Content extends Repository implements IContent
$query = $query->whereIn('contents.status', $statuses); $query = $query->whereIn('contents.status', $statuses);
} }
return $query->paginate(20); $pages = $query->paginate(setting('paginatedResults', 20));
return $pages;
} }
} }
+12 -3
View File
@@ -36,8 +36,8 @@ class Module extends Repository implements IModule
public function getUpdateContentTitle(ModuleModel $module, Content $content = null) public function getUpdateContentTitle(ModuleModel $module, Content $content = null)
{ {
$pageHeading = trans('admin/contents.new', ['name' => trans($module->name)]); $pageHeading = trans('admin/contents.edit', ['name' => trans($module->name)]);
$moduleHeading = $this->call($module, 'getEditTitle', $content); $moduleHeading = $this->call($module, 'getEditTitle', [$content]);
return is_null($moduleHeading) ? $pageHeading : $moduleHeading; return is_null($moduleHeading) ? $pageHeading : $moduleHeading;
} }
@@ -62,7 +62,7 @@ class Module extends Repository implements IModule
->firstOrFail(); ->firstOrFail();
} }
public function call(ModuleModel $module, $method, ...$parameters) public function call(ModuleModel $module, $method, $parameters = [])
{ {
if (!is_null($module) && is_callable([$module->handler, $method])) { if (!is_null($module) && is_callable([$module->handler, $method])) {
return call_user_func_array([$module->handler, $method], $parameters); return call_user_func_array([$module->handler, $method], $parameters);
@@ -70,4 +70,13 @@ class Module extends Repository implements IModule
return null; return null;
} }
public function callOnString($moduleHandler, $method, $parameters = [])
{
if (is_callable([$moduleHandler, $method])) {
return call_user_func_array([$moduleHandler, $method], $parameters);
}
return null;
}
} }
+2 -2
View File
@@ -54,8 +54,8 @@ class Menu implements WidgetRenderer
} }
$page = $pages[$pageId]; $page = $pages[$pageId];
$active = ($page->is_homepage && $route == 'page.index') || ($route == 'page.content' && isset($parameters['url']) && $parameters['url'] == $page->url); $active = ($page->isHomepage && $route == 'page.index') || ($route == 'page.content' && isset($parameters['url']) && $parameters['url'] == $page->url);
$route = $page->is_homepage ? route('page.index') : route('page.content', ['url' => $page->url]); $route = $page->isHomepage ? route('page.index') : route('page.content', ['url' => $page->url]);
$code .= '<li'; $code .= '<li';
if ($active) { if ($active) {
+1 -1
View File
@@ -42,7 +42,7 @@ class SetTemplate extends Command
$config['staticName'] = $template; $config['staticName'] = $template;
if ($current) { if ($current) {
$info = json_decode($current->module_settings); $info = json_decode($current->moduleSettings);
$this->line('Template is already installed. Currently using template ' . trans($current->name) . ' located in /templates/' . $info->staticName . '.'); $this->line('Template is already installed. Currently using template ' . trans($current->name) . ' located in /templates/' . $info->staticName . '.');
$confirm = $this->confirm('Uninstall it and install *' . trans($config['name']) . '*? All data associated with installed template will be lost!'); $confirm = $this->confirm('Uninstall it and install *' . trans($config['name']) . '*? All data associated with installed template will be lost!');
@@ -36,18 +36,17 @@ class ContentActions extends Controller
->with('error', trans('admin/contents.invalidStatus')); ->with('error', trans('admin/contents.invalidStatus'));
} }
try {
// try to find this page // try to find this page
$page = Content::findOrFail($id); $page = Content::findOrFail($id);
} catch (NotFoundHttpException $e) {
// page not found
return redirect()
->route('content.overview')
->with('error', trans('admin/contents.invalidPage'));
}
// try to change the page // try to change the page
list ($revision, $changedColumns) = $page->updateWithHistory(['status' => 'status'], ['status' => $status]); list ($revision, $changedColumns) = $page->updateWithHistory(['status' => 'status'], ['status' => $status]);
// fire events
if ($status != Content::STATUS_DRAFT) {
Event::fire(new PublishContent($page, $revision));
} else {
Event::fire(new MakeDraftFromContent($page, $revision));
}
// was something changed? // was something changed?
if ($changedColumns == 0) { if ($changedColumns == 0) {
@@ -56,12 +55,7 @@ class ContentActions extends Controller
->with('error', trans('admin/contents.nothingToEdit')); ->with('error', trans('admin/contents.nothingToEdit'));
} }
// fire events
if ($status != Content::STATUS_DRAFT) {
Event::fire(new PublishContent($page, $revision));
} else {
Event::fire(new MakeDraftFromContent($page, $revision));
}
// redirect back to overview with info for user // redirect back to overview with info for user
return redirect() return redirect()
@@ -97,7 +91,7 @@ class ContentActions extends Controller
$page->delete(); $page->delete();
// let module to delete some extra content created during page's life // let module to delete some extra content created during page's life
call_user_func([$page->module_handler, 'delete'], $page); call_user_func([$page->moduleHandler, 'delete'], $page);
// trigger delete event // trigger delete event
Event::fire(new DeleteContent($page)); Event::fire(new DeleteContent($page));
@@ -134,12 +128,12 @@ class ContentActions extends Controller
} }
// disable any other existing homepage // disable any other existing homepage
Content::where('is_homepage', 1) Content::where('isHomepage', 1)
->where('language', LaravelLocalization::getCurrentLocale()) ->where('language', LaravelLocalization::getCurrentLocale())
->update(['is_homepage' => 0]); ->update(['isHomepage' => 0]);
// set new homepage // set new homepage
list ($revision, $changedColumns) = $page->updateWithHistory(['is_homepage' => 'is_homepage'], ['is_homepage' => 1]); list ($revision, $changedColumns) = $page->updateWithHistory(['isHomepage' => 'isHomepage'], ['isHomepage' => 1]);
// was something changed? // was something changed?
if ($changedColumns == 0) { if ($changedColumns == 0) {
@@ -103,8 +103,11 @@ class CreateNewContent extends Controller
{ {
$module = $this->module->getOne($moduleId); $module = $this->module->getOne($moduleId);
$titlePhoto = $request->file('titlePhoto');
$relatedFiles = $request->all()['files'];
// create new page // create new page
Interaction::handle($request, new NewContent(), $module->handler); Interaction::handle(NewContent::class, $request->all(), $module->handler, $titlePhoto, $relatedFiles);
return redirect() return redirect()
->route('content.overview') ->route('content.overview')
@@ -71,24 +71,24 @@ class EditContent extends Controller
/** /**
* Display form for editing static page * Display form for editing static page
* *
* @param $url * @param $id
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/ */
public function edit($url) public function edit($id)
{ {
$statuses = ContentStatuses::getWithTranslations(); $statuses = ContentStatuses::getWithTranslations();
$page = $this->content->getOne($url); $page = $this->content->getOne($id);
// get module ID // get module ID
$module = $this->module->getByHandler($page->module_handler); $module = $this->module->getByHandler($page->moduleHandler);
$pageHeading = $this->module->getUpdateContentTitle($module, $page); $pageHeading = $this->module->getUpdateContentTitle($module, $page);
$templates = $this->template->getForModule($module); $templates = $this->template->getForModule($module);
$categories = $this->category->getForModule($module); $categories = $this->category->getForModule($module);
$history = $this->history->getStructuredHistoryOf($page); $history = $this->history->getStructuredHistoryOf($page);
// modify data for edit form according to installed template // modify data for edit form according to installed template
call_user_func_array([CurrentTemplate::handler(), 'beforePopulatingEditForm'], [&$page]); CurrentTemplate::beforePopulatingEditForm($page);
// render view // render view
return view('admin.content.edit', [ return view('admin.content.edit', [
@@ -132,14 +132,10 @@ class EditContent extends Controller
} }
// edit page // edit page
list($page, $revision, $changedColumns) = Interaction::handle($request, new EditContentInteraction(), $page); $titlePhoto = $request->file('titlePhoto');
$relatedFiles = $request->all()['files'];
// was something changed? Interaction::handle(EditContentInteraction::class, $request->all(), $page, $titlePhoto, $relatedFiles);
if ($changedColumns == 0) {
return redirect()
->route('content.edit', ['id' => $page->id])
->with('error', trans('admin/contents.nothingToEdit'));
}
// something was changed, inform user // something was changed, inform user
return redirect() return redirect()
@@ -150,12 +146,12 @@ class EditContent extends Controller
/** /**
* Convert object of all request data into array of only wanted fields * Convert object of all request data into array of only wanted fields
* *
* @param Request $request * @param $request
* @param $fields * @param $fields
* *
* @return array * @return array
*/ */
public static function getFields(Request $request, $fields) public static function getFields($request, $fields)
{ {
$requestData = []; $requestData = [];
+3 -4
View File
@@ -2,8 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\CMS\Contracts\Repositories\Content;
use App\Http\Requests; use App\Http\Requests;
use App\Models\Content\Content;
class Sitemap extends Controller class Sitemap extends Controller
{ {
@@ -30,14 +30,13 @@ class Sitemap extends Controller
public function getMap() public function getMap()
{ {
// load all public pages // load all public pages
$pages = $this->content->getPageQuery() $pages = $this->content->all();
->get();
// iterate over all pages and add tag for each of them // iterate over all pages and add tag for each of them
foreach ($pages as $page) { foreach ($pages as $page) {
// is this page a homepage? because of URL // is this page a homepage? because of URL
if ($page->is_homepage) { if ($page->isHomepage) {
$route = route('page.index'); $route = route('page.index');
$priority = 1; $priority = 1;
} else { } else {
+1 -1
View File
@@ -9,7 +9,7 @@ Route::group(['namespace' => 'Contents'], function () {
->name('content.new'); ->name('content.new');
// form for editing existing static page // form for editing existing static page
Route::get('content/edit/{url}', 'EditContent@edit') Route::get('content/edit/{id}', 'EditContent@edit')
->name('content.edit'); ->name('content.edit');
// post method for creating new static page // post method for creating new static page
+103 -14
View File
@@ -2,10 +2,14 @@
namespace App\Models\Content; namespace App\Models\Content;
use App\CMS\Contracts\Repositories\Content as ContentContract;
use App\CMS\Helpers\Traits\Nullable;
use App\CMS\Observers\Content as ContentObserver;
use App\Models\FileManager\File; use App\Models\FileManager\File;
use App\Models\User; use App\Models\User;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;
use Modules\Categories\Entities\Category; use Modules\Categories\Entities\Category;
/** /**
@@ -13,27 +17,41 @@ use Modules\Categories\Entities\Category;
*/ */
class Content extends Model class Content extends Model
{ {
use SoftDeletes, ModelTraits\Content; use SoftDeletes, ModelTraits\Content, Nullable;
public $timestamps = true; public $timestamps = true;
protected $fillable = [ protected $fillable = [
'user_id', 'userId',
'parent_id', 'parentId',
'category_id', 'categoryId',
'language', 'language',
'module_handler', 'moduleHandler',
'published_from', 'publishedFrom',
'published_to', 'publishedTo',
'title_photo', 'titlePhoto',
'template', 'template',
'is_homepage', 'isHomepage',
'title', 'title',
'url', 'url',
'meta_keywords', 'metaKeywords',
'meta_description', 'metaDescription',
'content', 'pageContent',
'module_settings', 'moduleSettings',
'status' 'status'
]; ];
protected $casts = [
'isHomepage' => 'boolean',
'moduleSettings' => 'array'
];
/**
* Assign observer for this model for logging
*/
protected static function boot()
{
parent::boot();
self::observe(ContentObserver::class);
}
/** /**
* Mark relationship with its historical records * Mark relationship with its historical records
@@ -52,7 +70,7 @@ class Content extends Model
*/ */
public function author() public function author()
{ {
return $this->belongsTo(User::class, 'user_id'); return $this->belongsTo(User::class, 'userId');
} }
/** /**
@@ -74,4 +92,75 @@ class Content extends Model
{ {
return $this->belongsTo(Category::class); return $this->belongsTo(Category::class);
} }
/**
* Subpages assigned to page
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function subpages()
{
return $this->hasMany(Content::class, 'parentId');
}
/**
* Parent page
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function parentPage()
{
return $this->belongsTo(Content::class, 'parentId');
}
/**
* Is current content draft?
*
* @return bool
*/
public function isDraft()
{
return $this->status == ContentContract::STATUS_DRAFT;
}
/**
* Is current content visible for all visitors?
*
* @return bool
*/
public function isPublic()
{
return $this->status == ContentContract::STATUS_PUBLIC;
}
/**
* Is current content visible only for logged users?
*
* @return bool
*/
public function isProtected()
{
return $this->status == ContentContract::STATUS_PROTECTED;
}
/**
* Is current content visible for logged user OR for everyone?
*
* @return bool
*/
public function isVisible()
{
return $this->isPublic() || $this->isProtected();
}
public function save(array $options = [])
{
$this->parentId = $this->nullable($this->parentId);
$this->categoryId = $this->nullable($this->categoryId);
$this->publishedFrom = $this->nullableDate($this->publishedFrom);
$this->publishedTo = $this->nullableDate($this->publishedTo);
$this->url = Str::slug($this->url);
return parent::save($options);
}
} }
+11 -1
View File
@@ -2,15 +2,25 @@
namespace App\Models\Content; namespace App\Models\Content;
use App\Models\FileManager\File;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class ContentHasFile extends Model class ContentHasFile extends Model
{ {
public $timestamps = false; public $timestamps = false;
public $table = 'contents_has_files'; public $table = 'contents_has_files';
protected $fillable = [ protected $fillable = [
'content_id', 'content_id',
'file_id' 'file_id'
]; ];
public function content()
{
return $this->hasOne(Content::class);
}
public function file()
{
return $this->hasOne(File::class);
}
} }
+12 -221
View File
@@ -1,215 +1,29 @@
<?php <?php
namespace App\Models\Content\ModelTraits; namespace App\Models\Content\ModelTraits;
use App\CMS\Contracts\Repositories\Content as IContent;
use App\Http\Requests\Request;
use App\Models\Content\ContentHasFile; use App\Models\Content\ContentHasFile;
use App\Models\Content\ContentHistory;
use App\Models\FileManager\Directory; use App\Models\FileManager\Directory;
use App\Models\FileManager\File; use App\Models\FileManager\File;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
trait Content trait Content
{ {
/**
* @var File
*/
private $file;
protected $foundSubpages = [];
protected $subpagesInit = false;
public function __construct()
{
$this->file = App::make(File::class);
}
/**
* Is current content draft?
*
* @return bool
*/
public function isDraft()
{
return $this->status == IContent::STATUS_DRAFT;
}
/**
* Is current content visible for all visitors?
*
* @return bool
*/
public function isPublic()
{
return $this->status == IContent::STATUS_PUBLIC;
}
/**
* Is current content visible only for logged users?
*
* @return bool
*/
public function isProtected()
{
return $this->status == IContent::STATUS_PROTECTED;
}
/**
* Is current content visible for logged user OR for everyone?
*
* @return bool
*/
public function isVisible()
{
return $this->isPublic() || $this->isProtected();
}
/**
* Get list of all subpages
*
* @param bool $orderBy
* @param bool $orderDirection
*
* @return array
*/
public function subpages($orderBy = false, $orderDirection = false)
{
if (!$this->subpagesInit) {
$subpages = $this->getPageQuery()
->where('contents.parent_id', $this->id);
if ($orderBy) {
$subpages->orderBy($orderBy, $orderDirection ? $orderDirection : 'ASC');
}
$subpages = $subpages->get();
// convert JSON settings into stdClass
foreach ($subpages as $i => $subpage) {
$subpages[$i]->module_settings = json_decode($subpage->module_settings);
}
$this->subpagesInit = true;
$this->foundSubpages = $subpages;
}
return $this->foundSubpages;
}
/**
* Returns list of all root pages - those pages, which parent_id is null
*
* @return mixed
*/
public function rootPages()
{
$rootPages = $this->getPageQuery()
->where('parent_id', null);
if ($this->id) {
$rootPages = $rootPages->where('id', '!=', $this->id);
}
return $rootPages->get();
}
/**
* Updates current model with information about changed columns
*
* @param array $fields
* @param array $request
* @param string $revisionId
*
* @return array revisionID and number of changed columns
*/
public function updateWithHistory(array $fields, array $request, $revisionId = null)
{
if (!$revisionId) {
$revisionId = uniqid();
}
$changed = 0;
foreach ($fields as $fieldDB => $fieldRequest) {
// ignore non-existing fields
if (!isset($request[$fieldRequest]) && !is_null($request[$fieldRequest])) {
continue;
}
// if module settings is still JSON, decode it to normal stdClass
if (is_string($this->module_settings)) {
$this->module_settings = json_decode($this->module_settings);
}
// are we editing common settings, or module-specific settings?
if (!in_array($fieldDB, $this->fillable)) {
// this field is not part of "core" content - probably it will be module settings
$commonField = false;
$fieldValue = isset($this->module_settings->$fieldDB) ? $this->module_settings->$fieldDB : null;
} else {
$commonField = true;
$fieldValue = $this->$fieldDB;
}
// remove any whitespaces around real content
if (!is_null($request[$fieldRequest])) {
$request[$fieldRequest] = trim($request[$fieldRequest]);
}
if (trim($fieldValue) != $request[$fieldRequest]) {
$this->saveHistory($revisionId, $fieldRequest, $fieldValue, $request);
// save change into database
if ($commonField) {
$this->$fieldDB = $request[$fieldRequest];
} else {
$this->module_settings->$fieldDB = $request[$fieldRequest];
}
$changed++;
}
}
// make JSON from stdClass
if (!is_string($this->module_settings)) {
$this->module_settings = json_encode($this->module_settings);
}
$this->save();
return [$revisionId, $changed];
}
/**
* Upload and set some image as title photo
*
* @param Request $request
*/
public function uploadTitlePhoto(Request $request)
{
if ($request->hasFile('titlePhoto')) {
return $this->file->upload($request->file('titlePhoto'), $request);
}
return null;
}
/** /**
* Upload and assign files to newly created content page * Upload and assign files to newly created content page
* *
* @param Request $request * @param $files
* @param null $revisionId * @param $assignedFiles
* @param null $revisionId
* *
* @return int * @return int
*/ */
public function uploadRelatedFiles(Request $request, $revisionId = null) public function uploadRelatedFiles($files, $assignedFiles = [], $revisionId = null)
{ {
$files = $request->all()['files'];
$changed = 0; $changed = 0;
// check if any file was removed // check if any file was removed
if ($revisionId) { if ($revisionId) {
$changed += $this->removeRelatedFiles($revisionId, $request); $changed += $this->removeRelatedFiles($revisionId, $assignedFiles);
} }
// allow uploading only on created pages // allow uploading only on created pages
@@ -222,13 +36,16 @@ trait Content
'name' => '.content_files', 'name' => '.content_files',
'hidden' => true 'hidden' => true
]); ]);
$request->directoryId = $directory->id; $data = new \stdClass();
$data->directoryId = $directory->id;
$fileModel = App::make(File::class);
foreach ($files as $file) { foreach ($files as $file) {
if (!$file) { if (!$file) {
continue; continue;
} }
$uploaded = $this->file->upload($file, $request); $uploaded = $fileModel->upload($file, $data);
// add assignement // add assignement
ContentHasFile::create([ ContentHasFile::create([
@@ -250,16 +67,13 @@ trait Content
* Delete files from association * Delete files from association
* *
* @param $revisionId * @param $revisionId
* @param $request
* *
* @return int * @return int
*/ */
private function removeRelatedFiles($revisionId, $request) private function removeRelatedFiles($revisionId, $assignedFiles)
{ {
$files = array_keys((array)$request->keepAssigned);
$allFiles = $this->files() $allFiles = $this->files()
->whereNotIn('id', $files) ->whereNotIn('id', $assignedFiles)
->get(); ->get();
foreach ($allFiles as $file) { foreach ($allFiles as $file) {
@@ -273,29 +87,6 @@ trait Content
return count($allFiles); return count($allFiles);
} }
/**
* Save history entry into database
*
* @param $revisionId
* @param $fieldRequest
* @param $fieldValue
* @param $request
*/
private function saveHistory($revisionId, $fieldRequest, $fieldValue, $request)
{ // setup history object
$history = [
'user_id' => \Auth::user()->id,
'content_id' => $this->id,
'edit_batch' => $revisionId,
'column' => $fieldRequest,
'old_value' => $fieldValue,
'new_value' => $request[$fieldRequest]
];
// save history
ContentHistory::create($history);
}
public function view() public function view()
{ {
$this->viewed++; $this->viewed++;
@@ -18,7 +18,7 @@ trait ContentHistory
public function getStructuredHistoryOf(Content $content) public function getStructuredHistoryOf(Content $content)
{ {
$data = $content->history() $data = $content->history()
->select('content_history.*', 'contents.module_handler', 'users.email AS user_email', 'users.name AS user_name') ->select('content_history.*', 'contents.moduleHandler', 'users.email AS user_email', 'users.name AS user_name')
->join('users', 'users.id', '=', 'content_history.user_id') ->join('users', 'users.id', '=', 'content_history.user_id')
->join('contents', 'contents.id', '=', 'content_history.content_id') ->join('contents', 'contents.id', '=', 'content_history.content_id')
->orderBy('changed_at', 'DESC') ->orderBy('changed_at', 'DESC')
@@ -61,7 +61,7 @@ trait ContentHistory
*/ */
// get handler of given content page // get handler of given content page
$handler = $change->module_handler; $handler = $change->moduleHandler;
return $handler::getHistoryHandler(); return $handler::getHistoryHandler();
} }
@@ -13,7 +13,7 @@ class ModuleHasCustomField extends Model
public $timestamps = false; public $timestamps = false;
protected $fillable = [ protected $fillable = [
'module_handler', 'moduleHandler',
'custom_field_id' 'custom_field_id'
]; ];
+11 -10
View File
@@ -3,7 +3,6 @@
namespace App\Models\FileManager\ModelTraits; namespace App\Models\FileManager\ModelTraits;
use App\Events\UploadFile; use App\Events\UploadFile;
use App\Http\Requests\Request;
use App\Models\FileManager\File as FileModel; use App\Models\FileManager\File as FileModel;
use Franzose\ClosureTable\Extensions\Str; use Franzose\ClosureTable\Extensions\Str;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@@ -34,13 +33,15 @@ trait File
* Saves file into FS and creates new record in database * Saves file into FS and creates new record in database
* *
* @param UploadedFile $file * @param UploadedFile $file
* @param Request $request * @param $data
* *
* @return array associative array - key 'file' is type of SymphonyFile and contains info about real file, key 'id' * @return array associative array - key 'file' is type of SymphonyFile and contains info about real file, key 'id'
* is ID of row in files table * is ID of row in files table
*/ */
public function upload(UploadedFile $file, Request $request) public function upload(UploadedFile $file, $data = [])
{ {
$data = (object)$data;
$destination = config('app.upload_path'); $destination = config('app.upload_path');
$filename = $this->getFilename($file); $filename = $this->getFilename($file);
@@ -54,7 +55,7 @@ trait File
} }
// insert record into database // insert record into database
$id = $this->saveIntoDatabase($uploadedFile, $request, $file->getClientOriginalName()); $id = $this->saveIntoDatabase($uploadedFile, $data, $file->getClientOriginalName());
// fire event about new file // fire event about new file
Event::fire(new UploadFile($uploadedFile, $id)); Event::fire(new UploadFile($uploadedFile, $id));
@@ -72,12 +73,12 @@ trait File
* This file saves new record into database. It also calculates hash of given file, obtains MIME type etc. * This file saves new record into database. It also calculates hash of given file, obtains MIME type etc.
* *
* @param SymphonyFile $file * @param SymphonyFile $file
* @param Request $request * @param $request
* @param $originalFilename * @param $originalFilename
* *
* @return mixed * @return mixed
*/ */
protected function saveIntoDatabase(SymphonyFile $file, Request $request, $originalFilename) protected function saveIntoDatabase(SymphonyFile $file, $request, $originalFilename)
{ {
// get path and hash of uploaded file // get path and hash of uploaded file
$path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->getFilename(); $path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->getFilename();
@@ -92,10 +93,10 @@ trait File
'hash_algorithm' => FileModel::HASH_ALGORITHM, 'hash_algorithm' => FileModel::HASH_ALGORITHM,
'mime_type' => $file->getMimeType(), 'mime_type' => $file->getMimeType(),
'file_size' => $file->getSize(), 'file_size' => $file->getSize(),
'name' => $request->name, 'name' => isset($request->name) ? $request->name : '',
'description' => $request->description, 'description' => isset($request->description) ? $request->description : '',
'directory_id' => $request->directoryId ? $request->directoryId : null, 'directory_id' => isset($request->directoryId) ? $request->directoryId ? $request->directoryId : null : null,
'keywords' => $request->keywords 'keywords' => isset($request->keyword) ? $request->keyword : ''
]); ]);
return $newFile->id; return $newFile->id;
+1 -1
View File
@@ -44,7 +44,7 @@ trait Module {
'manages_content' => $managesContent, 'manages_content' => $managesContent,
'support_categories' => $supportCategories, 'support_categories' => $supportCategories,
'alias' => $alias, 'alias' => $alias,
'module_settings' => json_encode($settings), 'moduleSettings' => json_encode($settings),
'parent_id' => $parentModuleId ? $parentModuleId : null, 'parent_id' => $parentModuleId ? $parentModuleId : null,
'enabled' => 1, 'enabled' => 1,
'is_template' => $isTemplate 'is_template' => $isTemplate
+1 -1
View File
@@ -17,7 +17,7 @@ class Module extends Model
'name', 'name',
'description', 'description',
'alias', 'alias',
'module_settings', 'moduleSettings',
'enabled', 'enabled',
'support_categories', 'support_categories',
'manages_content', 'manages_content',
+1
View File
@@ -20,6 +20,7 @@ class User extends Model implements AuthenticableInterface
'username', 'username',
'password', 'password',
'name', 'name',
'role'
]; ];
/** /**
* The attributes excluded from the model's JSON form. * The attributes excluded from the model's JSON form.
+7 -9
View File
@@ -32,18 +32,16 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
// ignore running from artisan
if (App::runningInConsole()) {
return;
}
$this->registerWidgets();
$this->registerSettings();
$this->registerSearch();
$this->app->bind(IContent::class, ContentRepository::class); $this->app->bind(IContent::class, ContentRepository::class);
$this->app->bind(IModule::class, ModuleRepository::class); $this->app->bind(IModule::class, ModuleRepository::class);
$this->app->bind(ITemplate::class, TemplateRepository::class); $this->app->bind(ITemplate::class, TemplateRepository::class);
// ignore running from artisan
if (!App::runningInConsole()) {
$this->registerWidgets();
$this->registerSettings();
$this->registerSearch();
}
} }
/** /**
@@ -1,7 +1,5 @@
<?php namespace App\Providers; <?php namespace App\Providers;
use App\Models\Language;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization; use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
@@ -16,14 +14,14 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
$supportedLocales = []; $supportedLocales = [];
if (empty($languages)) { if (empty($languages)) {
$supportedLocales[config('app.locale')] = [ $supportedLocales[config('app.locale')] = [
'native' => env('LOCALE_NATIVE_NAME'), 'native' => env('LOCALE_NATIVE_NAME', config('app.locale')),
'script' => env('LOCALE_SCRIPT'), 'script' => env('LOCALE_SCRIPT', 'Latn'),
'name' => env('LOCALE_TRANSLATED_NAME'), 'name' => env('LOCALE_TRANSLATED_NAME', config('app.locale')),
'code' => config('app.locale'), 'code' => config('app.locale'),
]; ];
// create default language // create default language
Language::create($supportedLocales[config('app.locale')]); DB::table('languages')
->insert($supportedLocales[config('app.locale')]);
} }
foreach ($languages as $language) { foreach ($languages as $language) {
+4 -4
View File
@@ -26,12 +26,12 @@ class ModuleManager extends ServiceProvider
// iterate over all modules and enable or disable them // iterate over all modules and enable or disable them
foreach ($modules as $module) { foreach ($modules as $module) {
$module->module_settings = json_decode($module->module_settings); $module->moduleSettings = json_decode($module->moduleSettings);
if ($module->is_template) { if ($module->is_template) {
if (isset($module->module_settings->providers) && !empty($module->module_settings->providers)) { if (isset($module->moduleSettings->providers) && !empty($module->moduleSettings->providers)) {
foreach ($module->module_settings->providers as $provider) { foreach ($module->moduleSettings->providers as $provider) {
$this->app->register($provider); $this->app->register($provider);
} }
} }
@@ -61,7 +61,7 @@ class ModuleManager extends ServiceProvider
*/ */
private function createModulesJson(Module $module) private function createModulesJson(Module $module)
{ {
$config = $module->module_settings; $config = $module->moduleSettings;
if (is_null($config)) { if (is_null($config)) {
return; return;
+12 -7
View File
@@ -2,9 +2,9 @@
namespace App\Providers; namespace App\Providers;
use App\CMS\Contracts\Repositories\Template as TemplateContract;
use App\CMS\Handlers\Registrators\TemplateRegistrator; use App\CMS\Handlers\Registrators\TemplateRegistrator;
use App\CMS\Helpers\CurrentTemplate; use App\CMS\Helpers\CurrentTemplate;
use App\Models\Templates\Template;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -13,7 +13,7 @@ class TemplateServiceProvider extends ServiceProvider
public function boot() public function boot()
{ {
// ignore running from artisan // ignore running from artisan
if (App::runningInConsole()) { if (App::runningInConsole() || App::environment('testing')) {
$this->publishViewResources(); $this->publishViewResources();
return; return;
@@ -26,19 +26,24 @@ class TemplateServiceProvider extends ServiceProvider
} }
// include files // include files
$files = isset($template->module_settings->files) ? $template->module_settings->files : []; $files = isset($template->moduleSettings->files) ? $template->moduleSettings->files : [];
foreach ($files as $file) { foreach ($files as $file) {
include_once $file; include_once $file;
} }
// register templates // register templates
$publicTemplates = call_user_func([CurrentTemplate::handler(), 'getPublicTemplatePaths']); $publicTemplates = CurrentTemplate::getPublicTemplatePaths();
if (!is_array($publicTemplates)) { if (!is_array($publicTemplates)) {
throw new \ErrorException(CurrentTemplate::handler() . '::getPublicTemplatePaths() must return array!'); throw new \ErrorException(CurrentTemplate::handler() . '::getPublicTemplatePaths() must return array!');
} }
$this->registerTemplatePaths($publicTemplates);
}
public function registerTemplatePaths($publicTemplates)
{
/** /**
* @var $registrator TemplateRegistrator * @var $registrator TemplateRegistrator
*/ */
@@ -76,12 +81,12 @@ class TemplateServiceProvider extends ServiceProvider
private function publishViewResources() private function publishViewResources()
{ {
$template = CurrentTemplate::get(); $template = CurrentTemplate::get();
if (!$template) { if (!$template || is_null($template->moduleSettings)) {
return; return;
} }
$templateDir = base_path('templates/' . $template->module_settings->staticName . '/Resources'); $templateDir = base_path('templates/' . $template->moduleSettings->staticName . '/Resources');
$assetsDir = $templateDir . '/' . Template::ASSETS_DIRECTORY; $assetsDir = $templateDir . '/' . TemplateContract::ASSETS_DIRECTORY;
$viewsDir = $templateDir . '/views'; $viewsDir = $templateDir . '/views';
// publish assets if exists for current theme // publish assets if exists for current theme
+14 -13
View File
@@ -55,8 +55,8 @@ return [
'mysql' => [ 'mysql' => [
'driver' => 'mysql', 'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'), 'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'), 'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME', 'forge'), 'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD', ''), 'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8', 'charset' => 'utf8',
'collation' => 'utf8_general_ci', 'collation' => 'utf8_general_ci',
@@ -64,6 +64,18 @@ return [
'strict' => false, 'strict' => false,
], ],
'mysqlTesting' => [
'driver' => 'mysql',
'host' => env('DB_UNIT_TESTS_HOST', 'localhost'),
'database' => env('DB_UNIT_TESTS_DATABASE'),
'username' => env('DB_UNIT_TESTS_USERNAME'),
'password' => env('DB_UNIT_TESTS_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
'strict' => false,
],
'pgsql' => [ 'pgsql' => [
'driver' => 'pgsql', 'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'), 'host' => env('DB_HOST', 'localhost'),
@@ -74,17 +86,6 @@ return [
'prefix' => '', 'prefix' => '',
'schema' => 'public', 'schema' => 'public',
], ],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
], ],
/* /*
+25 -4
View File
@@ -11,11 +11,32 @@
| |
*/ */
$factory->define(App\User::class, function (Faker\Generator $faker) { use App\CMS\Contracts\Repositories\Content as ContentContract;
use App\Models\Content\Content;
use App\Models\User;
use Carbon\Carbon;
$factory->define(User::class, function (Faker\Generator $faker) {
$email = $faker->email;
return [ return [
'name' => $faker->name, 'username' => $email,
'email' => $faker->email, 'email' => $email,
'name' => $faker->name,
'password' => bcrypt(str_random(10)), 'password' => bcrypt(str_random(10)),
'remember_token' => str_random(10), 'role' => 'admin',
]; ];
}); });
$factory->define(Content::class, function (Faker\Generator $faker) {
return [
'title' => $faker->sentence(5),
'userId' => 1,
'url' => $faker->slug(5),
'pageContent' => $faker->text(1500),
'metaDescription' => $faker->text,
'moduleHandler' => config('staticpages.handler'),
'language' => env('LOCALES'),
'publishedFrom' => Carbon::now(),
'status' => ContentContract::STATUS_PUBLIC
];
});
@@ -26,7 +26,7 @@ class AddUniqueCodeToWidgets extends Migration
}); });
// migrate data // migrate data
$widgets = \App\Models\Widget::all(); $widgets = \App\Models\Widgets\Widget::all();
foreach ($widgets as $widget) { foreach ($widgets as $widget) {
$widget->settings = json_decode($widget->settings); $widget->settings = json_decode($widget->settings);
if (isset($widget->settings->containerClass)) { if (isset($widget->settings->containerClass)) {
@@ -0,0 +1,67 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RenameColumnInContents extends Migration
{
protected $columns;
public function __construct()
{
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
$this->columns = [
'user_id',
'parent_id',
'category_id',
'language',
'module_handler',
'published_from',
'published_to',
'title_photo',
'template',
'is_homepage',
'title',
'url',
'meta_keywords',
'meta_description',
'content',
'module_settings',
'status'
];
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contents', function (Blueprint $table) {
foreach ($this->columns as $column) {
$table->renameColumn($column, camel_case($column));
}
$table->renameColumn('content', 'pageContent');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contents', function (Blueprint $table) {
foreach ($this->columns as $column) {
$table->renameColumn(camel_case($column), $column);
}
$table->renameColumn('pageContent', 'content');
});
}
}
+10 -18
View File
@@ -5,7 +5,6 @@ use App\CMS\Contracts\Content\AdvancedContentModifier;
use App\CMS\Contracts\Content\ContentTitles; use App\CMS\Contracts\Content\ContentTitles;
use App\CMS\Contracts\Modules\InstallableModule; use App\CMS\Contracts\Modules\InstallableModule;
use App\CMS\Handlers\Handler; use App\CMS\Handlers\Handler;
use App\Http\Controllers\Admin\Contents\EditContent;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\Request; use App\Http\Requests\Request;
use App\Models\ActionLog\ActionLogType; use App\Models\ActionLog\ActionLogType;
@@ -27,7 +26,7 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
public function render(Content $content, $parameters) public function render(Content $content, $parameters)
{ {
$content->comments = []; $content->comments = [];
if (isset($content->module_settings->allowComments) && $content->module_settings->allowComments) { if (isset($content->moduleSettings->allowComments) && $content->moduleSettings->allowComments) {
$content->comments = Comment::where('content_id', $content->id) $content->comments = Comment::where('content_id', $content->id)
->with('author') ->with('author')
->where('approved', 1) ->where('approved', 1)
@@ -62,7 +61,7 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
*/ */
public static function createNew(Content &$content, Request $request) public static function createNew(Content &$content, Request $request)
{ {
$content->module_settings = json_encode(['allowComments' => (int)$request->has('allowComments')]); $content->moduleSettings = ['allowComments' => (int)$request->has('allowComments')];
} }
/** /**
@@ -73,23 +72,18 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
* @param Content $content * @param Content $content
* @param Request $request * @param Request $request
* *
* @param $revisionID string ID of revision used * @return void
*
* @return int number of edited fields
*/ */
public static function edit(Content &$content, Request $request, $revisionID) public static function edit(Content $content, $request)
{ {
$fields = ['allowComments' => 'allowComments']; $settings = $content->moduleSettings;
if (!is_object($settings))
$settings = new \stdClass();
// get data and try to save them $settings->allowComments = isset($request['allowComments']) ? (int)$request['allowComments'] : 0;
$data = EditContent::getFields($request, $fields);
$data['allowComments'] = (int)$data['allowComments']; $content->moduleSettings = $settings;
$content->save();
list($revision, $changedColumns) = $content->updateWithHistory($fields, $data, $revisionID);
// return amount of changed columns
return $changedColumns;
} }
/** /**
@@ -99,8 +93,6 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
*/ */
public static function registerAdminMenu(User $user) public static function registerAdminMenu(User $user)
{ {
parent::registerAdminMenu($user);
$menu = \Menu::instance('mainMenu'); $menu = \Menu::instance('mainMenu');
$blogSubmenu = $menu->whereTitle(trans('article::module.blog')); $blogSubmenu = $menu->whereTitle(trans('article::module.blog'));
@@ -14,12 +14,12 @@ class CreateNewComment extends Controller
public function postNew(\Modules\Blog\Article\Http\Requests\CreateNewComment $request, $articleId) public function postNew(\Modules\Blog\Article\Http\Requests\CreateNewComment $request, $articleId)
{ {
$article = Content::where('id', $articleId) $article = Content::where('id', $articleId)
->where('module_handler', Article::class) ->where('moduleHandler', Article::class)
->firstOrFail(); ->firstOrFail();
$article->module_settings = json_decode($article->module_settings); $article->moduleSettings = json_decode($article->moduleSettings);
if (!isset($article->module_settings->allowComments) || !$article->module_settings->allowComments) { if (!isset($article->moduleSettings->allowComments) || !$article->moduleSettings->allowComments) {
return redirect() return redirect()
->route('page.content', ['url' => $article->url]) ->route('page.content', ['url' => $article->url])
->with('error', trans('article::comments.disabledComments')); ->with('error', trans('article::comments.disabledComments'));
@@ -37,12 +37,12 @@
@include('admin.snippets.hasError', ['field' => 'status']) @include('admin.snippets.hasError', ['field' => 'status'])
</div> </div>
<div class="col-lg-4"> <div class="col-lg-4">
<select class="form-control" name="parentPage"> <select class="form-control" name="parentId">
<option value="">@lang('admin/contents.noParentPage')</option> <option value="">@lang('admin/contents.noParentPage')</option>
@foreach($rootPages as $rootPage) @foreach($rootPages as $rootPage)
<option value="{{$rootPage->id}}" <option value="{{$rootPage->id}}"
@if(old('parent_page', $page->parent_id) == $rootPage->id) selected @endif> @if(old('parentId', $page->parentId) == $rootPage->id) selected @endif>
{{$rootPage->title}} {{$rootPage->title}}
</option> </option>
@endforeach @endforeach
@@ -54,7 +54,7 @@
<div class="col-lg-2 text-center"> <div class="col-lg-2 text-center">
<label> <label>
<input class="checkbox" value="1" <input class="checkbox" value="1"
@if(old('allowComments', isset($page->module_settings->allowComments) ? $page->module_settings->allowComments : true)) checked @if(old('allowComments', isset($page->moduleSettings->allowComments) ? $page->moduleSettings->allowComments : true)) checked
@endif name="allowComments" type="checkbox"> @endif name="allowComments" type="checkbox">
<span>@lang('article::article.allowComments')</span> <span>@lang('article::article.allowComments')</span>
</label> </label>
@@ -62,11 +62,11 @@
@if($module->support_categories && count($categories)) @if($module->support_categories && count($categories))
<div class="col-lg-12"> <div class="col-lg-12">
<select class="form-control" name="category"> <select class="form-control" name="categoryId">
<option value="">@lang('admin/contents.noCategory')</option> <option value="">@lang('admin/contents.noCategory')</option>
@foreach($categories as $category) @foreach($categories as $category)
<option value="{{$category->id}}" <option value="{{$category->id}}"
@if($category->id == old('category', $page->category_id)) selected @endif> @if($category->id == old('categoryId', $page->categoryId)) selected @endif>
{{str_repeat(' - ', $category->real_depth)}} {{$category->name}} {{str_repeat(' - ', $category->real_depth)}} {{$category->name}}
</option> </option>
@endforeach @endforeach
@@ -78,7 +78,7 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<textarea name="pageContent" id="pageContent" class="wysiwyg-editor"> <textarea name="pageContent" id="pageContent" class="wysiwyg-editor">
{{old('pageContent', $page->content)}} {{old('pageContent', $page->pageContent)}}
</textarea> </textarea>
</div> </div>
</div> </div>
@@ -96,18 +96,18 @@ class ArticleList extends Handler
*/ */
public function render(Content $content, $parameters) public function render(Content $content, $parameters)
{ {
$articles = ArticleModel::where('module_handler', Article::class) $articles = ArticleModel::where('moduleHandler', Article::class)
->with('comments') ->with('comments')
->with('category') ->with('category')
->where(function ($query) { ->where(function ($query) {
$query->where('published_from', '<', Carbon::now()) $query->where('publishedFrom', '<', Carbon::now())
->orWhereNull('published_from'); ->orWhereNull('publishedFrom');
}) })
->where(function ($query) { ->where(function ($query) {
$query->where('published_to', '>', Carbon::now()) $query->where('publishedTo', '>', Carbon::now())
->orWhereNull('published_to'); ->orWhereNull('publishedTo');
}) })
->orderBy('published_from', 'DESC') ->orderBy('publishedFrom', 'DESC')
->orderBy('created_at', 'DESC'); ->orderBy('created_at', 'DESC');
// show articles for not-logged users of even for logged onew? // show articles for not-logged users of even for logged onew?
@@ -135,7 +135,7 @@ class ArticleList extends Handler
// decode module settings // decode module settings
foreach ($articles as $article) { foreach ($articles as $article) {
$article->module_settings = json_decode($article->module_settings); $article->moduleSettings = json_decode($article->moduleSettings);
} }
return Controller::VisitorsView($content->template, [ return Controller::VisitorsView($content->template, [
+3 -3
View File
@@ -40,7 +40,7 @@ class ContactForm extends Handler implements ContentTitles, AdvancedContentModif
]; ];
// save settings // save settings
$content->module_settings = json_encode($settings); $content->moduleSettings = json_encode($settings);
} }
/** /**
@@ -55,7 +55,7 @@ class ContactForm extends Handler implements ContentTitles, AdvancedContentModif
* *
* @return int number of edited fields * @return int number of edited fields
*/ */
public static function edit(Content &$content, Request $request, $revisionID) public static function edit(Content $content, $request)
{ {
$fields = [ $fields = [
'phone' => 'phone', 'phone' => 'phone',
@@ -70,7 +70,7 @@ class ContactForm extends Handler implements ContentTitles, AdvancedContentModif
// get data and try to save them // get data and try to save them
$data = EditContent::getFields($request, $fields); $data = EditContent::getFields($request, $fields);
list($revision, $changedColumns) = $content->updateWithHistory($fields, $data, $revisionID); list($revision, $changedColumns) = $content->updateWithHistory($fields, $data);
// return amount of changed columns // return amount of changed columns
return $changedColumns; return $changedColumns;
@@ -21,22 +21,22 @@ class CreateNewMessage extends Controller
public function postMessage(SendNewEmailRequest $request, $formId) public function postMessage(SendNewEmailRequest $request, $formId)
{ {
// load form settings // load form settings
$form = Content::where('module_handler', config('contactform.handler')) $form = Content::where('moduleHandler', config('contactform.handler'))
->findOrFail($formId); ->findOrFail($formId);
$form->module_settings = json_decode($form->module_settings); $form->moduleSettings = json_decode($form->moduleSettings);
// select template // select template
$template = isset($form->module_settings->emailTemplate) ? $form->module_settings->emailTemplate : 'contactform::emails.default'; $template = isset($form->moduleSettings->emailTemplate) ? $form->moduleSettings->emailTemplate : 'contactform::emails.default';
// send email // send email
$status = Mail::send(Template::name($template), ['data' => $request], function (Message $message) use ($request, $form) { $status = Mail::send(Template::name($template), ['data' => $request], function (Message $message) use ($request, $form) {
$message->from($request->email, $request->name); $message->from($request->email, $request->name);
// get message subject // get message subject
$subject = isset($form->module_settings->subject) ? $form->module_settings->subject : trans('contactform::admin/contents.defaultSubject'); $subject = isset($form->moduleSettings->subject) ? $form->moduleSettings->subject : trans('contactform::admin/contents.defaultSubject');
$message->to($form->module_settings->email) $message->to($form->moduleSettings->email)
->subject($subject); ->subject($subject);
}); });
@@ -55,11 +55,11 @@
@if($module->support_categories && count($categories)) @if($module->support_categories && count($categories))
<div class="col-lg-12"> <div class="col-lg-12">
<select class="form-control" name="category"> <select class="form-control" name="categoryId">
<option value="">@lang('admin/contents.noCategory')</option> <option value="">@lang('admin/contents.noCategory')</option>
@foreach($categories as $category) @foreach($categories as $category)
<option value="{{$category->id}}" <option value="{{$category->id}}"
@if($category->id == old('category', $page->category_id)) selected @endif> @if($category->id == old('categoryId', $page->categoryId)) selected @endif>
{{str_repeat(' - ', $category->real_depth)}} {{$category->name}} {{str_repeat(' - ', $category->real_depth)}} {{$category->name}}
</option> </option>
@endforeach @endforeach
@@ -77,26 +77,26 @@
@lang('contactform::admin/content.email') @lang('contactform::admin/content.email')
</label> </label>
<input class="form-control" type="email" name="email" value="{{$page->module_settings->email or ""}}" /> <input class="form-control" type="email" name="email" value="{{$page->moduleSettings->email or ""}}" />
<label class="label-control"> <label class="label-control">
@lang('contactform::admin/content.phone') @lang('contactform::admin/content.phone')
</label> </label>
<input class="form-control" type="tel" name="phone" value="{{$page->module_settings->phone or ""}}" /> <input class="form-control" type="tel" name="phone" value="{{$page->moduleSettings->phone or ""}}" />
<label class="label-control"> <label class="label-control">
@lang('contactform::admin/content.compName') @lang('contactform::admin/content.compName')
</label> </label>
<input class="form-control" type="text" name="companyName" <input class="form-control" type="text" name="companyName"
value="{{$page->module_settings->companyName or ""}}" /> value="{{$page->moduleSettings->companyName or ""}}" />
<label class="label-control"> <label class="label-control">
@lang('contactform::admin/content.address') @lang('contactform::admin/content.address')
</label> </label>
<textarea rows="3" class="form-control" name="address">{{$page->module_settings->address or ""}}</textarea> <textarea rows="3" class="form-control" name="address">{{$page->moduleSettings->address or ""}}</textarea>
</div> </div>
<div class="column col-lg-6"> <div class="column col-lg-6">
@@ -105,14 +105,14 @@
</label> </label>
<input class="form-control" type="email" name="contactEmail" <input class="form-control" type="email" name="contactEmail"
value="{{$page->module_settings->contactEmail or \Auth::user()->email}}" /> value="{{$page->moduleSettings->contactEmail or \Auth::user()->email}}" />
<label class="label-control"> <label class="label-control">
@lang('contactform::admin/content.subject') @lang('contactform::admin/content.subject')
</label> </label>
<input class="form-control" type="text" name="subject" <input class="form-control" type="text" name="subject"
value="{{$page->module_settings->subject or trans('contactform::admin/content.defaultSubject')}}" /> value="{{$page->moduleSettings->subject or trans('contactform::admin/content.defaultSubject')}}" />
<div class="row"> <div class="row">
<div class="column col-lg-6"> <div class="column col-lg-6">
@@ -120,7 +120,7 @@
@lang('contactform::admin/content.gpsLat') @lang('contactform::admin/content.gpsLat')
</label> </label>
<input class="form-control" type="text" value="{{$page->module_settings->gpsLat or ""}}" <input class="form-control" type="text" value="{{$page->moduleSettings->gpsLat or ""}}"
name="gpsLat" /> name="gpsLat" />
</div> </div>
<div class="column col-lg-6"> <div class="column col-lg-6">
@@ -128,7 +128,7 @@
@lang('contactform::admin/content.gpsLng') @lang('contactform::admin/content.gpsLng')
</label> </label>
<input class="form-control" type="text" value="{{$page->module_settings->gpsLng or ""}}" <input class="form-control" type="text" value="{{$page->moduleSettings->gpsLng or ""}}"
name="gpsLng" /> name="gpsLng" />
</div> </div>
</div> </div>
@@ -24,7 +24,7 @@ class Presenter implements WidgetRenderer
if (!$form) if (!$form)
return null; return null;
$formData = json_decode($form->module_settings); $formData = json_decode($form->moduleSettings);
$code = '<div class="address-widget ' . e($widget->container_class) . '"'; $code = '<div class="address-widget ' . e($widget->container_class) . '"';
if ($widget->container_id) { if ($widget->container_id) {
@@ -47,7 +47,7 @@ class Presenter implements WidgetRenderer
*/ */
public static function renderAddForm(WidgetType $type) public static function renderAddForm(WidgetType $type)
{ {
$contactForms = Content::where('module_handler', config('contactform.handler')) $contactForms = Content::where('moduleHandler', config('contactform.handler'))
->get(); ->get();
return view('contactform::admin.widgets.address.new', [ return view('contactform::admin.widgets.address.new', [
@@ -66,7 +66,7 @@ class Presenter implements WidgetRenderer
*/ */
public static function renderEditForm(Widget $widget) public static function renderEditForm(Widget $widget)
{ {
$contactForms = Content::where('module_handler', config('contactform.handler')) $contactForms = Content::where('moduleHandler', config('contactform.handler'))
->get(); ->get();
return view('contactform::admin.widgets.address.edit', [ return view('contactform::admin.widgets.address.edit', [
'widget' => $widget, 'widget' => $widget,
@@ -32,7 +32,7 @@ class Presenter implements WidgetRenderer
return null; return null;
} }
$form->module_settings = json_decode($form->module_settings); $form->moduleSettings = json_decode($form->moduleSettings);
return view(self::$template, ['widget' => $widget, 'form' => $form]); return view(self::$template, ['widget' => $widget, 'form' => $form]);
} }
@@ -46,7 +46,7 @@ class Presenter implements WidgetRenderer
*/ */
public static function renderAddForm(WidgetType $type) public static function renderAddForm(WidgetType $type)
{ {
$contactForms = Content::where('module_handler', config('contactform.handler')) $contactForms = Content::where('moduleHandler', config('contactform.handler'))
->get(); ->get();
return view('contactform::admin.widgets.form.new', [ return view('contactform::admin.widgets.form.new', [
@@ -65,7 +65,7 @@ class Presenter implements WidgetRenderer
*/ */
public static function renderEditForm(Widget $widget) public static function renderEditForm(Widget $widget)
{ {
$contactForms = Content::where('module_handler', config('contactform.handler')) $contactForms = Content::where('moduleHandler', config('contactform.handler'))
->get(); ->get();
return view('contactform::admin.widgets.address.edit', [ return view('contactform::admin.widgets.address.edit', [
'widget' => $widget, 'widget' => $widget,
+9 -9
View File
@@ -29,7 +29,7 @@ class Gallery implements AppHandler
public function render(Content $content, $parameters) public function render(Content $content, $parameters)
{ {
// get directory ID // get directory ID
$directoryId = $content->module_settings->directoryId; $directoryId = $content->moduleSettings->directoryId;
// get all images in given directory // get all images in given directory
$images = File::where('directory_id', $directoryId) $images = File::where('directory_id', $directoryId)
@@ -56,12 +56,12 @@ class Gallery implements AppHandler
*/ */
public static function loadExtraData(Content $content) public static function loadExtraData(Content $content)
{ {
if (is_string($content->module_settings)) { if (is_string($content->moduleSettings)) {
$content->module_settings = json_decode($content->module_settings); $content->moduleSettings = json_decode($content->moduleSettings);
} }
$extra = [ $extra = [
'slider' => isset($content->module_settings->slider) ? $content->module_settings->slider : false 'slider' => isset($content->moduleSettings->slider) ? $content->moduleSettings->slider : false
]; ];
return $extra; return $extra;
@@ -91,7 +91,7 @@ class Gallery implements AppHandler
$settings = ['directoryId' => $directory->id]; $settings = ['directoryId' => $directory->id];
// save settings // save settings
$content->module_settings = json_encode($settings); $content->moduleSettings = json_encode($settings);
} }
/** /**
@@ -224,13 +224,13 @@ class Gallery implements AppHandler
*/ */
public static function delete(Content $content) public static function delete(Content $content)
{ {
// try to convert module_settings into something more accessible // try to convert moduleSettings into something more accessible
if (is_string($content->module_settings)) { if (is_string($content->moduleSettings)) {
$content->module_settings = json_decode($content->module_settings); $content->moduleSettings = json_decode($content->moduleSettings);
} }
// get directory id // get directory id
$directoryId = $content->module_settings->directoryId; $directoryId = $content->moduleSettings->directoryId;
$directory = Directory::find($directoryId); $directory = Directory::find($directoryId);
@@ -1,5 +1,5 @@
<div class="row column"> <div class="row column">
<a href="{{route('upload.overview', ['id' => $page->module_settings->directoryId])}}" class="button large expanded success">@lang('gallery::admin/content.upload')</a> <a href="{{route('upload.overview', ['id' => $page->moduleSettings->directoryId])}}" class="button large expanded success">@lang('gallery::admin/content.upload')</a>
</div> </div>
<div class="row column text-center"> <div class="row column text-center">
@@ -1,9 +1,9 @@
@if($page->title_photo) @if($page->titlePhoto)
<div class="row"> <div class="row">
<div id="titlePhotoContainer" <div id="titlePhotoContainer"
class="col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3 col-sm-12 title-photo text-center"> class="col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3 col-sm-12 title-photo text-center">
<input type="hidden" id="existingTitlePhoto" value="{{$page->title_photo}}" name="existingTitlePhoto"> <input type="hidden" id="existingTitlePhoto" value="{{$page->titlePhoto}}" name="existingTitlePhoto">
<p><img src="@thumbnail($page->title_photo)" alt="" /></p> <p><img src="@thumbnail($page->titlePhoto)" alt="" /></p>
<p> <p>
<a href="javascript:void(0)" id="removeTitlePhoto" class="btn btn-warning" data-toggle="tooltip" <a href="javascript:void(0)" id="removeTitlePhoto" class="btn btn-warning" data-toggle="tooltip"
title="@lang('admin/contents.deleteTitlePhoto')"><i title="@lang('admin/contents.deleteTitlePhoto')"><i
@@ -39,12 +39,12 @@
@include('admin.snippets.hasError', ['field' => 'status']) @include('admin.snippets.hasError', ['field' => 'status'])
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<select class="form-control" name="parentPage"> <select class="form-control" name="parentId">
<option value="">@lang('admin/contents.noParentPage')</option> <option value="">@lang('admin/contents.noParentPage')</option>
@foreach($rootPages as $rootPage) @foreach($rootPages as $rootPage)
<option value="{{$rootPage->id}}" <option value="{{$rootPage->id}}"
@if(old('parent_page', $page->parent_id) == $rootPage->id) selected @endif> @if(old('parentId', $page->parentId) == $rootPage->id) selected @endif>
{{$rootPage->title}} {{$rootPage->title}}
</option> </option>
@endforeach @endforeach
@@ -55,11 +55,11 @@
@if($module->support_categories && count($categories)) @if($module->support_categories && count($categories))
<div class="col-lg-12"> <div class="col-lg-12">
<select class="form-control" name="category"> <select class="form-control" name="categoryId">
<option value="">@lang('admin/contents.noCategory')</option> <option value="">@lang('admin/contents.noCategory')</option>
@foreach($categories as $category) @foreach($categories as $category)
<option value="{{$category->id}}" <option value="{{$category->id}}"
@if($category->id == old('category', $page->category_id)) selected @endif> @if($category->id == old('categoryId', $page->categoryId)) selected @endif>
{{str_repeat(' - ', $category->real_depth)}} {{$category->name}} {{str_repeat(' - ', $category->real_depth)}} {{$category->name}}
</option> </option>
@endforeach @endforeach
@@ -71,7 +71,7 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<textarea name="pageContent" id="pageContent" rows="15" class="wysiwyg-editor"> <textarea name="pageContent" id="pageContent" rows="15" class="wysiwyg-editor">
{{old('pageContent', $page->content)}} {{old('pageContent', $page->pageContent)}}
</textarea> </textarea>
</div> </div>
</div> </div>
@@ -4,7 +4,7 @@
@lang('admin/contents.field_meta_keywords') @lang('admin/contents.field_meta_keywords')
</label> </label>
<input type="text" name="metaKeywords" class="form-control" value="{{old('meta_keywords', $page->meta_keywords)}}" placeholder="@lang('admin/contents.field_meta_keywords')" /> <input type="text" name="metaKeywords" class="form-control" value="{{old('metaKeywords', $page->metaKeywords)}}" placeholder="@lang('admin/contents.field_meta_keywords')" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@@ -14,6 +14,6 @@
</label> </label>
<textarea class="form-control" name="metaDescription" placeholder="@lang('admin/contents.field_meta_description')" rows="5">{{old('meta_description', $page->meta_description)}}</textarea> <textarea class="form-control" name="metaDescription" placeholder="@lang('admin/contents.field_meta_description')" rows="5">{{old('metaDescription', $page->metaDescription)}}</textarea>
</div> </div>
</div> </div>
@@ -1,22 +1,22 @@
<div class="row"> <div class="row">
<div class="col-lg-6"> <div class="col-lg-6">
<label class="control-label"> <label class="control-label">
@lang('admin/contents.field_published_from') @lang('admin/contents.field_publishedFrom')
</label> </label>
<input type="datetime" class="form-control" name="publishedFrom" value="{{old('published_from', $page->published_from)}}" <input type="datetime" class="form-control" name="publishedFrom" value="{{old('publishedFrom', $page->publishedFrom)}}"
placeholder="@lang('admin/contents.field_published_from')" /> placeholder="@lang('admin/contents.field_publishedFrom')" />
@include('admin.snippets.hasError', ['field' => 'published_from']) @include('admin.snippets.hasError', ['field' => 'publishedFrom'])
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<label class="control-label"> <label class="control-label">
@lang('admin/contents.field_published_to') @lang('admin/contents.field_publishedTo')
</label> </label>
<input type="datetime" class="form-control" name="publishedTo" value="{{old('published_to', $page->published_to)}}" <input type="datetime" class="form-control" name="publishedTo" value="{{old('publishedTo', $page->publishedTo)}}"
placeholder="@lang('admin/contents.field_published_to')" /> placeholder="@lang('admin/contents.field_publishedTo')" />
@include('admin.snippets.hasError', ['field' => 'published_to']) @include('admin.snippets.hasError', ['field' => 'publishedTo'])
</div> </div>
</div> </div>
@@ -1,6 +1,6 @@
@extends('admin.layoutWithNavigation') @extends('admin.layoutWithNavigation')
@section('pageHeading', @trans(isset($pageHeading) ? $pageHeading : 'admin/contents.overview')) @section('pageHeading', @trans($pageHeading))
@section('headerButtons') @section('headerButtons')
@if($module->exists === true) @if($module->exists === true)
@@ -34,13 +34,13 @@
@foreach($pages as $page) @foreach($pages as $page)
<div class="row p-tb-15"> <div class="row p-tb-15">
<div class="col-md-1 hidden-sm-down text-center with-placeholder"> <div class="col-md-1 hidden-sm-down text-center with-placeholder">
<a href="{{route('content.edit', ['url' => $page->url])}}"> <a href="{{route('content.edit', ['id' => $page->id])}}">
@if(!view()->exists(\App\CMS\Helpers\Template::name($page->template, false))) @if(!view()->exists(template_name($page->template, false)))
<i class="fa fa-2x text-warning fa-warning" data-toggle="tooltip" <i class="fa fa-2x text-warning fa-warning" data-toggle="tooltip"
title="@lang('admin/contents.invalidTemplateSelected')"></i> title="@lang('admin/contents.invalidTemplateSelected')"></i>
@else @else
@if(!empty($page->title_photo)) @if(!empty($page->titlePhoto))
<img src="@thumbnail($page->title_photo)" class="placeholder" <img src="@thumbnail($page->titlePhoto)" class="placeholder"
alt="{{$page->title}}" /> alt="{{$page->title}}" />
@else @else
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}" <img src="{{asset('resources/assets/admin/img/placeholder.png')}}"
@@ -51,11 +51,11 @@
</a> </a>
</div> </div>
<div class="col-xs-10 col-md-3 col-lg-4"> <div class="col-xs-10 col-md-3 col-lg-4">
<a href="{{route('content.edit', ['url' => $page->url])}}"> <a href="{{route('content.edit', ['id' => $page->id])}}">
{{$page->title}} {{$page->title}}
</a> </a>
@if($page->is_homepage) <span class="m-l-10 tag tag-primary">@lang('admin/contents.homepage')</span> @endif @if($page->isHomepage) <span class="m-l-10 tag tag-primary">@lang('admin/contents.homepage')</span> @endif
</div> </div>
<div class="col-lg-2 col-md-3 hidden-sm-down"> <div class="col-lg-2 col-md-3 hidden-sm-down">
<span class="tag @if($page->isPublic()) tag-success <span class="tag @if($page->isPublic()) tag-success
@@ -81,7 +81,7 @@
<div class="item-actions-block"> <div class="item-actions-block">
<ul class="item-actions-list"> <ul class="item-actions-list">
@if(!$page->is_homepage) @if(!$page->isHomepage)
<li> <li>
<a href="{{route('content.setHomepage', ['id' => $page->id])}}" <a href="{{route('content.setHomepage', ['id' => $page->id])}}"
@@ -92,7 +92,7 @@
@endif @endif
<li> <li>
<a class="edit" href="{{route('content.edit', ['url' => $page->url])}}" <a class="edit" href="{{route('content.edit', ['id' => $page->id])}}"
data-toggle="tooltip" title="@lang('admin/contents.editPlain')"> data-toggle="tooltip" title="@lang('admin/contents.editPlain')">
<i class="fa fa-pencil"></i> <i class="fa fa-pencil"></i>
</a> </a>
@@ -115,7 +115,7 @@
</li> </li>
@else @else
<li> <li>
<a href="{{route('page.content', ['url' => $page->url])}}" target="_blank" <a href="{{route('page.content', ['id' => $page->id])}}" target="_blank"
data-toggle="tooltip" title="@lang('admin/contents.viewPage')" data-toggle="tooltip" title="@lang('admin/contents.viewPage')"
class="button tiny secondary"><i class="fa fa-globe"></i> class="button tiny secondary"><i class="fa fa-globe"></i>
</a> </a>
@@ -11,8 +11,8 @@
<tr> <tr>
<td class="text-center with-placeholder"> <td class="text-center with-placeholder">
<a href="{{route('content.edit', ['id' => $page->id])}}"> <a href="{{route('content.edit', ['id' => $page->id])}}">
@if(!empty($page->title_photo)) @if(!empty($page->titlePhoto))
<img src="@upload($page->title_photo)" class="placeholder" alt="{{$page->title}}" /> <img src="@upload($page->titlePhoto)" class="placeholder" alt="{{$page->title}}" />
@else @else
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}" class="placeholder" <img src="{{asset('resources/assets/admin/img/placeholder.png')}}" class="placeholder"
alt="{{$page->title}}" /> alt="{{$page->title}}" />
+2 -2
View File
@@ -40,7 +40,7 @@ abstract class OnePage implements TemplateHandler, InstallableModule
public static function registerAdminMenu(User $user) public static function registerAdminMenu(User $user)
{ {
$menu = \Menu::instance('mainMenu'); $menu = \Menu::instance('mainMenu');
$menu->route('template.setHomepage', trans('template::admin/mainMenu.setHomepage'), [], 1, ['icon' => 'fa fa-fw fa-home']); // $menu->route('template.setHomepage', trans('template::admin/mainMenu.setHomepage'), [], 1, ['icon' => 'fa fa-fw fa-home']);
} }
/** /**
@@ -92,7 +92,7 @@ abstract class OnePage implements TemplateHandler, InstallableModule
*/ */
public static function beforeRender(Content & $content) public static function beforeRender(Content & $content)
{ {
if ($content->is_homepage) { if ($content->isHomepage) {
$pages = self::getPagesOnHomepage(); $pages = self::getPagesOnHomepage();
// create real content from pages // create real content from pages
@@ -48,7 +48,7 @@ class SetHomepage extends Controller
$homepage = null; $homepage = null;
foreach ($allPages as $page) { foreach ($allPages as $page) {
if ($page->is_homepage) { if ($page->isHomepage) {
$homepage = $page; $homepage = $page;
continue; continue;
} }
@@ -82,7 +82,7 @@ class SetHomepage extends Controller
{ {
$page = $this->content->getOne($id); $page = $this->content->getOne($id);
if ($page->is_homepage) { if ($page->isHomepage) {
return redirect() return redirect()
->back() ->back()
->with('error', trans('template::admin/setHomepage.cannotSetHomepageAsPartOfHomepage')); ->with('error', trans('template::admin/setHomepage.cannotSetHomepageAsPartOfHomepage'));
@@ -66,7 +66,7 @@ Improvement: http://www.html5rocks.com/en/tutorials/dnd/basics/
<a href="{{route('content.edit', ['id' => $page->id])}}" <a href="{{route('content.edit', ['id' => $page->id])}}"
class="btn btn-secondary btn-sm"><i class="btn btn-secondary btn-sm"><i
class="fa fa-fw fa-pencil"></i></a> class="fa fa-fw fa-pencil"></i></a>
@if(!$page->is_homepage) @if(!$page->isHomepage)
<a href="{{route('content.setHomepage', ['id' => $page->id])}}" <a href="{{route('content.setHomepage', ['id' => $page->id])}}"
class="btn btn-secondary confirm btn-sm" class="btn btn-secondary confirm btn-sm"
data-toggle="tooltip" title="@lang('admin/contents.setHomepage')"> data-toggle="tooltip" title="@lang('admin/contents.setHomepage')">
@@ -7,8 +7,8 @@
<div class="row article-list-item"> <div class="row article-list-item">
<aside class="column text-right large-1"> <aside class="column text-right large-1">
<div class="date"> <div class="date">
<span class="date day big">@customDate('j', $page->published_from ?: $page->created_at)</span> <span class="date day big">@customDate('j', $page->publishedFrom ?: $page->created_at)</span>
<span class="date uppercase month">@monthName($page->published_from ?: $page->created_at)</span> <span class="date uppercase month">@monthName($page->publishedFrom ?: $page->created_at)</span>
</div> </div>
<div class="m-t-25 author"> <div class="m-t-25 author">
<img class="gravatar" src="@gravatar($page->author->email, 50)" alt=""> <img class="gravatar" src="@gravatar($page->author->email, 50)" alt="">
@@ -22,7 +22,7 @@
@endif @endif
@if(isset($page->module_settings->allowComments) && $page->module_settings->allowComments != 0) @if(isset($page->moduleSettings->allowComments) && $page->moduleSettings->allowComments != 0)
<div class="m-t-35"> <div class="m-t-35">
<a href="#comments">{{$page->comments->count()}} <i class="fa fa-comments"></i></a> <a href="#comments">{{$page->comments->count()}} <i class="fa fa-comments"></i></a>
</div> </div>
@@ -36,7 +36,7 @@
</article> </article>
</div> </div>
</div> </div>
@if(isset($page->module_settings->allowComments) && $page->module_settings->allowComments != 0) @if(isset($page->moduleSettings->allowComments) && $page->moduleSettings->allowComments != 0)
<div class="row m-t-50"> <div class="row m-t-50">
<a name="comments"></a> <a name="comments"></a>
@@ -14,9 +14,9 @@
<div class="row"> <div class="row">
<aside class="column text-right large-3"> <aside class="column text-right large-3">
<div class="date"> <div class="date">
<span class="date day big">@customDate('j', $article->published_from ?: $article->created_at)</span> <span class="date day big">@customDate('j', $article->publishedFrom ?: $article->created_at)</span>
<br> <br>
<span class="date uppercase month">@monthName($article->published_from ?: $article->created_at)</span> <span class="date uppercase month">@monthName($article->publishedFrom ?: $article->created_at)</span>
</div> </div>
<div class="m-t-15 author"> <div class="m-t-15 author">
{{--<small>{{str_limit($article->author->name, 15)}}</small>--}} {{--<small>{{str_limit($article->author->name, 15)}}</small>--}}
@@ -37,7 +37,7 @@
<a href="{{route('page.content', ['url' => $article->url])}}">více</a> <a href="{{route('page.content', ['url' => $article->url])}}">více</a>
</article> </article>
@if(isset($article->module_settings->allowComments) && $article->module_settings->allowComments != 0 || $article->category) @if(isset($article->moduleSettings->allowComments) && $article->moduleSettings->allowComments != 0 || $article->category)
<footer class="text-right"> <footer class="text-right">
@if($article->category) @if($article->category)
@@ -18,7 +18,7 @@
@if(session('error')) @if(session('error'))
<div class="callout alert"> <div class="callout alert">
Zprávu bohužel nebylo možné odeslat, zkuste nám napsat na {{$page->module_settings->contactEmail}}. Zprávu bohužel nebylo možné odeslat, zkuste nám napsat na {{$page->moduleSettings->contactEmail}}.
</div> </div>
@endif @endif
@@ -45,15 +45,15 @@
</div> </div>
<div class="small-8 column"> <div class="small-8 column">
<p><strong>{{$page->module_settings->companyName}}</strong></p> <p><strong>{{$page->moduleSettings->companyName}}</strong></p>
<p> <p>
{!! nl2br($page->module_settings->address) !!} {!! nl2br($page->moduleSettings->address) !!}
</p> </p>
<p><br></p> <p><br></p>
<p><a class="underline" <p><a class="underline"
href="mailto:{{$page->module_settings->email}}">{{$page->module_settings->email}}</a></p> href="mailto:{{$page->moduleSettings->email}}">{{$page->moduleSettings->email}}</a></p>
<p><a class="thin" <p><a class="thin"
href="tel:{{str_replace(' ', '', $page->module_settings->phone)}}">{{$page->module_settings->phone}}</a> href="tel:{{str_replace(' ', '', $page->moduleSettings->phone)}}">{{$page->moduleSettings->phone}}</a>
</p> </p>
</div> </div>
<div class="clearfix m-0"></div> <div class="clearfix m-0"></div>
@@ -7,14 +7,14 @@
<div class="row small-11 medium-11 large-11 xlarge-11 m-t-25 reference-gallery"> <div class="row small-11 medium-11 large-11 xlarge-11 m-t-25 reference-gallery">
<div class="row"> <div class="row">
<div class="ref-scr column xlarge-8 large-8 medium-4 m-b-25 p-lr-0 b-invo" data-img="" data-label=""> <div class="ref-scr column xlarge-8 large-8 medium-4 m-b-25 p-lr-0 b-invo" data-img="" data-label="">
<img class="thumbnail pointer" src="@upload($page->title_photo)" alt="{{$page->title}}"> <img class="thumbnail pointer" src="@upload($page->titlePhoto)" alt="{{$page->title}}">
</div> </div>
@foreach($page->files as $file) @foreach($page->files as $file)
@if(!\Illuminate\Support\Str::startsWith($file->mime_type, 'image')) @if(!\Illuminate\Support\Str::startsWith($file->mime_type, 'image'))
@continue; @continue;
@endif @endif
<div class="ref-scr b-invo column xlarge-4 large-4 medium-4 small-6" <div class="ref-scr b-invo column xlarge-4 large-4 medium-4 small-6"
data-img="@upload($page->title_photo)" data-img="@upload($page->titlePhoto)"
data-label="{{$file->description}}"> data-label="{{$file->description}}">
<img class="thumbnail pointer m-b-26" src="@upload($file->filename)" <img class="thumbnail pointer m-b-26" src="@upload($file->filename)"
alt="{{$file->name}}"> alt="{{$file->name}}">
@@ -18,7 +18,7 @@
<?php $counter++; ?> <?php $counter++; ?>
<div class="column reference-item @if($counter > 8) more-references @endif"> <div class="column reference-item @if($counter > 8) more-references @endif">
<div class="holder"> <div class="holder">
<img class="thumbnail" data-equalizer-watch src="@thumbnail($reference->title_photo)"> <img class="thumbnail" data-equalizer-watch src="@thumbnail($reference->titlePhoto)">
<div class="item-data"> <div class="item-data">
<h4>{{$reference->title}}</h4> <h4>{{$reference->title}}</h4>
<p>{{$reference->meta_description}}</p> <p>{{$reference->meta_description}}</p>
@@ -3,7 +3,7 @@
@section('pageDescription', $page->meta_description) @section('pageDescription', $page->meta_description)
@section('pageKeywords', $page->meta_keywords) @section('pageKeywords', $page->meta_keywords)
@section('pageTitleImage') @section('pageTitleImage')
@if (!empty($page->title_photo) && \App\CMS\Helpers\Template::upload($page->title_photo))@upload($page->title_photo) @if (!empty($page->titlePhoto) && \App\CMS\Helpers\Template::upload($page->titlePhoto))@upload($page->titlePhoto)
@else{{asset_path('visitor/images/social-cover.png')}}@endif @else{{asset_path('visitor/images/social-cover.png')}}@endif
@endsection @endsection
@endif @endif
+1 -1
View File
@@ -28,7 +28,7 @@ class Handler extends OnePage
* @param Content $content * @param Content $content
* @param Request $request * @param Request $request
*/ */
public static function beforeSave(Content & $content, Request $request) public static function beforeSave(Content & $content, $request)
{ {
// nothing to do // nothing to do
} }
@@ -9,7 +9,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="parallax"><img src="@upload($page->title_photo)" alt=""></div> <div class="parallax"><img src="@upload($page->titlePhoto)" alt=""></div>
</div> </div>
<div class="container"> <div class="container">
@@ -28,7 +28,7 @@ class Handler extends OnePage
* @param Content $content * @param Content $content
* @param Request $request * @param Request $request
*/ */
public static function beforeSave(Content & $content, Request $request) public static function beforeSave(Content & $content, $request)
{ {
// nothing to do // nothing to do
} }
@@ -6,7 +6,7 @@
@if(session('error')) @if(session('error'))
<div class="notification alert"> <div class="notification alert">
Bohužel nebylo možné odeslat zprávu. Pošlete mi to prosím ručně na {{$page->module_settings->contactEmail}}. Bohužel nebylo možné odeslat zprávu. Pošlete mi to prosím ručně na {{$page->moduleSettings->contactEmail}}.
Děkuji! Děkuji!
</div> </div>
@endif @endif
@@ -23,12 +23,12 @@
<div class="row"> <div class="row">
<div class="col-lg-5 text-right" style="font-size: 150%"> <div class="col-lg-5 text-right" style="font-size: 150%">
@if (isset($page->module_settings->phone)) @if (isset($page->moduleSettings->phone))
<p><i class="fa fa-fw fa-mobile-phone"></i> {{$page->module_settings->phone}}</p> <p><i class="fa fa-fw fa-mobile-phone"></i> {{$page->moduleSettings->phone}}</p>
@endif @endif
@if (isset($page->module_settings->contactEmail)) @if (isset($page->moduleSettings->contactEmail))
<p><i class="fa fa-fw fa-envelope-o"></i> {{$page->module_settings->contactEmail}}</p> <p><i class="fa fa-fw fa-envelope-o"></i> {{$page->moduleSettings->contactEmail}}</p>
@endif @endif
</div> </div>
<div class="col-lg-7"> <div class="col-lg-7">
@@ -1,7 +1,7 @@
@extendVisitor('layout') @extendVisitor('layout')
@section('content') @section('content')
<header class="intro" style="background-image: url('@upload($page->title_photo)')"> <header class="intro" style="background-image: url('@upload($page->titlePhoto)')">
<div class="intro-body"> <div class="intro-body">
<div class="container"> <div class="container">
<div class="row"> <div class="row">