Compare commits
827
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e262473f36 | ||
|
|
4a5c9ab1e6 | ||
|
|
e41c589225 | ||
|
|
870ca540c4 | ||
|
|
2e8f8dca1f | ||
|
|
8167b151d5 | ||
|
|
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 | ||
|
|
4128fcf88e | ||
|
|
4353345b3e | ||
|
|
455b9d6d4e | ||
|
|
77685b491e | ||
|
|
f90df0f4bc | ||
|
|
93fc9316a4 | ||
|
|
26854b7207 | ||
|
|
8db748089b | ||
|
|
507e186713 | ||
|
|
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 | ||
|
|
deb094b5c9 | ||
|
|
d425133cae | ||
|
|
9b6ae9f9f8 | ||
|
|
4a95a9692d | ||
|
|
06439bc9a0 | ||
|
|
12683df0ab | ||
|
|
0cb53b2d80 | ||
|
|
5fd9b1871f | ||
|
|
fb51ae80ac | ||
|
|
b9d141c4f1 | ||
|
|
af4edac469 | ||
|
|
0451f9942c | ||
|
|
657c030033 | ||
|
|
d761914786 | ||
|
|
625bdbb2e2 | ||
|
|
d5f9e1fc2b | ||
|
|
ce058ae824 | ||
|
|
dee5060a24 | ||
|
|
c70e8a6b0d | ||
|
|
cb9b96c861 | ||
|
|
4bd5a61fde | ||
|
|
46ff310b01 | ||
|
|
96b05a7b25 | ||
|
|
563528cdc6 | ||
|
|
efa3289491 | ||
|
|
3460f607b5 | ||
|
|
0384fab421 | ||
|
|
b3ac9b9eec | ||
|
|
bfa0685f2e | ||
|
|
59226dbdc4 | ||
|
|
446e8352b5 | ||
|
|
190ca25b2a | ||
|
|
f121ee356b | ||
|
|
b3d59fc182 | ||
|
|
20f6295f84 | ||
|
|
2c36203690 | ||
|
|
458d8ec61c | ||
|
|
284dfa3fe8 | ||
|
|
08e97fe2cb | ||
|
|
7e63047313 | ||
|
|
d9834fe068 | ||
|
|
dc43a9503d | ||
|
|
a75425ca12 | ||
|
|
8c20654280 | ||
|
|
bceef69a72 | ||
|
|
1e310f0da5 | ||
|
|
ab90b907f8 | ||
|
|
f1aacf8008 | ||
|
|
ce82b67c47 | ||
|
|
3024ae8b23 | ||
|
|
7dcb8e280c | ||
|
|
f9dfe076a0 | ||
|
|
db88079f26 | ||
|
|
3f1ae0f5a1 | ||
|
|
f699d2c569 | ||
|
|
fdb63fcd8a | ||
|
|
52fb27b4fe | ||
|
|
7234fa0810 | ||
|
|
581e32e98b | ||
|
|
06780015d4 | ||
|
|
35bdd38f4c | ||
|
|
eacba1bec3 | ||
|
|
975cc50272 | ||
|
|
52b0ec7c72 | ||
|
|
de02944d0d | ||
|
|
da1c8652e6 | ||
|
|
012ba1fd36 | ||
|
|
cbfc5fcee5 | ||
|
|
232e1d5ec9 | ||
|
|
aca3c778e0 | ||
|
|
88a2463d13 | ||
|
|
f3e797a59a | ||
|
|
0869ac7c24 | ||
|
|
304518fbe7 | ||
|
|
49577a7e1a | ||
|
|
606ee2016d | ||
|
|
8608a2d67b | ||
|
|
3bac8dc09b | ||
|
|
f61b8a7bcc | ||
|
|
b6d3daaa35 | ||
|
|
33a928febb | ||
|
|
06c84867ec | ||
|
|
8a9543cd2d | ||
|
|
4f67b69984 | ||
|
|
28df8681e4 | ||
|
|
4222dbc243 | ||
|
|
2f27e7f5c9 | ||
|
|
c5fb951546 | ||
|
|
ecd7aa27f0 | ||
|
|
ecd01e1396 | ||
|
|
76b226629f | ||
|
|
97fae9bf9d | ||
|
|
5621b5acba | ||
|
|
ff237599a8 | ||
|
|
679ca91fc9 | ||
|
|
1dea234cb7 | ||
|
|
e42d06904e | ||
|
|
cb2fa84ade | ||
|
|
0a0b0e7518 | ||
|
|
65dc4fd37e | ||
|
|
b13f6bbea9 | ||
|
|
10e463b8b4 | ||
|
|
316f7a9a16 | ||
|
|
5e79d0208a | ||
|
|
5cdca60cce | ||
|
|
86a2d277f6 | ||
|
|
ad59bc0adc | ||
|
|
556d863b45 | ||
|
|
673531ae22 | ||
|
|
a9d5c0de28 | ||
|
|
b43e37fa83 | ||
|
|
6c4b30f1f7 | ||
|
|
c4a4354aff | ||
|
|
ad77de0424 | ||
|
|
c4d4ac2bfe | ||
|
|
0718772740 | ||
|
|
0ace8c9cb6 | ||
|
|
0482121441 | ||
|
|
0df8eaa2e3 | ||
|
|
66a570bbf7 | ||
|
|
0badc52f17 | ||
|
|
4cf1fedc61 | ||
|
|
341b5dc9ec | ||
|
|
f5e2aec818 | ||
|
|
77a65b71a2 | ||
|
|
5f1cf06e36 | ||
|
|
b734c3de18 | ||
|
|
808bb0eb86 | ||
|
|
682f3b75bf | ||
|
|
5b9b5c0d38 | ||
|
|
3a0a132701 | ||
|
|
60c3582947 | ||
|
|
9039334138 | ||
|
|
5ee403ab28 | ||
|
|
fdf44e8b4a | ||
|
|
91cdbec3af | ||
|
|
45354a3192 | ||
|
|
846cfef1b8 | ||
|
|
80dba6d9b7 | ||
|
|
bf615f8494 | ||
|
|
4c67d442d6 | ||
|
|
36615aac21 | ||
|
|
4e6fc7c074 | ||
|
|
e0357d0003 | ||
|
|
8533c8cdc6 | ||
|
|
bb3d000e5e | ||
|
|
842b54d879 | ||
|
|
256e24c5a4 | ||
|
|
07df49c481 | ||
|
|
a11a29de19 | ||
|
|
044eb7e532 | ||
|
|
7f93a5035c | ||
|
|
358027a8e0 | ||
|
|
98fe43e12c | ||
|
|
c096a30b81 | ||
|
|
02157f332e | ||
|
|
cd28625309 | ||
|
|
6868af609f | ||
|
|
445f369ff2 | ||
|
|
2a1ffb4259 | ||
|
|
4876cb631e | ||
|
|
4c35d95a73 | ||
|
|
8f4e6268a4 | ||
|
|
d7b60690b2 | ||
|
|
4de93f9fd9 | ||
|
|
f26c384257 | ||
|
|
78213e6f41 | ||
|
|
a188c707d8 | ||
|
|
ff4585327e | ||
|
|
fa1d302ea6 | ||
|
|
52394c6289 | ||
|
|
76fa76a5af | ||
|
|
d6a441cb96 | ||
|
|
85bbc384a7 | ||
|
|
80105c857e | ||
|
|
09151e97d1 | ||
|
|
9802161af1 | ||
|
|
00d7bd562c | ||
|
|
124ad2f061 | ||
|
|
a37767c2e8 | ||
|
|
d5950d9cd7 | ||
|
|
82283e65be | ||
|
|
2f760fd56d | ||
|
|
939610cf9d | ||
|
|
6d107d0881 | ||
|
|
b7434d0a0b | ||
|
|
55ef5e4af1 | ||
|
|
dc289723a9 | ||
|
|
b15bbae037 | ||
|
|
7cd084e621 | ||
|
|
0857b4efd9 | ||
|
|
0c01b35188 | ||
|
|
9d33ae6d49 | ||
|
|
a9aaf797cd | ||
|
|
4b6f0b14ad | ||
|
|
a111b67c53 | ||
|
|
91ef424bd0 | ||
|
|
7589051216 | ||
|
|
fbb59277b9 | ||
|
|
0d8e927b08 | ||
|
|
72f7b9a047 | ||
|
|
139373145a | ||
|
|
0357417163 | ||
|
|
d5d4216a80 | ||
|
|
b982831fbf | ||
|
|
75c4a4a649 | ||
|
|
fb977ce1b9 | ||
|
|
7d051d1f6a | ||
|
|
f5e1e24df8 | ||
|
|
5ddb31b57b | ||
|
|
01a28fc65a | ||
|
|
67cd7fb36f | ||
|
|
5f8dab0068 | ||
|
|
40949eaa90 | ||
|
|
f25ef4ab1b | ||
|
|
f3873ed61c | ||
|
|
bbffbd5616 | ||
|
|
d9feb92612 | ||
|
|
5662dc7cf7 | ||
|
|
39279a1633 | ||
|
|
e8b91db6f2 | ||
|
|
df9ff7b259 | ||
|
|
a0f3409f82 | ||
|
|
694724945d | ||
|
|
5cbe19064b | ||
|
|
4ac084139c | ||
|
|
f92c1d0089 | ||
|
|
bcd19058ea | ||
|
|
d43073a011 | ||
|
|
8bd30d0301 | ||
|
|
f087da1b43 | ||
|
|
7a681fd7f7 | ||
|
|
2e483c7598 | ||
|
|
f98065e849 | ||
|
|
48294842bf | ||
|
|
65e9ca1c32 | ||
|
|
233f2007b0 | ||
|
|
5b29082ca6 | ||
|
|
48c0abbe89 | ||
|
|
8476d5fbd7 | ||
|
|
ea5aa8d873 | ||
|
|
3229a84ee5 | ||
|
|
f8127f3ed6 | ||
|
|
44677aea78 | ||
|
|
5b7b81ff4d | ||
|
|
68d37e87f6 | ||
|
|
51d6850cd6 | ||
|
|
8f66a96ec0 | ||
|
|
9ce9f62a45 | ||
|
|
a33023a4aa | ||
|
|
d2d0a48e9c | ||
|
|
e55672bdcd | ||
|
|
5ef2630810 | ||
|
|
8c4b1ad69b | ||
|
|
59dede6049 | ||
|
|
f304ef0141 | ||
|
|
3cfadc380d | ||
|
|
b73b575b71 | ||
|
|
9b64b54d7b | ||
|
|
e826b474b8 | ||
|
|
9d63c8d8b0 | ||
|
|
aa4161e451 | ||
|
|
9029f14523 | ||
|
|
98c8313475 | ||
|
|
8351137206 | ||
|
|
79ec8e1d2e | ||
|
|
418d9ac4ca | ||
|
|
d0be4d1e49 | ||
|
|
4cfd93161b | ||
|
|
05efb6b9f2 | ||
|
|
66caf7ce05 | ||
|
|
9c02c63704 | ||
|
|
8458622e32 | ||
|
|
f1121107c5 | ||
|
|
d954743e8b | ||
|
|
0a6528a845 | ||
|
|
f744ca81ca | ||
|
|
3a82696d62 | ||
|
|
cd6f1b4cfa | ||
|
|
28478ba165 | ||
|
|
d746d5b52b | ||
|
|
f6fd924cbd | ||
|
|
0d1d692c45 | ||
|
|
6f6497d540 | ||
|
|
7889548a7e | ||
|
|
fc1141184c | ||
|
|
0993d812cb | ||
|
|
be81834aad | ||
|
|
e389760204 | ||
|
|
6f799f00bb | ||
|
|
debe80a314 | ||
|
|
af3db57b29 | ||
|
|
8edde44c0d | ||
|
|
cd369c327f | ||
|
|
206e5201b8 | ||
|
|
aa462c2454 | ||
|
|
ae1123ba39 | ||
|
|
bd06797c24 | ||
|
|
5b79fd4323 | ||
|
|
53d532da82 | ||
|
|
fa21c407b4 | ||
|
|
d54f160d6a | ||
|
|
5df5fa8480 | ||
|
|
ddd3530993 | ||
|
|
befb95a4ac | ||
|
|
dc185bdc2e | ||
|
|
42967e72cd | ||
|
|
85e10b5631 | ||
|
|
54e5927bb1 | ||
|
|
9517d07692 | ||
|
|
93abfd2485 | ||
|
|
5aec27478a | ||
|
|
9f955d4544 | ||
|
|
597d161a38 | ||
|
|
48d301330f | ||
|
|
03f0d71dbb | ||
|
|
778c87ffa3 | ||
|
|
ed0b35f9d7 | ||
|
|
cfc3a148e7 | ||
|
|
a698d7a7db | ||
|
|
ba107184e1 | ||
|
|
7abd60e785 | ||
|
|
0d5e6d4133 | ||
|
|
790cc772a9 | ||
|
|
0d8148f22d | ||
|
|
bef37a5cce | ||
|
|
be4a136476 | ||
|
|
5fc4393729 | ||
|
|
097d76de93 | ||
|
|
0076cfba2e | ||
|
|
6b24c8a461 | ||
|
|
3733d24da8 | ||
|
|
b2b8084cfe | ||
|
|
ab3d8eab41 | ||
|
|
b89941b909 | ||
|
|
bce98e6eaf | ||
|
|
f90aee4108 | ||
|
|
2189bbed5e | ||
|
|
ebc7330717 | ||
|
|
bab897f01e | ||
|
|
fb2c705ac4 | ||
|
|
6021f1ea9a | ||
|
|
181e1fb721 | ||
|
|
5b54f6d45f | ||
|
|
15a29de894 | ||
|
|
db912c4c91 | ||
|
|
949b1f7c61 | ||
|
|
fc88a82888 | ||
|
|
bfcab20dad | ||
|
|
93bafee2e7 | ||
|
|
3a6211c875 | ||
|
|
e072e0e4af | ||
|
|
070e929bf7 | ||
|
|
6dd6394ff1 | ||
|
|
5c6b72f83a | ||
|
|
6a4cbb0a5c | ||
|
|
098ea3e7b1 | ||
|
|
a48bed04b1 | ||
|
|
288b1043b5 | ||
|
|
492225e176 | ||
|
|
951a8314b7 | ||
|
|
c99cee7a27 | ||
|
|
e94fff384a | ||
|
|
08026b286a | ||
|
|
5b97335536 | ||
|
|
8b157052e0 | ||
|
|
01d9df4dd0 | ||
|
|
971fc796a8 | ||
|
|
fa28de48ca | ||
|
|
037d0c8dff | ||
|
|
18ead80b5f | ||
|
|
d75c2838d3 | ||
|
|
25860ae501 | ||
|
|
56e2636e6c | ||
|
|
509ae17fca | ||
|
|
a20b9144a5 | ||
|
|
59503baa9c | ||
|
|
b996ef493d | ||
|
|
5bc077989f | ||
|
|
725c379cd7 | ||
|
|
eb8e7badd6 | ||
|
|
0cc1916346 | ||
|
|
5116fedac0 | ||
|
|
474405c69d | ||
|
|
74838f96fa | ||
|
|
d231065fb8 | ||
|
|
7fc01fa1ec | ||
|
|
5858820cb7 | ||
|
|
43051501bd | ||
|
|
e3d715d2d0 | ||
|
|
a4af5e2bac | ||
|
|
666557b585 | ||
|
|
85c33e9ada | ||
|
|
6690d7423e | ||
|
|
d996c4c800 | ||
|
|
de287abf24 | ||
|
|
fc9f3a403b | ||
|
|
dcce436c59 | ||
|
|
543cce17fa | ||
|
|
2f7a3790b9 | ||
|
|
d721aaf185 | ||
|
|
303a84904e | ||
|
|
e2f6fed4b1 | ||
|
|
87e4e96ca5 | ||
|
|
d7e5351d5b | ||
|
|
1efaaaa4e0 | ||
|
|
2eeb3227d3 | ||
|
|
b7c70bab7e | ||
|
|
c3085180c0 | ||
|
|
885dc691b2 | ||
|
|
4594e84945 | ||
|
|
c42f860e9f | ||
|
|
0ba38d146c | ||
|
|
a42c1fb6c7 | ||
|
|
b46c99efc4 | ||
|
|
dddabe7724 | ||
|
|
afc2af6e9b | ||
|
|
9fe7e04e2f | ||
|
|
ced6f978a8 | ||
|
|
522110aea1 | ||
|
|
5d1254da18 | ||
|
|
7446e2f4ef | ||
|
|
9570ad3da3 | ||
|
|
54f0566ee2 | ||
|
|
d17a0ec8ef | ||
|
|
ae1772652f | ||
|
|
19ad81a432 | ||
|
|
dac9de0024 | ||
|
|
281a1ed0ba | ||
|
|
9d2488e589 | ||
|
|
d3437aa2de | ||
|
|
1a33c74c6d | ||
|
|
439b048590 | ||
|
|
743c6bdb07 | ||
|
|
51b60440be | ||
|
|
ceaf9e7d6a | ||
|
|
30dcd045a6 | ||
|
|
a020e72dc5 | ||
|
|
3c90e20dd3 | ||
|
|
33bd049d92 | ||
|
|
b06c2bf5a0 | ||
|
|
090aed23cb | ||
|
|
d0411feebf | ||
|
|
3613c0fcf5 | ||
|
|
aff8e992d6 | ||
|
|
2d25e00d76 | ||
|
|
0f18b6361e | ||
|
|
f27ad7c421 | ||
|
|
753b0cf2e2 | ||
|
|
85dcf29c41 | ||
|
|
503d209319 | ||
|
|
ccf71dba81 | ||
|
|
3646c79e1d | ||
|
|
1f3cc2eebb | ||
|
|
8a33f1b4c7 | ||
|
|
08cb40b004 | ||
|
|
96d6f517dc | ||
|
|
d4ad1406bf | ||
|
|
9b2451fd98 | ||
|
|
90b6979237 | ||
|
|
97ba21df98 | ||
|
|
c481f374a0 | ||
|
|
d3f31c578f | ||
|
|
7947926f8d | ||
|
|
a989421036 | ||
|
|
d0438f56dd | ||
|
|
7de45fe377 | ||
|
|
9f8eb230e8 | ||
|
|
1914c17deb | ||
|
|
181f8a7e23 | ||
|
|
3a84279916 | ||
|
|
cfa9e2b09c | ||
|
|
5178c7236b | ||
|
|
1e6bc86800 | ||
|
|
a620bf9e32 | ||
|
|
7cc04bc9ce | ||
|
|
a56fdfb6ce | ||
|
|
213283b51f | ||
|
|
369cefe15f | ||
|
|
284837bf12 | ||
|
|
a0ec4fc02f | ||
|
|
f11c673173 | ||
|
|
ce030a40d4 | ||
|
|
31c1648597 | ||
|
|
7bb63aca3f | ||
|
|
497708283f | ||
|
|
2797ff0a89 | ||
|
|
307dbe0459 | ||
|
|
9f4cc158db | ||
|
|
19e0977bbb | ||
|
|
3900462229 | ||
|
|
c48b99eaf0 | ||
|
|
34060ebf2e | ||
|
|
bc73fbc208 | ||
|
|
32604653fb | ||
|
|
8de2c67323 | ||
|
|
f9afcae389 | ||
|
|
b9f721006d | ||
|
|
3f7c048ad0 | ||
|
|
acd85a1cad | ||
|
|
811f2162c9 | ||
|
|
3f03af7e03 | ||
|
|
7a71bbe90e | ||
|
|
5e51edcd48 | ||
|
|
f0f95cc04f | ||
|
|
7a23ca1d3f | ||
|
|
9cda47f93d | ||
|
|
a478f1491e | ||
|
|
5f050a7dea | ||
|
|
c2f024f8b8 | ||
|
|
f90f43fcd6 | ||
|
|
8838ecc6b1 | ||
|
|
efd2465b8b | ||
|
|
0c1162589c | ||
|
|
509ef1752e | ||
|
|
10dfe6b22e | ||
|
|
5661a3d849 | ||
|
|
cf2b4ac529 | ||
|
|
2b61709ade | ||
|
|
6378d17753 | ||
|
|
590e1eeaca | ||
|
|
7d674357fe | ||
|
|
e789b02a93 | ||
|
|
acc7541ab9 | ||
|
|
5045dca3d4 | ||
|
|
c99e7c156d | ||
|
|
bc80ccc8e5 | ||
|
|
5494121dfb | ||
|
|
26e5a52943 | ||
|
|
7a51c913d3 | ||
|
|
c49f4f2c5f | ||
|
|
980fec83c0 | ||
|
|
473342490c | ||
|
|
b40815eec7 | ||
|
|
7317a51a24 | ||
|
|
b228fe4615 | ||
|
|
c0f3c2cf07 | ||
|
|
9b9362b8e9 | ||
|
|
7ef09ec326 | ||
|
|
86d7ffdab9 | ||
|
|
d6f0489b5f | ||
|
|
64aec15c8a | ||
|
|
28c065e106 | ||
|
|
98090f69df | ||
|
|
c2463f5e59 | ||
|
|
7788a598f4 | ||
|
|
6c7122b494 | ||
|
|
29b0eab314 | ||
|
|
12f05586ed | ||
|
|
35fe7aada3 | ||
|
|
55ee35d14b | ||
|
|
3c9c53e04d | ||
|
|
6f50549072 | ||
|
|
b3da43921b | ||
|
|
c4e65e18c4 | ||
|
|
afbf3d1327 | ||
|
|
4d19d4388a | ||
|
|
81f6f4e46f | ||
|
|
72d00c8e64 | ||
|
|
8a94f1dbab | ||
|
|
a237133227 | ||
|
|
9ac8c24673 | ||
|
|
bee7e732cc | ||
|
|
e7c5a69f81 | ||
|
|
6d13576185 | ||
|
|
14f2673842 | ||
|
|
1bd00f1a4f | ||
|
|
4326105304 | ||
|
|
c3008f3dcc | ||
|
|
e6880c82ec | ||
|
|
ca2318a529 | ||
|
|
b707d27c3f | ||
|
|
f9562d55aa | ||
|
|
a39a402011 | ||
|
|
892a597912 | ||
|
|
85e9e6ebb6 | ||
|
|
2941d694da | ||
|
|
2a6672934d | ||
|
|
0313a1239f | ||
|
|
603e989b1e | ||
|
|
62a600b5fc | ||
|
|
1353fbfd79 | ||
|
|
df3bc22954 | ||
|
|
069367a816 | ||
|
|
8af9943100 | ||
|
|
97fc32c3ae | ||
|
|
063ba90ce8 | ||
|
|
141df72356 | ||
|
|
a9a4cb70f0 | ||
|
|
0a1a25b300 | ||
|
|
d0601c4fdd | ||
|
|
eed7e15650 | ||
|
|
9f5bd46ca3 | ||
|
|
3407707046 | ||
|
|
03dbf22eb0 | ||
|
|
661d5c486d | ||
|
|
d52dcbcf55 | ||
|
|
d7565ec7bf | ||
|
|
d7b247a2e3 | ||
|
|
a67417380f | ||
|
|
f79fc78868 | ||
|
|
fc58a4d31c | ||
|
|
fe9e76bf28 | ||
|
|
8aa2ebd0b0 | ||
|
|
bb7106d706 | ||
|
|
464eaf8b17 | ||
|
|
b6a1a4d444 | ||
|
|
f97ac0e868 | ||
|
|
b8f8c75146 | ||
|
|
6723381384 | ||
|
|
6e6be7f790 | ||
|
|
fa97ccc032 | ||
|
|
57e08b76a8 | ||
|
|
53395bc47a | ||
|
|
d082cee7b5 | ||
|
|
f3dde68481 | ||
|
|
66c9d7907a | ||
|
|
214cc9f3f9 | ||
|
|
2c95acfe76 | ||
|
|
4e85799403 | ||
|
|
ad457db740 | ||
|
|
6a7402248a | ||
|
|
d7c7e642a4 | ||
|
|
03086f7fd3 | ||
|
|
37a698b631 | ||
|
|
6d0e6e26f6 | ||
|
|
36fc280f55 | ||
|
|
9269d8c0b9 | ||
|
|
c75a6bd364 | ||
|
|
3b1ca7c1a7 | ||
|
|
b344c928b4 | ||
|
|
b5b41a0888 | ||
|
|
81a0fc83b9 | ||
|
|
c1e65d5651 | ||
|
|
e8f994ff5f | ||
|
|
1d553d1a15 | ||
|
|
8ba8a45938 | ||
|
|
ccc2d918c9 | ||
|
|
043c842aef | ||
|
|
da3046c990 | ||
|
|
677acf3dcb | ||
|
|
88d9ca48a3 | ||
|
|
b290fb3ff5 | ||
|
|
012b8b7588 | ||
|
|
d7dbdf7fc5 | ||
|
|
4a1ca1fcd8 | ||
|
|
2ab3896ee7 | ||
|
|
9de95c24c8 | ||
|
|
39591c11c3 | ||
|
|
5f38ad2e3a | ||
|
|
c73bc1452b | ||
|
|
a5e8eb8fc4 | ||
|
|
1a8b07971e | ||
|
|
3e9477ddc3 | ||
|
|
bd38e3fd98 | ||
|
|
e98032a3e1 | ||
|
|
eb28696d82 | ||
|
|
df1e1390e7 | ||
|
|
d414e53789 | ||
|
|
24144f6aa4 | ||
|
|
58a3386277 | ||
|
|
8763a5da95 | ||
|
|
fc33c06613 | ||
|
|
1c14bdd390 | ||
|
|
8fe0558374 | ||
|
|
2e276335af | ||
|
|
aeabe03911 | ||
|
|
620a5545d8 | ||
|
|
0216d923d4 | ||
|
|
f262be1dcb | ||
|
|
780ee89d21 | ||
|
|
270f77f451 | ||
|
|
3a0f7c7cd4 | ||
|
|
a880ab9e15 | ||
|
|
ee55715093 | ||
|
|
593506c646 | ||
|
|
3902a75b2c | ||
|
|
b7d0258f06 | ||
|
|
b3c543f06c | ||
|
|
4a8facc046 | ||
|
|
7054ce53b6 | ||
|
|
5fabc08a99 | ||
|
|
859d3ce753 | ||
|
|
26873a2db4 | ||
|
|
527b482ab8 | ||
|
|
da23bb4100 | ||
|
|
0c7a138e43 | ||
|
|
703adfcb78 | ||
|
|
73ff4e9331 | ||
|
|
1b2d7db8f3 | ||
|
|
0f4ad90cd8 | ||
|
|
d9b678036a | ||
|
|
8210eafad5 | ||
|
|
e63f78e67b | ||
|
|
ff80cbca4f | ||
|
|
4506b62387 | ||
|
|
63c05ba6f9 | ||
|
|
cac5b1dfb9 | ||
|
|
19ee504075 | ||
|
|
5db999e3b1 | ||
|
|
35a93091ff | ||
|
|
79d5277a13 | ||
|
|
686ce63ca7 | ||
|
|
76f865566e | ||
|
|
c4dd6cc229 | ||
|
|
cc832d5249 | ||
|
|
195ba54005 | ||
|
|
0302de734b | ||
|
|
452280a6fe |
+12
-16
@@ -1,23 +1,19 @@
|
|||||||
APP_ENV=local
|
APP_KEY=
|
||||||
APP_DEBUG=true
|
APP_ENV=
|
||||||
APP_KEY=SomeRandomString
|
APP_DEBUG=
|
||||||
|
|
||||||
DB_HOST=localhost
|
DB_HOST=
|
||||||
DB_DATABASE=homestead
|
DB_DATABASE=
|
||||||
DB_USERNAME=homestead
|
DB_USERNAME=
|
||||||
DB_PASSWORD=secret
|
DB_PASSWORD=
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_DRIVER=sync
|
||||||
|
|
||||||
REDIS_HOST=localhost
|
MAIL_USERNAME=@binarity.cz
|
||||||
REDIS_PASSWORD=null
|
MAIL_PASSWORD=
|
||||||
REDIS_PORT=6379
|
|
||||||
|
|
||||||
MAIL_DRIVER=smtp
|
SITE_URL=/
|
||||||
MAIL_HOST=mailtrap.io
|
UPLOAD_URL=/public/uploads
|
||||||
MAIL_PORT=2525
|
THUMBNAIL_URL=/public/uploads/thumbnails
|
||||||
MAIL_USERNAME=null
|
|
||||||
MAIL_PASSWORD=null
|
|
||||||
MAIL_ENCRYPTION=null
|
|
||||||
+31
-5
@@ -1,9 +1,35 @@
|
|||||||
|
# published files from modules
|
||||||
|
/public/modules
|
||||||
|
/public/assets
|
||||||
|
/resources/views/modules
|
||||||
|
/resources/views/visitor
|
||||||
/resources/views/vendor
|
/resources/views/vendor
|
||||||
!/resources/views/vendor/.gitkeep
|
|
||||||
|
# directories with custom templates
|
||||||
|
**/views/**/custom/*
|
||||||
|
!**/views/**/custom/.gitkeep
|
||||||
|
|
||||||
|
# module config - generated in ModuleManager service provider
|
||||||
|
**/module.json
|
||||||
|
|
||||||
|
# uploaded files
|
||||||
|
/public/uploads/*
|
||||||
|
!/public/uploads/.gitkeep
|
||||||
|
|
||||||
|
# environment settings
|
||||||
/.env
|
/.env
|
||||||
|
|
||||||
|
# dependecies - installed using Composer
|
||||||
/vendor
|
/vendor
|
||||||
|
|
||||||
|
# PhpStorm project directory
|
||||||
/.idea
|
/.idea
|
||||||
/node_modules
|
|
||||||
Homestead.yaml
|
# meta information created by installer
|
||||||
Homestead.json
|
.install
|
||||||
.env
|
/node_modules/
|
||||||
|
/public/css/
|
||||||
|
/public/js
|
||||||
|
/public/fonts
|
||||||
|
/bower_components
|
||||||
|
.sass-cache
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule ^(.*)/$ /$1 [L,R=301]
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|\.woff|robots\.txt)$ [NC]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ index.php [L]
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_URI} !^/public/
|
||||||
|
RewriteRule ^(assets)/(.*)$ public/$1/$2 [L,NC]
|
||||||
|
|
||||||
|
# disable viewing all hiden files
|
||||||
|
RedirectMatch 403 /\..*$
|
||||||
|
|
||||||
|
# disable browsing other files in root
|
||||||
|
RedirectMatch 403 /composer.*
|
||||||
|
RedirectMatch 403 /artisan
|
||||||
|
RedirectMatch 403 /phpunit.xml
|
||||||
|
|
||||||
|
# disable browsing directories
|
||||||
|
# this should be solved also with Option -Indexes, however...
|
||||||
|
RedirectMatch 403 ^/app
|
||||||
|
RedirectMatch 403 ^/artisan
|
||||||
|
RedirectMatch 403 ^/bootstrap
|
||||||
|
RedirectMatch 403 ^/config
|
||||||
|
RedirectMatch 403 ^/database
|
||||||
|
RedirectMatch 403 ^/modules
|
||||||
|
RedirectMatch 403 ^/scripts
|
||||||
|
RedirectMatch 403 ^/storage
|
||||||
|
RedirectMatch 403 ^/tests
|
||||||
|
RedirectMatch 403 ^/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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Content;
|
||||||
|
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface ContentTitles
|
||||||
|
*
|
||||||
|
* Classes which implement this interface get the ability to rewrite default text on edit/create/overview of content
|
||||||
|
* page.
|
||||||
|
*
|
||||||
|
* @package App\CMS\Handlers\Contracts
|
||||||
|
*/
|
||||||
|
interface 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();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title displayed above for for creating new content page
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getCreateNewTitle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for form displayed for editin content page
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getEditTitle(Content $content);
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Contracts;
|
||||||
|
|
||||||
|
interface HistoryHandler
|
||||||
|
{
|
||||||
|
public static function parseColumnName($name);
|
||||||
|
|
||||||
|
public static function parseChangedValue($changeset);
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Modules;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
interface 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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Contracts;
|
||||||
|
|
||||||
|
interface SearchHandler {
|
||||||
|
public function getId();
|
||||||
|
|
||||||
|
public function getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for given patttern/term
|
||||||
|
*
|
||||||
|
* @param string $term searched word
|
||||||
|
*
|
||||||
|
* @return array list of found objects
|
||||||
|
*/
|
||||||
|
public function search($term);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Contracts;
|
||||||
|
|
||||||
|
interface SearchPresenterHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method for rendering list of found results
|
||||||
|
*
|
||||||
|
* @param $foundItems
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function render($foundItems);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Widgets;
|
||||||
|
|
||||||
|
interface AdminDashboardWidget extends PublicWidget
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Getter for list of all roles which are allowed to display the widget
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function renderForRoles();
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Widgets\Contracts;
|
||||||
|
|
||||||
|
interface MenuExtensionHandler {
|
||||||
|
|
||||||
|
public function getName();
|
||||||
|
public function getDescription();
|
||||||
|
public function getId();
|
||||||
|
|
||||||
|
public function getPossibleValues();
|
||||||
|
|
||||||
|
public function getFormExtensionTemplate();
|
||||||
|
|
||||||
|
public function save();
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Widgets;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Widgets\Widget;
|
||||||
|
|
||||||
|
interface PublicWidget
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Name getter
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for description
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getDescription();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for presenter/renderer of this widget
|
||||||
|
*
|
||||||
|
* @return WidgetRenderer
|
||||||
|
*/
|
||||||
|
public static function getPresenter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get widget settings for saving into database
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function save(Request $request);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Contracts\Widgets;
|
||||||
|
|
||||||
|
use App\Models\Widgets\Widget;
|
||||||
|
use App\Models\Widgets\WidgetType;
|
||||||
|
|
||||||
|
interface WidgetRenderer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method used for displaying widget.
|
||||||
|
*
|
||||||
|
* This method renders some HTML code for displaying.
|
||||||
|
*
|
||||||
|
* @param Widget $settings
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function render(Widget $settings);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display form for creating new instance of widget
|
||||||
|
*
|
||||||
|
* @param WidgetType $type
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function renderAddForm(WidgetType $type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display form for editing already existing widget
|
||||||
|
*
|
||||||
|
* @param Widget $widget
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function renderEditForm(Widget $widget);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\ActionLogType;
|
||||||
|
|
||||||
|
class ActionLogTypes extends BaseEnumeration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Init list of all action log types
|
||||||
|
*
|
||||||
|
* @throws Exceptions\EnumerationExistsException
|
||||||
|
*/
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$types = ActionLogType::all(['id', 'name']);
|
||||||
|
|
||||||
|
foreach ($types as $type) {
|
||||||
|
self::push($type->id, $type->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\ActionLog\ActionLogType;
|
||||||
|
|
||||||
|
class ActionLogTypesForLogger extends BaseEnumeration
|
||||||
|
{
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$types = ActionLogType::all(['string_id', 'id']);
|
||||||
|
|
||||||
|
foreach ($types as $type) {
|
||||||
|
self::push($type->string_id, $type->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
{
|
{
|
||||||
@@ -26,6 +26,11 @@ abstract class BaseEnumeration
|
|||||||
$className::init();
|
$className::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it can happen that even after init no enumerations are available
|
||||||
|
if (empty(self::$items[$className])) {
|
||||||
|
self::$items[$className] = [];
|
||||||
|
}
|
||||||
|
|
||||||
self::$initiliazed[] = $className;
|
self::$initiliazed[] = $className;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +47,7 @@ abstract class BaseEnumeration
|
|||||||
public static function push($key, $translation, $overwrite = false)
|
public static function push($key, $translation, $overwrite = false)
|
||||||
{
|
{
|
||||||
// item exists and we do not want to overwrite items
|
// item exists and we do not want to overwrite items
|
||||||
if (!$overwrite && isset(self::$items[get_called_class()][$key])) {
|
if (!$overwrite && !is_null($key) && isset(self::$items[get_called_class()][$key])) {
|
||||||
throw new EnumerationExistsException(get_called_class() . ': ' . $key . ' already in ' . $translation);
|
throw new EnumerationExistsException(get_called_class() . ': ' . $key . ' already in ' . $translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Repositories\Content;
|
||||||
|
|
||||||
|
class ContentStatuses extends BaseEnumeration
|
||||||
|
{
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$roles = [
|
||||||
|
Content::STATUS_DRAFT => 'admin/contents.status_' . Content::STATUS_DRAFT,
|
||||||
|
Content::STATUS_PROTECTED => 'admin/contents.status_' . Content::STATUS_PROTECTED,
|
||||||
|
Content::STATUS_PUBLIC => 'admin/contents.status_' . Content::STATUS_PUBLIC
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($roles as $role => $translation) {
|
||||||
|
self::push($role, $translation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Module;
|
||||||
|
|
||||||
|
class ModuleNamesWithIds extends BaseEnumeration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Init list of all installed modules
|
||||||
|
*
|
||||||
|
* @throws Exceptions\EnumerationExistsException
|
||||||
|
*/
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$modules = Module::all(['id', 'name']);
|
||||||
|
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
self::push($module->id, $module->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Module;
|
||||||
|
|
||||||
|
class Modules extends BaseEnumeration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Init list of all installed modules
|
||||||
|
*
|
||||||
|
* @throws Exceptions\EnumerationExistsException
|
||||||
|
*/
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$modules = Module::all(['handler', 'name']);
|
||||||
|
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
self::push($module->handler, $module->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Module;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
|
class ModulesHandlerToId extends BaseEnumeration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Init list of all installed modules
|
||||||
|
*
|
||||||
|
* @throws Exceptions\EnumerationExistsException
|
||||||
|
*/
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$modules = Cache::rememberForever('module-handler-to-id-enumeration', function () {
|
||||||
|
return Module::all(['handler', 'id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
self::push($module->handler, $module->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: michal
|
||||||
|
* Date: 18.2.16
|
||||||
|
* Time: 10:33
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Templates\TemplatePath;
|
||||||
|
|
||||||
|
class TemplatePaths extends BaseEnumeration
|
||||||
|
{
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$paths = TemplatePath::all(['id', 'path']);
|
||||||
|
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
self::push($path->id, $path->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: michal
|
||||||
|
* Date: 18.2.16
|
||||||
|
* Time: 10:33
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Templates\TemplatePath;
|
||||||
|
|
||||||
|
class TemplatePathsHumanReadable extends BaseEnumeration
|
||||||
|
{
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$paths = TemplatePath::all(['id', 'name']);
|
||||||
|
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
self::push($path->id, $path->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: michal
|
||||||
|
* Date: 18.2.16
|
||||||
|
* Time: 10:33
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Templates\TemplatePath;
|
||||||
|
|
||||||
|
class TemplatePathsHumanReadableRootOnly extends BaseEnumeration
|
||||||
|
{
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$paths = TemplatePath::where('parent_id', null)
|
||||||
|
->select(['id', 'name'])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
self::push($path->id, $path->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: michal
|
||||||
|
* Date: 18.2.16
|
||||||
|
* Time: 15:50
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Templates\Template;
|
||||||
|
|
||||||
|
class Templates extends BaseEnumeration
|
||||||
|
{
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$templates = Template::all(['id', 'template_name']);
|
||||||
|
|
||||||
|
foreach ($templates as $template) {
|
||||||
|
self::push($template->id, $template->template_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Enumerations;
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -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;
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@ class UserStates extends BaseEnumeration
|
|||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
||||||
$items = [
|
$items = [
|
||||||
User::STATE_DELETED => 'admin/userManagement.status_' . User::STATE_DELETED,
|
|
||||||
User::STATE_BLOCKED => 'admin/userManagement.status_' . User::STATE_BLOCKED,
|
User::STATE_BLOCKED => 'admin/userManagement.status_' . User::STATE_BLOCKED,
|
||||||
User::STATE_ACTIVE => 'admin/userManagement.status_' . User::STATE_ACTIVE
|
User::STATE_ACTIVE => 'admin/userManagement.status_' . User::STATE_ACTIVE
|
||||||
];
|
];
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Widgets\WidgetType;
|
||||||
|
|
||||||
|
class WidgetTypes extends BaseEnumeration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Init list of all installed modules
|
||||||
|
*
|
||||||
|
* @throws Exceptions\EnumerationExistsException
|
||||||
|
*/
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$widgets = WidgetType::all(['id', 'name']);
|
||||||
|
|
||||||
|
foreach ($widgets as $widget) {
|
||||||
|
self::push($widget->id, $widget->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Enumerations;
|
||||||
|
|
||||||
|
use App\Models\Widgets\WidgetType;
|
||||||
|
|
||||||
|
class WidgetTypesWithHandlers extends BaseEnumeration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Init list of all installed modules
|
||||||
|
*
|
||||||
|
* @throws Exceptions\EnumerationExistsException
|
||||||
|
*/
|
||||||
|
protected static function init()
|
||||||
|
{
|
||||||
|
$modules = WidgetType::all(['handler', 'name']);
|
||||||
|
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
self::push($module->handler, $module->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Widgets\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class MissingParameterException extends \Exception
|
||||||
|
{
|
||||||
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
|
{
|
||||||
|
$message = trans('admin/widgets.missingValue', ['field' => $message]);
|
||||||
|
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Widgets\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class WidgetExistsException extends \Exception
|
||||||
|
{
|
||||||
|
public function __construct($message = "", $code = 0, Exception $previous = null)
|
||||||
|
{
|
||||||
|
$message = trans('admin/widgets.widgetExists', ['id' => $message]);
|
||||||
|
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Modules\BaseModuleHandler;
|
||||||
|
use App\CMS\Enumerations\TemplatePathsHumanReadableRootOnly;
|
||||||
|
use App\CMS\Enumerations\WidgetTypes;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
// $menu->route('admin.dashboard', trans('admin/mainMenu.dashboard'), [], 10, ['icon' => 'fa fa-fw fa-dashboard']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content pages
|
||||||
|
*
|
||||||
|
* Submenus can be registered later
|
||||||
|
*/
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.contentPages'), function ($sub) {
|
||||||
|
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 10000, ['icon' => 'fa fa-fw fa-list']);
|
||||||
|
}, 20, ['icon' => 'fa fa-fw fa-database']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File manager
|
||||||
|
*/
|
||||||
|
$menu->route('upload.overview', trans('admin/mainMenu.fileManager'), [], 40, ['icon' => 'fa fa-fw fa-folder']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Widgets and widget areas
|
||||||
|
*/
|
||||||
|
$menu->dropdown(trans('admin/mainMenu.widgets'), function ($sub) {
|
||||||
|
// create list of all widget types
|
||||||
|
$widgets = WidgetTypes::getWithTranslations();
|
||||||
|
|
||||||
|
if (!empty($widgets)) {
|
||||||
|
$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']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sub->route('widgets.overview', trans('admin/mainMenu.widgetsOverview'), [], 20, ['icon' => 'fa fa-fw fa-list']);
|
||||||
|
|
||||||
|
// menu for widget areas
|
||||||
|
$sub->dropdown(trans('admin/mainMenu.widgetAreas'), function ($sub) {
|
||||||
|
$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) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User management
|
||||||
|
*/
|
||||||
|
$sub->dropdown(trans('admin/mainMenu.userManagement'), function ($sub) {
|
||||||
|
$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
|
||||||
|
*/
|
||||||
|
$templatePaths = TemplatePathsHumanReadableRootOnly::getWithTranslations();
|
||||||
|
if (!empty($templatePaths)) {
|
||||||
|
$sub->dropdown(trans('admin/mainMenu.templates'), function ($sub) use ($templatePaths) {
|
||||||
|
$i = 1;
|
||||||
|
foreach ($templatePaths as $id => $name) {
|
||||||
|
$sub->route('templates.overview', $name, ['id' => $id], $i++);
|
||||||
|
}
|
||||||
|
}, 60, ['icon' => 'fa fa-fw fa-file-code-o']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sub->route('log.overview', trans('admin/mainMenu.actionLog'), [], 70, ['icon' => 'fa fa-fw fa-history']);
|
||||||
|
$sub->route('settings.overview', trans('admin/mainMenu.settings'), [], 80, ['icon' => 'fa fa-fw fa-gear']);
|
||||||
|
}, 10000, ['icon' => 'fa fa-fw fa-gears']);
|
||||||
|
});
|
||||||
|
|
||||||
|
// create menu with user profile
|
||||||
|
\Menu::create('profileMenu', function ($menu) {
|
||||||
|
$menu->route('users.detail', trans('admin/userManagement.profile'), [], 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']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Modules\AppHandler;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Handler
|
||||||
|
*
|
||||||
|
* Handler is a class which handles module-specific behaviour which cannot be done by module itself, resp. cannot be
|
||||||
|
* done by some abstract magic.
|
||||||
|
*
|
||||||
|
* @package App\CMS\Handlers\
|
||||||
|
*/
|
||||||
|
abstract class Handler extends BaseHandler implements AppHandler
|
||||||
|
{
|
||||||
|
public static function getHistoryHandler()
|
||||||
|
{
|
||||||
|
return History::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getExtendedFormSections()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'basicInfo' => trans('admin/contents.basicInfo'),
|
||||||
|
'meta' => trans('admin/contents.metaOptions'),
|
||||||
|
'publication' => trans('admin/contents.publicationOptions'),
|
||||||
|
'appearance' => trans('admin/contents.appearance'),
|
||||||
|
'files' => trans('admin/contents.files')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getExtendedFormInputsCreate()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'basicInfo' => 'admin.content.formParts.basicInformation',
|
||||||
|
'meta' => 'admin.content.formParts.metaInformation',
|
||||||
|
'publication' => 'admin.content.formParts.publicationSetup',
|
||||||
|
'appearance' => 'admin.content.formParts.appearance',
|
||||||
|
'files' => 'admin.content.formParts.files'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getExtendedFormInputsEdit()
|
||||||
|
{
|
||||||
|
return self::getExtendedFormInputsCreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers;
|
||||||
|
|
||||||
|
use App\CMS\Enumerations\ContentStatuses;
|
||||||
|
use App\CMS\Handlers\Contracts\HistoryHandler;
|
||||||
|
use App\CMS\Helpers\Differ;
|
||||||
|
|
||||||
|
class History implements HistoryHandler
|
||||||
|
{
|
||||||
|
public static function parseColumnName($column)
|
||||||
|
{
|
||||||
|
return trans('admin/history.column' . ucfirst($column));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function parseChangedValue($changeset)
|
||||||
|
{
|
||||||
|
switch ($changeset->column) {
|
||||||
|
case 'pageContent':
|
||||||
|
$route = route('history.diff', [
|
||||||
|
'revision' => $changeset->edit_batch,
|
||||||
|
'id' => $changeset->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
return "(<a href='" . $route . "'>" . trans('admin/history.diff') . "</a>)";
|
||||||
|
break;
|
||||||
|
case 'metaDescription':
|
||||||
|
return Differ::htmlDiff($changeset->old_value, $changeset->new_value);
|
||||||
|
break;
|
||||||
|
case 'file':
|
||||||
|
if (!$changeset->old_value) {
|
||||||
|
// old value is null -> new file was uploaded
|
||||||
|
return trans('admin/history.uploadedFile', ['file' => $changeset->new_value]);
|
||||||
|
} else {
|
||||||
|
return trans('admin/history.deletedFile', ['file' => $changeset->old_value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'status':
|
||||||
|
$statuses = ContentStatuses::getWithTranslations();
|
||||||
|
|
||||||
|
return trans('admin/history.changedFromTo', [
|
||||||
|
'from' => $statuses[$changeset->old_value],
|
||||||
|
'to' => $statuses[$changeset->new_value]
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
case 'isHomepage':
|
||||||
|
return trans('admin/history.setupAsHomepage');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return trans('admin/history.changedFromTo', [
|
||||||
|
'from' => is_null($changeset->old_value) ? trans('admin/history.emptyValue') : $changeset->old_value,
|
||||||
|
'to' => is_null($changeset->new_value) ? trans('admin/history.emptyValue') : $changeset->new_value,
|
||||||
|
]);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Registrators\Items;
|
||||||
|
|
||||||
|
class SettingExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string human readable ID of settings section (used e.g. as ID parameter in html)
|
||||||
|
*/
|
||||||
|
protected $id;
|
||||||
|
/**
|
||||||
|
* @var string translations string used for describing briefly settings section
|
||||||
|
*/
|
||||||
|
protected $name;
|
||||||
|
/**
|
||||||
|
* @var string view used for rendering given settings part
|
||||||
|
*/
|
||||||
|
protected $view;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SettingExtension constructor.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param string $name
|
||||||
|
* @param string $view
|
||||||
|
*/
|
||||||
|
public function __construct($id, $name, $view)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
$this->name = $name;
|
||||||
|
$this->view = $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getView()
|
||||||
|
{
|
||||||
|
return $this->view;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
|
use App\CMS\Widgets\Contracts\MenuExtensionHandler;
|
||||||
|
|
||||||
|
class MenuExtensionRegistrator {
|
||||||
|
|
||||||
|
protected $menuExtensions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param MenuExtensionHandler $handler
|
||||||
|
*/
|
||||||
|
public function register(MenuExtensionHandler $handler) {
|
||||||
|
$this->menuExtensions[] = $handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(){
|
||||||
|
return $this->menuExtensions;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
|
use App\CMS\Enumerations\Exceptions\EnumerationExistsException;
|
||||||
|
use App\CMS\Handlers\Contracts\SearchHandler;
|
||||||
|
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
||||||
|
use App\CMS\Handlers\Registrators\Items\SearchEngine;
|
||||||
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
|
class SearchEngineRegistrator
|
||||||
|
{
|
||||||
|
const ADMIN = 'admin';
|
||||||
|
const VISITOR = 'visitor';
|
||||||
|
protected $searchEngines;
|
||||||
|
|
||||||
|
function __construct($app)
|
||||||
|
{
|
||||||
|
$this->searchEngines = [
|
||||||
|
self::ADMIN => [],
|
||||||
|
self::VISITOR => []
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method for registering new settings extensions/parts
|
||||||
|
*
|
||||||
|
* @param SearchHandler $search
|
||||||
|
* @param SearchPresenterHandler $presenter
|
||||||
|
*
|
||||||
|
* @param $type
|
||||||
|
*
|
||||||
|
* @throws EnumerationExistsException
|
||||||
|
*/
|
||||||
|
public function register(SearchHandler $search, SearchPresenterHandler $presenter, $type)
|
||||||
|
{
|
||||||
|
$this->checkIfRegistered($type, $search->getId());
|
||||||
|
|
||||||
|
// register new extension
|
||||||
|
$this->searchEngines[$type][$search->getId()] = [$search, $presenter];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for all registered extensions
|
||||||
|
*
|
||||||
|
* @param $type
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get($type)
|
||||||
|
{
|
||||||
|
if (!isset($this->searchEngines[$type])) {
|
||||||
|
throw new InvalidArgumentException('Invalid type ' . $type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->searchEngines[$type];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this section is not already defined
|
||||||
|
*
|
||||||
|
* @param $type
|
||||||
|
* @param $id
|
||||||
|
*
|
||||||
|
* @throws EnumerationExistsException
|
||||||
|
*/
|
||||||
|
private function checkIfRegistered($type, $id)
|
||||||
|
{
|
||||||
|
if (isset($this->searchEngines[$type][$id])) {
|
||||||
|
throw new EnumerationExistsException('Already existing search engine ' . $id . ' in ' . $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
|
use App\CMS\Enumerations\Exceptions\EnumerationExistsException;
|
||||||
|
use App\CMS\Handlers\Registrators\Items\SettingExtension;
|
||||||
|
|
||||||
|
class SettingsExtensionRegistrator
|
||||||
|
{
|
||||||
|
protected $settingsExtensions;
|
||||||
|
|
||||||
|
function __construct($app)
|
||||||
|
{
|
||||||
|
$this->settingsExtensions = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method for registering new settings extensions/parts
|
||||||
|
*
|
||||||
|
* @param $sectionId
|
||||||
|
* @param $sectionName
|
||||||
|
* @param $sectionView
|
||||||
|
*
|
||||||
|
* @throws EnumerationExistsException
|
||||||
|
*/
|
||||||
|
public function register($sectionId, $sectionName, $sectionView)
|
||||||
|
{
|
||||||
|
$this->checkIfRegistered($sectionId);
|
||||||
|
|
||||||
|
// register new extension
|
||||||
|
$this->settingsExtensions[$sectionId] = new SettingExtension($sectionId, $sectionName, $sectionView);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers new setting part - only as SettingExtension directly
|
||||||
|
*
|
||||||
|
* @param SettingExtension $extension
|
||||||
|
*/
|
||||||
|
public function registerObject(SettingExtension $extension)
|
||||||
|
{
|
||||||
|
$this->checkIfRegistered($extension->getId());
|
||||||
|
|
||||||
|
$this->settingsExtensions[$extension->getId()] = $extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for all registered extensions
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
// sort registered extensions by key
|
||||||
|
ksort($this->settingsExtensions);
|
||||||
|
|
||||||
|
return $this->settingsExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this section is not already defined
|
||||||
|
*
|
||||||
|
* @param $sectionId
|
||||||
|
*
|
||||||
|
* @throws EnumerationExistsException
|
||||||
|
*/
|
||||||
|
private function checkIfRegistered($sectionId)
|
||||||
|
{
|
||||||
|
if (isset($this->settingsExtensions[$sectionId])) {
|
||||||
|
throw new EnumerationExistsException('Already existing key ' . $sectionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,319 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Repositories\Template;
|
||||||
|
use App\CMS\Enumerations\TemplatePaths;
|
||||||
|
use App\CMS\Enumerations\Templates;
|
||||||
|
use App\Models\Templates\Template as TemplateModel;
|
||||||
|
use App\Models\Templates\TemplatePath;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
|
class TemplateRegistrator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string absolute path to base directory of registered template paths
|
||||||
|
*/
|
||||||
|
protected $baseDirectory;
|
||||||
|
/**
|
||||||
|
* @var string namespace of registered templates
|
||||||
|
*/
|
||||||
|
protected $namespace;
|
||||||
|
/**
|
||||||
|
* @var string absolute path to currently registered directory
|
||||||
|
* This variable is set in register() method as $baseDirectory/$path
|
||||||
|
*/
|
||||||
|
protected $registeredPath;
|
||||||
|
/**
|
||||||
|
* @var int ID of module
|
||||||
|
*/
|
||||||
|
protected $moduleId;
|
||||||
|
/**
|
||||||
|
* @var array list of all registered template paths
|
||||||
|
*/
|
||||||
|
protected $paths = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set base path
|
||||||
|
*
|
||||||
|
* @param mixed $baseDirectory
|
||||||
|
*/
|
||||||
|
public function setBaseDirectory($baseDirectory)
|
||||||
|
{
|
||||||
|
$baseDirectory = str_replace('/', DIRECTORY_SEPARATOR, $baseDirectory);
|
||||||
|
$baseDirectory = base_path($baseDirectory);
|
||||||
|
$baseDirectory = rtrim($baseDirectory, DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
|
if (!is_dir($baseDirectory)) {
|
||||||
|
throw new InvalidArgumentException('Invalid path ' . $baseDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->baseDirectory = $baseDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set module ID for registered path
|
||||||
|
*
|
||||||
|
* @param int $moduleId
|
||||||
|
*/
|
||||||
|
public function setModuleId($moduleId)
|
||||||
|
{
|
||||||
|
$this->moduleId = $moduleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set namespace for registered template path
|
||||||
|
*
|
||||||
|
* @param string $namespace
|
||||||
|
*/
|
||||||
|
public function setNamespace($namespace)
|
||||||
|
{
|
||||||
|
$this->namespace = $namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets namespace
|
||||||
|
*/
|
||||||
|
public function unsetNamespace()
|
||||||
|
{
|
||||||
|
$this->namespace = null;
|
||||||
|
$this->setModuleId(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers new template path.
|
||||||
|
* This method registeres given path itself with all subdirectories
|
||||||
|
*
|
||||||
|
* @param $baseDirectory
|
||||||
|
* @param string $path path relatively to root of the project
|
||||||
|
* @param string $name human readable identification of given template path
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function register($baseDirectory, $path, $name)
|
||||||
|
{
|
||||||
|
$this->paths[] = [
|
||||||
|
'namespace' => $this->namespace,
|
||||||
|
'moduleId' => $this->moduleId,
|
||||||
|
'baseDirectory' => $baseDirectory,
|
||||||
|
'path' => $this->baseDirectory . DIRECTORY_SEPARATOR . $path,
|
||||||
|
'name' => $name
|
||||||
|
];
|
||||||
|
$this->unsetNamespace();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save templates into database
|
||||||
|
*/
|
||||||
|
public function saveTemplates()
|
||||||
|
{
|
||||||
|
if (!is_array($this->paths) || empty($this->paths)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->paths as $path) {
|
||||||
|
if (!empty($path['namespace'])) {
|
||||||
|
$this->setNamespace($path['namespace'] . '::');
|
||||||
|
}
|
||||||
|
$this->setModuleId($path['moduleId']);
|
||||||
|
$this->setBaseDirectory($path['baseDirectory']);
|
||||||
|
|
||||||
|
$this->registeredPath = $this->baseDirectory . DIRECTORY_SEPARATOR . $path['path'];
|
||||||
|
// register path
|
||||||
|
$this->registerPath($this->registeredPath, $path['name']);
|
||||||
|
$this->unsetNamespace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get relative path to project root
|
||||||
|
*
|
||||||
|
* @param $directory
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function relativePath($directory)
|
||||||
|
{
|
||||||
|
$directory = str_replace('/', DIRECTORY_SEPARATOR, $directory);
|
||||||
|
$directory = str_replace('\\', DIRECTORY_SEPARATOR, $directory);
|
||||||
|
|
||||||
|
return trim(str_replace(base_path(), '', $directory), '\\/');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crawl subdirectories and register them
|
||||||
|
*
|
||||||
|
* @param string $directory path relative to $baseDirectory variable
|
||||||
|
* @param string $name name of parent directory
|
||||||
|
*/
|
||||||
|
protected function scanForSubdirectories($directory, $name)
|
||||||
|
{
|
||||||
|
if (!is_dir($directory)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$directories = File::directories($directory);
|
||||||
|
|
||||||
|
foreach ($directories as $dir) {
|
||||||
|
$base = basename($dir);
|
||||||
|
$name = preg_replace('/\.(.+)/', '.' . $base, $name);
|
||||||
|
|
||||||
|
$this->registerPath($dir, $name, $directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers template path and templates into system
|
||||||
|
*
|
||||||
|
* @param string $path relative path to $baseDirectory variable
|
||||||
|
* @param string $name human readable name of this path (used in overview)
|
||||||
|
* @param null|string $parent path to parent directory
|
||||||
|
*/
|
||||||
|
protected function registerPath($path, $name, $parent = null)
|
||||||
|
{
|
||||||
|
// skip custom directories (contains updated templates only)
|
||||||
|
$dirName = basename($path);
|
||||||
|
$ignoredDirectories = [
|
||||||
|
Template::EDITED_TEMPLATES_DIRECTORY,
|
||||||
|
Template::ASSETS_DIRECTORY,
|
||||||
|
Template::MODULES_DIRECTORY
|
||||||
|
];
|
||||||
|
|
||||||
|
if (in_array($dirName, $ignoredDirectories)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save template path into database
|
||||||
|
$templatePathId = $this->saveTemplatePath($path, $name, $parent);
|
||||||
|
|
||||||
|
// save all templates into database
|
||||||
|
$this->registerTemplates($path, $templatePathId);
|
||||||
|
|
||||||
|
// try to find some subdirectories and other templates
|
||||||
|
$this->scanForSubdirectories($path, $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers all templates
|
||||||
|
* This method takes all templates in given directory and registers them into database. Templates registered in
|
||||||
|
* this way may be used for further manipulation.
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param $templatePathId
|
||||||
|
*
|
||||||
|
* @throws \App\CMS\Enumerations\Exceptions\EnumerationExistsException
|
||||||
|
*/
|
||||||
|
protected function registerTemplates($path, $templatePathId)
|
||||||
|
{
|
||||||
|
$templates = File::files($path);
|
||||||
|
|
||||||
|
foreach ($templates as $template) {
|
||||||
|
|
||||||
|
// skip all non-template files - we assume that every file with suffix ".blade.php" is Blade template
|
||||||
|
if (!Str::endsWith($template, Template::TEMPLATE_SUFFIX)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all templates and template name (path/to/template.blade.php -> path.to.template)
|
||||||
|
$templateName = $this->getTemplateName($template);
|
||||||
|
$registeredTemplates = Templates::getWithTranslations();
|
||||||
|
|
||||||
|
if (!in_array($templateName, $registeredTemplates)) {
|
||||||
|
$params = [
|
||||||
|
'template_name' => $templateName,
|
||||||
|
'name' => $templateName,
|
||||||
|
'path' => $templatePathId,
|
||||||
|
'module_id' => $this->moduleId,
|
||||||
|
'description' => '',
|
||||||
|
'editable' => 1
|
||||||
|
];
|
||||||
|
|
||||||
|
// save template into database
|
||||||
|
$newTemplate = TemplateModel::create($params);
|
||||||
|
|
||||||
|
// push template into enumeration - so it will not be registered again
|
||||||
|
Templates::push($newTemplate->id, $templateName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save template into database and return its ID
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
* @param $name
|
||||||
|
* @param null $parent
|
||||||
|
*
|
||||||
|
* @return mixed|null
|
||||||
|
* @throws \App\CMS\Enumerations\Exceptions\EnumerationExistsException
|
||||||
|
*/
|
||||||
|
protected function saveTemplatePath($path, $name, $parent = null)
|
||||||
|
{
|
||||||
|
$registeredPaths = TemplatePaths::getWithTranslations();
|
||||||
|
$relativePath = $this->relativePath($path);
|
||||||
|
|
||||||
|
if (!in_array($relativePath, $registeredPaths)) {
|
||||||
|
$parentId = $this->getId($this->relativePath($parent));
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'path' => $relativePath,
|
||||||
|
'name' => $name,
|
||||||
|
'namespace' => $this->namespace,
|
||||||
|
'parent_id' => $parentId
|
||||||
|
];
|
||||||
|
|
||||||
|
// save into database
|
||||||
|
$path = TemplatePath::create($params);
|
||||||
|
|
||||||
|
// add to enumeration
|
||||||
|
TemplatePaths::push($path->id, $relativePath);
|
||||||
|
|
||||||
|
return $path->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getId($relativePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ID of registered template
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
*
|
||||||
|
* @return null|int null when parent not found, ID of parent otherwise
|
||||||
|
*/
|
||||||
|
private function getId($path)
|
||||||
|
{
|
||||||
|
// get registered paths
|
||||||
|
$paths = TemplatePaths::getWithTranslations();
|
||||||
|
$paths = array_flip($paths);
|
||||||
|
|
||||||
|
if (is_null($path) || !isset($paths[$path])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $paths[$path];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get template name
|
||||||
|
* Converts path to template to corresponding name
|
||||||
|
*
|
||||||
|
* @param $template
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getTemplateName($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(Template::TEMPLATE_SUFFIX, '', $templateName);
|
||||||
|
$templateName = preg_replace('/\.{2,}/', '.', $templateName);
|
||||||
|
|
||||||
|
return $this->namespace . trim($templateName, '.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Registrators;
|
||||||
|
|
||||||
|
use App\CMS\Enumerations\WidgetTypesWithHandlers;
|
||||||
|
use App\Models\Widgets\WidgetType;
|
||||||
|
|
||||||
|
class WidgetRegistrator
|
||||||
|
{
|
||||||
|
protected $registeredWidgets = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method used for registering new widgets
|
||||||
|
*
|
||||||
|
* @param $classname
|
||||||
|
* @param null $templateId
|
||||||
|
* @param null $moduleId
|
||||||
|
*/
|
||||||
|
public function register($classname, $templateId = null, $moduleId = null)
|
||||||
|
{
|
||||||
|
$this->registeredWidgets[] = [
|
||||||
|
'class' => $classname,
|
||||||
|
'templateId' => $templateId,
|
||||||
|
'moduleId' => $moduleId
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install all non-installed widgets
|
||||||
|
*/
|
||||||
|
public function installWidgets()
|
||||||
|
{
|
||||||
|
$installed = WidgetTypesWithHandlers::getSimple();
|
||||||
|
foreach ($this->registeredWidgets as $registeredWidget) {
|
||||||
|
$classname = $registeredWidget['class'];
|
||||||
|
$templateId = $registeredWidget['templateId'];
|
||||||
|
$moduleId = $registeredWidget['moduleId'];
|
||||||
|
|
||||||
|
// register widget as new widget type
|
||||||
|
if (!in_array($classname, $installed)) {
|
||||||
|
$widgetName = call_user_func($classname . '::getName');
|
||||||
|
$widgetDescription = call_user_func($classname . '::getDescription');
|
||||||
|
|
||||||
|
// create row in widget types
|
||||||
|
WidgetType::create([
|
||||||
|
'handler' => $classname,
|
||||||
|
'name' => $widgetName,
|
||||||
|
'module_id' => $moduleId,
|
||||||
|
'template_id' => $templateId,
|
||||||
|
'description' => $widgetDescription
|
||||||
|
]);
|
||||||
|
|
||||||
|
// install widget (if neccessary)
|
||||||
|
if (is_callable([$classname, 'install'])) {
|
||||||
|
call_user_func($classname . '::install');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Search;
|
||||||
|
|
||||||
|
use App\Models\Content\Content as ContentModel;
|
||||||
|
|
||||||
|
class Content extends Search
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Search for given patttern/term
|
||||||
|
*
|
||||||
|
* @param string $term searched word
|
||||||
|
*
|
||||||
|
* @return array list of found objects
|
||||||
|
*/
|
||||||
|
public function search($term)
|
||||||
|
{
|
||||||
|
$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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Search;
|
||||||
|
|
||||||
|
use App\Models\FileManager\File;
|
||||||
|
|
||||||
|
class Files extends Search
|
||||||
|
{
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return "files";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return trans('search.files');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for given patttern/term
|
||||||
|
*
|
||||||
|
* @param string $term searched word
|
||||||
|
*
|
||||||
|
* @return array list of found objects
|
||||||
|
*/
|
||||||
|
public function search($term)
|
||||||
|
{
|
||||||
|
$token = $this->tokenize($term);
|
||||||
|
|
||||||
|
return File::where('original_filename', 'LIKE', $token)
|
||||||
|
->orWhere('name', 'LIKE', $token)
|
||||||
|
->orWhere('keywords', 'LIKE', $token)
|
||||||
|
->orWhere('description', 'LIKE', $token)
|
||||||
|
->orWhere('mime_type', 'LIKE', $token)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Search\Presenters;
|
||||||
|
|
||||||
|
use App\CMS\Enumerations\ContentStatuses;
|
||||||
|
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
||||||
|
|
||||||
|
class AdminContent implements SearchPresenterHandler
|
||||||
|
{
|
||||||
|
public function render($foundItems)
|
||||||
|
{
|
||||||
|
return view('admin.search.results.content', [
|
||||||
|
'pages' => $foundItems,
|
||||||
|
'statuses' => ContentStatuses::getWithTranslations(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Search\Presenters;
|
||||||
|
|
||||||
|
use App\CMS\Handlers\Contracts\SearchPresenterHandler;
|
||||||
|
|
||||||
|
class AdminFiles implements SearchPresenterHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method for rendering list of found results
|
||||||
|
*
|
||||||
|
* @param $foundItems
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function render($foundItems)
|
||||||
|
{
|
||||||
|
return view('admin.fileManager.filesTiles', ['files' => $foundItems, 'hideDelete' => true]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Handlers\Search;
|
||||||
|
|
||||||
|
use App\CMS\Handlers\Contracts\SearchHandler;
|
||||||
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
|
abstract class Search implements SearchHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Tokenize string for usage in LIKE clausules
|
||||||
|
*
|
||||||
|
* @param $term
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function tokenize($term)
|
||||||
|
{
|
||||||
|
$term = trim($term);
|
||||||
|
|
||||||
|
if (empty($term)) {
|
||||||
|
throw new InvalidArgumentException(trans('search.emptyString'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return '%' . str_replace(' ', '%', $term) . '%';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Modules\TemplateHandler;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
use App\Models\Module;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
|
class CurrentTemplate implements TemplateHandler
|
||||||
|
{
|
||||||
|
protected static $template;
|
||||||
|
protected static $initialized = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for currently set template
|
||||||
|
* @return Module
|
||||||
|
* @throws \ErrorException
|
||||||
|
*/
|
||||||
|
public static function get()
|
||||||
|
{
|
||||||
|
if (!self::$initialized) {
|
||||||
|
self::$template = Cache::rememberForever('current-template', function () {
|
||||||
|
$template = Module::where('is_template', true)
|
||||||
|
->where('enabled', true)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
// todo remove after adding $casts into Module model
|
||||||
|
if ($template) {
|
||||||
|
$template->module_settings = json_decode($template->module_settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
self::$initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$template;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for getting template handler
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws \ErrorException
|
||||||
|
*/
|
||||||
|
public static function handler()
|
||||||
|
{
|
||||||
|
$template = self::get();
|
||||||
|
|
||||||
|
if (!$template) {
|
||||||
|
throw new \ErrorException('No template selected, no handler available!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template->handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset currently set template and load another one on next call of get() method.
|
||||||
|
*/
|
||||||
|
public static function reset()
|
||||||
|
{
|
||||||
|
self::$initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register admin menu (or multiple ones)
|
||||||
|
*
|
||||||
|
* This cannot be in ServiceProvider because Session is started at middleware. And ServiceProvider is called before
|
||||||
|
* starting any middleware..
|
||||||
|
*
|
||||||
|
* @param User $user model of logged user
|
||||||
|
*/
|
||||||
|
public static function registerAdminMenu(User $user)
|
||||||
|
{
|
||||||
|
call_user_func_array([self::handler(), 'registerAdminMenu'], [$user]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of registered templates and supported modules.
|
||||||
|
*
|
||||||
|
* Returned array is expected to be array of arrays with following items: module, namespace and templateName.
|
||||||
|
* Example:
|
||||||
|
* return [
|
||||||
|
* ['module' => 'Article', 'templateName' => 'article::template.name']
|
||||||
|
* ];
|
||||||
|
*
|
||||||
|
* When no "namespace" is specified, value strtolower(module) is used instaed.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getPublicTemplatePaths()
|
||||||
|
{
|
||||||
|
return call_user_func([self::handler(), 'getPublicTemplatePaths']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
class Date
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dateFormatted($format, $datestamp)
|
||||||
|
{
|
||||||
|
$timestamp = strtotime($datestamp);
|
||||||
|
|
||||||
|
if ($timestamp <= 0) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return date($format, $timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function monthName($datestamp) {
|
||||||
|
$timestamp = strtotime($datestamp);
|
||||||
|
|
||||||
|
if ($timestamp <= 0) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$months = [
|
||||||
|
trans('common.months.january'),
|
||||||
|
trans('common.months.february'),
|
||||||
|
trans('common.months.march'),
|
||||||
|
trans('common.months.april'),
|
||||||
|
trans('common.months.may'),
|
||||||
|
trans('common.months.june'),
|
||||||
|
trans('common.months.july'),
|
||||||
|
trans('common.months.august'),
|
||||||
|
trans('common.months.semptember'),
|
||||||
|
trans('common.months.october'),
|
||||||
|
trans('common.months.november'),
|
||||||
|
trans('common.months.december'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$monthNumber = date('n', $timestamp);
|
||||||
|
|
||||||
|
return $months[$monthNumber - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Paul's Simple Differ Algorithm v 0.1
|
||||||
|
(C) Paul Butler 2007 <http://www.paulbutler.org/>
|
||||||
|
May be used and distributed under the zlib/libpng license.
|
||||||
|
|
||||||
|
This code is intended for learning purposes; it was written with short
|
||||||
|
code taking priority over performance. It could be used in a practical
|
||||||
|
application, but there are a few ways it could be optimized.
|
||||||
|
|
||||||
|
Given two arrays, the function diff will return an array of the changes.
|
||||||
|
I won't describe the format of the array, but it will be obvious
|
||||||
|
if you use print_r() on the result of a diff on some test data.
|
||||||
|
|
||||||
|
htmlDiff is a wrapper for the diff command, it takes two strings and
|
||||||
|
returns the differences in HTML. The tags used are <ins> and <del>,
|
||||||
|
which can easily be styled with CSS.
|
||||||
|
|
||||||
|
@url https://github.com/paulgb/simplediff/blob/master/php/simplediff.php
|
||||||
|
|
||||||
|
Sorry for this kind of magic, I have no idea how this works.. :(
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Differ
|
||||||
|
{
|
||||||
|
public static function diff($old, $new)
|
||||||
|
{
|
||||||
|
$matrix = [];
|
||||||
|
$maxlen = 0;
|
||||||
|
foreach ($old as $oindex => $ovalue) {
|
||||||
|
$nkeys = array_keys($new, $ovalue);
|
||||||
|
foreach ($nkeys as $nindex) {
|
||||||
|
$matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ? $matrix[$oindex - 1][$nindex - 1] + 1 : 1;
|
||||||
|
if ($matrix[$oindex][$nindex] > $maxlen) {
|
||||||
|
$maxlen = $matrix[$oindex][$nindex];
|
||||||
|
$omax = $oindex + 1 - $maxlen;
|
||||||
|
$nmax = $nindex + 1 - $maxlen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($maxlen == 0) {
|
||||||
|
return [['d' => $old, 'i' => $new]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_merge(self::diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)), array_slice($new, $nmax, $maxlen), self::diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function htmlDiff($old, $new)
|
||||||
|
{
|
||||||
|
$ret = '';
|
||||||
|
$diff = self::diff(preg_split("/[\s]+/", $old), preg_split("/[\s]+/", $new));
|
||||||
|
foreach ($diff as $k) {
|
||||||
|
if (is_array($k)) {
|
||||||
|
$ret .= (!empty($k['d']) ? "<del>" . implode(' ', $k['d']) . "</del> " : '') . (!empty($k['i']) ? "<ins>" . implode(' ', $k['i']) . "</ins> " : '');
|
||||||
|
} else {
|
||||||
|
$ret .= $k . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
use App\Models\FileManager\File;
|
||||||
|
|
||||||
|
class FileManager
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param File $file
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Routing\UrlGenerator|string
|
||||||
|
*/
|
||||||
|
public static function getPreview(File $file)
|
||||||
|
{
|
||||||
|
list($type, $subtype) = explode('/', $file->mime_type);
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'image':
|
||||||
|
|
||||||
|
$url = Path::thumbnail($file->filename);
|
||||||
|
|
||||||
|
return '<img src="' . $url . '" alt="' . $file->description . '" />';
|
||||||
|
break;
|
||||||
|
case 'text':
|
||||||
|
return self::getIcon($file, 'fa-file-text-o');
|
||||||
|
break;
|
||||||
|
case 'application':
|
||||||
|
switch ($subtype) {
|
||||||
|
case 'pdf':
|
||||||
|
return self::getIcon($file, 'fa-file-pdf-o');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return self::getIcon($file, 'fa-newspaper-o');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return self::getIcon($file, 'fa-question');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for displaying icons
|
||||||
|
*
|
||||||
|
* @param $file
|
||||||
|
* @param $icon
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected static function getIcon($file, $icon)
|
||||||
|
{
|
||||||
|
return '<p><i class="fa fa-2x ' . $icon . '"></i><br /><span>' . e(str_limit($file->original_filename, 15)) . '</span></p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param File $file
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getFormattedSize(File $file)
|
||||||
|
{
|
||||||
|
$bytes = $file->file_size;
|
||||||
|
|
||||||
|
$label = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||||
|
for ($i = 0; $bytes >= 1024 && $i < (count($label) - 1); $bytes /= 1024, $i++) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (round($bytes, 2) . " " . $label[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get preview for file detail
|
||||||
|
*
|
||||||
|
* @param File $file
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Routing\UrlGenerator|string
|
||||||
|
*/
|
||||||
|
public static function getLargePreview(File $file)
|
||||||
|
{
|
||||||
|
list($type, $subtype) = explode('/', $file->mime_type);
|
||||||
|
|
||||||
|
$url = config('app.upload_url') . '/' . $file->filename;
|
||||||
|
$path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->filename;
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'image':
|
||||||
|
return '<img src="' . $url . '" alt="' . $file->description . '" />';
|
||||||
|
break;
|
||||||
|
case 'text':
|
||||||
|
$string = '<pre><code>';
|
||||||
|
$string .= htmlspecialchars(file_get_contents($path));
|
||||||
|
$string .= '</pre></code>';
|
||||||
|
|
||||||
|
return $string;
|
||||||
|
break;
|
||||||
|
case 'application':
|
||||||
|
return '<iframe src = "'.asset('resources/assets/admin/js/viewerJs/').'/#'.Path::upload($file->filename).'" style="width: 100%; height: 50em" allowfullscreen webkitallowfullscreen></iframe>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return self::getPreview($file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param File $file
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getAdditionalInfo(File $file)
|
||||||
|
{
|
||||||
|
list($type, $subtype) = explode('/', $file->mime_type);
|
||||||
|
|
||||||
|
$path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->filename;
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'text':
|
||||||
|
return [trans('admin/fileManager.encoding') => mb_detect_encoding(file_get_contents($path))];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'image':
|
||||||
|
list ($width, $height) = getimagesize($path);
|
||||||
|
return [trans('admin/fileManager.resolution') => $height . ' x ' . $width,];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
class Gravatar
|
||||||
|
{
|
||||||
|
public static function img($email, $size = 50)
|
||||||
|
{
|
||||||
|
return "//www.gravatar.com/avatar/" . md5(strtolower(trim($email))) . "?s=" . $size;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
use App\CMS\Handlers\Contracts\AppHandler;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
use Webwizo\Shortcodes\Facades\Shortcode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PageRenderer
|
||||||
|
*
|
||||||
|
* Simple class for rendering page for visitor
|
||||||
|
*
|
||||||
|
* @package App\CMS\Helpers
|
||||||
|
*/
|
||||||
|
class PageRenderer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Render page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function render(Content $page)
|
||||||
|
{
|
||||||
|
// do something template-specific
|
||||||
|
$parameters = call_user_func_array([CurrentTemplate::handler(), 'beforeRender'], [&$page]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var $handler AppHandler
|
||||||
|
*/
|
||||||
|
$handler = new $page->moduleHandler;
|
||||||
|
|
||||||
|
// render page
|
||||||
|
return $handler->render($page, $parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
|
class Path
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get URL to uploaded file
|
||||||
|
*
|
||||||
|
* @param $filename
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function upload($filename)
|
||||||
|
{
|
||||||
|
// for debug environment check if file exists
|
||||||
|
if (env('APP_DEBUG') && !file_exists(config('app.upload_path') . '/' . $filename)) {
|
||||||
|
throw new NotFoundHttpException('File ' . $filename . ' cannot be found in ' . config('app.upload_path') . '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return url to uploaded file
|
||||||
|
return config('app.upload_url') . '/' . $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function thumbnail($filename)
|
||||||
|
{
|
||||||
|
// try to check if file have thumbnail
|
||||||
|
if (file_exists(config('app.thumbnail_path') . '/' . $filename)) {
|
||||||
|
$url = config('app.thumbnail_url') . '/' . $filename;
|
||||||
|
} else {
|
||||||
|
$url = self::upload($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get path to given asset
|
||||||
|
*
|
||||||
|
* @param $path
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function asset($path)
|
||||||
|
{
|
||||||
|
if (env('APP_DEBUG')) {
|
||||||
|
if (empty($path)) {
|
||||||
|
throw new InvalidArgumentException('No asset name defined!');
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if asset exists and is file
|
||||||
|
if (!file_exists(public_path('assets/' . config('app.theme') . '/' . $path))) {
|
||||||
|
throw new NotFoundHttpException('Cannot find any asset in ' . public_path('assets/' . config('app.theme') . '/' . $path) . '. Try to check your paths.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return config('app.url') . '/assets/' . config('app.theme') . '/' . $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
use App\Models\Settings as SettingsModel;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Settings
|
||||||
|
*
|
||||||
|
* Helper class for easier obtaining system settings
|
||||||
|
*
|
||||||
|
* @package App\CMS\Helpers
|
||||||
|
*/
|
||||||
|
class Settings
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array List of all used settings
|
||||||
|
*/
|
||||||
|
protected static $settings;
|
||||||
|
/**
|
||||||
|
* @var bool Are data already initialized?
|
||||||
|
*/
|
||||||
|
protected static $initialized = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for settings determined with key.
|
||||||
|
*
|
||||||
|
* @param string $key settings key
|
||||||
|
* @param string|null $default default value, which will be returned when given key does not exist
|
||||||
|
*
|
||||||
|
* @param null $exists
|
||||||
|
*
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
public static function get($key, $default = null, & $exists = null)
|
||||||
|
{
|
||||||
|
self::init();
|
||||||
|
|
||||||
|
if (isset(self::$settings->$key)) {
|
||||||
|
$exists = true;
|
||||||
|
self::$initialized = true;
|
||||||
|
return self::$settings->$key;
|
||||||
|
}
|
||||||
|
|
||||||
|
$exists = false;
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for obtaining settings saved as JSON
|
||||||
|
*
|
||||||
|
* @param $key
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getJson($key)
|
||||||
|
{
|
||||||
|
return json_decode(self::get($key, '{}'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all settings
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function all()
|
||||||
|
{
|
||||||
|
self::init();
|
||||||
|
|
||||||
|
return self::$settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize settings array
|
||||||
|
*/
|
||||||
|
private static function init()
|
||||||
|
{
|
||||||
|
if (!self::$initialized) {
|
||||||
|
self::$settings = Cache::remember('settings', config('cache.settingCacheLifetime'), function () {
|
||||||
|
$model = new SettingsModel();
|
||||||
|
return $model->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::parse($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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\CMS\Helpers;
|
||||||
|
|
||||||
|
use App\CMS\Repositories\Widgets\WidgetArea as WidgetAreaRepository;
|
||||||
|
use App\Models\Widgets\WidgetArea;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
|
class WidgetAreas
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array list of inicialized widget areas
|
||||||
|
*/
|
||||||
|
protected static $widgetAreas = [];
|
||||||
|
protected static $initialized = false;
|
||||||
|
|
||||||
|
protected static function saveRenderedWidgetArea($widgets)
|
||||||
|
{
|
||||||
|
foreach ($widgets as $widget) {
|
||||||
|
if (!isset(self::$widgetAreas[$widget->widget_area_code])) {
|
||||||
|
self::$widgetAreas[$widget->widget_area_code] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$widgetAreas[$widget->widget_area_code] .= Widget::render($widget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function loadWidgetArea($uniqueCode)
|
||||||
|
{
|
||||||
|
dd($uniqueCode);
|
||||||
|
WidgetArea::where('code', $uniqueCode)
|
||||||
|
->increment('viewed');
|
||||||
|
|
||||||
|
$widgets = Cache::remember('widget-area-' . $uniqueCode, setting('widgetCacheLifetime', 5), function () use ($uniqueCode) {
|
||||||
|
$widgetArea = new WidgetArea();
|
||||||
|
return $widgetArea->getWidgets($uniqueCode)
|
||||||
|
->get();
|
||||||
|
});
|
||||||
|
|
||||||
|
self::saveRenderedWidgetArea($widgets);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function initWidgetAreas()
|
||||||
|
{
|
||||||
|
if (self::$initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$widgets = Cache::remember('widgets', setting('widgetCacheLifetime', 5), function () {
|
||||||
|
$widgetArea = app(WidgetAreaRepository::class);
|
||||||
|
return $widgetArea->getWidgets()
|
||||||
|
->get();
|
||||||
|
});
|
||||||
|
|
||||||
|
self::saveRenderedWidgetArea($widgets);
|
||||||
|
self::$initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renderer for whole widget area.
|
||||||
|
*
|
||||||
|
* @param $uniqueCode
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function render($uniqueCode)
|
||||||
|
{
|
||||||
|
if (!self::$initialized) {
|
||||||
|
self::initWidgetAreas();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset(self::$widgetAreas[$uniqueCode])) {
|
||||||
|
self::loadWidgetArea($uniqueCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo isset(self::$widgetAreas[$uniqueCode]) ? self::$widgetAreas[$uniqueCode] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Define function for escaping characters.
|
||||||
|
*
|
||||||
|
* This funcion prevents of creating build-in function, which escapes also accents...
|
||||||
|
*
|
||||||
|
* @param $value
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function e($value)
|
||||||
|
{
|
||||||
|
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for \App\CMS\Helpers\Settings::get()
|
||||||
|
*
|
||||||
|
* @param $key
|
||||||
|
* @param null $default
|
||||||
|
*
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
function setting($key, $default = null) {
|
||||||
|
return \App\CMS\Helpers\Settings::get($key, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
function asset_path($path) {
|
||||||
|
return env('SITE_URL').'/assets/'.$path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function template_name($name, $throwExceptions = true) {
|
||||||
|
return \App\CMS\Helpers\Template::name($name, $throwExceptions);
|
||||||
|
}
|
||||||
@@ -0,0 +1,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,65 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Interactions\Admin\FileManager;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Interaction;
|
||||||
|
use App\CMS\Exceptions\FileManager\SubdirectoryExistsInDirectory;
|
||||||
|
use App\CMS\Repositories\FileManager\Directory as DirectoryRepository;
|
||||||
|
use App\Models\FileManager\Directory;
|
||||||
|
|
||||||
|
class CreateDirectory implements Interaction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var DirectoryRepository
|
||||||
|
*/
|
||||||
|
private $repository;
|
||||||
|
|
||||||
|
public function __construct(DirectoryRepository $repository)
|
||||||
|
{
|
||||||
|
$this->repository = $repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform given action
|
||||||
|
*
|
||||||
|
* @param $data array input data
|
||||||
|
* @param $parameters array parameters
|
||||||
|
*
|
||||||
|
* @return Directory
|
||||||
|
* @throws SubdirectoryExistsInDirectory
|
||||||
|
*/
|
||||||
|
public function handle($data, $parameters)
|
||||||
|
{
|
||||||
|
$data['parentDirectory'] = isset($data['parentDirectory']) ? $data['parentDirectory'] : null;
|
||||||
|
|
||||||
|
// todo this should probably go into validation, but we are not able to get $data in getValidationRules
|
||||||
|
// check if created folder does not exist in current directory
|
||||||
|
if ($this->repository->checkIfNameExists($data['name'], $data['parentDirectory'])) {
|
||||||
|
throw new SubdirectoryExistsInDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo use Directory::create() and rename columns/fields in request
|
||||||
|
// create new database entry
|
||||||
|
$directory = new Directory();
|
||||||
|
$directory->name = $data['name'];
|
||||||
|
$directory->parent_id = $data['parentDirectory'];
|
||||||
|
$directory->user_id = \Auth::user()->id;
|
||||||
|
$directory->description = $data['description'];
|
||||||
|
$directory->save();
|
||||||
|
|
||||||
|
return $directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $data array input data
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws SubdirectoryExistsInDirectory
|
||||||
|
*/
|
||||||
|
public function getValidationRules($data = [])
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
'parentDirectory' => 'exists:directories,id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-2
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\MenuPresenters;
|
namespace App\CMS\MenuPresenters;
|
||||||
|
|
||||||
use Pingpong\Menus\MenuItem;
|
use Pingpong\Menus\MenuItem;
|
||||||
use Pingpong\Menus\Presenters\Presenter;
|
use Pingpong\Menus\Presenters\Presenter;
|
||||||
@@ -60,6 +60,11 @@ class FoundationDrilldownMenuPresenter extends Presenter
|
|||||||
return '<li class="divider"></li>' . PHP_EOL;
|
return '<li class="divider"></li>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMultiLevelDropdownWrapper($item)
|
||||||
|
{
|
||||||
|
return $this->getMenuWithDropDownWrapper($item);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc }
|
* {@inheritdoc }
|
||||||
*/
|
*/
|
||||||
@@ -72,6 +77,6 @@ class FoundationDrilldownMenuPresenter extends Presenter
|
|||||||
<ul class="vertical menu">
|
<ul class="vertical menu">
|
||||||
' . $this->getChildMenuItems($item) . '
|
' . $this->getChildMenuItems($item) . '
|
||||||
</ul>
|
</ul>
|
||||||
</li>' . PHP_EOL;;
|
</li>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\MenuPresenters;
|
namespace App\CMS\MenuPresenters;
|
||||||
|
|
||||||
use Pingpong\Menus\Presenters\Presenter;
|
use Pingpong\Menus\Presenters\Presenter;
|
||||||
|
|
||||||
@@ -56,6 +56,6 @@ class FoundationDropdownMenuPresenter extends Presenter
|
|||||||
<ul class="vertical menu">
|
<ul class="vertical menu">
|
||||||
' . $this->getChildMenuItems($item) . '
|
' . $this->getChildMenuItems($item) . '
|
||||||
</ul>
|
</ul>
|
||||||
</li>' . PHP_EOL;;
|
</li>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\MenuPresenters;
|
namespace App\CMS\MenuPresenters;
|
||||||
|
|
||||||
class FoundationInitializedDropdownMenuPresenter extends FoundationDropdownMenuPresenter
|
class FoundationInitializedDropdownMenuPresenter extends FoundationDropdownMenuPresenter
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\MenuPresenters;
|
||||||
|
|
||||||
|
use Pingpong\Menus\MenuItem;
|
||||||
|
use Pingpong\Menus\Presenters\Presenter;
|
||||||
|
|
||||||
|
class MetismenuPresenter extends Presenter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getOpenTagWrapper()
|
||||||
|
{
|
||||||
|
return PHP_EOL . '<ul class="nav metismenu" id="sidebar-menu">' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getCloseTagWrapper()
|
||||||
|
{
|
||||||
|
return PHP_EOL . '</ul>' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getMenuWithoutDropdownWrapper($item)
|
||||||
|
{
|
||||||
|
return '<li' . $this->getActiveState($item) . '><a href="' . $item->getUrl() . '">' . $item->getIcon() . ' ' . $item->title . '</a></li>' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getActiveState(MenuItem $item)
|
||||||
|
{
|
||||||
|
if ($item->isDivider()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$active = ' class="active"';
|
||||||
|
|
||||||
|
if (empty($item->getChilds())) {
|
||||||
|
// for direct menu input return if page is active
|
||||||
|
return \Request::is($item->getRequest()) ? $active : null;
|
||||||
|
} else {
|
||||||
|
// on nested menu inputs loop over children and in case any of them is active, mark active also root level
|
||||||
|
foreach ($item->getChilds() as $child) {
|
||||||
|
if ($this->getActiveState($child)) {
|
||||||
|
return $active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getDividerWrapper()
|
||||||
|
{
|
||||||
|
return '<li class="divider"></li>' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMultiLevelDropdownWrapper($item)
|
||||||
|
{
|
||||||
|
return $this->getMenuWithDropDownWrapper($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getMenuWithDropDownWrapper($item)
|
||||||
|
{
|
||||||
|
$active = $this->getActiveState($item);
|
||||||
|
return '<li' . $active . '>
|
||||||
|
<a href="#">' . $item->getIcon() . ' ' . $item->title . ' <i class="fa arrow"></i></a>
|
||||||
|
<ul>
|
||||||
|
' . $this->getChildMenuItems($item) . '
|
||||||
|
</ul>
|
||||||
|
</li>' . PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\MenuPresenters;
|
||||||
|
|
||||||
|
use Pingpong\Menus\MenuItem;
|
||||||
|
use Pingpong\Menus\Presenters\Presenter;
|
||||||
|
|
||||||
|
class ProfileMenuPresenter extends Presenter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getOpenTagWrapper()
|
||||||
|
{
|
||||||
|
return PHP_EOL . '<div class="dropdown-menu profile-dropdown-menu">' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getCloseTagWrapper()
|
||||||
|
{
|
||||||
|
return PHP_EOL . '</div>' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getMenuWithoutDropdownWrapper($item)
|
||||||
|
{
|
||||||
|
return '<a href="' . $item->getUrl() . '" class="dropdown-item">' . $item->getIcon() . ' ' . $item->title . '</a>' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getActiveState(MenuItem $item)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getDividerWrapper()
|
||||||
|
{
|
||||||
|
return '<div class="dropdown-divider"></div>' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMultiLevelDropdownWrapper($item)
|
||||||
|
{
|
||||||
|
return null;//$this->getMenuWithDropDownWrapper($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc }
|
||||||
|
*/
|
||||||
|
public function getMenuWithDropDownWrapper($item)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Observers;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Repositories\Content as ContentContract;
|
||||||
|
use App\Events\CreateNewContent;
|
||||||
|
use App\Events\DeleteContent;
|
||||||
|
use App\Events\EditContent;
|
||||||
|
use App\Events\MakeDraftFromContent;
|
||||||
|
use App\Events\PublishContent;
|
||||||
|
use App\Events\SetHomepage;
|
||||||
|
use App\Models\Content\Content as ContentModel;
|
||||||
|
use App\Models\Content\ContentHistory;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Content
|
||||||
|
*
|
||||||
|
* Model observer for logging changes on content page.
|
||||||
|
*
|
||||||
|
* @package App\CMS\Observers
|
||||||
|
*/
|
||||||
|
class Content
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $changeset;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->changeset = uniqid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log changes on edit
|
||||||
|
*
|
||||||
|
* @param ContentModel $content
|
||||||
|
*/
|
||||||
|
public function updated(ContentModel $content)
|
||||||
|
{
|
||||||
|
$fields = $this->getDirtyFields($content->getDirty(), $content->getOriginal());
|
||||||
|
|
||||||
|
$normalFieldsEdited = 0;
|
||||||
|
foreach ($fields as $field => $change) {
|
||||||
|
if ($field == 'viewed')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$history = [
|
||||||
|
'user_id' => \Auth::user()->id,
|
||||||
|
'content_id' => $content->id,
|
||||||
|
'edit_batch' => $this->changeset,
|
||||||
|
'column' => $field,
|
||||||
|
'old_value' => $change['old'],
|
||||||
|
'new_value' => $change['new']
|
||||||
|
];
|
||||||
|
|
||||||
|
// save history
|
||||||
|
ContentHistory::create($history);
|
||||||
|
|
||||||
|
// fire event
|
||||||
|
$this->fireEvent($field, $change, $content, $normalFieldsEdited);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($normalFieldsEdited > 0) {
|
||||||
|
Event::fire(new EditContent($content, $this->changeset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire event when new instance of model is stored into database
|
||||||
|
*
|
||||||
|
* @param ContentModel $content
|
||||||
|
*/
|
||||||
|
public function created(ContentModel $content)
|
||||||
|
{
|
||||||
|
Event::fire(new CreateNewContent($content));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ContentModel $content
|
||||||
|
*/
|
||||||
|
public function deleted(ContentModel $content)
|
||||||
|
{
|
||||||
|
Event::fire(new DeleteContent($content));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all dirty changed from model.
|
||||||
|
*
|
||||||
|
* If user did not change moduleSettings column, return result from ContentModel::getDirty(). Otherwise append all
|
||||||
|
* changed columns from module settings.
|
||||||
|
*
|
||||||
|
* @param $changed
|
||||||
|
* @param $original
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getDirtyFields($changed, $original)
|
||||||
|
{
|
||||||
|
unset($changed['updated_at']);
|
||||||
|
|
||||||
|
$changes = $this->getNewAndOldValues(array_keys($changed), $changed, $original);
|
||||||
|
|
||||||
|
if (!isset($changed['moduleSettings'])) {
|
||||||
|
return $changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
$moduleSettings = (array)json_decode($changed['moduleSettings']);
|
||||||
|
$originalSettings = isset($original['moduleSettings']) ? (array)json_decode($original['moduleSettings']) : [];
|
||||||
|
unset($changed['moduleSettings']);
|
||||||
|
|
||||||
|
$settingChanged = array_keys(array_diff_assoc($moduleSettings, $originalSettings));
|
||||||
|
$changesInSettings = $this->getNewAndOldValues($settingChanged, $moduleSettings, $originalSettings);
|
||||||
|
|
||||||
|
return array_merge($changes, $changesInSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get original and changed values in one array
|
||||||
|
*
|
||||||
|
* @param $fields
|
||||||
|
* @param $new
|
||||||
|
* @param $original
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getNewAndOldValues($fields, $new, $original)
|
||||||
|
{
|
||||||
|
$changes = [];
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$changes[$field] = [
|
||||||
|
'new' => isset($new[$field]) ? $new[$field] : null,
|
||||||
|
'old' => isset($original[$field]) ? $original[$field] : null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire events for publishing/making draft and setting homepage
|
||||||
|
*
|
||||||
|
* @param $field
|
||||||
|
* @param $change
|
||||||
|
* @param ContentModel $content
|
||||||
|
* @param $normalFieldsEdited
|
||||||
|
*/
|
||||||
|
protected function fireEvent($field, $change, ContentModel $content, &$normalFieldsEdited)
|
||||||
|
{
|
||||||
|
switch ($field) {
|
||||||
|
case 'status':
|
||||||
|
if ($change['new'] !== ContentContract::STATUS_DRAFT) {
|
||||||
|
Event::fire(new PublishContent($content, $this->changeset));
|
||||||
|
} else {
|
||||||
|
Event::fire(new MakeDraftFromContent($content, $this->changeset));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'isHomepage':
|
||||||
|
Event::fire(new SetHomepage($content, $this->changeset));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$normalFieldsEdited++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Pipeline;
|
||||||
|
|
||||||
|
use App\CMS\Pipeline\Exceptions\InvalidProcessType;
|
||||||
|
|
||||||
|
abstract class AbstractPipeline {
|
||||||
|
protected $processes = [];
|
||||||
|
protected $beforeStart = null;
|
||||||
|
protected $beforeRender = null;
|
||||||
|
protected $acceptedProcessInterface = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if given classname implements valid Process interface
|
||||||
|
*
|
||||||
|
* @param $classname
|
||||||
|
*
|
||||||
|
* @throws InvalidProcessType
|
||||||
|
*/
|
||||||
|
protected function checkValidProcess($classname)
|
||||||
|
{
|
||||||
|
if (is_null($this->acceptedProcessInterface))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!in_array($this->acceptedProcessInterface, class_implements($classname))) {
|
||||||
|
throw new InvalidProcessType($classname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new process into pipeline
|
||||||
|
*
|
||||||
|
* @param $process
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws InvalidProcessType
|
||||||
|
*/
|
||||||
|
function add($process)
|
||||||
|
{
|
||||||
|
$this->checkValidProcess($process);
|
||||||
|
|
||||||
|
$this->processes[] = $process;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param null $beforeStart
|
||||||
|
*/
|
||||||
|
public function setBeforeStart($beforeStart)
|
||||||
|
{
|
||||||
|
$this->checkValidProcess($beforeStart);
|
||||||
|
|
||||||
|
if (!is_null($this->beforeStart)) {
|
||||||
|
array_unshift($this->processes, $this->beforeStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->beforeStart = $beforeStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param null $beforeRender
|
||||||
|
*/
|
||||||
|
public function setBeforeRender($beforeRender)
|
||||||
|
{
|
||||||
|
$this->checkValidProcess($beforeRender);
|
||||||
|
|
||||||
|
if (!is_null($this->beforeRender)) {
|
||||||
|
array_push($this->processes, $this->beforeRender);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->beforeRender = $beforeRender;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Pipeline\DisplayPipeline;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Content\DisplayPipeline\Pipeline;
|
||||||
|
use App\CMS\Contracts\Content\DisplayPipeline\Process;
|
||||||
|
use App\CMS\Pipeline\AbstractPipeline;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
class DisplayPipeline extends AbstractPipeline implements Pipeline
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* DisplayPipeline constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->acceptedProcessInterface = Process::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run pipeline
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
*
|
||||||
|
* @return Content
|
||||||
|
*/
|
||||||
|
function run(Content $page)
|
||||||
|
{
|
||||||
|
$this->runBeforeStart($page);
|
||||||
|
|
||||||
|
foreach ($this->processes as $process) {
|
||||||
|
/**
|
||||||
|
* @var $run Process
|
||||||
|
*/
|
||||||
|
$run = new $process;
|
||||||
|
$run->handle($page);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->runBeforeRender($page);
|
||||||
|
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function runBeforeStart($page)
|
||||||
|
{
|
||||||
|
if (!is_null($this->beforeStart)) {
|
||||||
|
$process = new $this->beforeStart;
|
||||||
|
$process->handle($page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function runBeforeRender($page)
|
||||||
|
{
|
||||||
|
if (!is_null($this->beforeRender)) {
|
||||||
|
$process = new $this->beforeRender;
|
||||||
|
$process->handle($page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Pipeline\DisplayPipeline\Process;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Content\DisplayPipeline\Process;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
class AddViewedToPage implements Process {
|
||||||
|
/**
|
||||||
|
* Process and modify given page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function handle(Content & $page)
|
||||||
|
{
|
||||||
|
$page->view();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Pipeline\DisplayPipeline\Process;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Content\DisplayPipeline\Process;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
use Webwizo\Shortcodes\Facades\Shortcode;
|
||||||
|
|
||||||
|
class CompileShortcodes implements Process {
|
||||||
|
/**
|
||||||
|
* Process and modify given page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function handle(Content & $page)
|
||||||
|
{
|
||||||
|
$page->pageContent = Shortcode::compile($page->pageContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Pipeline\Exceptions;
|
||||||
|
|
||||||
|
class InvalidProcessType extends \Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Pipeline\SavePipeline\Process;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Content\SavePipeline\Process;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
|
||||||
|
class SaveCommonFields implements Process {
|
||||||
|
/**
|
||||||
|
* Process and modify given page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function handle(Content & $page, array &$input)
|
||||||
|
{
|
||||||
|
($page->exists == false) ? $page = Content::create($input): $page->update($input);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Pipeline\SavePipeline\Process;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Content\SavePipeline\Process;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
use App\Models\Content\ContentHasFile;
|
||||||
|
use App\Models\FileManager\Directory;
|
||||||
|
use App\Models\FileManager\File;
|
||||||
|
|
||||||
|
class UploadRelatedFiles implements Process
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Process and modify given page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function handle(Content & $page, array & $input)
|
||||||
|
{
|
||||||
|
$files = $input['files'];
|
||||||
|
$assignedFiles = isset($input['keepAssigned']) ? $input['keepAssigned'] : [];
|
||||||
|
|
||||||
|
// check if any file was removed
|
||||||
|
$this->removeRelatedFiles($page, $assignedFiles);
|
||||||
|
|
||||||
|
// allow uploading only on created pages
|
||||||
|
if (!$page->id || !$files[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find or create new directory for files assigned to content
|
||||||
|
$directory = Directory::firstOrCreate([
|
||||||
|
'name' => '.content_files',
|
||||||
|
'hidden' => true
|
||||||
|
]);
|
||||||
|
$data = new \stdClass();
|
||||||
|
$data->directoryId = $directory->id;
|
||||||
|
|
||||||
|
$fileModel = app(File::class);
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
if (!$file) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$uploaded = $fileModel->upload($file, $data);
|
||||||
|
|
||||||
|
// add assignement
|
||||||
|
ContentHasFile::create([
|
||||||
|
'file_id' => $uploaded['id'],
|
||||||
|
'content_id' => $page->id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete files from association
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
* @param $assignedFiles
|
||||||
|
*/
|
||||||
|
private function removeRelatedFiles(Content $page, $assignedFiles)
|
||||||
|
{
|
||||||
|
$allFiles = $page->files()
|
||||||
|
->whereNotIn('id', array_keys($assignedFiles))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($allFiles as $file) {
|
||||||
|
ContentHasFile::where('content_id', $page->id)
|
||||||
|
->where('file_id', $file->id)
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\CMS\Pipeline\SavePipeline\Process;
|
||||||
|
|
||||||
|
use App\CMS\Contracts\Content\SavePipeline\Process;
|
||||||
|
use App\CMS\Helpers\RootDirectory;
|
||||||
|
use App\Models\Content\Content;
|
||||||
|
use App\Models\FileManager\File;
|
||||||
|
|
||||||
|
class UploadTitlePhoto implements Process
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Process and modify given page
|
||||||
|
*
|
||||||
|
* @param Content $page
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function handle(Content & $page, array & $input)
|
||||||
|
{
|
||||||
|
$fileModel = app(File::class);
|
||||||
|
$titlePhoto = isset($input['titlePhotoFile']) ? $input['titlePhotoFile'] : null;
|
||||||
|
|
||||||
|
// upload file - if provided
|
||||||
|
$page->titlePhoto = isset($input['existingTitlePhoto']) ? $input['existingTitlePhoto'] : null;
|
||||||
|
|
||||||
|
if (!is_null($titlePhoto)) {
|
||||||
|
$root = RootDirectory::get();
|
||||||
|
$data = ['directoryId' => $root->id];
|
||||||
|
|
||||||
|
$file = $fileModel->upload($titlePhoto, (object)$data);
|
||||||
|
|
||||||
|
$page->titlePhoto = $file ? $file['filename'] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$page->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user