|
From: Florin C B. <ory...@us...> - 2013-04-05 06:22:00
|
Update of /cvsroot/mxbb/core/includes In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7254 Modified Files: mx_functions.php mx_functions_core.php mx_functions_tools.php Log Message: function mx_t() for translation and compatibility with the calendar module features common with other CMS systems. Index: mx_functions_core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_core.php,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -d -r1.124 -r1.125 *** mx_functions_core.php 27 Jul 2011 21:17:47 -0000 1.124 --- mx_functions_core.php 5 Apr 2013 06:21:58 -0000 1.125 *************** *** 902,910 **** $lines[] = "'$k'=>" . $this->format_array($v); } ! else if (is_int($v)) { $lines[] = "'$k'=>$v"; } ! else if (is_bool($v)) { $lines[] = "'$k'=>" . (($v) ? 'true' : 'false'); --- 902,910 ---- $lines[] = "'$k'=>" . $this->format_array($v); } ! elseif (is_int($v)) { $lines[] = "'$k'=>$v"; } ! elseif (is_bool($v)) { $lines[] = "'$k'=>" . (($v) ? 'true' : 'false'); *************** *** 917,920 **** --- 917,952 ---- return 'array(' . implode(',', $lines) . ')'; } + + /** + * Replaces variable placeholders in a string with the requested values + * and escapes the values so they can be safely displayed as HTML. + * Function to sanitize values. + * @access private + * @param unknown_type $string + * @return unknown + */ + function format_string($string, array $args = array()) + { + $k = array(); + // Transform arguments before inserting them. + foreach ($args as $k => $v) + { + switch ($k[0]) + { + case '@': + // Escaped only. + $args[$k] = htmlspecialchars($v, ENT_QUOTE, 'UTF-8'); + break; + case '%': + default: + // Escaped and placeholder. + $args[$k] = '<em class="placeholder">' . htmlspecialchars($v, ENT_QUOTE, 'UTF-8') . '</em>'; + break; + case '!': + // Pass-through. + } + } + return strtr($string, $args); + } /** Index: mx_functions_tools.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_tools.php,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** mx_functions_tools.php 27 Feb 2011 00:49:59 -0000 1.63 --- mx_functions_tools.php 5 Apr 2013 06:21:58 -0000 1.64 *************** *** 3074,3078 **** return isset( $this->vars[$varname] ); } ! /** * Enter description here... --- 3074,3078 ---- return isset( $this->vars[$varname] ); } ! /** * Enter description here... *************** *** 3081,3098 **** * @return unknown */ ! function format_array( $array ) { $lines = array(); ! foreach ( $array as $k => $v ) { ! if ( is_array( $v ) ) { ! $lines[] = "'$k'=>" . $this->format_array( $v ); ! }elseif ( is_int( $v ) ) { $lines[] = "'$k'=>$v"; ! }elseif ( is_bool( $v ) ) { ! $lines[] = "'$k'=>" . ( ( $v ) ? 'TRUE' : 'FALSE' ); } else --- 3081,3100 ---- * @return unknown */ ! function format_array($array) { $lines = array(); ! foreach ($array as $k => $v) { ! if (is_array( $v )) { ! $lines[] = "'$k'=>" . $this->format_array($v); ! } ! elseif (is_int($v)) { $lines[] = "'$k'=>$v"; ! } ! elseif (is_bool($v)) { ! $lines[] = "'$k'=>" . (($v) ? 'TRUE' : 'FALSE'); } else *************** *** 3101,3108 **** } } ! return 'array(' . implode( ',', $lines ) . ')'; ! } } /** * Class mx_custom_field. --- 3103,3111 ---- } } ! return 'array(' . implode(',', $lines) . ')'; ! } } + /** * Class mx_custom_field. Index: mx_functions.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions.php,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** mx_functions.php 5 Apr 2013 05:13:24 -0000 1.111 --- mx_functions.php 5 Apr 2013 06:21:58 -0000 1.112 *************** *** 2662,2673 **** /** ! * function t ! * temp replacement for t() ! * We provide for a possible localization function, t(). ! * * ! function t($string, array $args = array(), array $options = array()) { ! global $lang; static $custom_strings; --- 2662,2672 ---- /** ! * function mx_t ! * replacement for t() * ! */ ! function mx_t($string, array $args = array(), array $options = array()) { ! global $lang, $mx_cache; static $custom_strings; *************** *** 2700,2707 **** else { ! return format_string($string, $args); } } */ /** --- 2699,2727 ---- else { ! return $mx_cache->format_string($string, $args); } } + + /** + * A wrapper for htmlcheck_plain($value, ENT_COMPAT, 'UTF-8') + * See also + * function utf8_htmlspecialchars($value) + * from + * @package utf + */ + function utf8_htmlcheck_plain($value) + { + return htmlspecialchars($value, ENT_QUOTE, 'UTF-8'); + } + + /** + * Trying to display in a placeholder inside a message or text + * */ + function mx_placeholder($message) + { + // Adding placeholders to returned text + return '<em class="placeholder">' . utf8_htmlcheck_plain($text) . '</em>'; + } /** |