|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by: Jens |
|
4
|
|
|
* Date: 9-1-2018 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace CloudControl\Cms\util; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
use CloudControl\Cms\cc\Request; |
|
11
|
|
|
use CloudControl\Cms\components\cms\CmsConstants; |
|
12
|
|
|
|
|
13
|
|
|
class Cms |
|
14
|
|
|
{ |
|
15
|
|
|
public static $assetsIncluded = false; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @param $path |
|
19
|
|
|
* @return string |
|
20
|
|
|
* @throws \Exception |
|
21
|
|
|
*/ |
|
22
|
|
|
public static function editDocument($path) |
|
23
|
|
|
{ |
|
24
|
|
|
if (self::checkLogin()) { |
|
25
|
|
|
$return = self::getAssetsIfNotIncluded(); |
|
26
|
|
|
return $return . '<a title="Edit Document" data-href="' . Request::$subfolders . 'cms/documents/edit-document?slug=' . substr($path, 1) . '&returnUrl=' . urlencode(Request::$requestUri) . '" class="ccEditDocumentButton"></a>'; |
|
27
|
|
|
} else { |
|
28
|
|
|
return ''; |
|
29
|
|
|
} |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* See if a user is logged or wants to log in and |
|
34
|
|
|
* takes appropriate actions. |
|
35
|
|
|
* |
|
36
|
|
|
* @throws \Exception |
|
37
|
|
|
*/ |
|
38
|
|
|
private static function checkLogin() |
|
39
|
|
|
{ |
|
40
|
|
|
return isset($_SESSION[CmsConstants::SESSION_PARAMETER_CLOUD_CONTROL]); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
private static function getAssetsIfNotIncluded() |
|
44
|
|
|
{ |
|
45
|
|
|
if (!self::$assetsIncluded) { |
|
46
|
|
|
self::$assetsIncluded = true; |
|
47
|
|
|
return '<style> |
|
48
|
|
|
.ccEditDocumentButton{ |
|
49
|
|
|
opacity:0; |
|
50
|
|
|
-webkit-transition: opacity 0.5s;-moz-transition: opacity 0.5s;-ms-transition: opacity 0.5s;-o-transition: opacity 0.5s;transition: opacity 0.5s; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
.ccEditDocumentButton.active { |
|
54
|
|
|
display:block; |
|
55
|
|
|
position:absolute; |
|
56
|
|
|
line-height:50px; |
|
57
|
|
|
width:50px; |
|
58
|
|
|
height:50px; |
|
59
|
|
|
background: rgb(0, 106, 193) url("data:image/svg+xml;utf8,<svg width=\'25\' height=\'25\' viewBox=\'0 0 1792 1792\' xmlns=\'http://www.w3.org/2000/svg\'><path d=\'M491 1536l91-91-235-235-91 91v107h128v128h107zm523-928q0-22-22-22-10 0-17 7l-542 542q-7 7-7 17 0 22 22 22 10 0 17-7l542-542q7-7 7-17zm-54-192l416 416-832 832h-416v-416zm683 96q0 53-37 90l-166 166-416-416 166-165q36-38 90-38 53 0 91 38l235 234q37 39 37 91z\' fill=\'#fff\'/></svg>") no-repeat center; |
|
60
|
|
|
border-radius:50%; |
|
61
|
|
|
color:#fff; |
|
62
|
|
|
font-family:Arial, sans-serif; |
|
63
|
|
|
text-align:center; |
|
64
|
|
|
cursor:pointer; |
|
65
|
|
|
box-shadow: 5px 5px 5px rgba(128, 128, 128, 0.5); |
|
66
|
|
|
z-index:255; |
|
67
|
|
|
opacity:0.7; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
.ccEditDocumentButton.active:hover { |
|
71
|
|
|
color:rgb(0, 106, 193); |
|
72
|
|
|
background: #fff url("data:image/svg+xml;utf8,<svg width=\'25\' height=\'25\' viewBox=\'0 0 1792 1792\' xmlns=\'http://www.w3.org/2000/svg\'><path d=\'M491 1536l91-91-235-235-91 91v107h128v128h107zm523-928q0-22-22-22-10 0-17 7l-542 542q-7 7-7 17 0 22 22 22 10 0 17-7l542-542q7-7 7-17zm-54-192l416 416-832 832h-416v-416zm683 96q0 53-37 90l-166 166-416-416 166-165q36-38 90-38 53 0 91 38l235 234q37 39 37 91z\' fill=\'#006AC1\'/></svg>") no-repeat center; |
|
73
|
|
|
opacity:1; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
.ccDocumentEditorHidden { |
|
77
|
|
|
transform: translateX(100%); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
@keyframes slideInFromRight { |
|
81
|
|
|
0% { |
|
82
|
|
|
transform: translateX(100%); |
|
83
|
|
|
} |
|
84
|
|
|
100% { |
|
85
|
|
|
transform: translateX(0); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
@keyframes slideOutToRight { |
|
90
|
|
|
0% { |
|
91
|
|
|
transform: translateX(0); |
|
92
|
|
|
} |
|
93
|
|
|
100% { |
|
94
|
|
|
transform: translateX(100%); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
</style>' . |
|
98
|
|
|
'<script src="' . Request::$subfolders . 'js/cms.js"></script>'; |
|
99
|
|
|
} |
|
100
|
|
|
return ''; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
|