attributesToString($attributes); if (stripos($attributes, 'method=') === FALSE) { $attributes .= ' method="post"'; } if (stripos($attributes, 'accept-charset=') === FALSE) { $attributes .= ' accept-charset="' . strtolower(self::CHARSET) . '"'; } $form = '
' . $extra; } /** * Form Prep * * Formats text so that it can be safely placed in a form field in the event it has HTML tags. * * @param string|string[] $str Value to escape * @return string|string[] Escaped values * @deprecated 3.0.0 An alias for strip_tags() */ function prep($str) { return strip_tags($str, TRUE); } /** * Parse the form attributes * * Helper function used by some of the form helpers * * @param array $attributes List of attributes * @param array $default Default values * @return string */ private function parseFormAttributes($attributes, $default) { if (is_array($attributes)) { foreach ($default as $key => $val) { if (isset($attributes[$key])) { $default[$key] = $attributes[$key]; unset($attributes[$key]); } } if (count($attributes) > 0) { $default = array_merge($default, $attributes); } } $att = ''; foreach ($default as $key => $val) { if ($key === 'value') { $val = strip_tags($val); } elseif ($key === 'name' && !strlen($default['name'])) { continue; } $att .= $key . '="' . $val . '" '; } return $att; } /** * Attributes To String * * Helper function used by some of the form helpers * * @param mixed * @return string */ private function attributesToString($attributes) { if (empty($attributes)) { return ''; } if (is_object($attributes)) { $attributes = (array)$attributes; } if (is_array($attributes)) { $atts = ''; foreach ($attributes as $key => $val) { $atts .= ' ' . $key . '="' . $val . '"'; } return $atts; } if (is_string($attributes)) { return ' ' . $attributes; } return FALSE; } }