Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields
Zend_Pdf_Element_String Class Reference
Inheritance diagram for Zend_Pdf_Element_String:
Zend_Pdf_Element Zend_Pdf_Element_String_Binary

Public Member Functions

 __construct ($val)
 
 getType ()
 
 toString ($factory=null)
 
- Public Member Functions inherited from Zend_Pdf_Element
 getType ()
 
 toString ($factory=null)
 
 makeClone (Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
 
 setParentObject (Zend_Pdf_Element_Object $parent)
 
 getParentObject ()
 
 touch ()
 
 cleanUp ()
 
 toPhp ()
 

Static Public Member Functions

static escape ($str)
 
static unescape ($str)
 
- Static Public Member Functions inherited from Zend_Pdf_Element
static phpToPdf ($input)
 

Data Fields

 $value
 
- Data Fields inherited from Zend_Pdf_Element
const TYPE_BOOL = 1
 
const TYPE_NUMERIC = 2
 
const TYPE_STRING = 3
 
const TYPE_NAME = 4
 
const TYPE_ARRAY = 5
 
const TYPE_DICTIONARY = 6
 
const TYPE_STREAM = 7
 
const TYPE_NULL = 11
 
const CLONE_MODE_SKIP_PAGES = 1
 
const CLONE_MODE_FORCE_CLONING = 2
 

Detailed Description

Definition at line 34 of file String.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $val)

Object constructor

Parameters
string$val

Definition at line 48 of file String.php.

49  {
50  $this->value = (string)$val;
51  }
$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

Member Function Documentation

◆ escape()

static escape (   $str)
static

Escape string according to the PDF rules

Parameters
string$str
Returns
string

Definition at line 83 of file String.php.

84  {
85  $outEntries = array();
86 
87  foreach (str_split($str, 128) as $chunk) {
88  // Collect sequence of unescaped characters
89  $offset = strcspn($chunk, "\n\r\t\x08\x0C()\\");
90  $chunkOut = substr($chunk, 0, $offset);
91 
92  while ($offset < strlen($chunk)) {
93  $nextCode = ord($chunk[$offset++]);
94  switch ($nextCode) {
95  // "\n" - line feed (LF)
96  case 10:
97  $chunkOut .= '\\n';
98  break;
99 
100  // "\r" - carriage return (CR)
101  case 13:
102  $chunkOut .= '\\r';
103  break;
104 
105  // "\t" - horizontal tab (HT)
106  case 9:
107  $chunkOut .= '\\t';
108  break;
109 
110  // "\b" - backspace (BS)
111  case 8:
112  $chunkOut .= '\\b';
113  break;
114 
115  // "\f" - form feed (FF)
116  case 12:
117  $chunkOut .= '\\f';
118  break;
119 
120  // '(' - left paranthesis
121  case 40:
122  $chunkOut .= '\\(';
123  break;
124 
125  // ')' - right paranthesis
126  case 41:
127  $chunkOut .= '\\)';
128  break;
129 
130  // '\' - backslash
131  case 92:
132  $chunkOut .= '\\\\';
133  break;
134 
135  default:
136  // This code is never executed extually
137  //
138  // Don't use non-ASCII characters escaping
139  // if ($nextCode >= 32 && $nextCode <= 126 ) {
140  // // Visible ASCII symbol
141  // $chunkEntries[] = chr($nextCode);
142  // } else {
143  // $chunkEntries[] = sprintf('\\%03o', $nextCode);
144  // }
145 
146  break;
147  }
148 
149  // Collect sequence of unescaped characters
150  $start = $offset;
151  $offset += strcspn($chunk, "\n\r\t\x08\x0C()\\", $offset);
152  $chunkOut .= substr($chunk, $start, $offset - $start);
153  }
154 
155  $outEntries[] = $chunkOut;
156  }
157 
158  return implode("\\\n", $outEntries);
159  }
$start
Definition: listing.phtml:18

◆ getType()

getType ( )

Return type of the element.

Returns
integer

Definition at line 59 of file String.php.

60  {
62  }
const TYPE_STRING
Definition: Element.php:34

◆ toString()

toString (   $factory = null)

Return object as string

Parameters
Zend_Pdf_Factory$factory
Returns
string

Definition at line 71 of file String.php.

72  {
73  return '(' . self::escape((string)$this->value) . ')';
74  }
$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
static escape($str)
Definition: String.php:83

◆ unescape()

static unescape (   $str)
static

Unescape string according to the PDF rules

Parameters
string$str
Returns
string

Definition at line 168 of file String.php.

169  {
170  $outEntries = array();
171 
172  $offset = 0;
173  while ($offset < strlen($str)) {
174  // Searche for the next escaped character/sequence
175  $escapeCharOffset = strpos($str, '\\', $offset);
176  if ($escapeCharOffset === false || $escapeCharOffset == strlen($str) - 1) {
177  // There are no escaped characters or '\' char has came at the end of string
178  $outEntries[] = substr($str, $offset);
179  break;
180  } else {
181  // Collect unescaped characters sequence
182  $outEntries[] = substr($str, $offset, $escapeCharOffset - $offset);
183  // Go to the escaped character
184  $offset = $escapeCharOffset + 1;
185 
186  switch ($str[$offset]) {
187  // '\\n' - line feed (LF)
188  case 'n':
189  $outEntries[] = "\n";
190  break;
191 
192  // '\\r' - carriage return (CR)
193  case 'r':
194  $outEntries[] = "\r";
195  break;
196 
197  // '\\t' - horizontal tab (HT)
198  case 't':
199  $outEntries[] = "\t";
200  break;
201 
202  // '\\b' - backspace (BS)
203  case 'b':
204  $outEntries[] = "\x08";
205  break;
206 
207  // '\\f' - form feed (FF)
208  case 'f':
209  $outEntries[] = "\x0C";
210  break;
211 
212  // '\\(' - left paranthesis
213  case '(':
214  $outEntries[] = '(';
215  break;
216 
217  // '\\)' - right paranthesis
218  case ')':
219  $outEntries[] = ')';
220  break;
221 
222  // '\\\\' - backslash
223  case '\\':
224  $outEntries[] = '\\';
225  break;
226 
227  // "\\\n" or "\\\n\r"
228  case "\n":
229  // skip new line symbol
230  if ($str[$offset + 1] == "\r") {
231  $offset++;
232  }
233  break;
234 
235  default:
236  if (strpos('0123456789', $str[$offset]) !== false) {
237  // Character in octal representation
238  // '\\xxx'
239  $nextCode = '0' . $str[$offset];
240 
241  if (strpos('0123456789', $str[$offset + 1]) !== false) {
242  $nextCode .= $str[++$offset];
243 
244  if (strpos('0123456789', $str[$offset + 1]) !== false) {
245  $nextCode .= $str[++$offset];
246  }
247  }
248 
249  $outEntries[] = chr(octdec($nextCode));
250  } else {
251  $outEntries[] = $str[$offset];
252  }
253  break;
254  }
255 
256  $offset++;
257  }
258  }
259 
260  return implode($outEntries);
261  }

Field Documentation

◆ $value

Definition at line 41 of file String.php.


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