REFACTORING #1880 @4h30m: another ugly refactoring commit
This commit is contained in:
@@ -21,12 +21,11 @@ interface AdvancedContentModifier {
|
||||
* Reason why it is separated from createNew() method is simple - we need to save history of changes.
|
||||
*
|
||||
* @param Content $content
|
||||
* @param Request $request
|
||||
* @param string $revisionId
|
||||
* @param $request
|
||||
*
|
||||
* @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
|
||||
*
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
<?php
|
||||
namespace App\CMS\Contracts;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
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
|
||||
*
|
||||
* @param Content $content
|
||||
* @param Request $request
|
||||
* @param $request
|
||||
*/
|
||||
public static function beforeSave(Content & $content, Request $request);
|
||||
public static function beforeSave(Content & $content, $request);
|
||||
}
|
||||
@@ -4,8 +4,8 @@ namespace App\CMS\Contracts\Repositories;
|
||||
use App\Models\Content\Content as ContentModel;
|
||||
use App\Models\Module as ModuleModel;
|
||||
|
||||
interface Module extends BaseRepository {
|
||||
|
||||
interface Module extends BaseRepository
|
||||
{
|
||||
public function getCreateContentTitle(ModuleModel $module);
|
||||
|
||||
public function getUpdateContentTitle(ModuleModel $module, ContentModel $content = null);
|
||||
@@ -14,5 +14,7 @@ interface Module extends BaseRepository {
|
||||
|
||||
public function getByHandler($handler);
|
||||
|
||||
public function call(ModuleModel $module, $method, ...$parameters);
|
||||
public function call(ModuleModel $module, $method, $parameters = []);
|
||||
|
||||
public function callOnString($moduleHandler, $method, $parameters = []);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class History implements HistoryHandler
|
||||
'to' => $statuses[$changeset->new_value]
|
||||
]);
|
||||
break;
|
||||
case 'is_homepage':
|
||||
case 'isHomepage':
|
||||
return trans('admin/history.setupAsHomepage');
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -3,30 +3,37 @@ namespace App\Cms\Handlers\Interactions;
|
||||
|
||||
use App\CMS\Contracts\Interaction as InteractionContract;
|
||||
use App\CMS\Exceptions\Validation\ValidationFailedException;
|
||||
use App\Http\Requests\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class Interaction {
|
||||
class Interaction
|
||||
{
|
||||
/**
|
||||
* Handle interaction with application
|
||||
*
|
||||
* @param Request $request
|
||||
* @param InteractionContract $interaction
|
||||
* @param array $parameters
|
||||
* @param string $interactionClass
|
||||
* @param array $data
|
||||
* @param array $extraParameters
|
||||
*
|
||||
* @return mixed
|
||||
* @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
|
||||
$validator = Validator::make($request->all(), $interaction->getValidationRules($parameters));
|
||||
$validator = Validator::make($data, $interaction->getValidationRules($extraParameters));
|
||||
|
||||
if ($validator->fails()) {
|
||||
throw new ValidationFailedException($validator);
|
||||
}
|
||||
|
||||
// handle it
|
||||
return $interaction->handle($request, $parameters);
|
||||
|
||||
return $interaction->handle($data, $extraParameters);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
namespace App\CMS\Helpers;
|
||||
|
||||
use App\CMS\Contracts\Modules\TemplateHandler;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\Module;
|
||||
use DebugBar\Bridge\MonologCollector;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Monolog\Logger;
|
||||
|
||||
class CurrentTemplate
|
||||
class CurrentTemplate implements TemplateHandler
|
||||
{
|
||||
protected static $template;
|
||||
protected static $initialized = false;
|
||||
@@ -20,14 +21,14 @@ class CurrentTemplate
|
||||
{
|
||||
if (!self::$initialized) {
|
||||
try {
|
||||
self::$template = Module::where('is_template', true)
|
||||
->where('enabled', true)
|
||||
->first();
|
||||
self::$template = Module::where('is_template', true)
|
||||
->where('enabled', true)
|
||||
->first();
|
||||
} catch (QueryException $e) {
|
||||
throw new \ErrorException('DB not migrated, please, do so!');
|
||||
}
|
||||
if (self::$template) {
|
||||
self::$template->module_settings = json_decode(self::$template->module_settings);
|
||||
self::$template->moduleSettings = json_decode(self::$template->moduleSettings);
|
||||
}
|
||||
|
||||
self::$initialized = true;
|
||||
@@ -60,4 +61,68 @@ class CurrentTemplate
|
||||
{
|
||||
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]);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class PageRenderer
|
||||
public static function render(Content $page)
|
||||
{
|
||||
// decode module settings
|
||||
$page->module_settings = json_decode($page->module_settings);
|
||||
$page->moduleSettings = json_decode($page->moduleSettings);
|
||||
|
||||
// do something template-specific
|
||||
$parameters = call_user_func_array([CurrentTemplate::handler(), 'beforeRender'], [&$page]);
|
||||
@@ -33,7 +33,7 @@ class PageRenderer
|
||||
* @var $handler AppHandler
|
||||
*/
|
||||
// get handler
|
||||
$handler = new $page->module_handler;
|
||||
$handler = new $page->moduleHandler;
|
||||
|
||||
$page->content = Shortcode::compile($page->content);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -27,4 +27,8 @@ function setting($key, $default = null) {
|
||||
|
||||
function asset_path($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\Events\EditContent as EditContentEvent;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\FileManager\File;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -17,74 +19,59 @@ class EditContent implements Interaction
|
||||
* @var Module
|
||||
*/
|
||||
protected $module;
|
||||
/**
|
||||
* @var File
|
||||
*/
|
||||
protected $file;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$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];
|
||||
|
||||
// upload file - if provided
|
||||
// todo use interaction
|
||||
$file = $page->uploadTitlePhoto($request);
|
||||
/**
|
||||
* @var $page Content
|
||||
*/
|
||||
list($page, $titlePhoto, $relatedFiles) = $parameters;
|
||||
|
||||
// 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);
|
||||
$request->parentPage = $request->parentPage ? $request->parentPage : null;
|
||||
$request->publishedFrom = empty($request->publishedFrom) ? null : $request->publishedFrom;
|
||||
$request->publishedTo = empty($request->publishedTo) ? null : $request->publishedTo;
|
||||
// upload file - if provided
|
||||
$data['titlePhoto'] = isset($data['existingTitlePhoto']) ? $data['existingTitlePhoto'] : null;
|
||||
|
||||
if (!$file) {
|
||||
$request->titlePhotoFilename = empty($request->existingTitlePhoto) ? null : $request->existingTitlePhoto;
|
||||
} else {
|
||||
$request->titlePhotoFilename = $file['filename'];
|
||||
if (!is_null($titlePhoto)) {
|
||||
$file = $this->file->upload($titlePhoto);
|
||||
$data['titlePhoto'] = $file ? $file['filename'] : null;
|
||||
}
|
||||
|
||||
// array of fields in database and fields from request
|
||||
$fields = [
|
||||
'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]);
|
||||
|
||||
$page->update($data);
|
||||
$this->module->callOnString($page->moduleHandler, 'edit', [$page, $data]);
|
||||
|
||||
// move to interaction
|
||||
$changedColumns += $page->uploadRelatedFiles($request, $revision);
|
||||
|
||||
if ($changedColumns > 0) {
|
||||
Event::fire(new EditContentEvent($page, $revision));
|
||||
}
|
||||
|
||||
return [$page, $revision, $changedColumns];
|
||||
$keepAssigned = isset($data->keepAssigned) ? $data->keepAssigned : [];
|
||||
$page->uploadRelatedFiles($relatedFiles, $keepAssigned);
|
||||
}
|
||||
|
||||
public function getValidationRules($parameters)
|
||||
/**
|
||||
* Validate this interaction
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValidationRules($parameters = [])
|
||||
{
|
||||
$id = $parameters[0]->id;
|
||||
|
||||
@@ -97,7 +84,7 @@ class EditContent implements Interaction
|
||||
'url' => 'required|unique:contents,url,' . $id,
|
||||
'publishedFrom' => 'date',
|
||||
'publishedTo' => 'date',
|
||||
'title_photo' => 'exists:files,id',
|
||||
'titlePhoto' => 'exists:files,id',
|
||||
'status' => 'required|in:' . $statuses,
|
||||
'parentPage' => 'exists:contents,id'
|
||||
];
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
namespace App\Cms\Interactions\Admin\Content;
|
||||
|
||||
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\Events\CreateNewContent;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\FileManager\File;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -13,73 +16,70 @@ use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
|
||||
class NewContent implements Interaction
|
||||
{
|
||||
/**
|
||||
* @var ContentRepository
|
||||
*/
|
||||
protected $content;
|
||||
/**
|
||||
* @var File
|
||||
*/
|
||||
protected $file;
|
||||
/**
|
||||
* @var Module
|
||||
*/
|
||||
protected $module;
|
||||
|
||||
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
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function handle(Request $request, $parameters)
|
||||
public function handle($data, $parameters)
|
||||
{
|
||||
list($moduleHandler) = $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;
|
||||
list($moduleHandler, $titlePhoto, $relatedFiles) = $parameters;
|
||||
|
||||
// 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
|
||||
call_user_func_array([$request->handler, 'createNew'], [&$page, $request]);
|
||||
$this->module->callOnString($moduleHandler, 'createNew', [&$page, $data]);
|
||||
|
||||
// let template to modify request and content page
|
||||
call_user_func_array([CurrentTemplate::handler(), 'beforeSave'], [&$page, $request]);
|
||||
// let template to modify data and content page
|
||||
CurrentTemplate::beforeSave($page, $data);
|
||||
|
||||
// save content of page before (possible) uploading related files
|
||||
$page->save();
|
||||
|
||||
// upload files assigned to content page
|
||||
$page->uploadRelatedFiles($request);
|
||||
|
||||
Event::fire(new CreateNewContent($this));
|
||||
|
||||
$page->uploadRelatedFiles($relatedFiles);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function getValidationRules($parameters)
|
||||
public function getValidationRules($parameters = [])
|
||||
{
|
||||
return [
|
||||
'titlePhoto' => 'image',
|
||||
'title' => 'required',
|
||||
'url' => 'required|unique:contents,url',
|
||||
'status' => 'required|in:draft,protected,public',
|
||||
'title_photo' => 'exists:files,id',
|
||||
'parentPage' => 'exists:contents,id',
|
||||
'publishedFrom' => 'date',
|
||||
'publishedTo' => 'date',
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -29,14 +29,14 @@ class Content extends Repository implements IContent
|
||||
return ContentModel::where('status', '!=', IContent::STATUS_DRAFT)
|
||||
->select('contents.*')
|
||||
->with('author')
|
||||
->join('modules', 'modules.handler', '=', 'contents.module_handler')
|
||||
->join('modules', 'modules.handler', '=', 'contents.moduleHandler')
|
||||
->where(function ($query) {
|
||||
$query->where('published_from', '<', Carbon::now())
|
||||
->orWhereNull('published_from');
|
||||
$query->where('publishedFrom', '<=', Carbon::now())
|
||||
->orWhereNull('publishedFrom');
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->where('published_to', '>', Carbon::now())
|
||||
->orWhereNull('published_to');
|
||||
$query->where('publishedTo', '>=', Carbon::now())
|
||||
->orWhereNull('publishedTo');
|
||||
})
|
||||
->where('language', LaravelLocalization::getCurrentLocale())
|
||||
->whereNull('contents.deleted_at')
|
||||
@@ -46,9 +46,14 @@ class Content extends Repository implements IContent
|
||||
public function all()
|
||||
{
|
||||
return $this->getPageQuery()
|
||||
->get();
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOne($id = null)
|
||||
{
|
||||
if (is_null($id)) {
|
||||
@@ -56,16 +61,9 @@ class Content extends Repository implements IContent
|
||||
$page->user_id = \Auth::user()->id;
|
||||
$page->language = LaravelLocalization::getCurrentLocale();
|
||||
$page->status = IContent::STATUS_DRAFT;
|
||||
$page->module_settings = [];
|
||||
$page->moduleSettings = [];
|
||||
} else {
|
||||
if (is_numeric($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;
|
||||
@@ -78,8 +76,9 @@ class Content extends Repository implements IContent
|
||||
public function getHomepage()
|
||||
{
|
||||
return $this->getPageQuery()
|
||||
->where('is_homepage', 1)
|
||||
->first();
|
||||
->where('isHomepage', 1)
|
||||
->first();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,9 +90,17 @@ class Content extends Repository implements IContent
|
||||
*/
|
||||
public function getByURL($url)
|
||||
{
|
||||
return $this->getPageQuery()
|
||||
->where('url', $url)
|
||||
->first();
|
||||
$page = $this->getPageQuery()
|
||||
->where('url', $url)
|
||||
->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)
|
||||
{
|
||||
$query = ContentModel::select('contents.*', 'modules.name AS module_name', 'modules.id AS module_id')
|
||||
->join('modules', 'modules.handler', '=', 'contents.module_handler')
|
||||
->join('users', 'users.id', '=', 'contents.user_id')
|
||||
->join('modules', 'modules.handler', '=', 'contents.moduleHandler')
|
||||
->join('users', 'users.id', '=', 'contents.userId')
|
||||
->addSelect(DB::raw('COALESCE(users.name, users.email) AS author_name'))
|
||||
->addSelect('users.email AS author_email')
|
||||
->whereNull('contents.deleted_at')
|
||||
@@ -119,7 +126,7 @@ class Content extends Repository implements IContent
|
||||
|
||||
// filter results using handler
|
||||
if (!is_null($handler)) {
|
||||
$query = $query->where('contents.module_handler', $handler);
|
||||
$query = $query->where('contents.moduleHandler', $handler);
|
||||
}
|
||||
|
||||
// add filtering by status
|
||||
@@ -127,6 +134,8 @@ class Content extends Repository implements IContent
|
||||
$query = $query->whereIn('contents.status', $statuses);
|
||||
}
|
||||
|
||||
return $query->paginate(20);
|
||||
$pages = $query->paginate(setting('paginatedResults', 20));
|
||||
|
||||
return $pages;
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,8 @@ class Module extends Repository implements IModule
|
||||
|
||||
public function getUpdateContentTitle(ModuleModel $module, Content $content = null)
|
||||
{
|
||||
$pageHeading = trans('admin/contents.new', ['name' => trans($module->name)]);
|
||||
$moduleHeading = $this->call($module, 'getEditTitle', $content);
|
||||
$pageHeading = trans('admin/contents.edit', ['name' => trans($module->name)]);
|
||||
$moduleHeading = $this->call($module, 'getEditTitle', [$content]);
|
||||
|
||||
return is_null($moduleHeading) ? $pageHeading : $moduleHeading;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class Module extends Repository implements IModule
|
||||
->firstOrFail();
|
||||
}
|
||||
|
||||
public function call(ModuleModel $module, $method, ...$parameters)
|
||||
public function call(ModuleModel $module, $method, $parameters = [])
|
||||
{
|
||||
if (!is_null($module) && is_callable([$module->handler, $method])) {
|
||||
return call_user_func_array([$module->handler, $method], $parameters);
|
||||
@@ -70,4 +70,13 @@ class Module extends Repository implements IModule
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function callOnString($moduleHandler, $method, $parameters = [])
|
||||
{
|
||||
if (is_callable([$moduleHandler, $method])) {
|
||||
return call_user_func_array([$moduleHandler, $method], $parameters);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,8 @@ class Menu implements WidgetRenderer
|
||||
}
|
||||
|
||||
$page = $pages[$pageId];
|
||||
$active = ($page->is_homepage && $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]);
|
||||
$active = ($page->isHomepage && $route == 'page.index') || ($route == 'page.content' && isset($parameters['url']) && $parameters['url'] == $page->url);
|
||||
$route = $page->isHomepage ? route('page.index') : route('page.content', ['url' => $page->url]);
|
||||
|
||||
$code .= '<li';
|
||||
if ($active) {
|
||||
|
||||
@@ -42,7 +42,7 @@ class SetTemplate extends Command
|
||||
$config['staticName'] = $template;
|
||||
|
||||
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 . '.');
|
||||
$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'));
|
||||
}
|
||||
|
||||
try {
|
||||
// try to find this page
|
||||
$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
|
||||
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?
|
||||
if ($changedColumns == 0) {
|
||||
@@ -56,12 +55,7 @@ class ContentActions extends Controller
|
||||
->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
|
||||
return redirect()
|
||||
@@ -97,7 +91,7 @@ class ContentActions extends Controller
|
||||
$page->delete();
|
||||
|
||||
// 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
|
||||
Event::fire(new DeleteContent($page));
|
||||
@@ -134,12 +128,12 @@ class ContentActions extends Controller
|
||||
}
|
||||
|
||||
// disable any other existing homepage
|
||||
Content::where('is_homepage', 1)
|
||||
Content::where('isHomepage', 1)
|
||||
->where('language', LaravelLocalization::getCurrentLocale())
|
||||
->update(['is_homepage' => 0]);
|
||||
->update(['isHomepage' => 0]);
|
||||
|
||||
// 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?
|
||||
if ($changedColumns == 0) {
|
||||
|
||||
@@ -103,8 +103,11 @@ class CreateNewContent extends Controller
|
||||
{
|
||||
$module = $this->module->getOne($moduleId);
|
||||
|
||||
$titlePhoto = $request->file('titlePhoto');
|
||||
$relatedFiles = $request->all()['files'];
|
||||
|
||||
// create new page
|
||||
Interaction::handle($request, new NewContent(), $module->handler);
|
||||
Interaction::handle(NewContent::class, $request->all(), $module->handler, $titlePhoto, $relatedFiles);
|
||||
|
||||
return redirect()
|
||||
->route('content.overview')
|
||||
|
||||
@@ -71,24 +71,24 @@ class EditContent extends Controller
|
||||
/**
|
||||
* Display form for editing static page
|
||||
*
|
||||
* @param $url
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function edit($url)
|
||||
public function edit($id)
|
||||
{
|
||||
$statuses = ContentStatuses::getWithTranslations();
|
||||
$page = $this->content->getOne($url);
|
||||
$page = $this->content->getOne($id);
|
||||
|
||||
// get module ID
|
||||
$module = $this->module->getByHandler($page->module_handler);
|
||||
$module = $this->module->getByHandler($page->moduleHandler);
|
||||
$pageHeading = $this->module->getUpdateContentTitle($module, $page);
|
||||
$templates = $this->template->getForModule($module);
|
||||
$categories = $this->category->getForModule($module);
|
||||
$history = $this->history->getStructuredHistoryOf($page);
|
||||
|
||||
// modify data for edit form according to installed template
|
||||
call_user_func_array([CurrentTemplate::handler(), 'beforePopulatingEditForm'], [&$page]);
|
||||
CurrentTemplate::beforePopulatingEditForm($page);
|
||||
|
||||
// render view
|
||||
return view('admin.content.edit', [
|
||||
@@ -132,14 +132,10 @@ class EditContent extends Controller
|
||||
}
|
||||
|
||||
// edit page
|
||||
list($page, $revision, $changedColumns) = Interaction::handle($request, new EditContentInteraction(), $page);
|
||||
$titlePhoto = $request->file('titlePhoto');
|
||||
$relatedFiles = $request->all()['files'];
|
||||
|
||||
// was something changed?
|
||||
if ($changedColumns == 0) {
|
||||
return redirect()
|
||||
->route('content.edit', ['id' => $page->id])
|
||||
->with('error', trans('admin/contents.nothingToEdit'));
|
||||
}
|
||||
Interaction::handle(EditContentInteraction::class, $request->all(), $page, $titlePhoto, $relatedFiles);
|
||||
|
||||
// something was changed, inform user
|
||||
return redirect()
|
||||
@@ -150,12 +146,12 @@ class EditContent extends Controller
|
||||
/**
|
||||
* Convert object of all request data into array of only wanted fields
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $request
|
||||
* @param $fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFields(Request $request, $fields)
|
||||
public static function getFields($request, $fields)
|
||||
{
|
||||
$requestData = [];
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\CMS\Contracts\Repositories\Content;
|
||||
use App\Http\Requests;
|
||||
use App\Models\Content\Content;
|
||||
|
||||
class Sitemap extends Controller
|
||||
{
|
||||
@@ -30,14 +30,13 @@ class Sitemap extends Controller
|
||||
public function getMap()
|
||||
{
|
||||
// load all public pages
|
||||
$pages = $this->content->getPageQuery()
|
||||
->get();
|
||||
$pages = $this->content->all();
|
||||
|
||||
// iterate over all pages and add tag for each of them
|
||||
foreach ($pages as $page) {
|
||||
|
||||
// is this page a homepage? because of URL
|
||||
if ($page->is_homepage) {
|
||||
if ($page->isHomepage) {
|
||||
$route = route('page.index');
|
||||
$priority = 1;
|
||||
} else {
|
||||
|
||||
@@ -9,7 +9,7 @@ Route::group(['namespace' => 'Contents'], function () {
|
||||
->name('content.new');
|
||||
|
||||
// form for editing existing static page
|
||||
Route::get('content/edit/{url}', 'EditContent@edit')
|
||||
Route::get('content/edit/{id}', 'EditContent@edit')
|
||||
->name('content.edit');
|
||||
|
||||
// post method for creating new static page
|
||||
|
||||
+103
-14
@@ -2,10 +2,14 @@
|
||||
|
||||
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\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Categories\Entities\Category;
|
||||
|
||||
/**
|
||||
@@ -13,27 +17,41 @@ use Modules\Categories\Entities\Category;
|
||||
*/
|
||||
class Content extends Model
|
||||
{
|
||||
use SoftDeletes, ModelTraits\Content;
|
||||
use SoftDeletes, ModelTraits\Content, Nullable;
|
||||
public $timestamps = true;
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'parent_id',
|
||||
'category_id',
|
||||
'userId',
|
||||
'parentId',
|
||||
'categoryId',
|
||||
'language',
|
||||
'module_handler',
|
||||
'published_from',
|
||||
'published_to',
|
||||
'title_photo',
|
||||
'moduleHandler',
|
||||
'publishedFrom',
|
||||
'publishedTo',
|
||||
'titlePhoto',
|
||||
'template',
|
||||
'is_homepage',
|
||||
'isHomepage',
|
||||
'title',
|
||||
'url',
|
||||
'meta_keywords',
|
||||
'meta_description',
|
||||
'content',
|
||||
'module_settings',
|
||||
'metaKeywords',
|
||||
'metaDescription',
|
||||
'pageContent',
|
||||
'moduleSettings',
|
||||
'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
|
||||
@@ -52,7 +70,7 @@ class Content extends Model
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,25 @@
|
||||
|
||||
namespace App\Models\Content;
|
||||
|
||||
use App\Models\FileManager\File;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ContentHasFile extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
public $table = 'contents_has_files';
|
||||
|
||||
protected $fillable = [
|
||||
'content_id',
|
||||
'file_id'
|
||||
];
|
||||
|
||||
public function content()
|
||||
{
|
||||
return $this->hasOne(Content::class);
|
||||
}
|
||||
|
||||
public function file()
|
||||
{
|
||||
return $this->hasOne(File::class);
|
||||
}
|
||||
}
|
||||
@@ -1,215 +1,29 @@
|
||||
<?php
|
||||
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\ContentHistory;
|
||||
use App\Models\FileManager\Directory;
|
||||
use App\Models\FileManager\File;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
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
|
||||
*
|
||||
* @param Request $request
|
||||
* @param null $revisionId
|
||||
* @param $files
|
||||
* @param $assignedFiles
|
||||
* @param null $revisionId
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function uploadRelatedFiles(Request $request, $revisionId = null)
|
||||
public function uploadRelatedFiles($files, $assignedFiles = [], $revisionId = null)
|
||||
{
|
||||
$files = $request->all()['files'];
|
||||
$changed = 0;
|
||||
|
||||
// check if any file was removed
|
||||
if ($revisionId) {
|
||||
$changed += $this->removeRelatedFiles($revisionId, $request);
|
||||
$changed += $this->removeRelatedFiles($revisionId, $assignedFiles);
|
||||
}
|
||||
|
||||
// allow uploading only on created pages
|
||||
@@ -222,13 +36,16 @@ trait Content
|
||||
'name' => '.content_files',
|
||||
'hidden' => true
|
||||
]);
|
||||
$request->directoryId = $directory->id;
|
||||
$data = new \stdClass();
|
||||
$data->directoryId = $directory->id;
|
||||
|
||||
$fileModel = App::make(File::class);
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!$file) {
|
||||
continue;
|
||||
}
|
||||
$uploaded = $this->file->upload($file, $request);
|
||||
$uploaded = $fileModel->upload($file, $data);
|
||||
|
||||
// add assignement
|
||||
ContentHasFile::create([
|
||||
@@ -250,16 +67,13 @@ trait Content
|
||||
* Delete files from association
|
||||
*
|
||||
* @param $revisionId
|
||||
* @param $request
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function removeRelatedFiles($revisionId, $request)
|
||||
private function removeRelatedFiles($revisionId, $assignedFiles)
|
||||
{
|
||||
$files = array_keys((array)$request->keepAssigned);
|
||||
|
||||
$allFiles = $this->files()
|
||||
->whereNotIn('id', $files)
|
||||
->whereNotIn('id', $assignedFiles)
|
||||
->get();
|
||||
|
||||
foreach ($allFiles as $file) {
|
||||
@@ -273,29 +87,6 @@ trait Content
|
||||
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()
|
||||
{
|
||||
$this->viewed++;
|
||||
|
||||
@@ -18,7 +18,7 @@ trait ContentHistory
|
||||
public function getStructuredHistoryOf(Content $content)
|
||||
{
|
||||
$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('contents', 'contents.id', '=', 'content_history.content_id')
|
||||
->orderBy('changed_at', 'DESC')
|
||||
@@ -61,7 +61,7 @@ trait ContentHistory
|
||||
*/
|
||||
|
||||
// get handler of given content page
|
||||
$handler = $change->module_handler;
|
||||
$handler = $change->moduleHandler;
|
||||
|
||||
return $handler::getHistoryHandler();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class ModuleHasCustomField extends Model
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'module_handler',
|
||||
'moduleHandler',
|
||||
'custom_field_id'
|
||||
];
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Models\FileManager\ModelTraits;
|
||||
|
||||
use App\Events\UploadFile;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\FileManager\File as FileModel;
|
||||
use Franzose\ClosureTable\Extensions\Str;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -34,13 +33,15 @@ trait File
|
||||
* Saves file into FS and creates new record in database
|
||||
*
|
||||
* @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'
|
||||
* 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');
|
||||
$filename = $this->getFilename($file);
|
||||
|
||||
@@ -54,7 +55,7 @@ trait File
|
||||
}
|
||||
|
||||
// insert record into database
|
||||
$id = $this->saveIntoDatabase($uploadedFile, $request, $file->getClientOriginalName());
|
||||
$id = $this->saveIntoDatabase($uploadedFile, $data, $file->getClientOriginalName());
|
||||
|
||||
// fire event about new file
|
||||
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.
|
||||
*
|
||||
* @param SymphonyFile $file
|
||||
* @param Request $request
|
||||
* @param $request
|
||||
* @param $originalFilename
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function saveIntoDatabase(SymphonyFile $file, Request $request, $originalFilename)
|
||||
protected function saveIntoDatabase(SymphonyFile $file, $request, $originalFilename)
|
||||
{
|
||||
// get path and hash of uploaded file
|
||||
$path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->getFilename();
|
||||
@@ -92,10 +93,10 @@ trait File
|
||||
'hash_algorithm' => FileModel::HASH_ALGORITHM,
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'file_size' => $file->getSize(),
|
||||
'name' => $request->name,
|
||||
'description' => $request->description,
|
||||
'directory_id' => $request->directoryId ? $request->directoryId : null,
|
||||
'keywords' => $request->keywords
|
||||
'name' => isset($request->name) ? $request->name : '',
|
||||
'description' => isset($request->description) ? $request->description : '',
|
||||
'directory_id' => isset($request->directoryId) ? $request->directoryId ? $request->directoryId : null : null,
|
||||
'keywords' => isset($request->keyword) ? $request->keyword : ''
|
||||
]);
|
||||
|
||||
return $newFile->id;
|
||||
|
||||
@@ -44,7 +44,7 @@ trait Module {
|
||||
'manages_content' => $managesContent,
|
||||
'support_categories' => $supportCategories,
|
||||
'alias' => $alias,
|
||||
'module_settings' => json_encode($settings),
|
||||
'moduleSettings' => json_encode($settings),
|
||||
'parent_id' => $parentModuleId ? $parentModuleId : null,
|
||||
'enabled' => 1,
|
||||
'is_template' => $isTemplate
|
||||
|
||||
@@ -17,7 +17,7 @@ class Module extends Model
|
||||
'name',
|
||||
'description',
|
||||
'alias',
|
||||
'module_settings',
|
||||
'moduleSettings',
|
||||
'enabled',
|
||||
'support_categories',
|
||||
'manages_content',
|
||||
|
||||
@@ -20,6 +20,7 @@ class User extends Model implements AuthenticableInterface
|
||||
'username',
|
||||
'password',
|
||||
'name',
|
||||
'role'
|
||||
];
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
|
||||
@@ -32,18 +32,16 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
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(IModule::class, ModuleRepository::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;
|
||||
|
||||
use App\Models\Language;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
@@ -16,14 +14,14 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
|
||||
$supportedLocales = [];
|
||||
if (empty($languages)) {
|
||||
$supportedLocales[config('app.locale')] = [
|
||||
'native' => env('LOCALE_NATIVE_NAME'),
|
||||
'script' => env('LOCALE_SCRIPT'),
|
||||
'name' => env('LOCALE_TRANSLATED_NAME'),
|
||||
'native' => env('LOCALE_NATIVE_NAME', config('app.locale')),
|
||||
'script' => env('LOCALE_SCRIPT', 'Latn'),
|
||||
'name' => env('LOCALE_TRANSLATED_NAME', config('app.locale')),
|
||||
'code' => config('app.locale'),
|
||||
];
|
||||
|
||||
// create default language
|
||||
Language::create($supportedLocales[config('app.locale')]);
|
||||
DB::table('languages')
|
||||
->insert($supportedLocales[config('app.locale')]);
|
||||
}
|
||||
|
||||
foreach ($languages as $language) {
|
||||
|
||||
@@ -26,12 +26,12 @@ class ModuleManager extends ServiceProvider
|
||||
// iterate over all modules and enable or disable them
|
||||
foreach ($modules as $module) {
|
||||
|
||||
$module->module_settings = json_decode($module->module_settings);
|
||||
$module->moduleSettings = json_decode($module->moduleSettings);
|
||||
|
||||
if ($module->is_template) {
|
||||
|
||||
if (isset($module->module_settings->providers) && !empty($module->module_settings->providers)) {
|
||||
foreach ($module->module_settings->providers as $provider) {
|
||||
if (isset($module->moduleSettings->providers) && !empty($module->moduleSettings->providers)) {
|
||||
foreach ($module->moduleSettings->providers as $provider) {
|
||||
$this->app->register($provider);
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class ModuleManager extends ServiceProvider
|
||||
*/
|
||||
private function createModulesJson(Module $module)
|
||||
{
|
||||
$config = $module->module_settings;
|
||||
$config = $module->moduleSettings;
|
||||
|
||||
if (is_null($config)) {
|
||||
return;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\CMS\Contracts\Repositories\Template as TemplateContract;
|
||||
use App\CMS\Handlers\Registrators\TemplateRegistrator;
|
||||
use App\CMS\Helpers\CurrentTemplate;
|
||||
use App\Models\Templates\Template;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -13,7 +13,7 @@ class TemplateServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
// ignore running from artisan
|
||||
if (App::runningInConsole()) {
|
||||
if (App::runningInConsole() || App::environment('testing')) {
|
||||
$this->publishViewResources();
|
||||
|
||||
return;
|
||||
@@ -26,19 +26,24 @@ class TemplateServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
// include files
|
||||
$files = isset($template->module_settings->files) ? $template->module_settings->files : [];
|
||||
$files = isset($template->moduleSettings->files) ? $template->moduleSettings->files : [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
include_once $file;
|
||||
}
|
||||
|
||||
// register templates
|
||||
$publicTemplates = call_user_func([CurrentTemplate::handler(), 'getPublicTemplatePaths']);
|
||||
$publicTemplates = CurrentTemplate::getPublicTemplatePaths();
|
||||
|
||||
if (!is_array($publicTemplates)) {
|
||||
throw new \ErrorException(CurrentTemplate::handler() . '::getPublicTemplatePaths() must return array!');
|
||||
}
|
||||
|
||||
$this->registerTemplatePaths($publicTemplates);
|
||||
}
|
||||
|
||||
public function registerTemplatePaths($publicTemplates)
|
||||
{
|
||||
/**
|
||||
* @var $registrator TemplateRegistrator
|
||||
*/
|
||||
@@ -76,12 +81,12 @@ class TemplateServiceProvider extends ServiceProvider
|
||||
private function publishViewResources()
|
||||
{
|
||||
$template = CurrentTemplate::get();
|
||||
if (!$template) {
|
||||
if (!$template || is_null($template->moduleSettings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$templateDir = base_path('templates/' . $template->module_settings->staticName . '/Resources');
|
||||
$assetsDir = $templateDir . '/' . Template::ASSETS_DIRECTORY;
|
||||
$templateDir = base_path('templates/' . $template->moduleSettings->staticName . '/Resources');
|
||||
$assetsDir = $templateDir . '/' . TemplateContract::ASSETS_DIRECTORY;
|
||||
$viewsDir = $templateDir . '/views';
|
||||
|
||||
// publish assets if exists for current theme
|
||||
|
||||
+14
-13
@@ -55,8 +55,8 @@ return [
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'database' => env('DB_DATABASE'),
|
||||
'username' => env('DB_USERNAME'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'collation' => 'utf8_general_ci',
|
||||
@@ -64,6 +64,18 @@ return [
|
||||
'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' => [
|
||||
'driver' => 'pgsql',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
@@ -74,17 +86,6 @@ return [
|
||||
'prefix' => '',
|
||||
'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' => '',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|
||||
@@ -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 [
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->email,
|
||||
'username' => $email,
|
||||
'email' => $email,
|
||||
'name' => $faker->name,
|
||||
'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
|
||||
$widgets = \App\Models\Widget::all();
|
||||
$widgets = \App\Models\Widgets\Widget::all();
|
||||
foreach ($widgets as $widget) {
|
||||
$widget->settings = json_decode($widget->settings);
|
||||
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');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ use App\CMS\Contracts\Content\AdvancedContentModifier;
|
||||
use App\CMS\Contracts\Content\ContentTitles;
|
||||
use App\CMS\Contracts\Modules\InstallableModule;
|
||||
use App\CMS\Handlers\Handler;
|
||||
use App\Http\Controllers\Admin\Contents\EditContent;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\ActionLog\ActionLogType;
|
||||
@@ -27,7 +26,7 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
|
||||
public function render(Content $content, $parameters)
|
||||
{
|
||||
$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)
|
||||
->with('author')
|
||||
->where('approved', 1)
|
||||
@@ -62,7 +61,7 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
|
||||
*/
|
||||
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 Request $request
|
||||
*
|
||||
* @param $revisionID string ID of revision used
|
||||
*
|
||||
* @return int number of edited fields
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
$data = EditContent::getFields($request, $fields);
|
||||
$settings->allowComments = isset($request['allowComments']) ? (int)$request['allowComments'] : 0;
|
||||
|
||||
$data['allowComments'] = (int)$data['allowComments'];
|
||||
|
||||
list($revision, $changedColumns) = $content->updateWithHistory($fields, $data, $revisionID);
|
||||
|
||||
// return amount of changed columns
|
||||
return $changedColumns;
|
||||
$content->moduleSettings = $settings;
|
||||
$content->save();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,8 +93,6 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
|
||||
*/
|
||||
public static function registerAdminMenu(User $user)
|
||||
{
|
||||
parent::registerAdminMenu($user);
|
||||
|
||||
$menu = \Menu::instance('mainMenu');
|
||||
|
||||
$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)
|
||||
{
|
||||
$article = Content::where('id', $articleId)
|
||||
->where('module_handler', Article::class)
|
||||
->where('moduleHandler', Article::class)
|
||||
->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()
|
||||
->route('page.content', ['url' => $article->url])
|
||||
->with('error', trans('article::comments.disabledComments'));
|
||||
|
||||
@@ -37,12 +37,12 @@
|
||||
@include('admin.snippets.hasError', ['field' => 'status'])
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<select class="form-control" name="parentPage">
|
||||
<select class="form-control" name="parentId">
|
||||
<option value="">@lang('admin/contents.noParentPage')</option>
|
||||
|
||||
@foreach($rootPages as $rootPage)
|
||||
<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}}
|
||||
</option>
|
||||
@endforeach
|
||||
@@ -54,7 +54,7 @@
|
||||
<div class="col-lg-2 text-center">
|
||||
<label>
|
||||
<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">
|
||||
<span>@lang('article::article.allowComments')</span>
|
||||
</label>
|
||||
@@ -62,11 +62,11 @@
|
||||
|
||||
@if($module->support_categories && count($categories))
|
||||
<div class="col-lg-12">
|
||||
<select class="form-control" name="category">
|
||||
<select class="form-control" name="categoryId">
|
||||
<option value="">@lang('admin/contents.noCategory')</option>
|
||||
@foreach($categories as $category)
|
||||
<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}}
|
||||
</option>
|
||||
@endforeach
|
||||
@@ -78,7 +78,7 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<textarea name="pageContent" id="pageContent" class="wysiwyg-editor">
|
||||
{{old('pageContent', $page->content)}}
|
||||
{{old('pageContent', $page->pageContent)}}
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -96,18 +96,18 @@ class ArticleList extends Handler
|
||||
*/
|
||||
public function render(Content $content, $parameters)
|
||||
{
|
||||
$articles = ArticleModel::where('module_handler', Article::class)
|
||||
$articles = ArticleModel::where('moduleHandler', Article::class)
|
||||
->with('comments')
|
||||
->with('category')
|
||||
->where(function ($query) {
|
||||
$query->where('published_from', '<', Carbon::now())
|
||||
->orWhereNull('published_from');
|
||||
$query->where('publishedFrom', '<', Carbon::now())
|
||||
->orWhereNull('publishedFrom');
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->where('published_to', '>', Carbon::now())
|
||||
->orWhereNull('published_to');
|
||||
$query->where('publishedTo', '>', Carbon::now())
|
||||
->orWhereNull('publishedTo');
|
||||
})
|
||||
->orderBy('published_from', 'DESC')
|
||||
->orderBy('publishedFrom', 'DESC')
|
||||
->orderBy('created_at', 'DESC');
|
||||
|
||||
// show articles for not-logged users of even for logged onew?
|
||||
@@ -135,7 +135,7 @@ class ArticleList extends Handler
|
||||
|
||||
// decode module settings
|
||||
foreach ($articles as $article) {
|
||||
$article->module_settings = json_decode($article->module_settings);
|
||||
$article->moduleSettings = json_decode($article->moduleSettings);
|
||||
}
|
||||
|
||||
return Controller::VisitorsView($content->template, [
|
||||
|
||||
@@ -40,7 +40,7 @@ class ContactForm extends Handler implements ContentTitles, AdvancedContentModif
|
||||
];
|
||||
|
||||
// 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
|
||||
*/
|
||||
public static function edit(Content &$content, Request $request, $revisionID)
|
||||
public static function edit(Content $content, $request)
|
||||
{
|
||||
$fields = [
|
||||
'phone' => 'phone',
|
||||
@@ -70,7 +70,7 @@ class ContactForm extends Handler implements ContentTitles, AdvancedContentModif
|
||||
|
||||
// get data and try to save them
|
||||
$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 $changedColumns;
|
||||
|
||||
@@ -21,22 +21,22 @@ class CreateNewMessage extends Controller
|
||||
public function postMessage(SendNewEmailRequest $request, $formId)
|
||||
{
|
||||
// load form settings
|
||||
$form = Content::where('module_handler', config('contactform.handler'))
|
||||
$form = Content::where('moduleHandler', config('contactform.handler'))
|
||||
->findOrFail($formId);
|
||||
|
||||
$form->module_settings = json_decode($form->module_settings);
|
||||
$form->moduleSettings = json_decode($form->moduleSettings);
|
||||
|
||||
// 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
|
||||
$status = Mail::send(Template::name($template), ['data' => $request], function (Message $message) use ($request, $form) {
|
||||
$message->from($request->email, $request->name);
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
|
||||
@@ -55,11 +55,11 @@
|
||||
|
||||
@if($module->support_categories && count($categories))
|
||||
<div class="col-lg-12">
|
||||
<select class="form-control" name="category">
|
||||
<select class="form-control" name="categoryId">
|
||||
<option value="">@lang('admin/contents.noCategory')</option>
|
||||
@foreach($categories as $category)
|
||||
<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}}
|
||||
</option>
|
||||
@endforeach
|
||||
@@ -77,26 +77,26 @@
|
||||
@lang('contactform::admin/content.email')
|
||||
</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">
|
||||
@lang('contactform::admin/content.phone')
|
||||
</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">
|
||||
@lang('contactform::admin/content.compName')
|
||||
</label>
|
||||
|
||||
<input class="form-control" type="text" name="companyName"
|
||||
value="{{$page->module_settings->companyName or ""}}" />
|
||||
value="{{$page->moduleSettings->companyName or ""}}" />
|
||||
|
||||
<label class="label-control">
|
||||
@lang('contactform::admin/content.address')
|
||||
</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 class="column col-lg-6">
|
||||
@@ -105,14 +105,14 @@
|
||||
</label>
|
||||
|
||||
<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">
|
||||
@lang('contactform::admin/content.subject')
|
||||
</label>
|
||||
|
||||
<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="column col-lg-6">
|
||||
@@ -120,7 +120,7 @@
|
||||
@lang('contactform::admin/content.gpsLat')
|
||||
</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" />
|
||||
</div>
|
||||
<div class="column col-lg-6">
|
||||
@@ -128,7 +128,7 @@
|
||||
@lang('contactform::admin/content.gpsLng')
|
||||
</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" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,7 +24,7 @@ class Presenter implements WidgetRenderer
|
||||
if (!$form)
|
||||
return null;
|
||||
|
||||
$formData = json_decode($form->module_settings);
|
||||
$formData = json_decode($form->moduleSettings);
|
||||
|
||||
$code = '<div class="address-widget ' . e($widget->container_class) . '"';
|
||||
if ($widget->container_id) {
|
||||
@@ -47,7 +47,7 @@ class Presenter implements WidgetRenderer
|
||||
*/
|
||||
public static function renderAddForm(WidgetType $type)
|
||||
{
|
||||
$contactForms = Content::where('module_handler', config('contactform.handler'))
|
||||
$contactForms = Content::where('moduleHandler', config('contactform.handler'))
|
||||
->get();
|
||||
|
||||
return view('contactform::admin.widgets.address.new', [
|
||||
@@ -66,7 +66,7 @@ class Presenter implements WidgetRenderer
|
||||
*/
|
||||
public static function renderEditForm(Widget $widget)
|
||||
{
|
||||
$contactForms = Content::where('module_handler', config('contactform.handler'))
|
||||
$contactForms = Content::where('moduleHandler', config('contactform.handler'))
|
||||
->get();
|
||||
return view('contactform::admin.widgets.address.edit', [
|
||||
'widget' => $widget,
|
||||
|
||||
@@ -32,7 +32,7 @@ class Presenter implements WidgetRenderer
|
||||
return null;
|
||||
}
|
||||
|
||||
$form->module_settings = json_decode($form->module_settings);
|
||||
$form->moduleSettings = json_decode($form->moduleSettings);
|
||||
|
||||
return view(self::$template, ['widget' => $widget, 'form' => $form]);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class Presenter implements WidgetRenderer
|
||||
*/
|
||||
public static function renderAddForm(WidgetType $type)
|
||||
{
|
||||
$contactForms = Content::where('module_handler', config('contactform.handler'))
|
||||
$contactForms = Content::where('moduleHandler', config('contactform.handler'))
|
||||
->get();
|
||||
|
||||
return view('contactform::admin.widgets.form.new', [
|
||||
@@ -65,7 +65,7 @@ class Presenter implements WidgetRenderer
|
||||
*/
|
||||
public static function renderEditForm(Widget $widget)
|
||||
{
|
||||
$contactForms = Content::where('module_handler', config('contactform.handler'))
|
||||
$contactForms = Content::where('moduleHandler', config('contactform.handler'))
|
||||
->get();
|
||||
return view('contactform::admin.widgets.address.edit', [
|
||||
'widget' => $widget,
|
||||
|
||||
@@ -29,7 +29,7 @@ class Gallery implements AppHandler
|
||||
public function render(Content $content, $parameters)
|
||||
{
|
||||
// get directory ID
|
||||
$directoryId = $content->module_settings->directoryId;
|
||||
$directoryId = $content->moduleSettings->directoryId;
|
||||
|
||||
// get all images in given directory
|
||||
$images = File::where('directory_id', $directoryId)
|
||||
@@ -56,12 +56,12 @@ class Gallery implements AppHandler
|
||||
*/
|
||||
public static function loadExtraData(Content $content)
|
||||
{
|
||||
if (is_string($content->module_settings)) {
|
||||
$content->module_settings = json_decode($content->module_settings);
|
||||
if (is_string($content->moduleSettings)) {
|
||||
$content->moduleSettings = json_decode($content->moduleSettings);
|
||||
}
|
||||
|
||||
$extra = [
|
||||
'slider' => isset($content->module_settings->slider) ? $content->module_settings->slider : false
|
||||
'slider' => isset($content->moduleSettings->slider) ? $content->moduleSettings->slider : false
|
||||
];
|
||||
|
||||
return $extra;
|
||||
@@ -91,7 +91,7 @@ class Gallery implements AppHandler
|
||||
$settings = ['directoryId' => $directory->id];
|
||||
|
||||
// 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)
|
||||
{
|
||||
// try to convert module_settings into something more accessible
|
||||
if (is_string($content->module_settings)) {
|
||||
$content->module_settings = json_decode($content->module_settings);
|
||||
// try to convert moduleSettings into something more accessible
|
||||
if (is_string($content->moduleSettings)) {
|
||||
$content->moduleSettings = json_decode($content->moduleSettings);
|
||||
}
|
||||
|
||||
// get directory id
|
||||
$directoryId = $content->module_settings->directoryId;
|
||||
$directoryId = $content->moduleSettings->directoryId;
|
||||
|
||||
$directory = Directory::find($directoryId);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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 class="row column text-center">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
@if($page->title_photo)
|
||||
@if($page->titlePhoto)
|
||||
<div class="row">
|
||||
<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">
|
||||
<input type="hidden" id="existingTitlePhoto" value="{{$page->title_photo}}" name="existingTitlePhoto">
|
||||
<p><img src="@thumbnail($page->title_photo)" alt="" /></p>
|
||||
<input type="hidden" id="existingTitlePhoto" value="{{$page->titlePhoto}}" name="existingTitlePhoto">
|
||||
<p><img src="@thumbnail($page->titlePhoto)" alt="" /></p>
|
||||
<p>
|
||||
<a href="javascript:void(0)" id="removeTitlePhoto" class="btn btn-warning" data-toggle="tooltip"
|
||||
title="@lang('admin/contents.deleteTitlePhoto')"><i
|
||||
|
||||
@@ -39,12 +39,12 @@
|
||||
@include('admin.snippets.hasError', ['field' => 'status'])
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<select class="form-control" name="parentPage">
|
||||
<select class="form-control" name="parentId">
|
||||
<option value="">@lang('admin/contents.noParentPage')</option>
|
||||
|
||||
@foreach($rootPages as $rootPage)
|
||||
<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}}
|
||||
</option>
|
||||
@endforeach
|
||||
@@ -55,11 +55,11 @@
|
||||
|
||||
@if($module->support_categories && count($categories))
|
||||
<div class="col-lg-12">
|
||||
<select class="form-control" name="category">
|
||||
<select class="form-control" name="categoryId">
|
||||
<option value="">@lang('admin/contents.noCategory')</option>
|
||||
@foreach($categories as $category)
|
||||
<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}}
|
||||
</option>
|
||||
@endforeach
|
||||
@@ -71,7 +71,7 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<textarea name="pageContent" id="pageContent" rows="15" class="wysiwyg-editor">
|
||||
{{old('pageContent', $page->content)}}
|
||||
{{old('pageContent', $page->pageContent)}}
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4,7 +4,7 @@
|
||||
@lang('admin/contents.field_meta_keywords')
|
||||
</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 class="row">
|
||||
@@ -14,6 +14,6 @@
|
||||
</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>
|
||||
@@ -1,22 +1,22 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<label class="control-label">
|
||||
@lang('admin/contents.field_published_from')
|
||||
@lang('admin/contents.field_publishedFrom')
|
||||
</label>
|
||||
|
||||
<input type="datetime" class="form-control" name="publishedFrom" value="{{old('published_from', $page->published_from)}}"
|
||||
placeholder="@lang('admin/contents.field_published_from')" />
|
||||
<input type="datetime" class="form-control" name="publishedFrom" value="{{old('publishedFrom', $page->publishedFrom)}}"
|
||||
placeholder="@lang('admin/contents.field_publishedFrom')" />
|
||||
|
||||
@include('admin.snippets.hasError', ['field' => 'published_from'])
|
||||
@include('admin.snippets.hasError', ['field' => 'publishedFrom'])
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<label class="control-label">
|
||||
@lang('admin/contents.field_published_to')
|
||||
@lang('admin/contents.field_publishedTo')
|
||||
</label>
|
||||
|
||||
<input type="datetime" class="form-control" name="publishedTo" value="{{old('published_to', $page->published_to)}}"
|
||||
placeholder="@lang('admin/contents.field_published_to')" />
|
||||
@include('admin.snippets.hasError', ['field' => 'published_to'])
|
||||
<input type="datetime" class="form-control" name="publishedTo" value="{{old('publishedTo', $page->publishedTo)}}"
|
||||
placeholder="@lang('admin/contents.field_publishedTo')" />
|
||||
@include('admin.snippets.hasError', ['field' => 'publishedTo'])
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
@extends('admin.layoutWithNavigation')
|
||||
|
||||
@section('pageHeading', @trans(isset($pageHeading) ? $pageHeading : 'admin/contents.overview'))
|
||||
@section('pageHeading', @trans($pageHeading))
|
||||
@section('headerButtons')
|
||||
|
||||
@if($module->exists === true)
|
||||
@@ -34,13 +34,13 @@
|
||||
@foreach($pages as $page)
|
||||
<div class="row p-tb-15">
|
||||
<div class="col-md-1 hidden-sm-down text-center with-placeholder">
|
||||
<a href="{{route('content.edit', ['url' => $page->url])}}">
|
||||
@if(!view()->exists(\App\CMS\Helpers\Template::name($page->template, false)))
|
||||
<a href="{{route('content.edit', ['id' => $page->id])}}">
|
||||
@if(!view()->exists(template_name($page->template, false)))
|
||||
<i class="fa fa-2x text-warning fa-warning" data-toggle="tooltip"
|
||||
title="@lang('admin/contents.invalidTemplateSelected')"></i>
|
||||
@else
|
||||
@if(!empty($page->title_photo))
|
||||
<img src="@thumbnail($page->title_photo)" class="placeholder"
|
||||
@if(!empty($page->titlePhoto))
|
||||
<img src="@thumbnail($page->titlePhoto)" class="placeholder"
|
||||
alt="{{$page->title}}" />
|
||||
@else
|
||||
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}"
|
||||
@@ -51,11 +51,11 @@
|
||||
</a>
|
||||
</div>
|
||||
<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}}
|
||||
</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 class="col-lg-2 col-md-3 hidden-sm-down">
|
||||
<span class="tag @if($page->isPublic()) tag-success
|
||||
@@ -81,7 +81,7 @@
|
||||
<div class="item-actions-block">
|
||||
<ul class="item-actions-list">
|
||||
|
||||
@if(!$page->is_homepage)
|
||||
@if(!$page->isHomepage)
|
||||
<li>
|
||||
|
||||
<a href="{{route('content.setHomepage', ['id' => $page->id])}}"
|
||||
@@ -92,7 +92,7 @@
|
||||
@endif
|
||||
|
||||
<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')">
|
||||
<i class="fa fa-pencil"></i>
|
||||
</a>
|
||||
@@ -115,7 +115,7 @@
|
||||
</li>
|
||||
@else
|
||||
<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')"
|
||||
class="button tiny secondary"><i class="fa fa-globe"></i>
|
||||
</a>
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
<tr>
|
||||
<td class="text-center with-placeholder">
|
||||
<a href="{{route('content.edit', ['id' => $page->id])}}">
|
||||
@if(!empty($page->title_photo))
|
||||
<img src="@upload($page->title_photo)" class="placeholder" alt="{{$page->title}}" />
|
||||
@if(!empty($page->titlePhoto))
|
||||
<img src="@upload($page->titlePhoto)" class="placeholder" alt="{{$page->title}}" />
|
||||
@else
|
||||
<img src="{{asset('resources/assets/admin/img/placeholder.png')}}" class="placeholder"
|
||||
alt="{{$page->title}}" />
|
||||
|
||||
@@ -40,7 +40,7 @@ abstract class OnePage implements TemplateHandler, InstallableModule
|
||||
public static function registerAdminMenu(User $user)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
if ($content->is_homepage) {
|
||||
if ($content->isHomepage) {
|
||||
$pages = self::getPagesOnHomepage();
|
||||
|
||||
// create real content from pages
|
||||
|
||||
@@ -48,7 +48,7 @@ class SetHomepage extends Controller
|
||||
$homepage = null;
|
||||
foreach ($allPages as $page) {
|
||||
|
||||
if ($page->is_homepage) {
|
||||
if ($page->isHomepage) {
|
||||
$homepage = $page;
|
||||
continue;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class SetHomepage extends Controller
|
||||
{
|
||||
$page = $this->content->getOne($id);
|
||||
|
||||
if ($page->is_homepage) {
|
||||
if ($page->isHomepage) {
|
||||
return redirect()
|
||||
->back()
|
||||
->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])}}"
|
||||
class="btn btn-secondary btn-sm"><i
|
||||
class="fa fa-fw fa-pencil"></i></a>
|
||||
@if(!$page->is_homepage)
|
||||
@if(!$page->isHomepage)
|
||||
<a href="{{route('content.setHomepage', ['id' => $page->id])}}"
|
||||
class="btn btn-secondary confirm btn-sm"
|
||||
data-toggle="tooltip" title="@lang('admin/contents.setHomepage')">
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<div class="row article-list-item">
|
||||
<aside class="column text-right large-1">
|
||||
<div class="date">
|
||||
<span class="date day big">@customDate('j', $page->published_from ?: $page->created_at)</span>
|
||||
<span class="date uppercase month">@monthName($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->publishedFrom ?: $page->created_at)</span>
|
||||
</div>
|
||||
<div class="m-t-25 author">
|
||||
<img class="gravatar" src="@gravatar($page->author->email, 50)" alt="">
|
||||
@@ -22,7 +22,7 @@
|
||||
@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">
|
||||
<a href="#comments">{{$page->comments->count()}} <i class="fa fa-comments"></i></a>
|
||||
</div>
|
||||
@@ -36,7 +36,7 @@
|
||||
</article>
|
||||
</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">
|
||||
<a name="comments"></a>
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<div class="row">
|
||||
<aside class="column text-right large-3">
|
||||
<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>
|
||||
<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 class="m-t-15 author">
|
||||
{{--<small>{{str_limit($article->author->name, 15)}}</small>--}}
|
||||
@@ -37,7 +37,7 @@
|
||||
<a href="{{route('page.content', ['url' => $article->url])}}">více</a>
|
||||
</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">
|
||||
|
||||
@if($article->category)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
@if(session('error'))
|
||||
<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>
|
||||
@endif
|
||||
|
||||
@@ -45,15 +45,15 @@
|
||||
</div>
|
||||
|
||||
<div class="small-8 column">
|
||||
<p><strong>{{$page->module_settings->companyName}}</strong></p>
|
||||
<p><strong>{{$page->moduleSettings->companyName}}</strong></p>
|
||||
<p>
|
||||
{!! nl2br($page->module_settings->address) !!}
|
||||
{!! nl2br($page->moduleSettings->address) !!}
|
||||
</p>
|
||||
<p><br></p>
|
||||
<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"
|
||||
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>
|
||||
</div>
|
||||
<div class="clearfix m-0"></div>
|
||||
|
||||
+2
-2
@@ -7,14 +7,14 @@
|
||||
<div class="row small-11 medium-11 large-11 xlarge-11 m-t-25 reference-gallery">
|
||||
<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="">
|
||||
<img class="thumbnail pointer" src="@upload($page->title_photo)" alt="{{$page->title}}">
|
||||
<img class="thumbnail pointer" src="@upload($page->titlePhoto)" alt="{{$page->title}}">
|
||||
</div>
|
||||
@foreach($page->files as $file)
|
||||
@if(!\Illuminate\Support\Str::startsWith($file->mime_type, 'image'))
|
||||
@continue;
|
||||
@endif
|
||||
<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}}">
|
||||
<img class="thumbnail pointer m-b-26" src="@upload($file->filename)"
|
||||
alt="{{$file->name}}">
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<?php $counter++; ?>
|
||||
<div class="column reference-item @if($counter > 8) more-references @endif">
|
||||
<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">
|
||||
<h4>{{$reference->title}}</h4>
|
||||
<p>{{$reference->meta_description}}</p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
@section('pageDescription', $page->meta_description)
|
||||
@section('pageKeywords', $page->meta_keywords)
|
||||
@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
|
||||
@endsection
|
||||
@endif
|
||||
@@ -28,7 +28,7 @@ class Handler extends OnePage
|
||||
* @param Content $content
|
||||
* @param Request $request
|
||||
*/
|
||||
public static function beforeSave(Content & $content, Request $request)
|
||||
public static function beforeSave(Content & $content, $request)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
</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 class="container">
|
||||
|
||||
@@ -28,7 +28,7 @@ class Handler extends OnePage
|
||||
* @param Content $content
|
||||
* @param Request $request
|
||||
*/
|
||||
public static function beforeSave(Content & $content, Request $request)
|
||||
public static function beforeSave(Content & $content, $request)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
+5
-5
@@ -6,7 +6,7 @@
|
||||
|
||||
@if(session('error'))
|
||||
<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!
|
||||
</div>
|
||||
@endif
|
||||
@@ -23,12 +23,12 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-5 text-right" style="font-size: 150%">
|
||||
@if (isset($page->module_settings->phone))
|
||||
<p><i class="fa fa-fw fa-mobile-phone"></i> {{$page->module_settings->phone}}</p>
|
||||
@if (isset($page->moduleSettings->phone))
|
||||
<p><i class="fa fa-fw fa-mobile-phone"></i> {{$page->moduleSettings->phone}}</p>
|
||||
@endif
|
||||
|
||||
@if (isset($page->module_settings->contactEmail))
|
||||
<p><i class="fa fa-fw fa-envelope-o"></i> {{$page->module_settings->contactEmail}}</p>
|
||||
@if (isset($page->moduleSettings->contactEmail))
|
||||
<p><i class="fa fa-fw fa-envelope-o"></i> {{$page->moduleSettings->contactEmail}}</p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-7">
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
@extendVisitor('layout')
|
||||
|
||||
@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="container">
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user