aboutsummaryrefslogtreecommitdiffstats
path: root/smarty/plugins/modifiercompiler.to_charset.php
diff options
context:
space:
mode:
authorJesús Eduardo <heckyel@hyperbola.info>2017-12-25 16:58:41 -0500
committerJesús Eduardo <heckyel@hyperbola.info>2017-12-25 16:58:41 -0500
commit49d54c0c3199fb8e380ce68f8fb08a308ddf56a7 (patch)
tree87e9be319452d75241476853a3b240aabdcbd7e2 /smarty/plugins/modifiercompiler.to_charset.php
parent6a844225b3b63b89926e136cf65c140df01a4677 (diff)
downloadytlibre-49d54c0c3199fb8e380ce68f8fb08a308ddf56a7.tar.lz
ytlibre-49d54c0c3199fb8e380ce68f8fb08a308ddf56a7.tar.xz
ytlibre-49d54c0c3199fb8e380ce68f8fb08a308ddf56a7.zip
migración mayor a smarty PHP
Diffstat (limited to 'smarty/plugins/modifiercompiler.to_charset.php')
-rw-r--r--smarty/plugins/modifiercompiler.to_charset.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/smarty/plugins/modifiercompiler.to_charset.php b/smarty/plugins/modifiercompiler.to_charset.php
new file mode 100644
index 0000000..fea8d82
--- /dev/null
+++ b/smarty/plugins/modifiercompiler.to_charset.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ *
+ * @package Smarty
+ * @subpackage PluginsModifierCompiler
+ */
+
+/**
+ * Smarty to_charset modifier plugin
+ * Type: modifier<br>
+ * Name: to_charset<br>
+ * Purpose: convert character encoding from internal encoding to $charset
+ *
+ * @author Rodney Rehm
+ *
+ * @param array $params parameters
+ *
+ * @return string with compiled code
+ */
+function smarty_modifiercompiler_to_charset($params)
+{
+ if (!Smarty::$_MBSTRING) {
+ // FIXME: (rodneyrehm) shouldn't this throw an error?
+ return $params[ 0 ];
+ }
+
+ if (!isset($params[ 1 ])) {
+ $params[ 1 ] = '"ISO-8859-1"';
+ }
+
+ return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
+}