Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f51dd9458c | ||
|
|
962225080d |
@@ -27,9 +27,3 @@
|
|||||||
|
|
||||||
# meta information created by installer
|
# meta information created by installer
|
||||||
.install
|
.install
|
||||||
/node_modules/
|
|
||||||
/public/css/
|
|
||||||
/public/js
|
|
||||||
/public/fonts
|
|
||||||
/bower_components
|
|
||||||
.sass-cache
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Contracts\Content;
|
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
|
||||||
use App\Models\Content\Content;
|
|
||||||
|
|
||||||
interface AdvancedContentModifier {
|
|
||||||
/**
|
|
||||||
* Save module-specific values into database
|
|
||||||
*
|
|
||||||
* @param Content $content
|
|
||||||
* @param array $inputData
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function createNew(Content &$content, array $inputData);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method used for editing existing content page.
|
|
||||||
*
|
|
||||||
* Reason why it is separated from createNew() method is simple - we need to save history of changes.
|
|
||||||
*
|
|
||||||
* @param Content $content
|
|
||||||
* @param $request
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function edit(Content $content, $request);
|
|
||||||
/**
|
|
||||||
* Method called right after content page is marked as deleted
|
|
||||||
*
|
|
||||||
* This method is supposed to clean after "deleted" page.
|
|
||||||
*
|
|
||||||
* @param Content $content
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function delete(Content $content);
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Contracts;
|
|
||||||
|
|
||||||
interface Interaction {
|
|
||||||
/**
|
|
||||||
* 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 = []);
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Contracts\Modules;
|
|
||||||
|
|
||||||
use App\Models\Module;
|
|
||||||
|
|
||||||
interface InstallableModule {
|
|
||||||
/**
|
|
||||||
* Install module.
|
|
||||||
*
|
|
||||||
* This method is called after inserting info about module into database. It can be called only using Artisan in
|
|
||||||
* CLI.
|
|
||||||
*/
|
|
||||||
public static function install();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uninstalls module
|
|
||||||
*
|
|
||||||
* @param Module $module
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function uninstall(Module $module);
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Contracts\Repositories;
|
|
||||||
|
|
||||||
interface BaseRepository {
|
|
||||||
public function getOne($id = null);
|
|
||||||
public function all();
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Contracts\Repositories;
|
|
||||||
|
|
||||||
interface Content extends BaseRepository
|
|
||||||
{
|
|
||||||
const STATUS_DRAFT = 'draft';
|
|
||||||
const STATUS_PROTECTED = 'protected';
|
|
||||||
const STATUS_PUBLIC = 'public';
|
|
||||||
|
|
||||||
public function getOverview($handler = null, $statuses = null);
|
|
||||||
|
|
||||||
public function getHomepage();
|
|
||||||
|
|
||||||
public function getByURL($url);
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Contracts\Repositories;
|
|
||||||
|
|
||||||
use App\Models\Content\Content as ContentModel;
|
|
||||||
use App\Models\Module as ModuleModel;
|
|
||||||
|
|
||||||
interface Module extends BaseRepository
|
|
||||||
{
|
|
||||||
public function getCreateContentTitle(ModuleModel $module);
|
|
||||||
|
|
||||||
public function getUpdateContentTitle(ModuleModel $module, ContentModel $content = null);
|
|
||||||
|
|
||||||
public function getOverviewTitle(ModuleModel $module);
|
|
||||||
|
|
||||||
public function getByHandler($handler);
|
|
||||||
|
|
||||||
public function call(ModuleModel $module, $method, $parameters = []);
|
|
||||||
|
|
||||||
public function callOnString($moduleHandler, $method, $parameters = []);
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Contracts\Repositories;
|
|
||||||
|
|
||||||
use App\Models\Module as ModuleModel;
|
|
||||||
use App\Models\Templates\Template as TemplateModel;
|
|
||||||
|
|
||||||
interface Template
|
|
||||||
{
|
|
||||||
const EDITED_TEMPLATES_DIRECTORY = 'custom';
|
|
||||||
const ASSETS_DIRECTORY = 'assets';
|
|
||||||
const MODULES_DIRECTORY = 'modules';
|
|
||||||
const TEMPLATE_SUFFIX = '.blade.php';
|
|
||||||
const CUSTOM_EDIT_DIRECTORY = 1;
|
|
||||||
const ORIGINAL_DIRECTORY = 2;
|
|
||||||
|
|
||||||
public function setModel(TemplateModel $model);
|
|
||||||
|
|
||||||
public function getPathToTemplate();
|
|
||||||
|
|
||||||
public function getForModule(ModuleModel $module);
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Contracts\Widgets;
|
|
||||||
|
|
||||||
interface InstallableWidget extends PublicWidget {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function for installing given widget
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function install();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function for uninstalling widget
|
|
||||||
*/
|
|
||||||
public static function uninstall();
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Exceptions\FileManager;
|
|
||||||
|
|
||||||
class SubdirectoryExistsInDirectory extends \Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Exceptions\Validation;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
|
|
||||||
class ValidationFailedException extends \Exception {
|
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
public function __construct($validator, $message = null, $code = null, Exception $previous = null)
|
|
||||||
{
|
|
||||||
parent::__construct($message, $code, $previous);
|
|
||||||
|
|
||||||
$this->validator = $validator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getValidator(){
|
|
||||||
return $this->validator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\Cms\Handlers\Interactions;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Interaction as InteractionContract;
|
|
||||||
use App\CMS\Exceptions\Validation\ValidationFailedException;
|
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
|
|
||||||
class Interaction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Handle interaction with application
|
|
||||||
*
|
|
||||||
* @param string $interactionClass
|
|
||||||
* @param array $data
|
|
||||||
* @param array $extraParameters
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @throws ValidationFailedException
|
|
||||||
*/
|
|
||||||
public static function handle($interactionClass, $data, ...$extraParameters)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var $interaction InteractionContract
|
|
||||||
*/
|
|
||||||
|
|
||||||
$interaction = app($interactionClass);
|
|
||||||
// validate interaction
|
|
||||||
$validator = Validator::make($data, $interaction->getValidationRules($extraParameters));
|
|
||||||
|
|
||||||
if ($validator->fails()) {
|
|
||||||
throw new ValidationFailedException($validator);
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle it
|
|
||||||
|
|
||||||
return $interaction->handle($data, $extraParameters);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Helpers;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Modules\TemplateHandler;
|
|
||||||
use App\Models\Content\Content;
|
|
||||||
use App\Models\Module;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Database\QueryException;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
|
|
||||||
class CurrentTemplate implements TemplateHandler
|
|
||||||
{
|
|
||||||
protected static $template;
|
|
||||||
protected static $initialized = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for currently set template
|
|
||||||
* @return Module
|
|
||||||
* @throws \ErrorException
|
|
||||||
*/
|
|
||||||
public static function get()
|
|
||||||
{
|
|
||||||
if (!self::$initialized) {
|
|
||||||
self::$template = Cache::rememberForever('current-template', function () {
|
|
||||||
$template = Module::where('is_template', true)
|
|
||||||
->where('enabled', true)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
// todo remove after adding $casts into Module model
|
|
||||||
if ($template) {
|
|
||||||
$template->module_settings = json_decode($template->module_settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
self::$initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$template;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shortcut for getting template handler
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* @throws \ErrorException
|
|
||||||
*/
|
|
||||||
public static function handler()
|
|
||||||
{
|
|
||||||
$template = self::get();
|
|
||||||
|
|
||||||
if (!$template) {
|
|
||||||
throw new \ErrorException('No template selected, no handler available!');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $template->handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset currently set template and load another one on next call of get() method.
|
|
||||||
*/
|
|
||||||
public static function reset()
|
|
||||||
{
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Helpers;
|
|
||||||
|
|
||||||
use App\Models\FileManager\Directory;
|
|
||||||
use App\Models\FileManager\File;
|
|
||||||
|
|
||||||
class RootDirectory
|
|
||||||
{
|
|
||||||
protected static $directory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create root directory
|
|
||||||
*
|
|
||||||
* @return Directory
|
|
||||||
*/
|
|
||||||
protected static function create()
|
|
||||||
{
|
|
||||||
$directory = new Directory();
|
|
||||||
$directory->name = 'Root';
|
|
||||||
$directory->is_root = true;
|
|
||||||
$directory->save();
|
|
||||||
|
|
||||||
Directory::whereNull('parent_id')
|
|
||||||
->where('is_root', false)
|
|
||||||
->update(['parent_id' => $directory->id]);
|
|
||||||
|
|
||||||
File::where('directory_id', null)
|
|
||||||
->update(['directory_id' => $directory->id]);
|
|
||||||
|
|
||||||
return $directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get root directory
|
|
||||||
*
|
|
||||||
* @return Directory
|
|
||||||
*/
|
|
||||||
public static function get()
|
|
||||||
{
|
|
||||||
self::$directory = Directory::where('is_root', true)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (is_null(self::$directory)) {
|
|
||||||
self::$directory = self::create();
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$directory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Helpers;
|
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
||||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
|
||||||
|
|
||||||
class Template
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Getter for real template name
|
|
||||||
*
|
|
||||||
* @param $template
|
|
||||||
*
|
|
||||||
* @param bool $throwExceptions
|
|
||||||
*
|
|
||||||
* @return null|string
|
|
||||||
*/
|
|
||||||
public static function name($template, $throwExceptions = true)
|
|
||||||
{
|
|
||||||
$namespace = null;
|
|
||||||
if (strpos($template, '::')) {
|
|
||||||
list($namespace, $template) = explode('::', $template);
|
|
||||||
$namespace .= '::';
|
|
||||||
}
|
|
||||||
|
|
||||||
// list of prefixes
|
|
||||||
$prefixes = ['custom.', ''];
|
|
||||||
|
|
||||||
$view = null;
|
|
||||||
foreach ($prefixes as $prefix) {
|
|
||||||
if (view()->exists($namespace . 'visitor.' . $prefix . $template)) {
|
|
||||||
$view = $namespace . 'visitor.' . $prefix . $template;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_null($view)) {
|
|
||||||
if ($throwExceptions) {
|
|
||||||
throw new InvalidArgumentException('Cannot find template for ' . $namespace . $template);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $view;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Helpers;
|
|
||||||
|
|
||||||
class Widget
|
|
||||||
{
|
|
||||||
public static function render(\App\Models\Widgets\Widget $widget)
|
|
||||||
{
|
|
||||||
$handler = $widget->widget_type_handler;
|
|
||||||
|
|
||||||
if (is_string($widget->settings)) {
|
|
||||||
$widget->settings = json_decode($widget->settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
$presenter = call_user_func([$handler, 'getPresenter']);
|
|
||||||
|
|
||||||
return call_user_func([$presenter, 'render'], $widget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Interactions\Admin\Content;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Interaction;
|
|
||||||
use App\CMS\Enumerations\ContentStatuses;
|
|
||||||
|
|
||||||
class ChangeStatus implements Interaction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Change status of content page
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @param array $parameters
|
|
||||||
*
|
|
||||||
* @return mixed|void
|
|
||||||
*/
|
|
||||||
public function handle($data, $parameters)
|
|
||||||
{
|
|
||||||
list ($page) = $parameters;
|
|
||||||
|
|
||||||
$page->status = $data['status'];
|
|
||||||
$page->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if status is valid
|
|
||||||
*
|
|
||||||
* @param array $parameters
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getValidationRules($parameters = [])
|
|
||||||
{
|
|
||||||
$statuses = ContentStatuses::getWithTranslations();
|
|
||||||
|
|
||||||
return ['status' => 'in:' . implode(',', array_keys($statuses))];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Interactions\Admin\Content;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Interaction;
|
|
||||||
use App\CMS\Contracts\Repositories\Module;
|
|
||||||
use App\Models\Content\Content;
|
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
|
|
||||||
class DeletePage implements Interaction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Perform given action
|
|
||||||
*
|
|
||||||
* @param $data array input data
|
|
||||||
* @param $parameters array parameters
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle($data, $parameters)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var $page Content
|
|
||||||
* @var $module Module
|
|
||||||
*/
|
|
||||||
|
|
||||||
$module = App::make(Module::class);
|
|
||||||
list ($page) = $parameters;
|
|
||||||
|
|
||||||
// delete page
|
|
||||||
$page->delete();
|
|
||||||
|
|
||||||
// let module to delete some extra content created during page's life
|
|
||||||
$module->callOnString($page->moduleHandler, 'delete', [$page]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $data array input data
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getValidationRules($data = [])
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\Cms\Interactions\Admin\Content;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Interaction;
|
|
||||||
use App\CMS\Contracts\Repositories\Module;
|
|
||||||
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;
|
|
||||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edit page
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @param array $parameters
|
|
||||||
*
|
|
||||||
* @return mixed|void
|
|
||||||
*/
|
|
||||||
public function handle($data, $parameters)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var $page Content
|
|
||||||
*/
|
|
||||||
list($page, $titlePhoto, $relatedFiles) = $parameters;
|
|
||||||
|
|
||||||
// let template to modify request and content page
|
|
||||||
CurrentTemplate::beforeSave($page, $data);
|
|
||||||
|
|
||||||
// upload file - if provided
|
|
||||||
$data['titlePhoto'] = isset($data['existingTitlePhoto']) ? $data['existingTitlePhoto'] : null;
|
|
||||||
|
|
||||||
if (!is_null($titlePhoto)) {
|
|
||||||
$file = $this->file->upload($titlePhoto);
|
|
||||||
$data['titlePhoto'] = $file ? $file['filename'] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$page->update($data);
|
|
||||||
$this->module->callOnString($page->moduleHandler, 'edit', [$page, $data]);
|
|
||||||
|
|
||||||
// move to interaction
|
|
||||||
$keepAssigned = isset($data->keepAssigned) ? $data->keepAssigned : [];
|
|
||||||
$page->uploadRelatedFiles($relatedFiles, $keepAssigned);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate this interaction
|
|
||||||
*
|
|
||||||
* @param array $parameters
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getValidationRules($parameters = [])
|
|
||||||
{
|
|
||||||
$id = $parameters[0]->id;
|
|
||||||
|
|
||||||
// get all available statuses
|
|
||||||
$statuses = ContentStatuses::getSimple();
|
|
||||||
$statuses = implode(',', $statuses);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'title' => 'required',
|
|
||||||
'url' => 'required|unique:contents,url,' . $id.',id,deleted_at,NULL,language,' . LaravelLocalization::getCurrentLocale(),
|
|
||||||
'publishedFrom' => 'date',
|
|
||||||
'publishedTo' => 'date',
|
|
||||||
'status' => 'required|in:' . $statuses,
|
|
||||||
'parentPage' => 'exists:contents,id'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
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\Enumerations\ContentStatuses;
|
|
||||||
use App\CMS\Helpers\CurrentTemplate;
|
|
||||||
use App\Models\Content\Content;
|
|
||||||
use App\Models\FileManager\File;
|
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
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(ContentRepository::class);
|
|
||||||
$this->module = App::make(Module::class);
|
|
||||||
$this->file = App::make(File::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new content page
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @param $parameters
|
|
||||||
*
|
|
||||||
* @return Content
|
|
||||||
*/
|
|
||||||
public function handle($data, $parameters)
|
|
||||||
{
|
|
||||||
list($moduleHandler, $titlePhoto, $relatedFiles) = $parameters;
|
|
||||||
|
|
||||||
// upload file - if provided
|
|
||||||
$file = !is_null($titlePhoto) ? $this->file->upload($titlePhoto) : 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
|
|
||||||
$this->module->callOnString($moduleHandler, 'createNew', [&$page, $data]);
|
|
||||||
|
|
||||||
// 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($relatedFiles);
|
|
||||||
|
|
||||||
return $page;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getValidationRules($parameters = [])
|
|
||||||
{
|
|
||||||
// get all available statuses
|
|
||||||
$statuses = ContentStatuses::getSimple();
|
|
||||||
$statuses = implode(',', $statuses);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'titlePhoto' => 'image',
|
|
||||||
'title' => 'required',
|
|
||||||
'url' => 'required|unique:contents,url,NULL,id,deleted_at,NULL,language,' . LaravelLocalization::getCurrentLocale(),
|
|
||||||
'status' => 'required|in:'.$statuses,
|
|
||||||
'parentPage' => 'exists:contents,id',
|
|
||||||
'publishedFrom' => 'date',
|
|
||||||
'publishedTo' => 'date',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Interactions\Admin\Content;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Interaction;
|
|
||||||
use App\CMS\Enumerations\ContentStatuses;
|
|
||||||
use App\Models\Content\Content;
|
|
||||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
|
||||||
|
|
||||||
class SetHomepage implements Interaction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Set homepage of given page
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @param array $parameters
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle($data, $parameters)
|
|
||||||
{
|
|
||||||
list ($page) = $parameters;
|
|
||||||
// disable any other existing homepage
|
|
||||||
Content::where('isHomepage', true)
|
|
||||||
->where('language', LaravelLocalization::getCurrentLocale())
|
|
||||||
->update(['isHomepage' => false]);
|
|
||||||
|
|
||||||
// set new homepage
|
|
||||||
$page->isHomepage = true;
|
|
||||||
$page->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if status is valid
|
|
||||||
*
|
|
||||||
* @param array $parameters
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getValidationRules($parameters = [])
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Interactions\Admin\FileManager;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Interaction;
|
|
||||||
use App\CMS\Exceptions\FileManager\SubdirectoryExistsInDirectory;
|
|
||||||
use App\CMS\Repositories\FileManager\Directory as DirectoryRepository;
|
|
||||||
use App\Models\FileManager\Directory;
|
|
||||||
|
|
||||||
class CreateDirectory implements Interaction
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var DirectoryRepository
|
|
||||||
*/
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
public function __construct(DirectoryRepository $repository)
|
|
||||||
{
|
|
||||||
$this->repository = $repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform given action
|
|
||||||
*
|
|
||||||
* @param $data array input data
|
|
||||||
* @param $parameters array parameters
|
|
||||||
*
|
|
||||||
* @return Directory
|
|
||||||
* @throws SubdirectoryExistsInDirectory
|
|
||||||
*/
|
|
||||||
public function handle($data, $parameters)
|
|
||||||
{
|
|
||||||
$data['parentDirectory'] = isset($data['parentDirectory']) ? $data['parentDirectory'] : null;
|
|
||||||
|
|
||||||
// todo this should probably go into validation, but we are not able to get $data in getValidationRules
|
|
||||||
// check if created folder does not exist in current directory
|
|
||||||
if ($this->repository->checkIfNameExists($data['name'], $data['parentDirectory'])) {
|
|
||||||
throw new SubdirectoryExistsInDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo use Directory::create() and rename columns/fields in request
|
|
||||||
// create new database entry
|
|
||||||
$directory = new Directory();
|
|
||||||
$directory->name = $data['name'];
|
|
||||||
$directory->parent_id = $data['parentDirectory'];
|
|
||||||
$directory->user_id = \Auth::user()->id;
|
|
||||||
$directory->description = $data['description'];
|
|
||||||
$directory->save();
|
|
||||||
|
|
||||||
return $directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $data array input data
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws SubdirectoryExistsInDirectory
|
|
||||||
*/
|
|
||||||
public function getValidationRules($data = [])
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name' => 'required|max:255',
|
|
||||||
'parentDirectory' => 'exists:directories,id'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Observers;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Repositories\Content as ContentContract;
|
|
||||||
use App\Events\CreateNewContent;
|
|
||||||
use App\Events\DeleteContent;
|
|
||||||
use App\Events\EditContent;
|
|
||||||
use App\Events\MakeDraftFromContent;
|
|
||||||
use App\Events\PublishContent;
|
|
||||||
use App\Events\SetHomepage;
|
|
||||||
use App\Models\Content\Content as ContentModel;
|
|
||||||
use App\Models\Content\ContentHistory;
|
|
||||||
use Illuminate\Support\Facades\Event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Content
|
|
||||||
*
|
|
||||||
* Model observer for logging changes on content page.
|
|
||||||
*
|
|
||||||
* @package App\CMS\Observers
|
|
||||||
*/
|
|
||||||
class Content
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $changeset;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->changeset = uniqid();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log changes on edit
|
|
||||||
*
|
|
||||||
* @param ContentModel $content
|
|
||||||
*/
|
|
||||||
public function updated(ContentModel $content)
|
|
||||||
{
|
|
||||||
$fields = $this->getDirtyFields($content->getDirty(), $content->getOriginal());
|
|
||||||
|
|
||||||
$normalFieldsEdited = 0;
|
|
||||||
foreach ($fields as $field => $change) {
|
|
||||||
if ($field == 'viewed')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$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);
|
|
||||||
|
|
||||||
// fire event
|
|
||||||
$this->fireEvent($field, $change, $content, $normalFieldsEdited);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($normalFieldsEdited > 0) {
|
|
||||||
Event::fire(new EditContent($content, $this->changeset));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fire event when new instance of model is stored into database
|
|
||||||
*
|
|
||||||
* @param ContentModel $content
|
|
||||||
*/
|
|
||||||
public function created(ContentModel $content)
|
|
||||||
{
|
|
||||||
Event::fire(new CreateNewContent($content));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ContentModel $content
|
|
||||||
*/
|
|
||||||
public function deleted(ContentModel $content)
|
|
||||||
{
|
|
||||||
Event::fire(new DeleteContent($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 = isset($original['moduleSettings']) ? (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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get original and changed values in one array
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fire events for publishing/making draft and setting homepage
|
|
||||||
*
|
|
||||||
* @param $field
|
|
||||||
* @param $change
|
|
||||||
* @param ContentModel $content
|
|
||||||
* @param $normalFieldsEdited
|
|
||||||
*/
|
|
||||||
protected function fireEvent($field, $change, ContentModel $content, &$normalFieldsEdited)
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
case 'status':
|
|
||||||
if ($change['new'] !== ContentContract::STATUS_DRAFT) {
|
|
||||||
Event::fire(new PublishContent($content, $this->changeset));
|
|
||||||
} else {
|
|
||||||
Event::fire(new MakeDraftFromContent($content, $this->changeset));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'isHomepage':
|
|
||||||
Event::fire(new SetHomepage($content, $this->changeset));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$normalFieldsEdited++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Repositories\Content;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Repositories\Content as IContent;
|
|
||||||
use App\CMS\Enumerations\ContentStatuses;
|
|
||||||
use App\CMS\Repositories\Repository;
|
|
||||||
use App\Models\Content\Content as ContentModel;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
|
||||||
|
|
||||||
class Content extends Repository implements IContent
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var ContentModel
|
|
||||||
*/
|
|
||||||
protected $model;
|
|
||||||
|
|
||||||
public function __construct(ContentModel $model)
|
|
||||||
{
|
|
||||||
$this->model = $model;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for query with setup filter for non-deleted and non-draft pages
|
|
||||||
*/
|
|
||||||
protected function getPageQuery()
|
|
||||||
{
|
|
||||||
return ContentModel::where('status', '!=', IContent::STATUS_DRAFT)
|
|
||||||
->select('contents.*')
|
|
||||||
->with('author')
|
|
||||||
->join('modules', 'modules.handler', '=', 'contents.moduleHandler')
|
|
||||||
->where(function ($query) {
|
|
||||||
$query->where('publishedFrom', '<=', Carbon::now())
|
|
||||||
->orWhereNull('publishedFrom');
|
|
||||||
})
|
|
||||||
->where(function ($query) {
|
|
||||||
$query->where('publishedTo', '>=', Carbon::now())
|
|
||||||
->orWhereNull('publishedTo');
|
|
||||||
})
|
|
||||||
->where('language', LaravelLocalization::getCurrentLocale())
|
|
||||||
->whereNull('contents.deleted_at')
|
|
||||||
->where('modules.enabled', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function all()
|
|
||||||
{
|
|
||||||
return $this->getPageQuery()
|
|
||||||
->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $id
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getOne($id = null)
|
|
||||||
{
|
|
||||||
if (is_null($id)) {
|
|
||||||
$page = new ContentModel();
|
|
||||||
$page->user_id = \Auth::user()->id;
|
|
||||||
$page->language = LaravelLocalization::getCurrentLocale();
|
|
||||||
$page->status = IContent::STATUS_DRAFT;
|
|
||||||
$page->moduleSettings = [];
|
|
||||||
} else {
|
|
||||||
$page = $this->model->findOrFail($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $page;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for homepage content page
|
|
||||||
* @return Content
|
|
||||||
*/
|
|
||||||
public function getHomepage()
|
|
||||||
{
|
|
||||||
return $this->getPageQuery()
|
|
||||||
->where('isHomepage', 1)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for any page specified by its url.
|
|
||||||
*
|
|
||||||
* @param $url
|
|
||||||
*
|
|
||||||
* @return Content
|
|
||||||
*/
|
|
||||||
public function getByURL($url)
|
|
||||||
{
|
|
||||||
return $this->getPageQuery()
|
|
||||||
->where('url', $url)
|
|
||||||
->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for overview of all content pages.
|
|
||||||
* These content pages may be filtered by using some handler
|
|
||||||
*
|
|
||||||
* @param bool $handler
|
|
||||||
* @param null $statuses
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
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.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')
|
|
||||||
->where('contents.language', LaravelLocalization::getCurrentLocale())
|
|
||||||
->where('modules.enabled', 1)
|
|
||||||
->orderBy('contents.created_at', 'DESC');
|
|
||||||
|
|
||||||
// filter results using handler
|
|
||||||
if (!is_null($handler)) {
|
|
||||||
$query = $query->where('contents.moduleHandler', $handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add filtering by status
|
|
||||||
if (is_array($statuses) && in_array($statuses, ContentStatuses::getSimple())) {
|
|
||||||
$query = $query->whereIn('contents.status', $statuses);
|
|
||||||
}
|
|
||||||
|
|
||||||
$pages = $query->paginate(setting('paginatedResults', 20));
|
|
||||||
|
|
||||||
return $pages;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Repositories\FileManager;
|
|
||||||
|
|
||||||
use App\CMS\Helpers\RootDirectory;
|
|
||||||
use App\Models\FileManager\Directory as DirectoryModel;
|
|
||||||
|
|
||||||
class Directory
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Checks if directory with given name does not exist in current directory
|
|
||||||
*
|
|
||||||
* @param $name
|
|
||||||
* @param $parentDirectoryId
|
|
||||||
* @param bool $ignoredId
|
|
||||||
*/
|
|
||||||
public function checkIfNameExists($name, $parentDirectoryId, $ignoredId = false)
|
|
||||||
{
|
|
||||||
$exists = DirectoryModel::where('name', $name)
|
|
||||||
->where('parent_id', $parentDirectoryId);
|
|
||||||
|
|
||||||
if ($ignoredId !== false) {
|
|
||||||
$exists = $exists->where('id', '!=', $ignoredId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $exists->exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(DirectoryModel $directory, $data) {
|
|
||||||
$directory->name = $data['name'];
|
|
||||||
$directory->description = $data['description'];
|
|
||||||
$directory->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param DirectoryModel $directory
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
||||||
*/
|
|
||||||
public function getAllSubdirectories(DirectoryModel &$directory)
|
|
||||||
{
|
|
||||||
if (!$directory->exists) {
|
|
||||||
$directory = DirectoryModel::where('is_root', true)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (is_null($directory)) {
|
|
||||||
$directory = RootDirectory::get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$subdirectories = $directory->allSubdirectories();
|
|
||||||
|
|
||||||
return $subdirectories;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Repositories;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Repositories\Module as IModule;
|
|
||||||
use App\Models\Content\Content;
|
|
||||||
use App\Models\Module as ModuleModel;
|
|
||||||
|
|
||||||
class Module extends Repository implements IModule
|
|
||||||
{
|
|
||||||
public function __construct(ModuleModel $module)
|
|
||||||
{
|
|
||||||
$this->model = $module;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOne($id = null)
|
|
||||||
{
|
|
||||||
if (is_null($id)) {
|
|
||||||
return new ModuleModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_numeric($id)) {
|
|
||||||
return ModuleModel::findOrFail($id);
|
|
||||||
} else {
|
|
||||||
return ModuleModel::where('alias', $id)
|
|
||||||
->firstOrFail();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCreateContentTitle(ModuleModel $module)
|
|
||||||
{
|
|
||||||
$pageHeading = trans('admin/contents.new', ['name' => trans($module->name)]);
|
|
||||||
$moduleHeading = $this->call($module, 'getCreateNewTitle');
|
|
||||||
|
|
||||||
return is_null($moduleHeading) ? $pageHeading : $moduleHeading;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUpdateContentTitle(ModuleModel $module, Content $content = null)
|
|
||||||
{
|
|
||||||
$pageHeading = trans('admin/contents.edit', ['name' => trans($module->name)]);
|
|
||||||
$moduleHeading = $this->call($module, 'getEditTitle', [$content]);
|
|
||||||
|
|
||||||
return is_null($moduleHeading) ? $pageHeading : $moduleHeading;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOverviewTitle(ModuleModel $module)
|
|
||||||
{
|
|
||||||
$pageHeading = 'admin/contents.overview';
|
|
||||||
$moduleHeading = $this->call($module, 'getOverviewTitle');
|
|
||||||
|
|
||||||
return is_null($moduleHeading) ? $pageHeading : $moduleHeading;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function all()
|
|
||||||
{
|
|
||||||
return ModuleModel::where('enabled', true)
|
|
||||||
->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getByHandler($handler)
|
|
||||||
{
|
|
||||||
return ModuleModel::where('handler', $handler)
|
|
||||||
->firstOrFail();
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function callOnString($moduleHandler, $method, $parameters = [])
|
|
||||||
{
|
|
||||||
if (is_callable([$moduleHandler, $method])) {
|
|
||||||
return call_user_func_array([$moduleHandler, $method], $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Repositories;
|
|
||||||
|
|
||||||
abstract class Repository
|
|
||||||
{
|
|
||||||
protected $model;
|
|
||||||
|
|
||||||
public function __call($method, $args)
|
|
||||||
{
|
|
||||||
return call_user_func_array([$this->model, $method], $args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\Cms\Repositories\Templates;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Repositories\Template as ITemplate;
|
|
||||||
use App\CMS\Repositories\Repository;
|
|
||||||
use App\Models\Module;
|
|
||||||
use App\Models\Templates\Template as TemplateModel;
|
|
||||||
|
|
||||||
class Template extends Repository implements ITemplate
|
|
||||||
{
|
|
||||||
public function setModel(TemplateModel $model)
|
|
||||||
{
|
|
||||||
$this->model = $model;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for absolute path to template
|
|
||||||
*
|
|
||||||
* @param null $mode
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPathToTemplate($mode = null)
|
|
||||||
{
|
|
||||||
$templateName = $this->model->template_name;
|
|
||||||
$path = $this->model->templatePath;
|
|
||||||
|
|
||||||
// delete namespace if given
|
|
||||||
if (strpos($this->model->template_name, '::')) {
|
|
||||||
list(, $templateName) = explode('::', $templateName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get template name, do not care about directories (they are already contained in path)
|
|
||||||
$parts = explode('.', $templateName);
|
|
||||||
$templateName = last($parts);
|
|
||||||
|
|
||||||
// just a shortcut for this unbelievable long constant name...
|
|
||||||
$_ = DIRECTORY_SEPARATOR;
|
|
||||||
|
|
||||||
// path parts
|
|
||||||
$absolutePath = base_path($path->path);
|
|
||||||
$templatePath = str_replace('.', $_, $templateName);
|
|
||||||
$file = $templatePath . ITemplate::TEMPLATE_SUFFIX;
|
|
||||||
|
|
||||||
// compose two versions of path - original and with "custom" directory
|
|
||||||
$original = $absolutePath . $_ . $file;
|
|
||||||
$edited = $absolutePath . $_ . ITemplate::EDITED_TEMPLATES_DIRECTORY . $_ . $file;
|
|
||||||
|
|
||||||
// decide which path will be returned
|
|
||||||
switch ($mode) {
|
|
||||||
case ITemplate::CUSTOM_EDIT_DIRECTORY:
|
|
||||||
return $edited;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ITemplate::ORIGINAL_DIRECTORY:
|
|
||||||
return $original;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (file_exists($absolutePath . $_ . ITemplate::EDITED_TEMPLATES_DIRECTORY . $_ . $file)) {
|
|
||||||
return $edited;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $original;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getForModule(Module $module)
|
|
||||||
{
|
|
||||||
return TemplateModel::where('module_id', $module->id)
|
|
||||||
->select(['template_name', 'name', 'description'])
|
|
||||||
->get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Widgets\SocialButtons\Presenters;
|
|
||||||
|
|
||||||
use App\Models\Widgets\Widget;
|
|
||||||
use App\Models\Widgets\WidgetType;
|
|
||||||
use App\Models\Settings as SettingsModel;
|
|
||||||
use App\CMS\Contracts\Widgets\WidgetRenderer;
|
|
||||||
use App\CMS\Widgets\SocialButtons\Presenters\Route;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Modules\Blog\Article\Entities\Article as ArticleModel;
|
|
||||||
use Modules\Blog\Article\Handlers\Article;
|
|
||||||
|
|
||||||
class SocialButtons implements WidgetRenderer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Method used for displaying widget.
|
|
||||||
*
|
|
||||||
* This method renders some HTML code for displaying.
|
|
||||||
*
|
|
||||||
* @param Widget $widget
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function render(Widget $widget)
|
|
||||||
{
|
|
||||||
return view('visitor.widgets.shareButtons.all', compact('widget'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display form for creating new instance of widget
|
|
||||||
*
|
|
||||||
* @param WidgetType $type
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function renderAddForm(WidgetType $type)
|
|
||||||
{
|
|
||||||
return view('admin.widgets.socialButtons.new', [
|
|
||||||
'type' => $type,
|
|
||||||
'widget' => new Widget(),
|
|
||||||
'settings' => new \stdClass()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display form for editing already existing widget
|
|
||||||
*
|
|
||||||
* @param Widget $widget
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function renderEditForm(Widget $widget)
|
|
||||||
{
|
|
||||||
$settings = $widget->settings;
|
|
||||||
return view('admin.widgets.socialButtons.edit', ['widget' => $widget, 'settings' => $settings]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\CMS\Widgets\SocialButtons;
|
|
||||||
|
|
||||||
use App\CMS\Contracts\Widgets\PublicWidget;
|
|
||||||
use App\CMS\Widgets\Exceptions\MissingParameterException;
|
|
||||||
use App\Http\Requests\Request;
|
|
||||||
use App\Models\Widgets\Widget;
|
|
||||||
|
|
||||||
class SocialButtons implements PublicWidget
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Name getter
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getName()
|
|
||||||
{
|
|
||||||
return 'widgets/socialButtons.widgetName';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for description
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getDescription()
|
|
||||||
{
|
|
||||||
return 'widgets/socialButtons.widgetDescription';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for presenter/renderer of this widget
|
|
||||||
*
|
|
||||||
* @return WidgetRenderer
|
|
||||||
*/
|
|
||||||
public static function getPresenter()
|
|
||||||
{
|
|
||||||
return Presenters\SocialButtons::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $data
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws MissingParameterException
|
|
||||||
*/
|
|
||||||
public static function save(Request $data)
|
|
||||||
{
|
|
||||||
//if (!isset($data->code) || empty($data->code)) {
|
|
||||||
// throw new MissingParameterException('code');
|
|
||||||
//}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,6 +32,8 @@ class AddLanguage extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,39 +14,33 @@ class ChangePassword extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'user:change-password {email}';
|
protected $signature = 'user:change-password {userID} {newPassword}';
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Change password for user with given e-mail';
|
protected $description = 'Change password for user with given ID';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$email = $this->argument('email');
|
$id = $this->argument('userID');
|
||||||
|
$newPassword = $this->argument('newPassword');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user = User::where(['email' => $email])
|
$user = User::findOrFail($id);
|
||||||
->first();
|
|
||||||
} catch (ModelNotFoundException $e) {
|
} catch (ModelNotFoundException $e) {
|
||||||
$this->error('Invalid user ' . $email . '.');
|
$this->error('Invalid user ID ' . $id . '. Please see table `users` for correct IDs.');
|
||||||
return;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
|
||||||
$password = $this->secret('Password');
|
|
||||||
$passwordAgain = $this->secret('Password again');
|
|
||||||
|
|
||||||
if ($password !== $passwordAgain) {
|
|
||||||
$this->error('Passwords does not match');
|
|
||||||
}
|
|
||||||
} while ($passwordAgain !== $password || strlen($password) === 0);
|
|
||||||
|
|
||||||
// set new password
|
// set new password
|
||||||
$user->password = Hash::make($password);
|
$user->password = Hash::make($newPassword);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$this->info('Password successfully changed.');
|
$this->info('Password successfully changed.');
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Console\Commands;
|
|||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
|
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
|
||||||
@@ -64,10 +63,6 @@ class InstallModule extends Command
|
|||||||
// all mandatory fields are present, we can write it into database and create modules.json
|
// all mandatory fields are present, we can write it into database and create modules.json
|
||||||
$this->installModule($config);
|
$this->installModule($config);
|
||||||
|
|
||||||
// delete cache
|
|
||||||
Cache::forget('enabled-modules');
|
|
||||||
Cache::forget('module-handler-to-id-enumeration');
|
|
||||||
|
|
||||||
// inform user
|
// inform user
|
||||||
$this->line('Module ' . $name . ' successfuly installed');
|
$this->line('Module ' . $name . ' successfuly installed');
|
||||||
}
|
}
|
||||||
@@ -98,7 +93,7 @@ class InstallModule extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we cannot rely on config() helper, because this module does not have to be published
|
// we cannot rely on config() helper, because this module does not have to be published
|
||||||
$config = include($path);
|
$config = @include($path);
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
@@ -151,7 +146,7 @@ class InstallModule extends Command
|
|||||||
throw new \Exception('Module ' . $config['name'] . ' already exists in database.');
|
throw new \Exception('Module ' . $config['name'] . ' already exists in database.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($module)) {
|
if (!$module) {
|
||||||
// insert module into database
|
// insert module into database
|
||||||
$settings = [
|
$settings = [
|
||||||
'staticName' => $this->moduleName,
|
'staticName' => $this->moduleName,
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\CMS\Enumerations\UserRoles;
|
use App\Enumerations\UserRoles;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
class NewUser extends Command
|
class NewUser extends Command
|
||||||
{
|
{
|
||||||
@@ -14,7 +15,7 @@ class NewUser extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'user:new {email}';
|
protected $signature = 'user:new {email} {password} {role}';
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
@@ -24,37 +25,20 @@ class NewUser extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$email = $this->argument('email');
|
$email = $this->argument('email');
|
||||||
|
$password = $this->argument('password');
|
||||||
|
$role = $this->argument('role');
|
||||||
|
|
||||||
// check if username is really email
|
// check if given role is valid
|
||||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
||||||
$this->error($email . ' is not a valid e-mail!');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ask for password
|
|
||||||
do {
|
|
||||||
$password = $this->secret('Password');
|
|
||||||
$passwordAgain = $this->secret('Password again');
|
|
||||||
|
|
||||||
if ($password !== $passwordAgain) {
|
|
||||||
$this->error('Passwords does not match');
|
|
||||||
}
|
|
||||||
} while ($passwordAgain !== $password || strlen($password) === 0);
|
|
||||||
|
|
||||||
// ask for role
|
|
||||||
$roles = UserRoles::getSimple();
|
$roles = UserRoles::getSimple();
|
||||||
do {
|
if (!in_array($role, $roles)) {
|
||||||
$role = $this->ask('Role (default ' . User::ROLE_ADMIN . '): ', User::ROLE_ADMIN);
|
throw new InvalidArgumentException('Invalid role specified. valid roles are: ' . implode(', ', $roles));
|
||||||
|
}
|
||||||
// check if given role is valid
|
|
||||||
if (!in_array($role, $roles)) {
|
|
||||||
$this->error('Invalid role specified. valid roles are: ' . implode(', ', $roles));
|
|
||||||
}
|
|
||||||
} while (!in_array($role, $roles));
|
|
||||||
|
|
||||||
// create new user
|
// create new user
|
||||||
$user = new User();
|
$user = new User();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
class SetTemplate extends Command
|
class SetTemplate extends Command
|
||||||
@@ -64,9 +63,6 @@ class SetTemplate extends Command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete cached current template
|
|
||||||
Cache::forget('current-template');
|
|
||||||
|
|
||||||
// theme written
|
// theme written
|
||||||
$this->line('Template successfully set up.');
|
$this->line('Template successfully set up.');
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CustomFields;
|
||||||
|
|
||||||
|
class BaseField {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CustomFields;
|
||||||
|
|
||||||
|
class Date extends BaseField {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CustomFields;
|
||||||
|
|
||||||
|
class Number extends BaseField {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CustomFields;
|
||||||
|
|
||||||
|
class SelectboxList extends BaseField {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CustomFields;
|
||||||
|
|
||||||
|
class String extends BaseField {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\ActionLogType;
|
use App\Models\ActionLogType;
|
||||||
|
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\ActionLog\ActionLogType;
|
use App\Models\ActionLogType;
|
||||||
|
|
||||||
class ActionLogTypesForLogger extends BaseEnumeration
|
class ActionLogTypesForLogger extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\CMS\Exceptions\Enumerations\EnumerationExistsException;
|
use App\Enumerations\Exceptions\EnumerationExistsException;
|
||||||
|
|
||||||
abstract class BaseEnumeration
|
abstract class BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Content;
|
||||||
use App\CMS\Contracts\Repositories\Content;
|
|
||||||
|
|
||||||
class ContentStatuses extends BaseEnumeration
|
class ContentStatuses extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\CustomFieldResource;
|
||||||
|
|
||||||
|
class CustomFieldResources extends BaseEnumeration
|
||||||
|
{
|
||||||
|
public static $items = [];
|
||||||
|
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
|
// load items from database
|
||||||
|
$types = CustomFieldResource::all(['id', 'name']);
|
||||||
|
|
||||||
|
// push items into collection
|
||||||
|
foreach ($types as $type) {
|
||||||
|
self::push($type->id, $type->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\CustomFieldType;
|
||||||
|
|
||||||
|
class CustomFieldTypes extends BaseEnumeration
|
||||||
|
{
|
||||||
|
public static $items = [];
|
||||||
|
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
|
|
||||||
|
// load items from database
|
||||||
|
$types = CustomFieldType::all(['id', 'name']);
|
||||||
|
|
||||||
|
// push items into collection
|
||||||
|
foreach ($types as $type) {
|
||||||
|
self::push($type->id, $type->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Exceptions\Enumerations;
|
namespace App\Enumerations\Exceptions;
|
||||||
|
|
||||||
class EnumerationExistsException extends \Exception {
|
class EnumerationExistsException extends \Exception {
|
||||||
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
|
|
||||||
+2
-5
@@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
|
|
||||||
class ModulesHandlerToId extends BaseEnumeration
|
class ModulesHandlerToId extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -13,9 +12,7 @@ class ModulesHandlerToId extends BaseEnumeration
|
|||||||
*/
|
*/
|
||||||
protected static function init()
|
protected static function init()
|
||||||
{
|
{
|
||||||
$modules = Cache::rememberForever('module-handler-to-id-enumeration', function () {
|
$modules = Module::all(['handler', 'id']);
|
||||||
return Module::all(['handler', 'id']);
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
self::push($module->handler, $module->id);
|
self::push($module->handler, $module->id);
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
* Time: 10:33
|
* Time: 10:33
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Templates\TemplatePath;
|
use App\Models\TemplatePath;
|
||||||
|
|
||||||
class TemplatePaths extends BaseEnumeration
|
class TemplatePaths extends BaseEnumeration
|
||||||
{
|
{
|
||||||
+2
-2
@@ -6,9 +6,9 @@
|
|||||||
* Time: 10:33
|
* Time: 10:33
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Templates\TemplatePath;
|
use App\Models\TemplatePath;
|
||||||
|
|
||||||
class TemplatePathsHumanReadable extends BaseEnumeration
|
class TemplatePathsHumanReadable extends BaseEnumeration
|
||||||
{
|
{
|
||||||
+2
-2
@@ -6,9 +6,9 @@
|
|||||||
* Time: 10:33
|
* Time: 10:33
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Templates\TemplatePath;
|
use App\Models\TemplatePath;
|
||||||
|
|
||||||
class TemplatePathsHumanReadableRootOnly extends BaseEnumeration
|
class TemplatePathsHumanReadableRootOnly extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
* Time: 15:50
|
* Time: 15:50
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Templates\Template;
|
use App\Models\Template;
|
||||||
|
|
||||||
class Templates extends BaseEnumeration
|
class Templates extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* Time: 23:20
|
* Time: 23:20
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Widgets\WidgetType;
|
use App\Models\WidgetType;
|
||||||
|
|
||||||
class WidgetTypes extends BaseEnumeration
|
class WidgetTypes extends BaseEnumeration
|
||||||
{
|
{
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Enumerations;
|
namespace App\Enumerations;
|
||||||
|
|
||||||
use App\Models\Widgets\WidgetType;
|
use App\Models\WidgetType;
|
||||||
|
|
||||||
class WidgetTypesWithHandlers extends BaseEnumeration
|
class WidgetTypesWithHandlers extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Widgets\Widget;
|
use App\Models\Widget;
|
||||||
use App\Models\Widgets\WidgetArea;
|
use App\Models\WidgetArea;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class AssignWidget extends Event
|
class AssignWidget extends Event
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Events\Event;
|
use App\Events\Event;
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Events\Event;
|
||||||
|
use App\Models\CustomField;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
class CreateNewCustomField extends Event
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
/**
|
||||||
|
* @var CustomField
|
||||||
|
*/
|
||||||
|
public $customField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param CustomField $customField
|
||||||
|
*/
|
||||||
|
public function __construct(CustomField $customField)
|
||||||
|
{
|
||||||
|
$this->customField = $customField;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Widgets\Widget;
|
use App\Models\Widget;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class CreateNewWidget extends Event
|
class CreateNewWidget extends Event
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Widgets\WidgetArea;
|
use App\Models\WidgetArea;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class CreateNewWidgetArea extends Event
|
class CreateNewWidgetArea extends Event
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class DeleteContent extends Event
|
class DeleteContent extends Event
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Events\Event;
|
||||||
|
use App\Models\CustomField;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
class DeleteCustomField extends Event
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
/**
|
||||||
|
* @var CustomField
|
||||||
|
*/
|
||||||
|
public $customField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param CustomField $customField
|
||||||
|
*/
|
||||||
|
public function __construct(CustomField $customField)
|
||||||
|
{
|
||||||
|
$this->customField = $customField;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class EditContent extends Event
|
class EditContent extends Event
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Events\Event;
|
||||||
|
use App\Models\CustomField;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
class EditCustomField extends Event
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
/**
|
||||||
|
* @var CustomField
|
||||||
|
*/
|
||||||
|
public $customField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param CustomField $customField
|
||||||
|
*/
|
||||||
|
public function __construct(CustomField $customField)
|
||||||
|
{
|
||||||
|
$this->customField = $customField;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Events\Event;
|
use App\Events\Event;
|
||||||
use App\Models\FileManager\File;
|
use App\Models\File;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Widgets\Widget;
|
use App\Models\Widget;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class EditWidget extends Event
|
class EditWidget extends Event
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class MakeDraftFromContent extends Event
|
class MakeDraftFromContent extends Event
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class PublishContent extends Event
|
class PublishContent extends Event
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Models\Widgets\Widget;
|
use App\Models\Widget;
|
||||||
use App\Models\Widgets\WidgetArea;
|
use App\Models\WidgetArea;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class RemoveWidgetFromArea extends Event
|
class RemoveWidgetFromArea extends Event
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use App\Events\Event;
|
use App\Events\Event;
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use App\CMS\Exceptions\Validation\ValidationFailedException;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
|
||||||
use Illuminate\Session\TokenMismatchException;
|
use Illuminate\Session\TokenMismatchException;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
@@ -30,8 +29,7 @@ class Handler extends ExceptionHandler
|
|||||||
*
|
*
|
||||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||||
*
|
*
|
||||||
* @param \Exception $e
|
* @param \Exception $e
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function report(Exception $e)
|
public function report(Exception $e)
|
||||||
@@ -42,21 +40,15 @@ class Handler extends ExceptionHandler
|
|||||||
/**
|
/**
|
||||||
* Render an exception into an HTTP response.
|
* Render an exception into an HTTP response.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Exception $e
|
* @param \Exception $e
|
||||||
*
|
* @return \Illuminate\Http\Response
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function render($request, Exception $e)
|
public function render($request, Exception $e)
|
||||||
{
|
{
|
||||||
if ($e instanceof TokenMismatchException) {
|
if ($e instanceof TokenMismatchException){
|
||||||
//redirect to form an example of how I handle mine
|
//redirect to form an example of how I handle mine
|
||||||
return redirect($request->fullUrl())->with('error', trans('validation.csrf'));
|
return redirect($request->fullUrl())->with('error', trans('validation.csrf'));
|
||||||
} elseif ($e instanceof ValidationFailedException) {
|
|
||||||
return redirect()
|
|
||||||
->back()
|
|
||||||
->withInput()
|
|
||||||
->withErrors($e->getValidator());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::render($request, $e);
|
return parent::render($request, $e);
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers;
|
namespace App\Handlers;
|
||||||
|
|
||||||
use App\CMS\Contracts\Modules\BaseModuleHandler;
|
use App\Enumerations\TemplatePathsHumanReadableRootOnly;
|
||||||
use App\CMS\Enumerations\TemplatePathsHumanReadableRootOnly;
|
use App\Enumerations\WidgetTypes;
|
||||||
use App\CMS\Enumerations\WidgetTypes;
|
use App\Handlers\Contracts\AppHandler;
|
||||||
|
use App\Handlers\Contracts\BaseModuleHandler;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
abstract class BaseHandler implements BaseModuleHandler
|
abstract class BaseHandler implements BaseModuleHandler
|
||||||
@@ -34,6 +35,7 @@ abstract class BaseHandler implements BaseModuleHandler
|
|||||||
* Submenus can be registered later
|
* Submenus can be registered later
|
||||||
*/
|
*/
|
||||||
$menu->dropdown(trans('admin/mainMenu.contentPages'), function ($sub) {
|
$menu->dropdown(trans('admin/mainMenu.contentPages'), function ($sub) {
|
||||||
|
$sub->addDivider(9999);
|
||||||
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 10000, ['icon' => 'fa fa-fw fa-list']);
|
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 10000, ['icon' => 'fa fa-fw fa-list']);
|
||||||
}, 20, ['icon' => 'fa fa-fw fa-database']);
|
}, 20, ['icon' => 'fa fa-fw fa-database']);
|
||||||
|
|
||||||
@@ -95,11 +97,22 @@ abstract class BaseHandler implements BaseModuleHandler
|
|||||||
}, 60, ['icon' => 'fa fa-fw fa-file-code-o']);
|
}, 60, ['icon' => 'fa fa-fw fa-file-code-o']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// $menu->dropdown(trans('admin/mainMenu.customFields'), function ($sub) {
|
||||||
|
// $sub->route('customfields.new', trans('admin/mainMenu.customFieldsNew'), [], 10, ['icon' => 'fa fa-fw fa-code']);
|
||||||
|
// $sub->route('customfields.overview', trans('admin/mainMenu.customFieldsOverview'), [], 50, ['icon' => 'fa fa-fw fa-code-fork']);
|
||||||
|
// }, 30, ['icon' => 'fa fa-fw fa-code']);
|
||||||
|
|
||||||
$sub->route('log.overview', trans('admin/mainMenu.actionLog'), [], 70, ['icon' => 'fa fa-fw fa-history']);
|
$sub->route('log.overview', trans('admin/mainMenu.actionLog'), [], 70, ['icon' => 'fa fa-fw fa-history']);
|
||||||
$sub->route('settings.overview', trans('admin/mainMenu.settings'), [], 80, ['icon' => 'fa fa-fw fa-gear']);
|
$sub->route('settings.overview', trans('admin/mainMenu.settings'), [], 80, ['icon' => 'fa fa-fw fa-gear']);
|
||||||
}, 10000, ['icon' => 'fa fa-fw fa-gears']);
|
}, 10000, ['icon' => 'fa fa-fw fa-gears']);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// order
|
||||||
|
|
||||||
// create menu with user profile
|
// create menu with user profile
|
||||||
\Menu::create('profileMenu', function ($menu) {
|
\Menu::create('profileMenu', function ($menu) {
|
||||||
$menu->route('users.detail', trans('admin/userManagement.profile'), [], 10, ['icon' => 'fa fa-fw fa-user icon']);
|
$menu->route('users.detail', trans('admin/userManagement.profile'), [], 10, ['icon' => 'fa fa-fw fa-user icon']);
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Contracts\Modules;
|
namespace App\Handlers\Contracts;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
|
|
||||||
interface AppHandler extends BaseModuleHandler
|
interface AppHandler extends BaseModuleHandler
|
||||||
{
|
{
|
||||||
@@ -18,6 +18,51 @@ interface AppHandler extends BaseModuleHandler
|
|||||||
|
|
||||||
public static function getHistoryHandler();
|
public static function getHistoryHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load some extra data for content management form?
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function loadExtraData(Content $content);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save module-specific values into database
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @internal param Widget $widget
|
||||||
|
*/
|
||||||
|
public static function createNew(Content &$content, Request $request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method used for editing existing content page.
|
||||||
|
*
|
||||||
|
* Reason why it is separated from createNew() method is simple - we need to save history of changes.
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @param $revisionID string ID of revision used
|
||||||
|
*
|
||||||
|
* @return int number of edited fields
|
||||||
|
*/
|
||||||
|
public static function edit(Content &$content, Request $request, $revisionID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called right after content page is marked as deleted
|
||||||
|
*
|
||||||
|
* This method is supposed to clean after "deleted" page.
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function delete(Content $content);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for section names in creating/editing content resource
|
* Getter for section names in creating/editing content resource
|
||||||
*
|
*
|
||||||
+8
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Contracts\Modules;
|
namespace App\Handlers\Contracts;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -15,4 +15,11 @@ interface BaseModuleHandler
|
|||||||
*/
|
*/
|
||||||
public static function registerAdminMenu(User $user);
|
public static function registerAdminMenu(User $user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install module.
|
||||||
|
*
|
||||||
|
* This method is called after inserting info about module into database. It can be called only using Artisan in
|
||||||
|
* CLI.
|
||||||
|
*/
|
||||||
|
public static function install();
|
||||||
}
|
}
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Contracts\Content;
|
namespace App\Handlers\Contracts;
|
||||||
|
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface ContentTitles
|
* Interface ContentTitles
|
||||||
@@ -9,7 +9,7 @@ use App\Models\Content\Content;
|
|||||||
* Classes which implement this interface get the ability to rewrite default text on edit/create/overview of content
|
* Classes which implement this interface get the ability to rewrite default text on edit/create/overview of content
|
||||||
* page.
|
* page.
|
||||||
*
|
*
|
||||||
* @package App\CMS\Handlers\Contracts
|
* @package App\Handlers\Contracts
|
||||||
*/
|
*/
|
||||||
interface ContentTitles
|
interface ContentTitles
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Contracts;
|
namespace App\Handlers\Contracts;
|
||||||
|
|
||||||
interface HistoryHandler
|
interface HistoryHandler
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Contracts;
|
namespace App\Handlers\Contracts;
|
||||||
|
|
||||||
interface SearchHandler {
|
interface SearchHandler {
|
||||||
public function getId();
|
public function getId();
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Contracts;
|
namespace App\Handlers\Contracts;
|
||||||
|
|
||||||
interface SearchPresenterHandler
|
interface SearchPresenterHandler
|
||||||
{
|
{
|
||||||
+15
-5
@@ -1,18 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Contracts\Modules;
|
namespace App\Handlers\Contracts;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
|
use App\Models\Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface TemplateHandler
|
* Interface TemplateHandler
|
||||||
*
|
*
|
||||||
* Inerface used for registering template into CMS core.
|
* Inerface used for registering template into CMS core.
|
||||||
*
|
*
|
||||||
* @package App\CMS\Handlers\Contracts
|
* @package App\Handlers\Contracts
|
||||||
*/
|
*/
|
||||||
interface TemplateHandler extends BaseModuleHandler
|
interface TemplateHandler extends BaseModuleHandler
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Uninstall template
|
||||||
|
*
|
||||||
|
* Delete some items in database, delete files etc.
|
||||||
|
*
|
||||||
|
* @param Module $template
|
||||||
|
*/
|
||||||
|
public static function uninstall(Module $template);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of registered templates and supported modules.
|
* Get list of registered templates and supported modules.
|
||||||
*
|
*
|
||||||
@@ -48,7 +58,7 @@ interface TemplateHandler extends BaseModuleHandler
|
|||||||
* This way we can do almost whatever we want - even in template
|
* This way we can do almost whatever we want - even in template
|
||||||
*
|
*
|
||||||
* @param Content $content
|
* @param Content $content
|
||||||
* @param $request
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
public static function beforeSave(Content & $content, $request);
|
public static function beforeSave(Content & $content, Request $request);
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers;
|
namespace App\Handlers;
|
||||||
|
|
||||||
use App\CMS\Contracts\Modules\AppHandler;
|
use App\Handlers\Contracts\AppHandler;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Content\Content;
|
use App\Models\Content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Handler
|
* Class Handler
|
||||||
@@ -11,10 +11,20 @@ use App\Models\Content\Content;
|
|||||||
* Handler is a class which handles module-specific behaviour which cannot be done by module itself, resp. cannot be
|
* Handler is a class which handles module-specific behaviour which cannot be done by module itself, resp. cannot be
|
||||||
* done by some abstract magic.
|
* done by some abstract magic.
|
||||||
*
|
*
|
||||||
* @package App\CMS\Handlers\
|
* @package App\Handlers
|
||||||
*/
|
*/
|
||||||
abstract class Handler extends BaseHandler implements AppHandler
|
abstract class Handler extends BaseHandler implements AppHandler
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* todo: Temporary method, will be implemented for each Handler
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function supportCategories()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getHistoryHandler()
|
public static function getHistoryHandler()
|
||||||
{
|
{
|
||||||
return History::class;
|
return History::class;
|
||||||
@@ -54,7 +64,16 @@ abstract class Handler extends BaseHandler implements AppHandler
|
|||||||
'files' => 'admin.content.formParts.files'
|
'files' => 'admin.content.formParts.files'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function delete(Content $content)
|
||||||
|
{
|
||||||
|
// temporarily nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadExtraData(Content $content) {
|
||||||
|
// temporarily nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
public static function getExtendedFormInputsEdit()
|
public static function getExtendedFormInputsEdit()
|
||||||
{
|
{
|
||||||
return self::getExtendedFormInputsCreate();
|
return self::getExtendedFormInputsCreate();
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers;
|
namespace App\Handlers;
|
||||||
|
|
||||||
use App\CMS\Enumerations\ContentStatuses;
|
use App\Enumerations\ContentStatuses;
|
||||||
use App\CMS\Handlers\Contracts\HistoryHandler;
|
use App\Handlers\Contracts\HistoryHandler;
|
||||||
use App\CMS\Helpers\Differ;
|
use App\Helpers\Differ;
|
||||||
|
|
||||||
class History implements HistoryHandler
|
class History implements HistoryHandler
|
||||||
{
|
{
|
||||||
@@ -43,7 +43,7 @@ class History implements HistoryHandler
|
|||||||
'to' => $statuses[$changeset->new_value]
|
'to' => $statuses[$changeset->new_value]
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
case 'isHomepage':
|
case 'is_homepage':
|
||||||
return trans('admin/history.setupAsHomepage');
|
return trans('admin/history.setupAsHomepage');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Registrators\Items;
|
namespace App\Handlers\Registrators\Items;
|
||||||
|
|
||||||
class SettingExtension
|
class SettingExtension
|
||||||
{
|
{
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Registrators;
|
namespace App\Handlers\Registrators;
|
||||||
|
|
||||||
use App\CMS\Widgets\Contracts\MenuExtensionHandler;
|
use App\Widgets\Contracts\MenuExtensionHandler;
|
||||||
|
|
||||||
class MenuExtensionRegistrator {
|
class MenuExtensionRegistrator {
|
||||||
|
|
||||||
+5
-5
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Registrators;
|
namespace App\Handlers\Registrators;
|
||||||
|
|
||||||
use App\CMS\Enumerations\Exceptions\EnumerationExistsException;
|
use App\Enumerations\Exceptions\EnumerationExistsException;
|
||||||
use App\CMS\Handlers\Contracts\SearchHandler;
|
use App\Handlers\Contracts\SearchHandler;
|
||||||
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
use App\Handlers\Contracts\SearchPresenterHandler;
|
||||||
use App\CMS\Handlers\Registrators\Items\SearchEngine;
|
use App\Handlers\Registrators\Items\SearchEngine;
|
||||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
class SearchEngineRegistrator
|
class SearchEngineRegistrator
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Registrators;
|
namespace App\Handlers\Registrators;
|
||||||
|
|
||||||
use App\CMS\Enumerations\Exceptions\EnumerationExistsException;
|
use App\Enumerations\Exceptions\EnumerationExistsException;
|
||||||
use App\CMS\Handlers\Registrators\Items\SettingExtension;
|
use App\Handlers\Registrators\Items\SettingExtension;
|
||||||
|
|
||||||
class SettingsExtensionRegistrator
|
class SettingsExtensionRegistrator
|
||||||
{
|
{
|
||||||
+12
-25
@@ -1,11 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Registrators;
|
namespace App\Handlers\Registrators;
|
||||||
|
|
||||||
use App\CMS\Contracts\Repositories\Template;
|
use App\Enumerations\TemplatePaths;
|
||||||
use App\CMS\Enumerations\TemplatePaths;
|
use App\Enumerations\Templates;
|
||||||
use App\CMS\Enumerations\Templates;
|
use App\Models\Template;
|
||||||
use App\Models\Templates\Template as TemplateModel;
|
use App\Models\TemplatePath;
|
||||||
use App\Models\Templates\TemplatePath;
|
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
@@ -135,10 +134,7 @@ class TemplateRegistrator
|
|||||||
*/
|
*/
|
||||||
protected function relativePath($directory)
|
protected function relativePath($directory)
|
||||||
{
|
{
|
||||||
$directory = str_replace('/', DIRECTORY_SEPARATOR, $directory);
|
return trim(str_replace(base_path(), '', $directory), '/');
|
||||||
$directory = str_replace('\\', DIRECTORY_SEPARATOR, $directory);
|
|
||||||
|
|
||||||
return trim(str_replace(base_path(), '', $directory), '\\/');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,10 +145,6 @@ class TemplateRegistrator
|
|||||||
*/
|
*/
|
||||||
protected function scanForSubdirectories($directory, $name)
|
protected function scanForSubdirectories($directory, $name)
|
||||||
{
|
{
|
||||||
if (!is_dir($directory)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$directories = File::directories($directory);
|
$directories = File::directories($directory);
|
||||||
|
|
||||||
foreach ($directories as $dir) {
|
foreach ($directories as $dir) {
|
||||||
@@ -202,7 +194,7 @@ class TemplateRegistrator
|
|||||||
* @param $path
|
* @param $path
|
||||||
* @param $templatePathId
|
* @param $templatePathId
|
||||||
*
|
*
|
||||||
* @throws \App\CMS\Enumerations\Exceptions\EnumerationExistsException
|
* @throws \App\Enumerations\Exceptions\EnumerationExistsException
|
||||||
*/
|
*/
|
||||||
protected function registerTemplates($path, $templatePathId)
|
protected function registerTemplates($path, $templatePathId)
|
||||||
{
|
{
|
||||||
@@ -230,7 +222,7 @@ class TemplateRegistrator
|
|||||||
];
|
];
|
||||||
|
|
||||||
// save template into database
|
// save template into database
|
||||||
$newTemplate = TemplateModel::create($params);
|
$newTemplate = Template::create($params);
|
||||||
|
|
||||||
// push template into enumeration - so it will not be registered again
|
// push template into enumeration - so it will not be registered again
|
||||||
Templates::push($newTemplate->id, $templateName);
|
Templates::push($newTemplate->id, $templateName);
|
||||||
@@ -246,7 +238,7 @@ class TemplateRegistrator
|
|||||||
* @param null $parent
|
* @param null $parent
|
||||||
*
|
*
|
||||||
* @return mixed|null
|
* @return mixed|null
|
||||||
* @throws \App\CMS\Enumerations\Exceptions\EnumerationExistsException
|
* @throws \App\Enumerations\Exceptions\EnumerationExistsException
|
||||||
*/
|
*/
|
||||||
protected function saveTemplatePath($path, $name, $parent = null)
|
protected function saveTemplatePath($path, $name, $parent = null)
|
||||||
{
|
{
|
||||||
@@ -303,17 +295,12 @@ class TemplateRegistrator
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getTemplateName($template)
|
private function getTemplateName($template)
|
||||||
{
|
{
|
||||||
$templateName = $template;
|
$templateName = str_replace($this->registeredPath . DIRECTORY_SEPARATOR, '', $template);
|
||||||
|
|
||||||
$templateName = str_replace($this->registeredPath, '', $templateName);
|
|
||||||
$templateName = str_replace('\\', DIRECTORY_SEPARATOR, $templateName);
|
|
||||||
$templateName = str_replace('/', DIRECTORY_SEPARATOR, $templateName);
|
|
||||||
$templateName = str_replace(DIRECTORY_SEPARATOR, '.', $templateName);
|
$templateName = str_replace(DIRECTORY_SEPARATOR, '.', $templateName);
|
||||||
$templateName = str_replace(Template::TEMPLATE_SUFFIX, '', $templateName);
|
$templateName = str_replace(Template::TEMPLATE_SUFFIX, '', $templateName);
|
||||||
$templateName = preg_replace('/\.{2,}/', '.', $templateName);
|
|
||||||
|
|
||||||
return $this->namespace . trim($templateName, '.');
|
return $this->namespace . $templateName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-6
@@ -1,13 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Registrators;
|
namespace App\Handlers\Registrators;
|
||||||
|
|
||||||
use App\CMS\Enumerations\WidgetTypesWithHandlers;
|
use App\Enumerations\WidgetTypesWithHandlers;
|
||||||
use App\Models\Widgets\WidgetType;
|
use App\Models\WidgetType;
|
||||||
|
|
||||||
class WidgetRegistrator
|
class WidgetRegistrator
|
||||||
{
|
{
|
||||||
protected $registeredWidgets = [];
|
protected $registeredWidgets = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used for registering new widgets
|
* Method used for registering new widgets
|
||||||
*
|
*
|
||||||
@@ -50,9 +51,7 @@ class WidgetRegistrator
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// install widget (if neccessary)
|
// install widget (if neccessary)
|
||||||
if (is_callable([$classname, 'install'])) {
|
call_user_func($classname . '::install');
|
||||||
call_user_func($classname . '::install');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Search;
|
namespace App\Handlers\Search;
|
||||||
|
|
||||||
use App\Models\Content\Content as ContentModel;
|
use App\Models\Content as ContentModel;
|
||||||
|
|
||||||
class Content extends Search
|
class Content extends Search
|
||||||
{
|
{
|
||||||
@@ -16,9 +16,9 @@ class Content extends Search
|
|||||||
{
|
{
|
||||||
$token = $this->tokenize($term);
|
$token = $this->tokenize($term);
|
||||||
|
|
||||||
return ContentModel::where('pageContent', 'LIKE', $token)
|
return ContentModel::where('content', 'LIKE', $token)
|
||||||
->orWhere('metaDescription', 'LIKE', $token)
|
->orWhere('meta_description', 'LIKE', $token)
|
||||||
->orWhere('metaKeywords', 'LIKE', $token)
|
->orWhere('meta_keywords', 'LIKE', $token)
|
||||||
->orWhere('title', 'LIKE', $token)
|
->orWhere('title', 'LIKE', $token)
|
||||||
->orWhere('url', 'LIKE', $token)
|
->orWhere('url', 'LIKE', $token)
|
||||||
->get();
|
->get();
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Search;
|
namespace App\Handlers\Search;
|
||||||
|
|
||||||
use App\Models\FileManager\File;
|
use App\Models\File;
|
||||||
|
|
||||||
class Files extends Search
|
class Files extends Search
|
||||||
{
|
{
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Search\Presenters;
|
namespace App\Handlers\Search\Presenters;
|
||||||
|
|
||||||
use App\CMS\Enumerations\ContentStatuses;
|
use App\Enumerations\ContentStatuses;
|
||||||
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
use App\Handlers\Contracts\SearchPresenterHandler;
|
||||||
|
|
||||||
class AdminContent implements SearchPresenterHandler
|
class AdminContent implements SearchPresenterHandler
|
||||||
{
|
{
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Search\Presenters;
|
namespace App\Handlers\Search\Presenters;
|
||||||
|
|
||||||
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
use App\Handlers\Contracts\SearchPresenterHandler;
|
||||||
|
|
||||||
class AdminFiles implements SearchPresenterHandler
|
class AdminFiles implements SearchPresenterHandler
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Handlers\Search;
|
namespace App\Handlers\Search;
|
||||||
|
|
||||||
use App\CMS\Handlers\Contracts\SearchHandler;
|
use App\Handlers\Contracts\SearchHandler;
|
||||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
abstract class Search implements SearchHandler
|
abstract class Search implements SearchHandler
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use App\Models\Module;
|
||||||
|
use DebugBar\Bridge\MonologCollector;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Monolog\Logger;
|
||||||
|
|
||||||
|
class CurrentTemplate
|
||||||
|
{
|
||||||
|
protected static $template;
|
||||||
|
protected static $initialized = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for currently set template
|
||||||
|
* @return Module
|
||||||
|
* @throws \ErrorException
|
||||||
|
*/
|
||||||
|
public static function get()
|
||||||
|
{
|
||||||
|
if (!self::$initialized) {
|
||||||
|
try {
|
||||||
|
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::$initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$template;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for getting template handler
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws \ErrorException
|
||||||
|
*/
|
||||||
|
public static function handler()
|
||||||
|
{
|
||||||
|
$template = self::get();
|
||||||
|
|
||||||
|
if (!$template) {
|
||||||
|
throw new \ErrorException('No template selected, no handler available!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template->handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset currently set template and load another one on next call of get() method.
|
||||||
|
*/
|
||||||
|
public static function reset()
|
||||||
|
{
|
||||||
|
self::$initialized = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
class Date
|
class Date
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Paul's Simple Differ Algorithm v 0.1
|
Paul's Simple Differ Algorithm v 0.1
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\CMS\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
use App\Models\FileManager\File;
|
use App\Models\File;
|
||||||
|
|
||||||
class FileManager
|
class FileManager
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ class FileManager
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'image':
|
case 'image':
|
||||||
|
|
||||||
$url = Path::thumbnail($file->filename);
|
$url = Template::thumbnail($file->filename);
|
||||||
|
|
||||||
return '<img src="' . $url . '" alt="' . $file->description . '" />';
|
return '<img src="' . $url . '" alt="' . $file->description . '" />';
|
||||||
break;
|
break;
|
||||||
@@ -98,7 +98,7 @@ class FileManager
|
|||||||
return $string;
|
return $string;
|
||||||
break;
|
break;
|
||||||
case 'application':
|
case 'application':
|
||||||
return '<iframe src = "'.asset('resources/assets/admin/js/viewerJs/').'/#'.Path::upload($file->filename).'" style="width: 100%; height: 50em" allowfullscreen webkitallowfullscreen></iframe>';
|
return '<iframe src = "'.asset('resources/assets/admin/js/viewerJs/').'/#'.Template::upload($file->filename).'" style="width: 100%; height: 50em" allowfullscreen webkitallowfullscreen></iframe>';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return self::getPreview($file);
|
return self::getPreview($file);
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user