/** * Set Response properties as HTML entities and accept HTML tags * * @author Basilio Briceno <*****@*****.**> * @param mixed $value * @return mixed */ function tlalokes_str_to_html($value, $charset = 'UTF-8') { if (is_array($value)) { foreach ($value as $key => $item) { $value[$key] = tlalokes_str_to_html($item); } $response = $value; } else { // $response = is_string( $value ) // ? htmlentities( $value, ENT_QUOTES, $charset ) : $value; $response = is_string($value) ? str_replace(array('<', '>'), array('<', '>'), htmlentities($value, ENT_QUOTES, $charset)) : $value; } return $response; }
/** * Loads TlalokesResponse properties into template file * * @author Basilio Briceno <*****@*****.**> * @param string $template_path * @param TlalokesResponse $response * @param string $charset */ function tlalokes_core_load_template($template_path, &$response, &$charset) { // set local variables from TlalokesResponse foreach ($response as $key => $value) { ${$key} = tlalokes_str_to_html($value, $charset); } if (!is_readable($template_path)) { tlalokes_error_msg('Template: Cannot read ' . $template_path); } require $template_path; }