[TASK] Cleanup CSH calls
[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 * View helper which returns CSH (context sensitive help) button with icon
25 * Note: The CSH button will only work, if the current BE user has
26 * the "Context Sensitive Help mode" set to something else than
27 * "Display no help information" in the Users settings
28 * Note: This view helper is experimental!
29 *
30 * = Examples =
31 *
32 * <code title="Default">
33 * <f:be.buttons.csh />
34 * </code>
35 * <output>
36 * CSH button as known from the TYPO3 backend.
37 * </output>
38 *
39 * <code title="Full configuration">
40 * <f:be.buttons.csh table="xMOD_csh_corebe" field="someCshKey" iconOnly="1" styleAttributes="border: 1px solid red" />
41 * </code>
42 * <output>
43 * CSH button as known from the TYPO3 backend with some custom settings.
44 * </output>
45 */
46 class CshViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper {
47
48 /**
49 * Render context sensitive help (CSH) for the given table
50 *
51 * @param string $table Table name ('_MOD_'+module name). If not set, the current module name will be used
52 * @param string $field Field name (CSH locallang main key)
53 * @param bool $iconOnly If set, the full text will never be shown (only icon)
54 * @param string $styleAttributes Additional style-attribute content for wrapping table (full text mode only)
55 * @return string the rendered CSH icon
56 */
57 public function render($table = NULL, $field = '', $iconOnly = FALSE, $styleAttributes = '') {
58 if ($table === NULL) {
59 $currentRequest = $this->controllerContext->getRequest();
60 $moduleName = $currentRequest->getPluginName();
61 $table = '_MOD_' . $moduleName;
62 }
63 $cshButton = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem($table, $field);
64 return '<div class="docheader-csh">' . $cshButton . '</div>';
65 }
66 }