xmlHelper = new XmlHelper(); $this->csvHelper = new CsvHelper(); $this->htmlHelper = new HtmlUrlHelper(); $this->commonHelper = new CommonHelper(); } /** * @example {escapeXml}{$evilString}{/escapeXml} * @example {escapeXml charset="UTF-32"}{$evilString}{/escapeXml} * * @param array $params * @param mixed $content * @param Smarty_Internal_Template $template * @param bool $repeat * * @return string */ public function compileBlockEscapeXml($params, $content, $template, &$repeat) { // Only output on closing tag @see https://www.smarty.net/docs/en/plugins.block.functions.tpl if ($repeat === true) { return null; } $charset = isset($params['charset']) && !empty($params['charset']) ? (string)$params['charset'] : 'UTF-8'; return $this->xmlHelper->escapeXml($content, $charset); } /** * @example {escapeXml}{$evilString}{/escapeXml} * @example {escapeXml charset="UTF-32"}{$evilString}{/escapeXml} * * @param array $params * @param mixed $content * @param Smarty_Internal_Template $template * @param bool $repeat * * @throws TransferTemplateUserException */ public function compileBlockError($params, $content, $template, &$repeat) { if ($repeat === true) { return null; } throw new TransferTemplateUserException($content); } /** * @example `{cdata}Long text data{/cdata}` => Ausgabe `` * * @param array $params * @param mixed $content * @param Smarty_Internal_Template $template * @param bool $repeat * * @return string */ public function compileBlockCdata($params, $content, $template, &$repeat) { // Only output on closing tag @see https://www.smarty.net/docs/en/plugins.block.functions.tpl if ($repeat === true) { return null; } return $this->xmlHelper->createXmlCdataSection($content); } /** * @example {$url|urlEncode} * * @param mixed $content * * @return string */ public function compileModifierEncodeUrl($content) { return $this->htmlHelper->encodeUrl($content); } /** * @example {$url|urlDecode} * * @param mixed $content * * @return string */ public function compileModifierDecodeUrl($content) { return $this->htmlHelper->decodeUrl($content); } /** * @example `{"Inhalt"|cdata}` => Ausgabe `` * * @param string $content * * @return string */ public function compileModifierCdata($content) { return $this->xmlHelper->createXmlCdataSection($content); } /** * @param string $content */ public function compileModifierError($content) { throw new TransferTemplateUserException($content); } /** * @example {$value|escapeXml} * * @param string $content * * @return string */ public function compileModifierEscapeXml($content) { return $this->xmlHelper->escapeXml($content); } /** * @example {$value|quoteCsv} * @example {$value|quoteCsv:"'"} * * * @param string $content * @param string $quoteChar * * @return string */ public function compileModifierQuoteCsv($content, $quoteChar = '"') { if (empty($quoteChar)) { $quoteChar = '"'; } return $this->csvHelper->quoteCsv($content, (string)$quoteChar); } /** * @example {$value|htmlEntitiesDecode} * * @param string $content * * @return string */ public function compileModifierDecodeHtmlEntities($content) { return $this->htmlHelper->decodeHtmlEntities($content); } /** * @example {$value|htmlSpecialCharsDecode} * * @param string $content * * @return string */ public function compileModifierDecodeHtmlSpecialChars($content) { return $this->htmlHelper->decodeHtmlSpecialChars($content); } /** * Converts HTML-BR-Tags to line breaks * * @example {$value|br2nl} * * @param string $content * * @return string */ public function compileModifierBr2Nl($content) { return $this->htmlHelper->convertBr2LineBreak($content); } /** * @example {$var|replaceLineBreaks} * @example {$var|replaceLineBreaks:"ZEILENUMBRUCH"} * * @param string $string * @param string $replaceChar * * @return string */ public function compileModifierReplaceLineBreaks($string, $replaceChar = ' ') { return $this->commonHelper->replaceLineBreaks($string, $replaceChar); } /** * Dumps a template variable * * @example {$var|dump} * * @param mixed $data * * @return string */ public function compileModifierDumpVariable($data) { return $this->commonHelper->dumpVariable($data); } }