-
Notifications
You must be signed in to change notification settings - Fork 638
/
FrontendHooks.php
70 lines (66 loc) · 2.26 KB
/
FrontendHooks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace TYPO3\CMS\Frontend\Hooks;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
/**
* Uses frontend hooks to show preview information
*/
class FrontendHooks
{
/**
* Include the preview block in case we're looking at a hidden page
* in the LIVE workspace
*
* @param array $params
* @param TypoScriptFrontendController $pObj
* @return string
*/
public function hook_previewInfo($params, $pObj)
{
if (!$pObj->fePreview || $pObj->doWorkspacePreview()) {
return '';
}
if ($pObj->config['config']['message_preview']) {
$message = $pObj->config['config']['message_preview'];
} else {
$label = $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_tsfe.xlf:preview');
$styles = [];
$styles[] = 'position: fixed';
$styles[] = 'top: 15px';
$styles[] = 'right: 15px';
$styles[] = 'padding: 8px 18px';
$styles[] = 'background: #fff3cd';
$styles[] = 'border: 1px solid #ffeeba';
$styles[] = 'font-family: sans-serif';
$styles[] = 'font-size: 14px';
$styles[] = 'font-weight: bold';
$styles[] = 'color: #856404';
$styles[] = 'z-index: 20000';
$styles[] = 'user-select: none';
$styles[] = 'pointer-events: none';
$styles[] = 'text-align: center';
$styles[] = 'border-radius: 2px';
$message = '<div id="typo3-preview-info" style="' . implode(';', $styles) . '">' . htmlspecialchars($label) . '</div>';
}
return $message;
}
/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}