Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Name.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/Element.php';
25 
26 
36 {
42  public $value;
43 
44 
51  public function __construct($val)
52  {
53  settype($val, 'string');
54  if (strpos($val,"\x00") !== false) {
55  #require_once 'Zend/Pdf/Exception.php';
56  throw new Zend_Pdf_Exception('Null character is not allowed in PDF Names');
57  }
58  $this->value = (string)$val;
59  }
60 
61 
67  public function getType()
68  {
70  }
71 
72 
79  public static function escape($inStr)
80  {
81  $outStr = '';
82 
83  for ($count = 0; $count < strlen($inStr); $count++) {
84  $nextCode = ord($inStr[$count]);
85 
86  switch ($inStr[$count]) {
87  case '(':
88  // fall through to next case
89  case ')':
90  // fall through to next case
91  case '<':
92  // fall through to next case
93  case '>':
94  // fall through to next case
95  case '[':
96  // fall through to next case
97  case ']':
98  // fall through to next case
99  case '{':
100  // fall through to next case
101  case '}':
102  // fall through to next case
103  case '/':
104  // fall through to next case
105  case '%':
106  // fall through to next case
107  case '\\':
108  // fall through to next case
109  case '#':
110  $outStr .= sprintf('#%02X', $nextCode);
111  break;
112 
113  default:
114  if ($nextCode >= 33 && $nextCode <= 126 ) {
115  // Visible ASCII symbol
116  $outStr .= $inStr[$count];
117  } else {
118  $outStr .= sprintf('#%02X', $nextCode);
119  }
120  }
121 
122  }
123 
124  return $outStr;
125  }
126 
127 
134  public static function unescape($inStr)
135  {
136  $outStr = '';
137 
138  for ($count = 0; $count < strlen($inStr); $count++) {
139  if ($inStr[$count] != '#' ) {
140  $outStr .= $inStr[$count];
141  } else {
142  // Escape sequence
143  $outStr .= chr(base_convert(substr($inStr, $count+1, 2), 16, 10 ));
144  $count +=2;
145  }
146  }
147  return $outStr;
148  }
149 
150 
157  public function toString($factory = null)
158  {
159  return '/' . self::escape((string)$this->value);
160  }
161 }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
const TYPE_NAME
Definition: Element.php:35
$count
Definition: recent.phtml:13
toString($factory=null)
Definition: Name.php:157
static escape($inStr)
Definition: Name.php:79
static unescape($inStr)
Definition: Name.php:134