6e33daf12c15c401897b5316a327b088c9970587
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Be / Buttons / CshViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * *
12 * This script is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15 * General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with the script. *
19 * If not, see http://www.gnu.org/licenses/lgpl.html *
20 * *
21 * The TYPO3 project - inspiring people to share! *
22 * */
23
24 use TYPO3\CMS\Backend\Utility\BackendUtility;
25 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
26 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
27 use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
28
29 /**
30 * View helper which returns CSH (context sensitive help) button with icon
31 * Note: The CSH button will only work, if the current BE user has
32 * the "Context Sensitive Help mode" set to something else than
33 * "Display no help information" in the Users settings
34 * Note: This view helper is experimental!
35 *
36 * = Examples =
37 *
38 * <code title="Default">
39 * <f:be.buttons.csh />
40 * </code>
41 * <output>
42 * CSH button as known from the TYPO3 backend.
43 * </output>
44 *
45 * <code title="Full configuration">
46 * <f:be.buttons.csh table="xMOD_csh_corebe" field="someCshKey" />
47 * </code>
48 * <output>
49 * CSH button as known from the TYPO3 backend with some custom settings.
50 * </output>
51 */
52 class CshViewHelper extends AbstractBackendViewHelper implements CompilableInterface {
53
54 /**
55 * Render context sensitive help (CSH) for the given table
56 *
57 * @param string $table Table name ('_MOD_'+module name). If not set, the current module name will be used
58 * @param string $field Field name (CSH locallang main key)
59 * @param bool $iconOnly Deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
60 * @param string $styleAttributes Deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
61 * @return string the rendered CSH icon
62 */
63 public function render($table = NULL, $field = '', $iconOnly = FALSE, $styleAttributes = '') {
64 if ($iconOnly) {
65 \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
66 'The option iconOnly has no effect anymore and can be removed without problems. The parameter will be removed in TYPO3 CMS 8.'
67 );
68 }
69 if ($styleAttributes) {
70 \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
71 'The option styleAttributes has no effect anymore and can be removed without problems. The parameter will be removed in TYPO3 CMS 8.'
72 );
73 }
74 return self::renderStatic(
75 array(
76 'table' => $table,
77 'field' => $field,
78 ),
79 $this->buildRenderChildrenClosure(),
80 $this->renderingContext
81 );
82 }
83
84 /**
85 * @param array $arguments
86 * @param callable $renderChildrenClosure
87 * @param RenderingContextInterface $renderingContext
88 * @return string
89 */
90 static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
91 $table = $arguments['table'];
92 $field = $arguments['field'];
93
94 if ($table === NULL) {
95 $currentRequest = $renderingContext->getControllerContext()->getRequest();
96 $moduleName = $currentRequest->getPluginName();
97 $table = '_MOD_' . $moduleName;
98 }
99 return '<div class="docheader-csh">' . BackendUtility::cshItem($table, $field) . '</div>';
100 }
101 }