` tags from the $dirty string.
*
- * @param string $str String to sanitize
- * @param string $tag Tag to remove (add more parameters as needed)
+ * @param string $str,... String to sanitize
* @return string sanitized String
*/
- public static function stripTags() {
+ public static function stripTags($str) {
$params = func_get_args();
- $str = $params[0];
for ($i = 1, $count = count($params); $i < $count; $i++) {
$str = preg_replace('/<' . $params[$i] . '\b[^>]*>/i', '', $str);
diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php
index f5527dd58..e949964d0 100644
--- a/lib/Cake/Utility/Set.php
+++ b/lib/Cake/Utility/Set.php
@@ -59,8 +59,7 @@ class Set {
/**
* Filters empty elements out of a route array, excluding '0'.
*
- * @param mixed $var Either an array to filter, or value when in callback
- * @param boolean $isArray Force to tell $var is an array when $var is empty
+ * @param array $var Either an array to filter, or value when in callback
* @return mixed Either filtered array, or true/false when in callback
*/
public static function filter(array $var) {
@@ -127,7 +126,7 @@ class Set {
if (empty($val)) {
return null;
}
- return Set::__map($val, $class);
+ return Set::_map($val, $class);
}
/**
@@ -138,12 +137,12 @@ class Set {
* returned object (recursively). If $key is numeric will maintain array
* structure
*
- * @param mixed $value Value to map
+ * @param array $array Array to map
* @param string $class Class name
* @param boolean $primary whether to assign first array key as the _name_
* @return mixed Mapped object
*/
- public static function __map(&$array, $class, $primary = false) {
+ protected static function _map(&$array, $class, $primary = false) {
if ($class === true) {
$out = new stdClass;
} else {
@@ -159,7 +158,7 @@ class Set {
if (is_object($out)) {
$out = get_object_vars($out);
}
- $out[$key] = Set::__map($value, $class);
+ $out[$key] = Set::_map($value, $class);
if (is_object($out[$key])) {
if ($primary !== true && is_array($value) && Set::countDim($value, true) === 2) {
if (!isset($out[$key]->_name_)) {
@@ -174,18 +173,18 @@ class Set {
}
$primary = false;
foreach ($value as $key2 => $value2) {
- $out->{$key2} = Set::__map($value2, true);
+ $out->{$key2} = Set::_map($value2, true);
}
} else {
if (!is_numeric($key)) {
- $out->{$key} = Set::__map($value, true, $key);
+ $out->{$key} = Set::_map($value, true, $key);
if (is_object($out->{$key}) && !is_numeric($key)) {
if (!isset($out->{$key}->_name_)) {
$out->{$key}->_name_ = $key;
}
}
} else {
- $out->{$key} = Set::__map($value, true);
+ $out->{$key} = Set::_map($value, true);
}
}
} else {
@@ -487,6 +486,7 @@ class Set {
* @param mixed $conditions An array of condition strings or an XPath expression
* @param array $data An array of data to execute the match on
* @param integer $i Optional: The 'nth'-number of the item being matched.
+ * @param integer $length
* @return boolean
*/
public static function matches($conditions, $data = array(), $i = null, $length = null) {
@@ -1012,7 +1012,7 @@ class Set {
* @param string $key
* @return array
*/
- private static function __flatten($results, $key = null) {
+ protected static function _flatten($results, $key = null) {
$stack = array();
foreach ($results as $k => $r) {
$id = $k;
@@ -1020,7 +1020,7 @@ class Set {
$id = $key;
}
if (is_array($r) && !empty($r)) {
- $stack = array_merge($stack, Set::__flatten($r, $id));
+ $stack = array_merge($stack, Set::_flatten($r, $id));
} else {
$stack[] = array('id' => $id, 'value' => $r);
}
@@ -1041,7 +1041,7 @@ class Set {
if (is_numeric(implode('', $originalKeys))) {
$data = array_values($data);
}
- $result = Set::__flatten(Set::extract($data, $path));
+ $result = Set::_flatten(Set::extract($data, $path));
list($keys, $values) = array(Set::extract($result, '{n}.id'), Set::extract($result, '{n}.value'));
$dir = strtolower($dir);
diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php
index 24275b272..2187c054e 100644
--- a/lib/Cake/Utility/Validation.php
+++ b/lib/Cake/Utility/Validation.php
@@ -36,7 +36,7 @@ class Validation {
*
* @var array
*/
- private static $__pattern = array(
+ protected static $_pattern = array(
'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
);
@@ -318,7 +318,7 @@ class Validation {
/**
* Validates a datetime value
* All values matching the "date" core validation rule, and the "time" one will be valid
- *
+ *
* @param array $check Value to check
* @param mixed $dateFormat Format of the date part
* Use a string or an array of the keys below. Arrays should be passed as array('dmy', 'mdy', etc)
@@ -336,7 +336,7 @@ class Validation {
* @see Validation::date
* @see Validation::time
*/
- function datetime($check, $dateFormat = 'ymd', $regex = null) {
+ public function datetime($check, $dateFormat = 'ymd', $regex = null) {
$valid = false;
$parts = explode(' ', $check);
if (!empty($parts) && count($parts) > 1) {
@@ -407,14 +407,14 @@ class Validation {
}
if (is_null($regex)) {
- $regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$__pattern['hostname'] . '$/i';
+ $regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i';
}
$return = self::_check($check, $regex);
if ($deep === false || $deep === null) {
return $return;
}
- if ($return === true && preg_match('/@(' . self::$__pattern['hostname'] . ')$/i', $check, $regs)) {
+ if ($return === true && preg_match('/@(' . self::$_pattern['hostname'] . ')$/i', $check, $regs)) {
if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) {
return true;
}
@@ -462,7 +462,7 @@ class Validation {
* Validation of an IP address.
*
* @param string $check The string to test.
- * @param string $ipVersion The IP Protocol version to validate against
+ * @param string $type The IP Protocol version to validate against
* @return boolean Success
*/
public static function ip($check, $type = 'both') {
@@ -697,14 +697,13 @@ class Validation {
*
* @param string $check Value to check
* @param boolean $strict Require URL to be prefixed by a valid scheme (one of http(s)/ftp(s)/file/news/gopher)
- * @param string $ipVersion The IP Protocol version to validate against
* @return boolean Success
*/
public static function url($check, $strict = false) {
- self::__populateIp();
+ self::_populateIp();
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
$regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
- '(?:' . self::$__pattern['IPv4'] . '|\[' . self::$__pattern['IPv6'] . '\]|' . self::$__pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' .
+ '(?:' . self::$_pattern['IPv4'] . '|\[' . self::$_pattern['IPv6'] . '\]|' . self::$_pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' .
'(?:\/?|\/' . $validChars . '*)?' .
'(?:\?' . $validChars . '*)?' .
'(?:#' . $validChars . '*)?$/iu';
@@ -740,7 +739,6 @@ class Validation {
*
* @param string $check Value to check
* @return boolean Success
- * @access public
*/
public static function uuid($check) {
$regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
@@ -796,7 +794,7 @@ class Validation {
* @return void
*/
protected static function _defaults($params) {
- self::__reset();
+ self::_reset();
$defaults = array(
'check' => null,
'regex' => null,
@@ -814,8 +812,10 @@ class Validation {
/**
* Luhn algorithm
*
- * @see http://en.wikipedia.org/wiki/Luhn_algorithm
+ * @param string|array $check
+ * @param boolean $deep
* @return boolean Success
+ * @see http://en.wikipedia.org/wiki/Luhn_algorithm
*/
public static function luhn($check, $deep = false) {
if (is_array($check)) {
@@ -847,8 +847,8 @@ class Validation {
*
* @return void
*/
- private static function __populateIp() {
- if (!isset(self::$__pattern['IPv6'])) {
+ protected static function _populateIp() {
+ if (!isset(self::$_pattern['IPv6'])) {
$pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}';
$pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})';
$pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})';
@@ -864,11 +864,11 @@ class Validation {
$pattern .= '\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4})';
$pattern .= '{1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?';
- self::$__pattern['IPv6'] = $pattern;
+ self::$_pattern['IPv6'] = $pattern;
}
- if (!isset(self::$__pattern['IPv4'])) {
+ if (!isset(self::$_pattern['IPv4'])) {
$pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])';
- self::$__pattern['IPv4'] = $pattern;
+ self::$_pattern['IPv4'] = $pattern;
}
}
@@ -877,7 +877,7 @@ class Validation {
*
* @return void
*/
- private static function __reset() {
+ protected static function _reset() {
self::$errors = array();
}
}
diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php
index abb3c0053..965d0516f 100644
--- a/lib/Cake/Utility/Xml.php
+++ b/lib/Cake/Utility/Xml.php
@@ -61,7 +61,7 @@ class Xml {
* );
* $xml = Xml::build($value);
* }}}
- *
+ *
* When building XML from an array ensure that there is only one top level element.
*
* ### Options
@@ -71,7 +71,7 @@ class Xml {
*
* @param mixed $input XML string, a path to a file, an URL or an array
* @param array $options The options to use
- * @return object SimpleXMLElement or DOMDocument
+ * @return SimpleXMLElement|DOMDocument SimpleXMLElement or DOMDocument
* @throws XmlException
*/
public static function build($input, $options = array()) {
@@ -116,7 +116,7 @@ class Xml {
* - `return` If return object of SimpleXMLElement ('simplexml') or DOMDocument ('domdocument'). Default is SimpleXMLElement.
*
* Using the following data:
- *
+ *
* {{{
* $value = array(
* 'root' => array(
@@ -139,7 +139,7 @@ class Xml {
*
* @param array $input Array with data
* @param array $options The options to use
- * @return object SimpleXMLElement or DOMDocument
+ * @return SimpleXMLElement|DOMDocument SimpleXMLElement or DOMDocument
* @throws XmlException
*/
public static function fromArray($input, $options = array()) {
@@ -175,11 +175,12 @@ class Xml {
/**
* Recursive method to create childs from array
*
- * @param object $dom Handler to DOMDocument
- * @param object $node Handler to DOMElement (child)
+ * @param DOMDocument $dom Handler to DOMDocument
+ * @param DOMElement $node Handler to DOMElement (child)
* @param array $data Array of data to append to the $node.
* @param string $format Either 'attribute' or 'tags'. This determines where nested keys go.
* @return void
+ * @throws XmlException
*/
protected static function _fromArray($dom, $node, &$data, $format) {
if (empty($data) || !is_array($data)) {
@@ -217,10 +218,10 @@ class Xml {
foreach ($value as $item) {
$data = compact('dom', 'node', 'key', 'format');
$data['value'] = $item;
- self::__createChild($data);
+ self::_createChild($data);
}
} else { // Struct
- self::__createChild(compact('dom', 'node', 'key', 'value', 'format'));
+ self::_createChild(compact('dom', 'node', 'key', 'value', 'format'));
}
}
} else {
@@ -235,7 +236,7 @@ class Xml {
* @param array $data Array with informations to create childs
* @return void
*/
- private static function __createChild($data) {
+ protected static function _createChild($data) {
extract($data);
$childNS = $childValue = null;
if (is_array($value)) {
@@ -267,7 +268,7 @@ class Xml {
/**
* Returns this XML structure as a array.
*
- * @param object $obj SimpleXMLElement, DOMDocument or DOMNode instance
+ * @param SimpleXMLElement|DOMDocument|DOMNode $obj SimpleXMLElement, DOMDocument or DOMNode instance
* @return array Array representation of the XML structure.
* @throws XmlException
*/
@@ -287,7 +288,7 @@ class Xml {
/**
* Recursive method to toArray
*
- * @param object $xml SimpleXMLElement object
+ * @param SimpleXMLElement $xml SimpleXMLElement object
* @param array $parentData Parent array with data
* @param string $ns Namespace of current child
* @param array $namespaces List of namespaces in XML
diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php
index 8dee5cd99..112f2c490 100644
--- a/lib/Cake/View/Helper.php
+++ b/lib/Cake/View/Helper.php
@@ -67,7 +67,6 @@ class Helper extends Object {
/**
* Holds tag templates.
*
- * @access public
* @var array
*/
public $tags = array();
@@ -75,18 +74,16 @@ class Helper extends Object {
/**
* Holds the content to be cleaned.
*
- * @access private
* @var mixed
*/
- private $__tainted = null;
+ protected $_tainted = null;
/**
* Holds the cleaned content.
*
- * @access private
* @var mixed
*/
- private $__cleaned = null;
+ protected $_cleaned = null;
/**
* The View instance this helper is attached to
@@ -149,6 +146,7 @@ class Helper extends Object {
*
* @param string $method Method to invoke
* @param array $params Array of params for the method.
+ * @return void
*/
public function __call($method, $params) {
trigger_error(__d('cake_dev', 'Method %1$s::%2$s does not exist', get_class($this), $method), E_USER_WARNING);
@@ -184,7 +182,9 @@ class Helper extends Object {
/**
* Provides backwards compatiblity access for setting values to the request object.
*
- * @return void
+ * @param string $name Name of the property being accessed.
+ * @param mixed $value
+ * @return mixed Return the $value
*/
public function __set($name, $value) {
switch ($name) {
@@ -292,10 +292,10 @@ class Helper extends Object {
* content is the best way to prevent all possible attacks.
*
* @param mixed $output Either an array of strings to clean or a single string to clean.
- * @return cleaned content for output
+ * @return string|array cleaned content for output
*/
public function clean($output) {
- $this->__reset();
+ $this->_reset();
if (empty($output)) {
return null;
}
@@ -305,9 +305,9 @@ class Helper extends Object {
}
return $return;
}
- $this->__tainted = $output;
- $this->__clean();
- return $this->__cleaned;
+ $this->_tainted = $output;
+ $this->_clean();
+ return $this->_cleaned;
}
/**
@@ -348,6 +348,7 @@ class Helper extends Object {
* @param string $insertBefore String to be inserted before options.
* @param string $insertAfter String to be inserted after options.
* @return string Composed attributes.
+ * @deprecated This method has been moved to HtmlHelper
*/
protected function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
if (!is_string($options)) {
@@ -379,7 +380,9 @@ class Helper extends Object {
*
* @param string $key The name of the attribute to create
* @param string $value The value of the attribute to create.
+ * @param boolean $escape Define if the value must be escaped
* @return string The composed attribute.
+ * @deprecated This method has been moved to HtmlHelper
*/
protected function _formatAttribute($key, $value, $escape = true) {
$attribute = '';
@@ -454,7 +457,7 @@ class Helper extends Object {
// habtm models are special
if (
- isset($this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type']) &&
+ isset($this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type']) &&
$this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type'] === 'multiple'
) {
$entity = $parts[0] . '.' . $parts[0];
@@ -542,7 +545,6 @@ class Helper extends Object {
* @param string $key The name of the attribute to be set, defaults to 'name'
* @return mixed If an array was given for $options, an array with $key set will be returned.
* If a string was supplied a string will be returned.
- * @access protected
* @todo Refactor this method to not have as many input/output options.
*/
protected function _name($options = array(), $field = null, $key = 'name') {
@@ -587,7 +589,6 @@ class Helper extends Object {
* @param string $key The name of the attribute to be set, defaults to 'value'
* @return mixed If an array was given for $options, an array with $key set will be returned.
* If a string was supplied a string will be returned.
- * @access public
* @todo Refactor this method to not have as many input/output options.
*/
public function value($options = array(), $field = null, $key = 'value') {
@@ -619,7 +620,7 @@ class Helper extends Object {
} elseif (empty($result) && isset($data[$habtmKey]) && is_array($data[$habtmKey])) {
if (ClassRegistry::isKeySet($habtmKey)) {
$model = ClassRegistry::getObject($habtmKey);
- $result = $this->__selectedArray($data[$habtmKey], $model->primaryKey);
+ $result = $this->_selectedArray($data[$habtmKey], $model->primaryKey);
}
}
@@ -743,9 +744,8 @@ class Helper extends Object {
* @param mixed $data
* @param string $key
* @return array
- * @access private
*/
- private function __selectedArray($data, $key = 'id') {
+ protected function _selectedArray($data, $key = 'id') {
if (!is_array($data)) {
$model = $data;
if (!empty($this->request->data[$model][$model])) {
@@ -770,43 +770,41 @@ class Helper extends Object {
* Resets the vars used by Helper::clean() to null
*
* @return void
- * @access private
*/
- private function __reset() {
- $this->__tainted = null;
- $this->__cleaned = null;
+ protected function _reset() {
+ $this->_tainted = null;
+ $this->_cleaned = null;
}
/**
* Removes harmful content from output
*
* @return void
- * @access private
*/
- private function __clean() {
+ protected function _clean() {
if (get_magic_quotes_gpc()) {
- $this->__cleaned = stripslashes($this->__tainted);
+ $this->_cleaned = stripslashes($this->_tainted);
} else {
- $this->__cleaned = $this->__tainted;
+ $this->_cleaned = $this->_tainted;
}
- $this->__cleaned = str_replace(array("&", "<", ">"), array("&", "<", ">"), $this->__cleaned);
- $this->__cleaned = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u', "$1;", $this->__cleaned);
- $this->__cleaned = preg_replace('#(&\#x*)([0-9A-F]+);*#iu', "$1$2;", $this->__cleaned);
- $this->__cleaned = html_entity_decode($this->__cleaned, ENT_COMPAT, "UTF-8");
- $this->__cleaned = preg_replace('#(<[^>]+[\x00-\x20\"\'\/])(on|xmlns)[^>]*>#iUu', "$1>", $this->__cleaned);
- $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2nojavascript...', $this->__cleaned);
- $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2novbscript...', $this->__cleaned);
- $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=*([\'\"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#iUu','$1=$2nomozbinding...', $this->__cleaned);
- $this->__cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*data[\x00-\x20]*:#Uu', '$1=$2nodata...', $this->__cleaned);
- $this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU', "$1>", $this->__cleaned);
- $this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU', "$1>", $this->__cleaned);
- $this->__cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu', "$1>", $this->__cleaned);
- $this->__cleaned = preg_replace('#*\w+:\w[^>]*>#i', "", $this->__cleaned);
+ $this->_cleaned = str_replace(array("&", "<", ">"), array("&", "<", ">"), $this->_cleaned);
+ $this->_cleaned = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u', "$1;", $this->_cleaned);
+ $this->_cleaned = preg_replace('#(&\#x*)([0-9A-F]+);*#iu', "$1$2;", $this->_cleaned);
+ $this->_cleaned = html_entity_decode($this->_cleaned, ENT_COMPAT, "UTF-8");
+ $this->_cleaned = preg_replace('#(<[^>]+[\x00-\x20\"\'\/])(on|xmlns)[^>]*>#iUu', "$1>", $this->_cleaned);
+ $this->_cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2nojavascript...', $this->_cleaned);
+ $this->_cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2novbscript...', $this->_cleaned);
+ $this->_cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=*([\'\"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#iUu','$1=$2nomozbinding...', $this->_cleaned);
+ $this->_cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*data[\x00-\x20]*:#Uu', '$1=$2nodata...', $this->_cleaned);
+ $this->_cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU', "$1>", $this->_cleaned);
+ $this->_cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU', "$1>", $this->_cleaned);
+ $this->_cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu', "$1>", $this->_cleaned);
+ $this->_cleaned = preg_replace('#*\w+:\w[^>]*>#i', "", $this->_cleaned);
do {
- $oldstring = $this->__cleaned;
- $this->__cleaned = preg_replace('#*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->__cleaned);
- } while ($oldstring != $this->__cleaned);
- $this->__cleaned = str_replace(array("&", "<", ">"), array("&", "<", ">"), $this->__cleaned);
+ $oldstring = $this->_cleaned;
+ $this->_cleaned = preg_replace('#*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->_cleaned);
+ } while ($oldstring != $this->_cleaned);
+ $this->_cleaned = str_replace(array("&", "<", ">"), array("&", "<", ">"), $this->_cleaned);
}
}
diff --git a/lib/Cake/View/Helper/CacheHelper.php b/lib/Cake/View/Helper/CacheHelper.php
index 3a8e293f0..7ce4e9a74 100644
--- a/lib/Cake/View/Helper/CacheHelper.php
+++ b/lib/Cake/View/Helper/CacheHelper.php
@@ -46,9 +46,17 @@ class CacheHelper extends AppHelper {
*/
protected $_match = array();
+/**
+ * Counter used for counting nocache section tags.
+ *
+ * @var integer
+ */
+ protected $_counter = 0;
+
/**
* Parses the view file and stores content for cache file building.
*
+ * @param string $viewFile
* @return void
*/
public function afterRender($viewFile) {
@@ -61,6 +69,7 @@ class CacheHelper extends AppHelper {
/**
* Parses the layout file and stores content for cache file building.
*
+ * @param string $layoutFile
* @return void
*/
public function afterLayout($layoutFile) {
@@ -71,13 +80,6 @@ class CacheHelper extends AppHelper {
$this->_View->output = preg_replace('//', '', $this->_View->output);
}
-/**
- * Counter used for counting nocache section tags.
- *
- * @var integer
- */
- protected $_counter = 0;
-
/**
* Main method used to cache a view
*
@@ -144,6 +146,7 @@ class CacheHelper extends AppHelper {
*
* @param string $file The filename that needs to be parsed.
* @param string $cache The cached content
+ * @return void
*/
protected function _parseFile($file, $cache) {
if (is_file($file)) {
@@ -182,10 +185,9 @@ class CacheHelper extends AppHelper {
* Munges the output from a view with cache tags, and numbers the sections.
* This helps solve issues with empty/duplicate content.
*
- * @param string $content The content to munge.
* @return string The content with cake:nocache tags replaced.
*/
- protected function _replaceSection($matches) {
+ protected function _replaceSection() {
$this->_counter += 1;
return sprintf('', $this->_counter);
}
@@ -238,7 +240,8 @@ class CacheHelper extends AppHelper {
* Write a cached version of the file
*
* @param string $content view content to write to a cache file.
- * @param sting $timestamp Duration to set for cache file.
+ * @param string $timestamp Duration to set for cache file.
+ * @param boolean $useCallbacks
* @return boolean success of caching view.
*/
protected function _writeFile($content, $timestamp, $useCallbacks = false) {
diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php
index fa6f3320c..46ccf3698 100644
--- a/lib/Cake/View/Helper/FormHelper.php
+++ b/lib/Cake/View/Helper/FormHelper.php
@@ -27,6 +27,7 @@ App::uses('AppHelper', 'View/Helper');
* Automatic generation of HTML FORMs from given data.
*
* @package Cake.View.Helper
+ * @property HtmlHelper $Html
* @link http://book.cakephp.org/view/1383/Form
*/
class FormHelper extends AppHelper {
@@ -35,7 +36,6 @@ class FormHelper extends AppHelper {
* Other helpers used by FormHelper
*
* @var array
- * @access public
*/
public $helpers = array('Html');
@@ -43,7 +43,7 @@ class FormHelper extends AppHelper {
* Holds the fields array('field_name' => array('type'=> 'string', 'length'=> 100),
* primaryKey and validates array('field_name')
*
- * @access public
+ * @var array
*/
public $fieldset = array();
@@ -52,7 +52,7 @@ class FormHelper extends AppHelper {
*
* @var array
*/
- private $__options = array(
+ protected $_options = array(
'day' => array(), 'minute' => array(), 'hour' => array(),
'month' => array(), 'year' => array(), 'meridian' => array()
);
@@ -65,7 +65,7 @@ class FormHelper extends AppHelper {
public $fields = array();
/**
- * Constant used internally to skip the securing process,
+ * Constant used internally to skip the securing process,
* and neither add the field to the hash or to the unlocked fields.
*
* @var string
@@ -76,7 +76,6 @@ class FormHelper extends AppHelper {
* Defines the type of form being created. Set by FormHelper::create().
*
* @var string
- * @access public
*/
public $requestType = null;
@@ -84,7 +83,6 @@ class FormHelper extends AppHelper {
* The default model being used for the current form.
*
* @var string
- * @access public
*/
public $defaultModel = null;
@@ -93,7 +91,6 @@ class FormHelper extends AppHelper {
* Persistent default options used by input(). Set by FormHelper::create().
*
* @var array
- * @access protected
*/
protected $_inputDefaults = array();
@@ -101,7 +98,7 @@ class FormHelper extends AppHelper {
* An array of fieldnames that have been excluded from
* the Token hash used by SecurityComponent's validatePost method
*
- * @see FormHelper::__secure()
+ * @see FormHelper::_secure()
* @see SecurityComponent::validatePost()
* @var array
*/
@@ -139,6 +136,7 @@ class FormHelper extends AppHelper {
* Guess the location for a model based on its name and tries to create a new instance
* or get an already created instance of the model
*
+ * @param string $model
* @return Model model instance
*/
protected function _getModel($model) {
@@ -242,7 +240,7 @@ class FormHelper extends AppHelper {
if (empty($field)) {
return $this->fieldset[$model]['validates'];
} else {
- return isset($this->fieldset[$model]['validates'][$field]) ?
+ return isset($this->fieldset[$model]['validates'][$field]) ?
$this->fieldset[$model]['validates'] : null;
}
}
@@ -251,6 +249,7 @@ class FormHelper extends AppHelper {
/**
* Returns if a field is required to be filled based on validation properties from the validating object
*
+ * @param array $validateProperties
* @return boolean true if field is required to be filled, false otherwise
*/
protected function _isRequiredField($validateProperties) {
@@ -310,7 +309,6 @@ class FormHelper extends AppHelper {
* can be overridden when calling input()
* - `encoding` Set the accept-charset encoding for the form. Defaults to `Configure::read('App.encoding')`
*
- * @access public
* @param string $model The model object which the form is being defined for
* @param array $options An array of html attributes and options.
* @return string An formatted opening FORM tag.
@@ -490,7 +488,6 @@ class FormHelper extends AppHelper {
*
* @param mixed $options as a string will use $options as the value of button,
* @return string a closing FORM tag optional submit button.
- * @access public
* @link http://book.cakephp.org/view/1389/Closing-the-Form
*/
public function end($options = null) {
@@ -594,7 +591,7 @@ class FormHelper extends AppHelper {
* @param mixed $value Field value, if value should not be tampered with.
* @return void
*/
- protected function __secure($lock, $field = null, $value = null) {
+ protected function _secure($lock, $field = null, $value = null) {
if (!$field) {
$field = $this->entity();
} elseif (is_string($field)) {
@@ -627,7 +624,6 @@ class FormHelper extends AppHelper {
*
* @param string $field This should be "Modelname.fieldname"
* @return boolean If there are errors this method returns true, else false.
- * @access public
* @link http://book.cakephp.org/view/1426/isFieldError
*/
public function isFieldError($field) {
@@ -650,7 +646,6 @@ class FormHelper extends AppHelper {
* If array contains `attributes` key it will be used as options for error container
* @param array $options Rendering options for
wrapper tag
* @return string If there are errors this method returns an error message, otherwise null.
- * @access public
* @link http://book.cakephp.org/view/1423/error
*/
public function error($field, $text = null, $options = array()) {
@@ -893,7 +888,6 @@ class FormHelper extends AppHelper {
* @param string $fieldName This should be "Modelname.fieldname"
* @param array $options Each type of input takes different options.
* @return string Completed form widget.
- * @access public
* @link http://book.cakephp.org/view/1390/Automagic-Form-Elements
*/
public function input($fieldName, $options = array()) {
@@ -940,7 +934,7 @@ class FormHelper extends AppHelper {
$options['type'] = 'hidden';
}
if (
- $options['type'] === 'number' &&
+ $options['type'] === 'number' &&
$type === 'float' &&
!isset($options['step'])
) {
@@ -1126,7 +1120,7 @@ class FormHelper extends AppHelper {
* @param string $name The name of the option to pull out.
* @param array $options The array of options you want to extract.
* @param mixed $default The default option value
- * @return the contents of the option or default
+ * @return mixed the contents of the option or default
*/
protected function _extractOption($name, $options, $default = null) {
if (array_key_exists($name, $options)) {
@@ -1138,6 +1132,8 @@ class FormHelper extends AppHelper {
/**
* Generate a label for an input() call.
*
+ * @param string $fieldName
+ * @param string $label
* @param array $options Options for the label element.
* @return string Generated label element
*/
@@ -1195,7 +1191,6 @@ class FormHelper extends AppHelper {
* @param string $fieldName Name of a field, like this "Modelname.fieldname"
* @param array $options Array of HTML attributes.
* @return string An HTML text input element.
- * @access public
* @link http://book.cakephp.org/view/1414/checkbox
*/
public function checkbox($fieldName, $options = array()) {
@@ -1250,7 +1245,6 @@ class FormHelper extends AppHelper {
* @param array $options Radio button options array.
* @param array $attributes Array of HTML attributes, and special attributes above.
* @return string Completed radio widget set.
- * @access public
* @link http://book.cakephp.org/view/1429/radio
*/
public function radio($fieldName, $options = array(), $attributes = array()) {
@@ -1377,7 +1371,6 @@ class FormHelper extends AppHelper {
* @param string $fieldName Name of a field, in the form "Modelname.fieldname"
* @param array $options Array of HTML attributes, and special options above.
* @return string A generated HTML text input element
- * @access public
* @link http://book.cakephp.org/view/1433/textarea
*/
public function textarea($fieldName, $options = array()) {
@@ -1400,7 +1393,6 @@ class FormHelper extends AppHelper {
* @param string $fieldName Name of a field, in the form of "Modelname.fieldname"
* @param array $options Array of HTML attributes.
* @return string A generated hidden input
- * @access public
* @link http://book.cakephp.org/view/1425/hidden
*/
public function hidden($fieldName, $options = array()) {
@@ -1415,7 +1407,7 @@ class FormHelper extends AppHelper {
));
if ($secure && $secure !== self::SECURE_SKIP) {
- $this->__secure(true, null, '' . $options['value']);
+ $this->_secure(true, null, '' . $options['value']);
}
return $this->Html->useTag('hidden', $options['name'], array_diff_key($options, array('name' => '')));
@@ -1427,7 +1419,6 @@ class FormHelper extends AppHelper {
* @param string $fieldName Name of a field, in the form "Modelname.fieldname"
* @param array $options Array of HTML attributes.
* @return string A generated file input.
- * @access public
* @link http://book.cakephp.org/view/1424/file
*/
public function file($fieldName, $options = array()) {
@@ -1439,7 +1430,7 @@ class FormHelper extends AppHelper {
$field = $this->entity();
foreach (array('name', 'type', 'tmp_name', 'error', 'size') as $suffix) {
- $this->__secure($secure, array_merge($field, array($suffix)));
+ $this->_secure($secure, array_merge($field, array($suffix)));
}
return $this->Html->useTag('file', $options['name'], array_diff_key($options, array('name' => '')));
@@ -1456,7 +1447,6 @@ class FormHelper extends AppHelper {
* @param string $title The button's caption. Not automatically HTML encoded
* @param array $options Array of options and HTML attributes.
* @return string A HTML button tag.
- * @access public
* @link http://book.cakephp.org/view/1415/button
*/
public function button($title, $options = array()) {
@@ -1465,7 +1455,7 @@ class FormHelper extends AppHelper {
$title = h($title);
}
if (isset($options['name'])) {
- $this->__secure($options['secure'], $options['name']);
+ $this->_secure($options['secure'], $options['name']);
}
return $this->Html->useTag('button', $options['type'], array_diff_key($options, array('type' => '')), $title);
}
@@ -1500,7 +1490,7 @@ class FormHelper extends AppHelper {
}
/**
- * Creates an HTML link, but access the url using method POST.
+ * Creates an HTML link, but access the url using method POST.
* Requires javascript to be enabled in browser.
*
* This method creates a `