some.label * * some.label * * @author Claus Due * @package Vhs * @subpackage ViewHelpers */ class LViewHelper extends AbstractViewHelper { /** * Initialize arguments */ public function initializeArguments() { $this->registerArgument('key', 'string', 'Translation Key'); $this->registerArgument('id', 'string', 'Translation Key compatible to TYPO3 Flow'); $this->registerArgument('default', 'string', 'if the given locallang key could not be found, this value is used. If this argument is not set, child nodes will be used to render the default'); $this->registerArgument('htmlEscape', 'boolean', 'TRUE if the result should be htmlescaped. This won\'t have an effect for the default value'); $this->registerArgument('arguments', 'array', 'Arguments to be replaced in the resulting string'); $this->registerArgument('extensionName', 'string', 'UpperCamelCased extension key (for example BlogExample)'); } /** * Render method * @return string */ public function render() { if (TRUE === isset($this->arguments['id']) && FALSE === empty($this->arguments['id'])) { $id = $this->arguments['id']; } else { $id = $this->arguments['key']; } $default = $this->arguments['default']; $htmlEscape = (boolean) $this->arguments['htmlEscape']; $arguments = $this->arguments['arguments']; $extensionName = $this->arguments['extensionName']; if (TRUE === empty($id)) { $id = $this->renderChildren(); } if (TRUE === empty($default)) { $default = $id; } if (TRUE === empty($extensionName)) { if (TRUE === method_exists($this, 'getControllerContext')) { $request = $this->getControllerContext()->getRequest(); } else { $request = $this->controllerContext->getRequest(); } $extensionName = $request->getControllerExtensionName(); } $value = LocalizationUtility::translate($id, $extensionName, $arguments); if (TRUE === empty($value)) { $value = $default; if (TRUE === is_array($arguments)) { $value = vsprintf($value, $arguments); } } elseif (TRUE === $htmlEscape) { $value = htmlspecialchars($value); } return $value; } }