Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Filter_HtmlEntities Class Reference
Inheritance diagram for Zend_Filter_HtmlEntities:
Zend_Filter_Interface

Public Member Functions

 __construct ($options=array())
 
 getQuoteStyle ()
 
 setQuoteStyle ($quoteStyle)
 
 getEncoding ()
 
 setEncoding ($value)
 
 getCharSet ()
 
 setCharSet ($charSet)
 
 getDoubleQuote ()
 
 setDoubleQuote ($doubleQuote)
 
 filter ($value)
 

Protected Attributes

 $_quoteStyle
 
 $_encoding
 
 $_doubleQuote
 

Detailed Description

Definition at line 33 of file HtmlEntities.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options = array())

Sets filter options

Parameters
integer | array$quoteStyle
string$charSet
Returns
void

Definition at line 63 of file HtmlEntities.php.

64  {
65  if ($options instanceof Zend_Config) {
66  $options = $options->toArray();
67  } else if (!is_array($options)) {
68  $options = func_get_args();
69  $temp['quotestyle'] = array_shift($options);
70  if (!empty($options)) {
71  $temp['charset'] = array_shift($options);
72  }
73 
74  $options = $temp;
75  }
76 
77  if (!isset($options['quotestyle'])) {
78  $options['quotestyle'] = ENT_COMPAT;
79  }
80 
81  if (!isset($options['encoding'])) {
82  $options['encoding'] = 'UTF-8';
83  }
84  if (isset($options['charset'])) {
85  $options['encoding'] = $options['charset'];
86  }
87 
88  if (!isset($options['doublequote'])) {
89  $options['doublequote'] = true;
90  }
91 
92  $this->setQuoteStyle($options['quotestyle']);
93  $this->setEncoding($options['encoding']);
94  $this->setDoubleQuote($options['doublequote']);
95  }
setDoubleQuote($doubleQuote)

Member Function Documentation

◆ filter()

filter (   $value)

Defined by Zend_Filter_Interface

Returns the string $value, converting characters to their corresponding HTML entity equivalents where they exist

Parameters
string$value
Returns
string

Implements Zend_Filter_Interface.

Definition at line 198 of file HtmlEntities.php.

199  {
200  $filtered = htmlentities((string) $value, $this->getQuoteStyle(), $this->getEncoding(), $this->getDoubleQuote());
201  if (strlen((string) $value) && !strlen($filtered)) {
202  if (!function_exists('iconv')) {
203  #require_once 'Zend/Filter/Exception.php';
204  throw new Zend_Filter_Exception('Encoding mismatch has resulted in htmlentities errors');
205  }
206  $enc = $this->getEncoding();
207  $value = iconv('', $enc . '//IGNORE', (string) $value);
208  $filtered = htmlentities($value, $this->getQuoteStyle(), $enc, $this->getDoubleQuote());
209  if (!strlen($filtered)) {
210  #require_once 'Zend/Filter/Exception.php';
211  throw new Zend_Filter_Exception('Encoding mismatch has resulted in htmlentities errors');
212  }
213  }
214  return $filtered;
215  }
$value
Definition: gender.phtml:16

◆ getCharSet()

getCharSet ( )

Returns the charSet option

Proxies to getEncoding()

Returns
string

Definition at line 149 of file HtmlEntities.php.

150  {
151  return $this->getEncoding();
152  }

◆ getDoubleQuote()

getDoubleQuote ( )

Returns the doubleQuote option

Returns
boolean

Definition at line 172 of file HtmlEntities.php.

173  {
174  return $this->_doubleQuote;
175  }

◆ getEncoding()

getEncoding ( )

Get encoding

Returns
string

Definition at line 125 of file HtmlEntities.php.

126  {
127  return $this->_encoding;
128  }

◆ getQuoteStyle()

getQuoteStyle ( )

Returns the quoteStyle option

Returns
integer

Definition at line 102 of file HtmlEntities.php.

103  {
104  return $this->_quoteStyle;
105  }

◆ setCharSet()

setCharSet (   $charSet)

Sets the charSet option

Proxies to setEncoding()

Parameters
string$charSet
Returns
Zend_Filter_HtmlEntities Provides a fluent interface

Definition at line 162 of file HtmlEntities.php.

163  {
164  return $this->setEncoding($charSet);
165  }

◆ setDoubleQuote()

setDoubleQuote (   $doubleQuote)

Sets the doubleQuote option

Parameters
boolean$doubleQuote
Returns
Zend_Filter_HtmlEntities Provides a fluent interface

Definition at line 183 of file HtmlEntities.php.

184  {
185  $this->_doubleQuote = (boolean) $doubleQuote;
186  return $this;
187  }

◆ setEncoding()

setEncoding (   $value)

Set encoding

Parameters
string$value
Returns
Zend_Filter_HtmlEntities

Definition at line 136 of file HtmlEntities.php.

137  {
138  $this->_encoding = (string) $value;
139  return $this;
140  }
$value
Definition: gender.phtml:16

◆ setQuoteStyle()

setQuoteStyle (   $quoteStyle)

Sets the quoteStyle option

Parameters
integer$quoteStyle
Returns
Zend_Filter_HtmlEntities Provides a fluent interface

Definition at line 113 of file HtmlEntities.php.

114  {
115  $this->_quoteStyle = $quoteStyle;
116  return $this;
117  }

Field Documentation

◆ $_doubleQuote

$_doubleQuote
protected

Definition at line 54 of file HtmlEntities.php.

◆ $_encoding

$_encoding
protected

Definition at line 47 of file HtmlEntities.php.

◆ $_quoteStyle

$_quoteStyle
protected

Definition at line 40 of file HtmlEntities.php.


The documentation for this class was generated from the following file: