File modules/template_engine/Output.class.php

Last commit: Wed May 15 00:55:16 2024 +0200	Jan Dankert	New support for mapper in the Set-Component for better abstraction between UI and Actions
1 <?php 2 3 4 namespace template_engine; 5 6 7 use cms\base\Configuration; 8 use cms\base\Language; 9 use template_engine\mapper\Mapper; 10 use util\Text; 11 12 /** 13 * A collection of methods, used by the templates. 14 */ 15 class Output 16 { 17 /** 18 * Ersetzt alle Zeichen mit dem Ordinalwert > 127 mit einer HTML-Maskierung. 19 * 20 * @return String 21 */ 22 public static function encodeHtml($text) 23 { 24 return Text::translateutf8tohtml($text); 25 } 26 27 public static function escapeHtml($text) 28 { 29 return Text::translateutf8tohtml(htmlentities($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 )); 30 } 31 32 /** 33 * Gets a localized message 34 * @param $key string message key 35 * @return string 36 */ 37 public static function lang($key) { 38 return Language::lang($key); 39 } 40 41 42 /** 43 * Gets a configuraton value. 44 * 45 * Delegating to the Configuration. 46 * 47 * @param $keys array 48 * @return mixed 49 */ 50 public static function config( $keys ) { 51 return Configuration::get( $keys ); 52 } 53 54 public static function map( $mapper,$value ) { 55 56 $mapperClassName = ucfirst($mapper).'Mapper'; 57 $class = "template_engine\\mapper\\$mapperClassName"; 58 /* @type $do Mapper */ 59 $mapper = new $class; 60 return $mapper->map( $value ); 61 } 62 }
Download modules/template_engine/Output.class.php
History Wed, 15 May 2024 00:55:16 +0200 Jan Dankert New support for mapper in the Set-Component for better abstraction between UI and Actions Tue, 9 Nov 2021 23:53:41 +0100 Jan Dankert Very crazy bug in Alpine (like the iconv bug yesterday): htmlentities() must be called with the default flags. Mon, 9 Nov 2020 22:58:36 +0100 Jan Dankert Code-Cleanup Sun, 1 Nov 2020 00:36:50 +0100 Jan Dankert Refactoring: Only using the configuration object. Sun, 25 Oct 2020 02:11:58 +0200 Jan Dankert Fix: The config was not read in the templates :-O. Sat, 26 Sep 2020 21:05:03 +0200 Jan Dankert Refactoring: An alias for the Output class, this results in a cleaner template. Sat, 26 Sep 2020 04:26:55 +0200 Jan Dankert Refactoring: read configuration values with a class. Sat, 26 Sep 2020 04:03:53 +0200 Jan Dankert Refactoring: read language keys with a class.