Compare commits
202
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1ca6e4cfb | ||
|
|
c69bd9bcf7 | ||
|
|
271e7f5170 | ||
|
|
1ecef555ef | ||
|
|
4ef5e3e3cd | ||
|
|
1388383bb6 | ||
|
|
f1ff45cfb1 | ||
|
|
6d723f026d | ||
|
|
b99f70c269 | ||
|
|
680edb14c1 | ||
|
|
ced920505a | ||
|
|
a1c4a19a59 | ||
|
|
62f73c51e6 | ||
|
|
ba55702585 | ||
|
|
4d68156a73 | ||
|
|
f10847dede | ||
|
|
73681a5a4d | ||
|
|
a2d83ce3fa | ||
|
|
a0c31c7a5f | ||
|
|
422339b313 | ||
|
|
3fdae2669b | ||
|
|
d90ca08ba6 | ||
|
|
e8cbc1b537 | ||
|
|
983efad9f0 | ||
|
|
2d66cf672a | ||
|
|
a5b6f6fa0d | ||
|
|
c92ba41def | ||
|
|
6468c8f49c | ||
|
|
8bae8a43f9 | ||
|
|
0e535c3ed1 | ||
|
|
ce183d4805 | ||
|
|
8946ef7441 | ||
|
|
295e8927a9 | ||
|
|
029d84fed1 | ||
|
|
862f49771f | ||
|
|
5abd7d9151 | ||
|
|
ac8e3aeacc | ||
|
|
49bd38db50 | ||
|
|
b35149ad67 | ||
|
|
e0f5cba9a4 | ||
|
|
0aaa626124 | ||
|
|
1050271915 | ||
|
|
e0b5559b96 | ||
|
|
3955d7290f | ||
|
|
81ef15b8d6 | ||
|
|
f06d9b35d8 | ||
|
|
c4c328d21d | ||
|
|
fc8b76960a | ||
|
|
b2e99bef05 | ||
|
|
7d847cbab9 | ||
|
|
ef432702b4 | ||
|
|
7f43316602 | ||
|
|
335ec4a167 | ||
|
|
cccdbda543 | ||
|
|
f702ba3a29 | ||
|
|
6af0c16a9a | ||
|
|
c2209538db | ||
|
|
25d9ded124 | ||
|
|
3a1e4b9c5b | ||
|
|
3d73bffa6e | ||
|
|
a4c020daa0 | ||
|
|
67fb3c6945 | ||
|
|
e8065c99c7 | ||
|
|
e5d9ce682d | ||
|
|
7a38f357dc | ||
|
|
8c15a63c2a | ||
|
|
c2502a2355 | ||
|
|
2d60010f9e | ||
|
|
3275e5aeed | ||
|
|
a7e91ef499 | ||
|
|
638f6ef134 | ||
|
|
e9e9f0976c | ||
|
|
5707750f5b | ||
|
|
72c64dc6d1 | ||
|
|
f876a08429 | ||
|
|
f48c0cfac3 | ||
|
|
e262473f36 | ||
|
|
4a5c9ab1e6 | ||
|
|
e41c589225 | ||
|
|
870ca540c4 | ||
|
|
7d6a3737e3 | ||
|
|
aa55ffe46a | ||
|
|
848fa7b7cb | ||
|
|
2e8f8dca1f | ||
|
|
8167b151d5 | ||
|
|
05c9e56973 | ||
|
|
52e02d67c6 | ||
|
|
ad8a6e3c61 | ||
|
|
74f1501af6 | ||
|
|
217d78f214 | ||
|
|
16532faa5b | ||
|
|
ead55a8165 | ||
|
|
e943120dc6 | ||
|
|
dd978c05f7 | ||
|
|
348883603a | ||
|
|
5de8e01d77 | ||
|
|
5d623a1a62 | ||
|
|
69253693ce | ||
|
|
42066d4ae9 | ||
|
|
52f39fda0c | ||
|
|
9cb4deecd4 | ||
|
|
fcd7651841 | ||
|
|
09daba1dc1 | ||
|
|
66e5d649be | ||
|
|
78532a6832 | ||
|
|
1f633c3281 | ||
|
|
8658ea1d39 | ||
|
|
ce58b325c8 | ||
|
|
ed8e2565ff | ||
|
|
87af6a018c | ||
|
|
0e2aecb529 | ||
|
|
9bec808d38 | ||
|
|
55f9c0a679 | ||
|
|
03ce64a731 | ||
|
|
450000fadd | ||
|
|
44fb6b1be5 | ||
|
|
09c87661d3 | ||
|
|
0007425c86 | ||
|
|
2a15f3eab5 | ||
|
|
57f9c21a43 | ||
|
|
eff61a1481 | ||
|
|
9c90e844b0 | ||
|
|
d99c046103 | ||
|
|
4128fcf88e | ||
|
|
4353345b3e | ||
|
|
455b9d6d4e | ||
|
|
77685b491e | ||
|
|
f90df0f4bc | ||
|
|
93fc9316a4 | ||
|
|
26854b7207 | ||
|
|
8db748089b | ||
|
|
507e186713 | ||
|
|
c027ffe2df | ||
|
|
5132278ee1 | ||
|
|
c64f825886 | ||
|
|
f3b1951d25 | ||
|
|
cad205960d | ||
|
|
73e049e47d | ||
|
|
0ae3e4fe08 | ||
|
|
28addf5e33 | ||
|
|
d5a33b382e | ||
|
|
2fdec0a65f | ||
|
|
6fb6aef199 | ||
|
|
f69b8f39ad | ||
|
|
35bda2828c | ||
|
|
bda659b910 | ||
|
|
c8ec9c4eeb | ||
|
|
9451357e02 | ||
|
|
727e449ebc | ||
|
|
b5425423d6 | ||
|
|
66e78aff6a | ||
|
|
497ff1b96d | ||
|
|
c429024a54 | ||
|
|
0778a1d30c | ||
|
|
3748d00c2f | ||
|
|
a525d9c085 | ||
|
|
dff8dcf565 | ||
|
|
0d22a14604 | ||
|
|
724478d0c9 | ||
|
|
0ba0d1c15d | ||
|
|
9593b6502e | ||
|
|
e53283da65 | ||
|
|
f0d1cb8020 | ||
|
|
9076f81185 | ||
|
|
b7d4ab9515 | ||
|
|
2b98c60d2a | ||
|
|
99ed8806da | ||
|
|
d0fbce13fb | ||
|
|
675aec669b | ||
|
|
ca718a5efe | ||
|
|
3aabb8fa7b | ||
|
|
2fffea39fa | ||
|
|
7584491ff5 | ||
|
|
84b2902613 | ||
|
|
2d6be0cb2e | ||
|
|
e6c02617e6 | ||
|
|
0b56b41c3c | ||
|
|
f89e11b5fb | ||
|
|
785168ecc2 | ||
|
|
9f430cee11 | ||
|
|
785387b796 | ||
|
|
f940930c66 | ||
|
|
8cb06bf641 | ||
|
|
000352052d | ||
|
|
988f153d9f | ||
|
|
6dd452317b | ||
|
|
34feaac2ac | ||
|
|
e25f47a511 | ||
|
|
cc999dd24e | ||
|
|
28f67ffe3c | ||
|
|
4f6a006ad9 | ||
|
|
662700b4f2 | ||
|
|
eabbf48ee0 | ||
|
|
6ec692bd1c | ||
|
|
aa0ef7ccc6 | ||
|
|
e26e6fd460 | ||
|
|
2ded2924a1 | ||
|
|
87f1920373 | ||
|
|
b7f911c9b8 | ||
|
|
84aea5c847 | ||
|
|
98fc287f10 | ||
|
|
686edf1c6f |
+1
-1
@@ -16,4 +16,4 @@ MAIL_PASSWORD=
|
|||||||
|
|
||||||
SITE_URL=/
|
SITE_URL=/
|
||||||
UPLOAD_URL=/public/uploads
|
UPLOAD_URL=/public/uploads
|
||||||
THUMBNAILS_URL=/uploads/thumbnails
|
THUMBNAIL_URL=/public/uploads/thumbnails
|
||||||
+10
-3
@@ -1,3 +1,6 @@
|
|||||||
|
/modules
|
||||||
|
/templates
|
||||||
|
|
||||||
# published files from modules
|
# published files from modules
|
||||||
/public/modules
|
/public/modules
|
||||||
/public/assets
|
/public/assets
|
||||||
@@ -9,9 +12,6 @@
|
|||||||
**/views/**/custom/*
|
**/views/**/custom/*
|
||||||
!**/views/**/custom/.gitkeep
|
!**/views/**/custom/.gitkeep
|
||||||
|
|
||||||
# module config - generated in ModuleManager service provider
|
|
||||||
**/module.json
|
|
||||||
|
|
||||||
# uploaded files
|
# uploaded files
|
||||||
/public/uploads/*
|
/public/uploads/*
|
||||||
!/public/uploads/.gitkeep
|
!/public/uploads/.gitkeep
|
||||||
@@ -27,3 +27,10 @@
|
|||||||
|
|
||||||
# meta information created by installer
|
# meta information created by installer
|
||||||
.install
|
.install
|
||||||
|
/node_modules/
|
||||||
|
/public/css/
|
||||||
|
/public/js
|
||||||
|
/public/fonts
|
||||||
|
/bower_components
|
||||||
|
.sass-cache
|
||||||
|
!/resources/views/vendor/
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Content;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
interface AdvancedContentModifier {
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Contracts;
|
namespace App\CMS\Contracts\Content;
|
||||||
|
|
||||||
use App\Models\Content;
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface ContentTitles
|
* Interface ContentTitles
|
||||||
@@ -9,7 +9,7 @@ use App\Models\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\Handlers\Contracts
|
* @package App\CMS\Handlers\Contracts
|
||||||
*/
|
*/
|
||||||
interface ContentTitles
|
interface ContentTitles
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Content\DisplayPipeline;
|
||||||
|
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
interface Pipeline {
|
||||||
|
/**
|
||||||
|
* Add new process into pipeline
|
||||||
|
*
|
||||||
|
* @param string $process
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function add($process);
|
||||||
|
function run(Content $page);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Content\DisplayPipeline;
|
||||||
|
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
interface Process {
|
||||||
|
/**
|
||||||
|
* Process and modify given page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function handle(Content & $page);
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Contracts;
|
namespace App\CMS\Handlers\Contracts;
|
||||||
|
|
||||||
interface HistoryHandler
|
interface HistoryHandler
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Content\SavePipeline;
|
||||||
|
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
interface Pipeline {
|
||||||
|
/**
|
||||||
|
* Add new process into pipeline
|
||||||
|
*
|
||||||
|
* @param string $process
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function add($process);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save content page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return Content
|
||||||
|
*/
|
||||||
|
function run(Content & $page, array $input);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Content\SavePipeline;
|
||||||
|
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
interface Process {
|
||||||
|
/**
|
||||||
|
* Process and modify given page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function handle(Content & $page, array & $input);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?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 = []);
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Modules;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
interface AppHandler extends BaseModuleHandler
|
||||||
|
{
|
||||||
|
public static function getHistoryHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for section names in creating/editing content resource
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getExtendedFormSections();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for views used in extended part of form for creating new content
|
||||||
|
*
|
||||||
|
* This method should return pairs <section, view-name>. View is returned only as name in plain text
|
||||||
|
*
|
||||||
|
* @return array of views/templates/html codes divided into section
|
||||||
|
*/
|
||||||
|
public static function getExtendedFormInputsCreate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for extended part of form for editing existing content
|
||||||
|
*
|
||||||
|
* Basically, this method may be
|
||||||
|
*
|
||||||
|
* @return array of views/templates/html codes divided into section
|
||||||
|
*/
|
||||||
|
public static function getExtendedFormInputsEdit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this module support categories?
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function supportCategories();
|
||||||
|
}
|
||||||
+1
-8
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Contracts;
|
namespace App\CMS\Contracts\Modules;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -15,11 +15,4 @@ 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();
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Modules;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface TemplateHandler
|
||||||
|
*
|
||||||
|
* Inerface used for registering template into CMS core.
|
||||||
|
*
|
||||||
|
* @package App\CMS\Handlers\Contracts
|
||||||
|
*/
|
||||||
|
interface TemplateHandler extends BaseModuleHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Repositories;
|
||||||
|
|
||||||
|
interface BaseRepository {
|
||||||
|
public function getOne($id = null);
|
||||||
|
public function all();
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?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 = null);
|
||||||
|
|
||||||
|
public function getByHandler($handler);
|
||||||
|
|
||||||
|
public function call(ModuleModel $module, $method, $parameters = []);
|
||||||
|
|
||||||
|
public function callOnString($moduleHandler, $method, $parameters = []);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?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($mode = null);
|
||||||
|
|
||||||
|
public function getForModule(ModuleModel $module);
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Contracts;
|
namespace App\CMS\Handlers\Contracts;
|
||||||
|
|
||||||
interface SearchHandler {
|
interface SearchHandler {
|
||||||
public function getId();
|
public function getId();
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Contracts;
|
namespace App\CMS\Handlers\Contracts;
|
||||||
|
|
||||||
interface SearchPresenterHandler
|
interface SearchPresenterHandler
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Widgets\Contracts;
|
namespace App\CMS\Contracts\Widgets;
|
||||||
|
|
||||||
interface AdminDashboardWidget extends PublicWidget
|
interface AdminDashboardWidget extends PublicWidget
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?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
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Widgets\Contracts;
|
namespace App\CMS\Widgets\Contracts;
|
||||||
|
|
||||||
interface MenuExtensionHandler {
|
interface MenuExtensionHandler {
|
||||||
|
|
||||||
+6
-17
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Widgets\Contracts;
|
namespace App\CMS\Contracts\Widgets;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\Widget;
|
use App\Models\Widgets\Widget;
|
||||||
|
|
||||||
interface PublicWidget
|
interface PublicWidget
|
||||||
{
|
{
|
||||||
@@ -28,22 +28,11 @@ interface PublicWidget
|
|||||||
public static function getPresenter();
|
public static function getPresenter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Widget $widget
|
* Get widget settings for saving into database
|
||||||
* @param \stdClass $data
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @param Request $request
|
||||||
*/
|
|
||||||
public static function save(Widget $widget, \stdClass $data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function for installing given widget
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function install();
|
public static function save(Request $request);
|
||||||
|
|
||||||
/**
|
|
||||||
* Function for uninstalling widget
|
|
||||||
*/
|
|
||||||
public static function uninstall();
|
|
||||||
}
|
}
|
||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Widgets\Contracts;
|
namespace App\CMS\Contracts\Widgets;
|
||||||
|
|
||||||
use App\Models\Widget;
|
use App\Models\Widgets\Widget;
|
||||||
use App\Models\WidgetType;
|
use App\Models\Widgets\WidgetType;
|
||||||
|
|
||||||
interface WidgetRenderer
|
interface WidgetRenderer
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,7 @@ interface WidgetRenderer
|
|||||||
*
|
*
|
||||||
* This method renders some HTML code for displaying.
|
* This method renders some HTML code for displaying.
|
||||||
*
|
*
|
||||||
* @param object $settings
|
* @param Widget $settings
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\ActionLogType;
|
use App\Models\ActionLogType;
|
||||||
|
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\ActionLogType;
|
use App\Models\ActionLog\ActionLogType;
|
||||||
|
|
||||||
class ActionLogTypesForLogger extends BaseEnumeration
|
class ActionLogTypesForLogger extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Enumerations\Exceptions\EnumerationExistsException;
|
use App\CMS\Exceptions\Enumerations\EnumerationExistsException;
|
||||||
|
|
||||||
abstract class BaseEnumeration
|
abstract class BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\Content;
|
|
||||||
|
use App\CMS\Contracts\Repositories\Content;
|
||||||
|
|
||||||
class ContentStatuses extends BaseEnumeration
|
class ContentStatuses extends BaseEnumeration
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
|
|
||||||
+5
-2
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
class ModulesHandlerToId extends BaseEnumeration
|
class ModulesHandlerToId extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -12,7 +13,9 @@ class ModulesHandlerToId extends BaseEnumeration
|
|||||||
*/
|
*/
|
||||||
protected static function init()
|
protected static function init()
|
||||||
{
|
{
|
||||||
$modules = Module::all(['handler', 'id']);
|
$modules = Cache::rememberForever('module-handler-to-id-enumeration', function () {
|
||||||
|
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\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\TemplatePath;
|
use App\Models\Templates\TemplatePath;
|
||||||
|
|
||||||
class TemplatePaths extends BaseEnumeration
|
class TemplatePaths extends BaseEnumeration
|
||||||
{
|
{
|
||||||
+2
-2
@@ -6,9 +6,9 @@
|
|||||||
* Time: 10:33
|
* Time: 10:33
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\TemplatePath;
|
use App\Models\Templates\TemplatePath;
|
||||||
|
|
||||||
class TemplatePathsHumanReadable extends BaseEnumeration
|
class TemplatePathsHumanReadable extends BaseEnumeration
|
||||||
{
|
{
|
||||||
+2
-2
@@ -6,9 +6,9 @@
|
|||||||
* Time: 10:33
|
* Time: 10:33
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\TemplatePath;
|
use App\Models\Templates\TemplatePath;
|
||||||
|
|
||||||
class TemplatePathsHumanReadableRootOnly extends BaseEnumeration
|
class TemplatePathsHumanReadableRootOnly extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
* Time: 15:50
|
* Time: 15:50
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\Template;
|
use App\Models\Templates\Template;
|
||||||
|
|
||||||
class Templates extends BaseEnumeration
|
class Templates extends BaseEnumeration
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ class UserRoles extends BaseEnumeration
|
|||||||
{
|
{
|
||||||
$roles = [
|
$roles = [
|
||||||
User::ROLE_ADMIN => 'admin/userManagement.role_' . User::ROLE_ADMIN,
|
User::ROLE_ADMIN => 'admin/userManagement.role_' . User::ROLE_ADMIN,
|
||||||
User::ROLE_EDITOR => 'admin/userManagement.role_' . User::ROLE_EDITOR,
|
// User::ROLE_EDITOR => 'admin/userManagement.role_' . User::ROLE_EDITOR,
|
||||||
User::ROLE_VISITOR => 'admin/userManagement.role_' . User::ROLE_VISITOR
|
User::ROLE_VISITOR => 'admin/userManagement.role_' . User::ROLE_VISITOR
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* Time: 23:20
|
* Time: 23:20
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\WidgetType;
|
use App\Models\Widgets\WidgetType;
|
||||||
|
|
||||||
class WidgetTypes extends BaseEnumeration
|
class WidgetTypes extends BaseEnumeration
|
||||||
{
|
{
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\WidgetType;
|
use App\Models\Widgets\WidgetType;
|
||||||
|
|
||||||
class WidgetTypesWithHandlers extends BaseEnumeration
|
class WidgetTypesWithHandlers extends BaseEnumeration
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations\Exceptions;
|
namespace App\CMS\Exceptions\Enumerations;
|
||||||
|
|
||||||
class EnumerationExistsException extends \Exception {
|
class EnumerationExistsException extends \Exception {
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Exceptions\FileManager;
|
||||||
|
|
||||||
|
class SubdirectoryExistsInDirectory extends \Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?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
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Widgets\Exceptions;
|
namespace App\CMS\Widgets\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Widgets\Exceptions;
|
namespace App\CMS\Widgets\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
@@ -1,77 +1,55 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers;
|
|
||||||
|
|
||||||
use App\Handlers\Contracts\AppHandler;
|
namespace App\CMS\Handlers;
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Models\Content;
|
use App\CMS\Contracts\Modules\AppHandler;
|
||||||
|
use App\Models\FileManager\File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Handler
|
* Class Handler
|
||||||
*
|
|
||||||
* 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 AdminHandler 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Render given module into visitor area.
|
|
||||||
*
|
|
||||||
* @param Content $content DB model from table contents
|
|
||||||
* @param array $parameters parameters used for modifications/custom settings of given model
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function render(Content $content, $parameters)
|
|
||||||
{
|
|
||||||
return Controller::VisitorsView($content->template, ['page' => $content, 'extra' => $parameters]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getExtendedFormSections()
|
public static function getExtendedFormSections()
|
||||||
{
|
{
|
||||||
return [
|
$formParts = [
|
||||||
'basicInfo' => trans('admin/contents.basicInfo'),
|
'basicInfo' => trans('admin/contents.basicInfo'),
|
||||||
'meta' => trans('admin/contents.metaOptions'),
|
'meta' => trans('admin/contents.metaOptions'),
|
||||||
'publication' => trans('admin/contents.publicationOptions'),
|
'publication' => trans('admin/contents.publicationOptions'),
|
||||||
'appearance' => trans('admin/contents.appearance'),
|
'appearance' => trans('admin/contents.appearance'),
|
||||||
'files' => trans('admin/contents.files')
|
'files' => trans('admin/contents.files')
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (\Auth::user()->cannot('upload', File::class)) {
|
||||||
|
unset($formParts['files']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $formParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getExtendedFormInputsCreate()
|
public static function getExtendedFormInputsCreate()
|
||||||
{
|
{
|
||||||
return [
|
$formParts = [
|
||||||
'basicInfo' => 'admin.content.formParts.basicInformation',
|
'basicInfo' => 'admin.content.formParts.basicInformation',
|
||||||
'meta' => 'admin.content.formParts.metaInformation',
|
'meta' => 'admin.content.formParts.metaInformation',
|
||||||
'publication' => 'admin.content.formParts.publicationSetup',
|
'publication' => 'admin.content.formParts.publicationSetup',
|
||||||
'appearance' => 'admin.content.formParts.appearance',
|
'appearance' => 'admin.content.formParts.appearance',
|
||||||
'files' => 'admin.content.formParts.files'
|
'files' => 'admin.content.formParts.files'
|
||||||
];
|
];
|
||||||
}
|
|
||||||
|
|
||||||
public static function delete(Content $content)
|
if (\Auth::user()->cannot('upload', File::class)) {
|
||||||
{
|
unset($formParts['files']);
|
||||||
// temporarily nothing to do
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static function loadExtraData(Content $content) {
|
return $formParts;
|
||||||
// temporarily nothing to do
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getExtendedFormInputsEdit()
|
public static function getExtendedFormInputsEdit()
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\CMS\Handlers;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Modules\BaseModuleHandler;
|
||||||
|
use App\CMS\Enumerations\WidgetTypes;
|
||||||
|
use App\CMS\Repositories\Module;
|
||||||
|
use App\Models\ActionLog\ActionLog;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
use App\Models\FileManager\File;
|
||||||
|
use App\Models\Settings;
|
||||||
|
use App\Models\Templates\Template;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Widgets\Widget;
|
||||||
|
use App\Models\Widgets\WidgetArea;
|
||||||
|
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||||
|
|
||||||
|
abstract class BaseHandler implements BaseModuleHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
$menu = \Menu::instance('mainMenu');
|
||||||
|
if (!is_null($menu)) {
|
||||||
|
// menus were already defined
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create instance of main menu
|
||||||
|
\Menu::create('mainMenu', function ($menu) use ($user) {
|
||||||
|
// $menu->route('admin.dashboard', trans('admin/mainMenu.dashboard'), [], 10, ['icon' => 'fa fa-fw fa-dashboard']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content pages
|
||||||
|
* Submenus can be registered later
|
||||||
|
*/
|
||||||
|
$contentModules = app(Module::class)->getContentModules();
|
||||||
|
|
||||||
|
if ($user->can('manage', Content::class) && !$contentModules->isEmpty()) {
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.contentPages'), function ($sub) {
|
||||||
|
$sub->route('content.order', trans('admin/mainMenu.contentOrder'), [], 999, ['icon' => 'fa fa-fw fa-reorder']);
|
||||||
|
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 10000, ['icon' => 'fa fa-fw fa-list']);
|
||||||
|
}, 20, ['icon' => 'fa fa-fw fa-database']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File manager
|
||||||
|
*/
|
||||||
|
if ($user->can('manage', File::class)) {
|
||||||
|
$menu->route('upload.overview', trans('admin/mainMenu.fileManager'), [], 40, ['icon' => 'fa fa-fw fa-folder']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Widgets and widget areas
|
||||||
|
*/
|
||||||
|
if ($user->can('manage', Widget::class) || $user->can('manage', WidgetArea::class)) {
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.widgets'), function ($sub) use ($user) {
|
||||||
|
// create list of all widget types
|
||||||
|
$widgets = WidgetTypes::getWithTranslations();
|
||||||
|
|
||||||
|
if (!empty($widgets) && $user->can('create', Widget::class)) {
|
||||||
|
$sub->dropdown(trans('admin/mainMenu.newWidget'), function ($sub) use ($widgets) {
|
||||||
|
$i = 1;
|
||||||
|
foreach ($widgets as $type => $name) {
|
||||||
|
$sub->route('widgets.new', $name, ['type' => $type], $i++);
|
||||||
|
}
|
||||||
|
}, 10, ['icon' => 'fa fa-fw fa-plus']);
|
||||||
|
}
|
||||||
|
if ($user->can('manage', Widget::class)) {
|
||||||
|
$sub->route('widgets.overview', trans('admin/mainMenu.widgetsOverview'), [], 20, ['icon' => 'fa fa-fw fa-list']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// menu for widget areas
|
||||||
|
if ($user->can('manage', WidgetArea::class)) {
|
||||||
|
$sub->dropdown(trans('admin/mainMenu.widgetAreas'), function ($sub) use ($user) {
|
||||||
|
if ($user->can('create', WidgetArea::class)) {
|
||||||
|
$sub->route('widgetareas.new', trans('admin/mainMenu.newWidgetArea'), [], 1, ['icon' => 'fa fa-fw fa-plus']);
|
||||||
|
}
|
||||||
|
$sub->route('widgetareas.overview', trans('admin/mainMenu.widgetAreaOverview'), [], 2, ['icon' => 'fa fa-fw fa-list']);
|
||||||
|
}, 50, ['icon' => 'fa fa-fw fa-object-group']);
|
||||||
|
}
|
||||||
|
}, 50, ['icon' => 'fa fa-fw fa-puzzle-piece']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Divide system entries and other links in menu
|
||||||
|
*/
|
||||||
|
$menu->addDivider(9999);
|
||||||
|
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.system'), function ($sub) use ($user) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User management
|
||||||
|
*/
|
||||||
|
if ($user->can('manage', User::class)) {
|
||||||
|
$sub->dropdown(trans('admin/mainMenu.userManagement'), function ($sub) use ($user) {
|
||||||
|
if ($user->can('create', User::class)) {
|
||||||
|
$sub->route('users.new', trans('admin/mainMenu.newUser'), [], 10, ['icon' => 'fa fa-fw fa-user-plus']);
|
||||||
|
}
|
||||||
|
$sub->route('users.overview', trans('admin/mainMenu.usersOverview'), [], 30, ['icon' => 'fa fa-fw fa-users']);
|
||||||
|
}, 20, ['icon' => 'fa fa-fw fa-users']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Templates
|
||||||
|
*/
|
||||||
|
if ($user->can('manage', Template::class)) {
|
||||||
|
$sub->route('templates.index', trans('admin/mainMenu.templates'), [], 70, ['icon' => 'fa fa-fw fa-file-code-o']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->can('manage', ActionLog::class)) {
|
||||||
|
$sub->route('log.overview', trans('admin/mainMenu.actionLog'), [], 70, ['icon' => 'fa fa-fw fa-history']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->can('manage', Settings::class)) {
|
||||||
|
$sub->route('settings.overview', trans('admin/mainMenu.settings'), [], 80, ['icon' => 'fa fa-fw fa-gear']);
|
||||||
|
$sub->route('permissions.index', trans('admin/mainMenu.permissions'), [], 90, ['icon' => 'fa fa-fw fa-key']);
|
||||||
|
}
|
||||||
|
}, 10000, ['icon' => 'fa fa-fw fa-gears']);
|
||||||
|
});
|
||||||
|
|
||||||
|
\Menu::create('topMenu', function ($menu) use ($user) {
|
||||||
|
if (count(LaravelLocalization::getSupportedLocales()) > 1) {
|
||||||
|
$menu->dropdown(trans(LaravelLocalization::getCurrentLocaleName()), function ($menu) use ($user) {
|
||||||
|
foreach (LaravelLocalization::getSupportedLocales() as $localeCode => $properties) {
|
||||||
|
$menu->url(LaravelLocalization::getLocalizedURL($localeCode), $properties['native']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->can('manage', Content::class)) {
|
||||||
|
$menu->route('page.index', '', [], 10, [
|
||||||
|
'icon' => 'fa fa-fw fa-globe',
|
||||||
|
'title' => trans('common.goToWeb'),
|
||||||
|
'target' => '_blank',
|
||||||
|
'data-toggle' => 'tooltip',
|
||||||
|
'data-placement' => 'left'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// create menu with user profile
|
||||||
|
\Menu::create('profileMenu', function ($menu) use ($user) {
|
||||||
|
$menu->route('users.detail', trans('admin/userManagement.profile'), ['user' => $user], 10, ['icon' => 'fa fa-fw fa-user icon']);
|
||||||
|
$menu->addDivider(999);
|
||||||
|
$menu->route('logout', trans('admin/common.logout'), [], 1000, ['icon' => 'fa fa-fw fa-power-off icon']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers;
|
namespace App\CMS\Handlers;
|
||||||
|
|
||||||
use App\Enumerations\ContentStatuses;
|
use App\CMS\Enumerations\ContentStatuses;
|
||||||
use App\Handlers\Contracts\HistoryHandler;
|
use App\CMS\Handlers\Contracts\HistoryHandler;
|
||||||
use App\Helpers\Differ;
|
use App\CMS\Helpers\Differ;
|
||||||
|
|
||||||
class History implements HistoryHandler
|
class History implements HistoryHandler
|
||||||
{
|
{
|
||||||
@@ -17,8 +17,7 @@ class History implements HistoryHandler
|
|||||||
switch ($changeset->column) {
|
switch ($changeset->column) {
|
||||||
case 'pageContent':
|
case 'pageContent':
|
||||||
$route = route('history.diff', [
|
$route = route('history.diff', [
|
||||||
'revision' => $changeset->edit_batch,
|
'revision' => $changeset->id
|
||||||
'id' => $changeset->id
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return "(<a href='" . $route . "'>" . trans('admin/history.diff') . "</a>)";
|
return "(<a href='" . $route . "'>" . trans('admin/history.diff') . "</a>)";
|
||||||
@@ -43,13 +42,13 @@ class History implements HistoryHandler
|
|||||||
'to' => $statuses[$changeset->new_value]
|
'to' => $statuses[$changeset->new_value]
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
case 'is_homepage':
|
case 'isHomepage':
|
||||||
return trans('admin/history.setupAsHomepage');
|
return trans('admin/history.setupAsHomepage');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return trans('admin/history.changedFromTo', [
|
return trans('admin/history.changedFromTo', [
|
||||||
'from' => is_null($changeset->old_value) ? trans('admin/history.emptyValue') : $changeset->old_value,
|
'from' => empty($changeset->old_value) ? trans('admin/history.emptyValue') : $changeset->old_value,
|
||||||
'to' => is_null($changeset->new_value) ? trans('admin/history.emptyValue') : $changeset->new_value,
|
'to' => empty($changeset->new_value) ? trans('admin/history.emptyValue') : $changeset->new_value,
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-2
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Registrators\Items;
|
namespace App\CMS\Handlers\Registrators\Items;
|
||||||
|
|
||||||
class SettingExtension
|
class SettingExtension
|
||||||
{
|
{
|
||||||
@@ -15,6 +15,7 @@ class SettingExtension
|
|||||||
* @var string view used for rendering given settings part
|
* @var string view used for rendering given settings part
|
||||||
*/
|
*/
|
||||||
protected $view;
|
protected $view;
|
||||||
|
protected $order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SettingExtension constructor.
|
* SettingExtension constructor.
|
||||||
@@ -23,11 +24,12 @@ class SettingExtension
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $view
|
* @param string $view
|
||||||
*/
|
*/
|
||||||
public function __construct($id, $name, $view)
|
public function __construct($id, $name, $view, $order)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->view = $view;
|
$this->view = $view;
|
||||||
|
$this->order = $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,4 +55,14 @@ class SettingExtension
|
|||||||
{
|
{
|
||||||
return $this->view;
|
return $this->view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getOrder()
|
||||||
|
{
|
||||||
|
return $this->order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Registrators;
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
use App\Widgets\Contracts\MenuExtensionHandler;
|
use App\CMS\Widgets\Contracts\MenuExtensionHandler;
|
||||||
|
|
||||||
class MenuExtensionRegistrator {
|
class MenuExtensionRegistrator {
|
||||||
|
|
||||||
+5
-5
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Registrators;
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
use App\Enumerations\Exceptions\EnumerationExistsException;
|
use App\CMS\Exceptions\Enumerations\EnumerationExistsException;
|
||||||
use App\Handlers\Contracts\SearchHandler;
|
use App\CMS\Handlers\Contracts\SearchHandler;
|
||||||
use App\Handlers\Contracts\SearchPresenterHandler;
|
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
||||||
use App\Handlers\Registrators\Items\SearchEngine;
|
use App\CMS\Handlers\Registrators\Items\SearchEngine;
|
||||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
class SearchEngineRegistrator
|
class SearchEngineRegistrator
|
||||||
+15
-9
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Registrators;
|
|
||||||
|
|
||||||
use App\Enumerations\Exceptions\EnumerationExistsException;
|
namespace App\CMS\Handlers\Registrators;
|
||||||
use App\Handlers\Registrators\Items\SettingExtension;
|
|
||||||
|
use App\CMS\Exceptions\Enumerations\EnumerationExistsException;
|
||||||
|
use App\CMS\Handlers\Registrators\Items\SettingExtension;
|
||||||
|
|
||||||
class SettingsExtensionRegistrator
|
class SettingsExtensionRegistrator
|
||||||
{
|
{
|
||||||
@@ -22,12 +23,16 @@ class SettingsExtensionRegistrator
|
|||||||
*
|
*
|
||||||
* @throws EnumerationExistsException
|
* @throws EnumerationExistsException
|
||||||
*/
|
*/
|
||||||
public function register($sectionId, $sectionName, $sectionView)
|
public function register($sectionId, $sectionName, $sectionView, $order = null)
|
||||||
{
|
{
|
||||||
$this->checkIfRegistered($sectionId);
|
$this->checkIfRegistered($sectionId);
|
||||||
|
|
||||||
|
if (is_null($order)) {
|
||||||
|
$order = count($this->settingsExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
// register new extension
|
// register new extension
|
||||||
$this->settingsExtensions[$sectionId] = new SettingExtension($sectionId, $sectionName, $sectionView);
|
$this->settingsExtensions[$sectionId] = new SettingExtension($sectionId, $sectionName, $sectionView, $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,14 +49,15 @@ class SettingsExtensionRegistrator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for all registered extensions
|
* Getter for all registered extensions
|
||||||
*
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
// sort registered extensions by key
|
// sort registered extensions
|
||||||
ksort($this->settingsExtensions);
|
uasort($this->settingsExtensions, function (SettingExtension $a, SettingExtension $b) {
|
||||||
|
return $a->getOrder() - $b->getOrder();
|
||||||
|
});
|
||||||
|
|
||||||
return $this->settingsExtensions;
|
return $this->settingsExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
+36
-13
@@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Registrators;
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
use App\Enumerations\TemplatePaths;
|
use App\CMS\Contracts\Repositories\Template;
|
||||||
use App\Enumerations\Templates;
|
use App\CMS\Enumerations\TemplatePaths;
|
||||||
use App\Models\Template;
|
use App\CMS\Enumerations\Templates;
|
||||||
use App\Models\TemplatePath;
|
use App\Models\Templates\Template as TemplateModel;
|
||||||
|
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;
|
||||||
@@ -134,7 +135,10 @@ class TemplateRegistrator
|
|||||||
*/
|
*/
|
||||||
protected function relativePath($directory)
|
protected function relativePath($directory)
|
||||||
{
|
{
|
||||||
return trim(str_replace(base_path(), '', $directory), '/');
|
$directory = str_replace('/', DIRECTORY_SEPARATOR, $directory);
|
||||||
|
$directory = str_replace('\\', DIRECTORY_SEPARATOR, $directory);
|
||||||
|
|
||||||
|
return trim(str_replace(base_path(), '', $directory), '\\/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,6 +149,10 @@ 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) {
|
||||||
@@ -194,11 +202,12 @@ class TemplateRegistrator
|
|||||||
* @param $path
|
* @param $path
|
||||||
* @param $templatePathId
|
* @param $templatePathId
|
||||||
*
|
*
|
||||||
* @throws \App\Enumerations\Exceptions\EnumerationExistsException
|
* @throws \App\CMS\Enumerations\Exceptions\EnumerationExistsException
|
||||||
*/
|
*/
|
||||||
protected function registerTemplates($path, $templatePathId)
|
protected function registerTemplates($path, $templatePathId)
|
||||||
{
|
{
|
||||||
$templates = File::files($path);
|
$templates = File::files($path);
|
||||||
|
$registeredTemplates = Templates::getWithTranslations();
|
||||||
|
|
||||||
foreach ($templates as $template) {
|
foreach ($templates as $template) {
|
||||||
|
|
||||||
@@ -209,7 +218,6 @@ class TemplateRegistrator
|
|||||||
|
|
||||||
// get all templates and template name (path/to/template.blade.php -> path.to.template)
|
// get all templates and template name (path/to/template.blade.php -> path.to.template)
|
||||||
$templateName = $this->getTemplateName($template);
|
$templateName = $this->getTemplateName($template);
|
||||||
$registeredTemplates = Templates::getWithTranslations();
|
|
||||||
|
|
||||||
if (!in_array($templateName, $registeredTemplates)) {
|
if (!in_array($templateName, $registeredTemplates)) {
|
||||||
$params = [
|
$params = [
|
||||||
@@ -222,7 +230,7 @@ class TemplateRegistrator
|
|||||||
];
|
];
|
||||||
|
|
||||||
// save template into database
|
// save template into database
|
||||||
$newTemplate = Template::create($params);
|
$newTemplate = TemplateModel::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);
|
||||||
@@ -238,7 +246,7 @@ class TemplateRegistrator
|
|||||||
* @param null $parent
|
* @param null $parent
|
||||||
*
|
*
|
||||||
* @return mixed|null
|
* @return mixed|null
|
||||||
* @throws \App\Enumerations\Exceptions\EnumerationExistsException
|
* @throws \App\CMS\Enumerations\Exceptions\EnumerationExistsException
|
||||||
*/
|
*/
|
||||||
protected function saveTemplatePath($path, $name, $parent = null)
|
protected function saveTemplatePath($path, $name, $parent = null)
|
||||||
{
|
{
|
||||||
@@ -295,12 +303,27 @@ class TemplateRegistrator
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getTemplateName($template)
|
protected function getTemplateName($template)
|
||||||
{
|
{
|
||||||
$templateName = str_replace($this->registeredPath . DIRECTORY_SEPARATOR, '', $template);
|
$templateName = $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 . $templateName;
|
return $this->namespace . trim($templateName, '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteNonExistingPaths()
|
||||||
|
{
|
||||||
|
$paths = TemplatePath::all();
|
||||||
|
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
if (!is_dir(base_path($path->path)))
|
||||||
|
\File::deleteDirectory($path->path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-5
@@ -1,14 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Registrators;
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
use App\Enumerations\WidgetTypesWithHandlers;
|
use App\CMS\Enumerations\WidgetTypesWithHandlers;
|
||||||
use App\Models\WidgetType;
|
use App\Models\Widgets\WidgetType;
|
||||||
|
|
||||||
class WidgetRegistrator
|
class WidgetRegistrator
|
||||||
{
|
{
|
||||||
protected $registeredWidgets = [];
|
protected $registeredWidgets = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used for registering new widgets
|
* Method used for registering new widgets
|
||||||
*
|
*
|
||||||
@@ -51,7 +50,9 @@ class WidgetRegistrator
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// install widget (if neccessary)
|
// install widget (if neccessary)
|
||||||
call_user_func($classname . '::install');
|
if (is_callable([$classname, 'install'])) {
|
||||||
|
call_user_func($classname . '::install');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\CMS\Handlers\Search;
|
||||||
|
|
||||||
|
use App\Models\Content\Content as ContentModel;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class Content extends Search
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Search for given patttern/term
|
||||||
|
*
|
||||||
|
* @param string $term searched word
|
||||||
|
*
|
||||||
|
* @return array|\Illuminate\Database\Eloquent\Collection|Collection|static[]
|
||||||
|
*/
|
||||||
|
public function search($term)
|
||||||
|
{
|
||||||
|
if (Auth::user()
|
||||||
|
->cannot('manage', ContentModel::class)) {
|
||||||
|
return new Collection();
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $this->tokenize($term);
|
||||||
|
|
||||||
|
return ContentModel::where('pageContent', 'LIKE', $token)
|
||||||
|
->orWhere('metaDescription', 'LIKE', $token)
|
||||||
|
->orWhere('metaKeywords', 'LIKE', $token)
|
||||||
|
->orWhere('title', 'LIKE', $token)
|
||||||
|
->orWhere('url', 'LIKE', $token)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return 'content';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return trans('search.content');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Search;
|
|
||||||
|
|
||||||
use App\Models\File;
|
namespace App\CMS\Handlers\Search;
|
||||||
|
|
||||||
|
use App\Models\FileManager\File;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class Files extends Search
|
class Files extends Search
|
||||||
{
|
{
|
||||||
@@ -24,6 +26,11 @@ class Files extends Search
|
|||||||
*/
|
*/
|
||||||
public function search($term)
|
public function search($term)
|
||||||
{
|
{
|
||||||
|
if (\Auth::user()
|
||||||
|
->cannot('manage', File::class)) {
|
||||||
|
return new Collection();
|
||||||
|
}
|
||||||
|
|
||||||
$token = $this->tokenize($term);
|
$token = $this->tokenize($term);
|
||||||
|
|
||||||
return File::where('original_filename', 'LIKE', $token)
|
return File::where('original_filename', 'LIKE', $token)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Search\Presenters;
|
||||||
|
|
||||||
|
use App\CMS\Enumerations\ContentStatuses;
|
||||||
|
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
class AdminContent implements SearchPresenterHandler
|
||||||
|
{
|
||||||
|
public function render($foundItems)
|
||||||
|
{
|
||||||
|
if (\Auth::user()
|
||||||
|
->cannot('manage', Content::class)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.search.results.content', [
|
||||||
|
'pages' => $foundItems,
|
||||||
|
'statuses' => ContentStatuses::getWithTranslations(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-2
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Search\Presenters;
|
namespace App\CMS\Handlers\Search\Presenters;
|
||||||
|
|
||||||
use App\Handlers\Contracts\SearchPresenterHandler;
|
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
||||||
|
use App\Models\FileManager\File;
|
||||||
|
|
||||||
class AdminFiles implements SearchPresenterHandler
|
class AdminFiles implements SearchPresenterHandler
|
||||||
{
|
{
|
||||||
@@ -14,6 +15,11 @@ class AdminFiles implements SearchPresenterHandler
|
|||||||
*/
|
*/
|
||||||
public function render($foundItems)
|
public function render($foundItems)
|
||||||
{
|
{
|
||||||
|
if (\Auth::user()
|
||||||
|
->cannot('manage', File::class)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return view('admin.fileManager.filesTiles', ['files' => $foundItems, 'hideDelete' => true]);
|
return view('admin.fileManager.filesTiles', ['files' => $foundItems, 'hideDelete' => true]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Handlers\Search;
|
namespace App\CMS\Handlers\Search;
|
||||||
|
|
||||||
use App\Handlers\Contracts\SearchHandler;
|
use App\CMS\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,92 @@
|
|||||||
|
<?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 () {
|
||||||
|
return Module::where('is_template', true)
|
||||||
|
->where('enabled', true)
|
||||||
|
->first();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Helpers;
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
class Date
|
class Date
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Helpers;
|
namespace App\CMS\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\Helpers;
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
use App\Models\File;
|
use App\Models\FileManager\File;
|
||||||
|
|
||||||
class FileManager
|
class FileManager
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ class FileManager
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'image':
|
case 'image':
|
||||||
|
|
||||||
$url = Template::thumbnail($file->filename);
|
$url = Path::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/').'/#'.Template::upload($file->filename).'" style="width: 100%; height: 50em" allowfullscreen webkitallowfullscreen></iframe>';
|
return '<iframe src = "'.asset('resources/assets/admin/js/viewerJs/').'/#'.Path::upload($file->filename).'" style="width: 100%; height: 50em" allowfullscreen webkitallowfullscreen></iframe>';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return self::getPreview($file);
|
return self::getPreview($file);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Helpers;
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
class Gravatar
|
class Gravatar
|
||||||
{
|
{
|
||||||
@@ -1,48 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Helpers;
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
class Template
|
class Path
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Getter for real template name
|
|
||||||
*
|
|
||||||
* @param $template
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get URL to uploaded file
|
* Get URL to uploaded file
|
||||||
*
|
*
|
||||||
@@ -95,25 +58,4 @@ class Template
|
|||||||
|
|
||||||
return config('app.url') . '/assets/' . config('app.theme') . '/' . $path;
|
return config('app.url') . '/assets/' . config('app.theme') . '/' . $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Print date in configured format
|
|
||||||
*
|
|
||||||
* @param $datestamp
|
|
||||||
* @param bool $withTime
|
|
||||||
*
|
|
||||||
* @return false|string
|
|
||||||
*/
|
|
||||||
public static function date($datestamp, $withTime = true)
|
|
||||||
{
|
|
||||||
$timestamp = strtotime($datestamp);
|
|
||||||
|
|
||||||
if ($timestamp <= 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$format = $withTime ? config('app.datetime_format') : config('app.date_format');
|
|
||||||
|
|
||||||
return date($format, $timestamp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?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,15 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
use App\CMS\Repositories\Settings\Settings as SettingsRepository;
|
||||||
use App\Models\Settings as SettingsModel;
|
use App\Models\Settings as SettingsModel;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Settings
|
* Class Settings
|
||||||
*
|
*
|
||||||
* Helper class for easier obtaining system settings
|
* Helper class for easier obtaining system settings
|
||||||
*
|
*
|
||||||
* @package App\Helpers
|
* @package App\CMS\Helpers
|
||||||
*/
|
*/
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
@@ -76,8 +78,9 @@ class Settings
|
|||||||
private static function init()
|
private static function init()
|
||||||
{
|
{
|
||||||
if (!self::$initialized) {
|
if (!self::$initialized) {
|
||||||
$model = new SettingsModel();
|
self::$settings = Cache::remember('settings', config('cache.settingCacheLifetime'), function () {
|
||||||
self::$settings = $model->getAll();
|
return app(SettingsRepository::class)->getAll();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Helpers\Traits;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Nullable
|
||||||
|
*
|
||||||
|
* @package App\CMS\Helpers\Traits
|
||||||
|
*/
|
||||||
|
trait Nullable {
|
||||||
|
/**
|
||||||
|
* Get null or parsed date
|
||||||
|
*
|
||||||
|
* @param $date
|
||||||
|
*
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
public function nullableDate($date) {
|
||||||
|
return empty($date) ? null : Carbon::createFromFormat(config('app.date_format'), $date)->toDateTimeString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get null or input value
|
||||||
|
*
|
||||||
|
* @param $string
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function nullable($string) {
|
||||||
|
return empty($string) ? null : $string;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?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,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Helpers;
|
|
||||||
|
|
||||||
use App\Models\WidgetArea;
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
use App\CMS\Repositories\Widgets\WidgetArea as WidgetAreaRepository;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
class WidgetAreas
|
class WidgetAreas
|
||||||
{
|
{
|
||||||
@@ -14,37 +16,37 @@ class WidgetAreas
|
|||||||
protected static function saveRenderedWidgetArea($widgets)
|
protected static function saveRenderedWidgetArea($widgets)
|
||||||
{
|
{
|
||||||
foreach ($widgets as $widget) {
|
foreach ($widgets as $widget) {
|
||||||
if (!isset(self::$widgetAreas[$widget->widget_area_code]))
|
if (!isset(self::$widgetAreas[$widget->widget_area_code])) {
|
||||||
self::$widgetAreas[$widget->widget_area_code] = '';
|
self::$widgetAreas[$widget->widget_area_code] = '';
|
||||||
|
}
|
||||||
|
|
||||||
$handler = $widget->widget_type_handler;
|
self::$widgetAreas[$widget->widget_area_code] .= Widget::render($widget);
|
||||||
$widget->settings = json_decode($widget->settings);
|
|
||||||
$presenter = call_user_func([$handler, 'getPresenter']);
|
|
||||||
|
|
||||||
self::$widgetAreas[$widget->widget_area_code] .= call_user_func([$presenter, 'render'], $widget);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function loadWidgetArea($uniqueCode)
|
protected static function loadWidgetArea($uniqueCode)
|
||||||
{
|
{
|
||||||
$widgetArea = new WidgetArea();
|
$widgets = Cache::remember('widget-area-' . $uniqueCode, setting('widgetCacheLifetime', 5), function () use ($uniqueCode) {
|
||||||
$widgets = $widgetArea->getWidgets($uniqueCode)
|
$widgetArea = app(\App\CMS\Repositories\Widgets\WidgetArea::class);
|
||||||
->get();
|
|
||||||
|
|
||||||
WidgetArea::where('code', $uniqueCode)
|
return $widgetArea->getWidgets($uniqueCode)
|
||||||
->increment('viewed');
|
->get();
|
||||||
|
});
|
||||||
|
|
||||||
self::saveRenderedWidgetArea($widgets);
|
self::saveRenderedWidgetArea($widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function initWidgetAreas()
|
protected static function initWidgetAreas()
|
||||||
{
|
{
|
||||||
if (self::$initialized)
|
if (self::$initialized) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$widgetArea = new WidgetArea();
|
$widgets = Cache::remember('widgets', setting('widgetCacheLifetime', 5), function () {
|
||||||
$widgets = $widgetArea->getWidgets()
|
$widgetArea = app(WidgetAreaRepository::class);
|
||||||
|
return $widgetArea->getWidgets()
|
||||||
->get();
|
->get();
|
||||||
|
});
|
||||||
|
|
||||||
self::saveRenderedWidgetArea($widgets);
|
self::saveRenderedWidgetArea($widgets);
|
||||||
self::$initialized = true;
|
self::$initialized = true;
|
||||||
@@ -55,7 +57,7 @@ class WidgetAreas
|
|||||||
*
|
*
|
||||||
* @param $uniqueCode
|
* @param $uniqueCode
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function render($uniqueCode)
|
public static function render($uniqueCode)
|
||||||
{
|
{
|
||||||
@@ -69,4 +71,14 @@ class WidgetAreas
|
|||||||
|
|
||||||
echo isset(self::$widgetAreas[$uniqueCode]) ? self::$widgetAreas[$uniqueCode] : null;
|
echo isset(self::$widgetAreas[$uniqueCode]) ? self::$widgetAreas[$uniqueCode] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of loaded widgets and areas
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getLoadedWidgets()
|
||||||
|
{
|
||||||
|
return ['areas' => array_keys(self::$widgetAreas)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ function e($value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut for \App\Helpers\Settings::get()
|
* Shortcut for \App\CMS\Helpers\Settings::get()
|
||||||
*
|
*
|
||||||
* @param $key
|
* @param $key
|
||||||
* @param null $default
|
* @param null $default
|
||||||
@@ -22,9 +22,13 @@ function e($value)
|
|||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
function setting($key, $default = null) {
|
function setting($key, $default = null) {
|
||||||
return \App\Helpers\Settings::get($key, $default);
|
return \App\CMS\Helpers\Settings::get($key, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
function asset_path($path) {
|
function asset_path($path) {
|
||||||
return env('SITE_URL').'/assets/'.$path;
|
return env('SITE_URL').'/assets/'.$path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function template_name($name, $throwExceptions = true) {
|
||||||
|
return \App\CMS\Helpers\Template::name($name, $throwExceptions);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?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))];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?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
|
||||||
|
*/
|
||||||
|
public function handle($data, $parameters)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var $page Content
|
||||||
|
*/
|
||||||
|
list($page) = $parameters;
|
||||||
|
|
||||||
|
app('saveContentPipeline')->run($page, $data);
|
||||||
|
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?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) = $parameters;
|
||||||
|
|
||||||
|
$data['userId'] = \Auth::user()->id;
|
||||||
|
$data['language'] = LaravelLocalization::getCurrentLocale();
|
||||||
|
$data['moduleHandler'] = $moduleHandler;
|
||||||
|
|
||||||
|
$page = new Content();
|
||||||
|
app('saveContentPipeline')->run($page, $data);
|
||||||
|
|
||||||
|
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',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
// check if created folder does not exist in current directory
|
||||||
|
if ($this->repository->checkIfNameExists($data['name'], $data['parentDirectory'])) {
|
||||||
|
throw new SubdirectoryExistsInDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
// create new database entry
|
||||||
|
return $this->repository->create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $data array input data
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws SubdirectoryExistsInDirectory
|
||||||
|
*/
|
||||||
|
public function getValidationRules($data = [])
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
'parentDirectory' => 'exists:directories,id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-3
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\MenuPresenters;
|
|
||||||
|
|
||||||
use Pingpong\Menus\MenuItem;
|
namespace App\CMS\MenuPresenters;
|
||||||
use Pingpong\Menus\Presenters\Presenter;
|
|
||||||
|
use Nwidart\Menus\MenuItem;
|
||||||
|
use Nwidart\Menus\Presenters\Presenter;
|
||||||
|
|
||||||
class MetismenuPresenter extends Presenter
|
class MetismenuPresenter extends Presenter
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,10 @@ class MetismenuPresenter extends Presenter
|
|||||||
*/
|
*/
|
||||||
public function getMenuWithoutDropdownWrapper($item)
|
public function getMenuWithoutDropdownWrapper($item)
|
||||||
{
|
{
|
||||||
|
if (!is_string($item->getUrl())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return '<li' . $this->getActiveState($item) . '><a href="' . $item->getUrl() . '">' . $item->getIcon() . ' ' . $item->title . '</a></li>' . PHP_EOL;
|
return '<li' . $this->getActiveState($item) . '><a href="' . $item->getUrl() . '">' . $item->getIcon() . ' ' . $item->title . '</a></li>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
+4
-3
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\MenuPresenters;
|
namespace App\CMS\MenuPresenters;
|
||||||
|
|
||||||
|
use Nwidart\Menus\MenuItem;
|
||||||
|
use Nwidart\Menus\Presenters\Presenter;
|
||||||
|
|
||||||
use Pingpong\Menus\MenuItem;
|
|
||||||
use Pingpong\Menus\Presenters\Presenter;
|
|
||||||
|
|
||||||
class ProfileMenuPresenter extends Presenter
|
class ProfileMenuPresenter extends Presenter
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\MenuPresenters;
|
||||||
|
|
||||||
|
use Nwidart\Menus\Presenters\Bootstrap\NavbarPresenter;
|
||||||
|
|
||||||
|
class TopMenuPresenter extends NavbarPresenter {
|
||||||
|
public function getOpenTagWrapper()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCloseTagWrapper()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\CMS\ModuleManager;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Modules\AppHandler;
|
||||||
|
use App\CMS\Contracts\Modules\TemplateHandler;
|
||||||
|
use App\Models\Module;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
|
||||||
|
class Installer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create new module in database
|
||||||
|
*
|
||||||
|
* @param $name
|
||||||
|
* @param $alias
|
||||||
|
* @param string $description
|
||||||
|
* @param null $handler
|
||||||
|
* @param $parentModuleId
|
||||||
|
* @param array $settings
|
||||||
|
*
|
||||||
|
* @return Module
|
||||||
|
* @throws \ErrorException
|
||||||
|
*/
|
||||||
|
public static function install($name, $alias, $staticName, $description, $handler, $parentModuleId, $settings)
|
||||||
|
{
|
||||||
|
// check if user does not want to install module in runtime
|
||||||
|
if (!App::runningInConsole()) {
|
||||||
|
throw new \ErrorException('Modules can be installed only via Artisan!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$managesContent = $handler ? in_array(AppHandler::class, class_implements($handler)) : false;
|
||||||
|
$isTemplate = $handler ? in_array(TemplateHandler::class, class_implements($handler)) : false;
|
||||||
|
$supportCategories = $managesContent ? call_user_func([$handler, 'supportCategories']) : false;
|
||||||
|
|
||||||
|
if ($parentModuleId) {
|
||||||
|
$parentModule = Module::findOrFail($parentModuleId);
|
||||||
|
$parentModule->has_submodules = true;
|
||||||
|
$parentModule->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert module into database
|
||||||
|
$module = Module::create([
|
||||||
|
'name' => $name,
|
||||||
|
'description' => $description,
|
||||||
|
'handler' => $handler,
|
||||||
|
'static_name' => $staticName,
|
||||||
|
'manages_content' => $managesContent,
|
||||||
|
'support_categories' => $supportCategories,
|
||||||
|
'alias' => $alias,
|
||||||
|
'module_settings' => $settings,
|
||||||
|
'parent_id' => $parentModuleId ? $parentModuleId : null,
|
||||||
|
'enabled' => 1,
|
||||||
|
'is_template' => $isTemplate
|
||||||
|
]);
|
||||||
|
|
||||||
|
// install something module-specific
|
||||||
|
if ($handler && is_callable([$handler, 'install'])) {
|
||||||
|
call_user_func([$handler, 'install']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $module;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\CMS\ModuleManager\Providers;
|
||||||
|
|
||||||
|
use App\CMS\Repositories\Module as ModuleRepository;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class ModuleManager extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the application services.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
// this service provider needs published config - config is merged right after this service provider
|
||||||
|
try {
|
||||||
|
$modules = app(ModuleRepository::class)->all();
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate over all modules and enable or disable them
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
if (isset($module->module_settings['providers']) && !empty($module->module_settings['providers'])) {
|
||||||
|
foreach ($module->module_settings['providers'] as $provider) {
|
||||||
|
|
||||||
|
if (!class_exists($provider)) {
|
||||||
|
Log::warning($provider.' does not exists. Skipping');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->app->register($provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// include files (if any)
|
||||||
|
if (isset($module->module_settings['files']) && !empty($module->module_settings['files'])) {
|
||||||
|
foreach ($module->module_settings['files'] as $file) {
|
||||||
|
$path = config('modules.paths.modules') . '/' . $module->static_name . '/' . $file;
|
||||||
|
|
||||||
|
if (!file_exists($path)) {
|
||||||
|
$path = base_path($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@include_once $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the application services.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\ModuleManager;
|
||||||
|
|
||||||
|
use App\Models\Module;
|
||||||
|
use App\Models\Templates\TemplatePath;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
|
||||||
|
class Uninstaller {
|
||||||
|
/**
|
||||||
|
* Delete module from database and uninstall its dependencies
|
||||||
|
*
|
||||||
|
* @param Module $module
|
||||||
|
*
|
||||||
|
* @throws \ErrorException
|
||||||
|
*/
|
||||||
|
public static function uninstall(Module $module)
|
||||||
|
{
|
||||||
|
// check if user does not want to install module in runtime
|
||||||
|
if (!App::runningInConsole()) {
|
||||||
|
throw new \ErrorException('Modules can be uninstalled only via Artisan!');
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete everything in /resources/views/visitor
|
||||||
|
if ($module->is_template) {
|
||||||
|
self::deleteDirectory(resource_path('views/visitor'));
|
||||||
|
self::deleteDirectory(resource_path('views/modules'));
|
||||||
|
self::deleteDirectory(public_path('assets'));
|
||||||
|
|
||||||
|
// delete all template paths
|
||||||
|
TemplatePath::getQuery()
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($module->handler && is_callable([$module->handler, 'uninstall'])) {
|
||||||
|
call_user_func([$module->handler, 'uninstall'], $module);
|
||||||
|
}
|
||||||
|
|
||||||
|
$module->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete directory when uninstalling module.
|
||||||
|
*
|
||||||
|
* @param $directory
|
||||||
|
*
|
||||||
|
* @throws \ErrorException
|
||||||
|
*/
|
||||||
|
private static function deleteDirectory($directory)
|
||||||
|
{
|
||||||
|
if (!is_dir($directory)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$success = \File::deleteDirectory($directory, true);
|
||||||
|
|
||||||
|
if (!$success) {
|
||||||
|
throw new \ErrorException('Cannot delete ' . $directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-16
@@ -1,32 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Providers;
|
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
namespace App\CMS\Modules\ServiceProviders;
|
||||||
|
|
||||||
abstract class ModuleServiceProvider extends ServiceProvider {
|
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
|
||||||
|
|
||||||
|
abstract class ServiceProvider extends LaravelServiceProvider
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Indicates if loading of the provider is deferred.
|
* Indicates if loading of the provider is deferred.
|
||||||
*
|
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $defer = false;
|
protected $defer = false;
|
||||||
|
|
||||||
protected $alias = false;
|
protected $alias = false;
|
||||||
protected $path = false;
|
protected $path = false;
|
||||||
|
protected $publishViews = true;
|
||||||
|
|
||||||
abstract protected function setModuleAlias();
|
abstract protected function setModuleAlias();
|
||||||
|
|
||||||
abstract protected function setModulePath();
|
abstract protected function setModulePath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boot the application events.
|
* Boot the application events.
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->setModuleAlias();
|
$this->setModuleAlias();
|
||||||
$this->setModulePath();
|
$this->setModulePath();
|
||||||
|
|
||||||
$this->registerTranslations();
|
$this->registerTranslations();
|
||||||
$this->registerConfig();
|
$this->registerConfig();
|
||||||
$this->registerViews();
|
$this->registerViews();
|
||||||
@@ -34,12 +35,11 @@ abstract class ModuleServiceProvider extends ServiceProvider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register config.
|
* Register config.
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function registerConfig()
|
protected function registerConfig()
|
||||||
{
|
{
|
||||||
$this->publishes([$this->path . '/../Config/config.php' => config_path($this->alias.'.php')]);
|
$this->publishes([$this->path . '/../Config/config.php' => config_path($this->alias . '.php')]);
|
||||||
$this->mergeConfigFrom($this->path . '/../Config/config.php', $this->alias);
|
$this->mergeConfigFrom($this->path . '/../Config/config.php', $this->alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,29 +49,28 @@ abstract class ModuleServiceProvider extends ServiceProvider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register views.
|
* Register views.
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function registerViews()
|
protected function registerViews()
|
||||||
{
|
{
|
||||||
$viewPath = base_path('resources/views/modules/'.$this->alias);
|
$viewPath = base_path('resources/views/modules/' . $this->alias);
|
||||||
$sourcePath = $this->path . '/../Resources/views';
|
$sourcePath = $this->path . '/../Resources/views';
|
||||||
|
|
||||||
$this->publishes([$sourcePath => $viewPath], 'module-views');
|
|
||||||
|
|
||||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||||
return $path . '/modules/'.$this->alias;
|
return $path . '/modules/' . $this->alias;
|
||||||
}, \Config::get('view.paths')), [$sourcePath]), $this->alias);
|
}, \Config::get('view.paths')), [$sourcePath]), $this->alias);
|
||||||
|
|
||||||
|
if (is_dir($sourcePath) && $this->publishViews) {
|
||||||
|
$this->publishes([$sourcePath => $viewPath], 'module-views');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register translations.
|
* Register translations.
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function registerTranslations()
|
protected function registerTranslations()
|
||||||
{
|
{
|
||||||
$this->loadTranslationsFrom($this->path . '/../Resources/lang', $this->alias);
|
$this->loadTranslationsFrom($this->path . '/../Resources/lang', $this->alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class $MigrationName$ extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run migration
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('$TableName$', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollback migration
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('$TableName$');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class $MigrationName$ extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run migration
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('$TableName$', function (Blueprint $table) {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollback migration
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('$TableName$', function (Blueprint $table) {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => '$Module$',
|
||||||
|
'translatedName' => '$module$::$module$.name',
|
||||||
|
'translatedDescription' => '$module$::$module$.description',
|
||||||
|
'alias' => strtolower('$Module$'),
|
||||||
|
'handler' => \Modules\$Module$\Handlers\$Module$Handler::class,
|
||||||
|
'providers' => [\Modules\$Module$\Providers\$Module$ServiceProvider::class],
|
||||||
|
'files' => ['Http/routes.php'],
|
||||||
|
'order' => 0,
|
||||||
|
];
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace Modules\$ModuleNamespace$\Entities;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class $Entity$ extends Model {
|
||||||
|
|
||||||
|
protected $table = 'contents';
|
||||||
|
// ...
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\$ModuleNamespace$\Handlers;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Content\ContentTitles;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
class $Module$ContentHandler extends $Module$Handler implements ContentTitles
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get translated title for pages overview of given type.
|
||||||
|
* This value is used for rendering list of all content pages of given type in administration.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getOverviewTitle()
|
||||||
|
{
|
||||||
|
// TODO: Implement getOverviewTitle() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title displayed above for for creating new content page
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getCreateNewTitle()
|
||||||
|
{
|
||||||
|
// TODO: Implement getCreateNewTitle() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for form displayed for editin content page
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getEditTitle(Content $content)
|
||||||
|
{
|
||||||
|
// TODO: Implement getEditTitle() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\$ModuleNamespace$\Handlers;
|
||||||
|
|
||||||
|
use App\CMS\Handlers\BaseHandler;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class $Module$Handler extends BaseHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register admin menu
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
public static function registerAdminMenu(User $user)
|
||||||
|
{
|
||||||
|
// register links in admin menu
|
||||||
|
$menu = \Menu::instance('mainMenu');
|
||||||
|
|
||||||
|
$menu->dropdown(trans('$module$::$module$.name'), function ($submenu) use ($user) {
|
||||||
|
$submenu->route('$module$.overview', trans('$module$::$module$.overview'), [], 20, ['icon' => 'fa fa-fw fa-list']);
|
||||||
|
$submenu->route('$module$.new', trans('$module$::$module$.new'), [], 21, ['icon' => 'fa fa-fw fa-plus']);
|
||||||
|
}, 15, ['icon' => 'fa fa-fw']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: add admin menu entries
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this module support categories?
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function supportCategories()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\$ModuleNamespace$\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Admin\Controller;
|
||||||
|
use Modules\$ModuleNamespace$\Http\Requests\Update$Entity$;
|
||||||
|
use Modules\$ModuleNamespace$\Http\Requests\Create$Entity$;
|
||||||
|
use Modules\$ModuleNamespace$\Repositories\$Module$Repository;
|
||||||
|
use $EntityNamespace$$Entity$ as $Entity$Entity;
|
||||||
|
|
||||||
|
class $Module$ extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var $Module$Repository
|
||||||
|
*/
|
||||||
|
private $$module$Repository;
|
||||||
|
|
||||||
|
public function __construct($Module$Repository $$module$Repository)
|
||||||
|
{
|
||||||
|
$this->$module$Repository = $$module$Repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$items = $Entity$Entity::all();
|
||||||
|
|
||||||
|
return view('$module$::admin/index', compact('items'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display form for updating entity
|
||||||
|
*
|
||||||
|
* @param $Entity$Entity $entity
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function edit($Entity$Entity $entity)
|
||||||
|
{
|
||||||
|
return view('$module$::admin/update', compact('entity'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update existing entity
|
||||||
|
*
|
||||||
|
* @param Update$Entity$ $request
|
||||||
|
* @param $Entity$Entity $item
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(Update$Entity$ $request, $Entity$Entity $entity)
|
||||||
|
{
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
$this->$module$Repository->update($entity, $request->all());
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with('success', trans('$module$.$module.successfullyUpdated'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display form for creating new entity
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function create() {
|
||||||
|
$entity = new $Entity$Entity();
|
||||||
|
|
||||||
|
return view('$module$::admin/create', compact('entity'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new instance of entity
|
||||||
|
*/
|
||||||
|
public function store(Create$Entity$ $request) {
|
||||||
|
// ...
|
||||||
|
|
||||||
|
$this->$module$Repository->create($request->all());
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with('success', trans('$module$.$module.successfullyUpdated'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete entity
|
||||||
|
*
|
||||||
|
* @param $Entity$ $entity
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy($Entity$ $entity) {
|
||||||
|
$entity->delete();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with('success', trans('$module$.$module.successfullyDeleted'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace Modules\$ModuleNamespace$\Http\Requests;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
|
||||||
|
class Create$Entity$ extends Request {
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return parent::rules();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace Modules\$ModuleNamespace$\Http\Requests;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
|
||||||
|
class Update$Entity$ extends Request {
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return parent::rules();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
\Route::group([
|
||||||
|
'prefix' => \LaravelLocalization::setLocale() . '/admin/$module$',
|
||||||
|
'middleware' => ['admin'],
|
||||||
|
'namespace' => 'Modules\$Module$\Http\Controllers\Admin'
|
||||||
|
], function () {
|
||||||
|
Route::get('/', '$Module$@index')
|
||||||
|
->name('$module$.overview');
|
||||||
|
|
||||||
|
Route::get('/new', '$Module$@create')
|
||||||
|
->name('$module$.new');
|
||||||
|
|
||||||
|
Route::post('/new', '$Module$@store')
|
||||||
|
->name('$module$.postNew');
|
||||||
|
|
||||||
|
Route::get('/edit/{id}', '$Module$@edit')
|
||||||
|
->name('$module$.edit');
|
||||||
|
|
||||||
|
Route::post('/edit/{id}', '$Module$@update')
|
||||||
|
->name('$module$.postEdit');
|
||||||
|
|
||||||
|
Route::get('/delete/{id}', '$Module$@delete')
|
||||||
|
->name('$module$.delete');
|
||||||
|
});
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\$Module$\Providers;
|
||||||
|
|
||||||
|
use App\CMS\Modules\ServiceProviders\ServiceProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class $Module$ServiceProvider
|
||||||
|
*
|
||||||
|
* Service provider for module $Module$
|
||||||
|
*
|
||||||
|
* @package Modules\$Module$\Providers
|
||||||
|
*/
|
||||||
|
class $Module$ServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Set module Alias
|
||||||
|
*/
|
||||||
|
protected function setModuleAlias()
|
||||||
|
{
|
||||||
|
$this->alias = strtolower('$module$');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set path to module
|
||||||
|
*/
|
||||||
|
protected function setModulePath()
|
||||||
|
{
|
||||||
|
$this->path = __DIR__;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
namespace Modules\$ModuleNamespace$\Repositories;
|
||||||
|
|
||||||
|
use $EntityNamespace$$Entity$ as $Entity$Entity;
|
||||||
|
|
||||||
|
class $Module$Repository {
|
||||||
|
/**
|
||||||
|
* Create new instance of entity
|
||||||
|
*
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
public function create($data) {
|
||||||
|
$Entity$Entity::create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update entity
|
||||||
|
*
|
||||||
|
* @param $Entity$Entity $entity
|
||||||
|
*/
|
||||||
|
public function update($Entity$Entity $entity, $data) {
|
||||||
|
$entity->update($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => '$Module$',
|
||||||
|
'new' => 'Vytvořit nový',
|
||||||
|
'description' => '',
|
||||||
|
'successfullyUpdated' => 'Úspěšně upraveno.',
|
||||||
|
'successfullyCreated' => 'Úspěšně vytvořeno.',
|
||||||
|
'successfullyDeleted' => 'Úspěšně smazáno.',
|
||||||
|
'overview' => 'Přehled',
|
||||||
|
'noItems' => 'Žádná data.',
|
||||||
|
'save' => 'Uložit'
|
||||||
|
];
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user