protected function sanitizeValue($value, $mode) { if (!isset($value)) { return null; } if ($mode === self::SANITIZE_DISABLE) { return $value; } if ($mode & self::SANITIZE_TO_TYPE) { $value = Helper::toType($value); } if (!is_string($value)) { return $value; } if ($mode & self::SANITIZE_STRIP_TAGS) { $value = strip_tags($value); } if ($mode & self::SANITIZE_ESCAPE) { $value = StringHelper::encode($value); } return $value; }
/** * Encodes special characters into HTML entities. * * @param string $value * @return string */ public static function encode($value) { return StringHelper::encode($value); }
/** * @inheritdoc */ public function sanitize($input) { return is_string($input) ? \rock\helpers\StringHelper::encode($input, $this->doubleEncode) : $input; }
/** * Encodes special characters into HTML entities. * * The {@see \rock\Rock::$charset} will be used for encoding. * * @param string $content the content to be encoded * @param boolean $doubleEncode whether to encode HTML entities in `$content`. If false, * HTML entities in `$content` will not be further encoded. * @return string the encoded content * @see decode() * @see http://www.php.net/manual/en/function.htmlspecialchars.php */ public static function encode($content, $doubleEncode = true) { return StringHelper::encode($content, $doubleEncode); }