public function index($config = array()) { if (!is_array($config)) { $config = array(); } $element_name = isset($config['element_name']) && $config['element_name'] != '' ? nohtml($config['element_name']) : 'country_id'; $element_id = isset($config['element_id']) && $config['element_id'] != '' ? nohtml($config['element_id']) : $element_name; $element_class = isset($config['element_class']) && $config['element_class'] != '' ? nohtml($config['element_class']) : ''; $value = isset($config['value']) ? (int) $config['value'] : null; $language = isset($config['language']) ? (string) $config['language'] : null; $options = $this->countries->get_dropdown($language); $codes = $this->countries->get_dropdown_codes(); $this->load->view('country_dropdown_widget', compact('element_name', 'element_id', 'element_class', 'value', 'language', 'options', 'codes'), false, 'i18n'); }
public function index($data = array()) { if (empty($data)) { $data = array(); } if (!is_array($data)) { $data = array(); } if (!is_array($data)) { $data = array('feedback_message_id' => (string) $data); } $feedback_message_id = isset($data['element_id']) && $data['element_id'] != '' ? nohtml($data['element_id']) : 'main_feedback_message'; $feedback_message_full_width = array_key_exists('full_width', $data) ? !empty($data['full_width']) : true; $feedback_message_with_javascript = array_key_exists('with_javascript', $data) ? !empty($data['with_javascript']) : true; $this->load->view('feedback_messages_widget', compact('feedback_message_id', 'feedback_message_full_width', 'feedback_message_with_javascript')); }
function trim_html($string) { return trim(nohtml($string), " \t\n\r\v") == '' ? '' : $string; }
function trim_html($string) { return nohtml($string) == '' ? '' : $string; }
/** * Smarty escape modifier plugin * * Type: modifier<br> * Name: escape<br> * Purpose: escape string for output * * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> * @param string $string input string * @param string $esc_type escape type * @param string $char_set character set, used for htmlspecialchars() or htmlentities() * @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities() * @return string escaped input string */ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true) { static $_double_encode = null; if ($_double_encode === null) { $_double_encode = version_compare(PHP_VERSION, '5.2.3', '>='); } if (!$char_set) { $char_set = Smarty::$_CHARSET; } switch ($esc_type) { case 'html': if ($_double_encode) { // php >=5.3.2 - go native return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); } else { if ($double_encode) { // php <5.2.3 - only handle double encoding return htmlspecialchars($string, ENT_QUOTES, $char_set); } else { // php <5.2.3 - prevent double encoding $string = preg_replace('!&(#?\\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = htmlspecialchars($string, ENT_QUOTES, $char_set); $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); return $string; } } case 'htmlall': if (Smarty::$_MBSTRING) { // mb_convert_encoding ignores htmlspecialchars() if ($_double_encode) { // php >=5.3.2 - go native $string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); } else { if ($double_encode) { // php <5.2.3 - only handle double encoding $string = htmlspecialchars($string, ENT_QUOTES, $char_set); } else { // php <5.2.3 - prevent double encoding $string = preg_replace('!&(#?\\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = htmlspecialchars($string, ENT_QUOTES, $char_set); $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); return $string; } } // htmlentities() won't convert everything, so use mb_convert_encoding return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set); } // no MBString fallback if ($_double_encode) { return htmlentities($string, ENT_QUOTES, $char_set, $double_encode); } else { if ($double_encode) { return htmlentities($string, ENT_QUOTES, $char_set); } else { $string = preg_replace('!&(#?\\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = htmlentities($string, ENT_QUOTES, $char_set); $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); return $string; } } case 'url': return rawurlencode($string); case 'urlpathinfo': return str_replace('%2F', '/', rawurlencode($string)); case 'quotes': // escape unescaped single quotes return preg_replace("%(?<!\\\\)'%", "\\'", $string); case 'hex': // escape every byte into hex // Note that the UTF-8 encoded character รค will be represented as %c3%a4 $return = ''; $_length = strlen($string); for ($x = 0; $x < $_length; $x++) { $return .= '%' . bin2hex($string[$x]); } return $return; case 'hexentity': $return = ''; if (Smarty::$_MBSTRING) { require_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'; $return = ''; foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { $return .= '&#x' . strtoupper(dechex($unicode)) . ';'; } return $return; } // no MBString fallback $_length = strlen($string); for ($x = 0; $x < $_length; $x++) { $return .= '&#x' . bin2hex($string[$x]) . ';'; } return $return; case 'decentity': $return = ''; if (Smarty::$_MBSTRING) { require_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'; $return = ''; foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { $return .= '&#' . $unicode . ';'; } return $return; } // no MBString fallback $_length = strlen($string); for ($x = 0; $x < $_length; $x++) { $return .= '&#' . ord($string[$x]) . ';'; } return $return; case 'javascript': // escape quotes and backslashes, newlines, etc. return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/')); case 'mail': if (Smarty::$_MBSTRING) { require_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'; return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); } // no MBString fallback return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); case 'nonstd': // escape non-standard chars, such as ms document quotes $return = ''; if (Smarty::$_MBSTRING) { require_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'; foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { if ($unicode >= 126) { $return .= '&#' . $unicode . ';'; } else { $return .= chr($unicode); } } return $return; } $_length = strlen($string); for ($_i = 0; $_i < $_length; $_i++) { $_ord = ord(substr($string, $_i, 1)); // non-standard char, escape it if ($_ord >= 126) { $return .= '&#' . $_ord . ';'; } else { $return .= substr($string, $_i, 1); } } return $return; case 'noscript': return noscript($string); case 'nohtml': return nohtml($string); default: return $string; } }