Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Created.php
Go to the documentation of this file.
1 <?php
25 #require_once 'Zend/Pdf/Element/Array.php';
26 #require_once 'Zend/Pdf/Element/Dictionary.php';
27 #require_once 'Zend/Pdf/Element/Numeric.php';
28 #require_once 'Zend/Pdf/Element/String.php';
29 
30 
32 #require_once 'Zend/Pdf/Outline.php';
33 
45 {
51  protected $_title;
52 
61  protected $_color = null;
62 
69  protected $_italic = false;
70 
77  protected $_bold = false;
78 
87  protected $_target = null;
88 
89 
95  public function getTitle()
96  {
97  return $this->_title;
98  }
99 
106  public function setTitle($title)
107  {
108  $this->_title = $title;
109  return $this;
110  }
111 
117  public function isItalic()
118  {
119  return $this->_italic;
120  }
121 
128  public function setIsItalic($isItalic)
129  {
130  $this->_italic = $isItalic;
131  return $this;
132  }
133 
139  public function isBold()
140  {
141  return $this->_bold;
142  }
143 
150  public function setIsBold($isBold)
151  {
152  $this->_bold = $isBold;
153  return $this;
154  }
155 
156 
162  public function getColor()
163  {
164  return $this->_color;
165  }
166 
174  public function setColor(Zend_Pdf_Color_Rgb $color)
175  {
176  $this->_color = $color;
177  return $this;
178  }
179 
185  public function getTarget()
186  {
187  return $this->_target;
188  }
189 
198  public function setTarget($target = null)
199  {
200  if (is_string($target)) {
201  #require_once 'Zend/Pdf/Destination/Named.php';
203  }
204 
205  if ($target === null || $target instanceof Zend_Pdf_Target) {
206  $this->_target = $target;
207  } else {
208  #require_once 'Zend/Pdf/Exception.php';
209  throw new Zend_Pdf_Exception('Outline target has to be Zend_Pdf_Destination or Zend_Pdf_Action object or string');
210  }
211 
212  return $this;
213  }
214 
215 
222  public function __construct($options = array())
223  {
224  if (!isset($options['title'])) {
225  #require_once 'Zend/Pdf/Exception.php';
226  throw new Zend_Pdf_Exception('Title parameter is required.');
227  }
228 
229  $this->setOptions($options);
230  }
231 
247  $updateNavigation,
248  Zend_Pdf_Element $parent,
249  Zend_Pdf_Element $prev = null,
250  SplObjectStorage $processedOutlines = null)
251  {
252  if ($processedOutlines === null) {
253  $processedOutlines = new SplObjectStorage();
254  }
255  $processedOutlines->attach($this);
256 
257  $outlineDictionary = $factory->newObject(new Zend_Pdf_Element_Dictionary());
258 
259  $outlineDictionary->Title = new Zend_Pdf_Element_String($this->getTitle());
260 
261  $target = $this->getTarget();
262  if ($target === null) {
263  // Do nothing
264  } else if ($target instanceof Zend_Pdf_Destination) {
265  $outlineDictionary->Dest = $target->getResource();
266  } else if ($target instanceof Zend_Pdf_Action) {
267  $outlineDictionary->A = $target->getResource();
268  } else {
269  #require_once 'Zend/Pdf/Exception.php';
270  throw new Zend_Pdf_Exception('Outline target has to be Zend_Pdf_Destination, Zend_Pdf_Action object or null');
271  }
272 
273  $color = $this->getColor();
274  if ($color !== null) {
275  $components = $color->getComponents();
276  $colorComponentElements = array(new Zend_Pdf_Element_Numeric($components[0]),
277  new Zend_Pdf_Element_Numeric($components[1]),
278  new Zend_Pdf_Element_Numeric($components[2]));
279  $outlineDictionary->C = new Zend_Pdf_Element_Array($colorComponentElements);
280  }
281 
282  if ($this->isItalic() || $this->isBold()) {
283  $outlineDictionary->F = new Zend_Pdf_Element_Numeric(($this->isItalic()? 1 : 0) | // Bit 1 - Italic
284  ($this->isBold()? 2 : 0)); // Bit 2 - Bold
285  }
286 
287 
288  $outlineDictionary->Parent = $parent;
289  $outlineDictionary->Prev = $prev;
290 
291  $lastChild = null;
292  foreach ($this->childOutlines as $childOutline) {
293  if ($processedOutlines->contains($childOutline)) {
294  #require_once 'Zend/Pdf/Exception.php';
295  throw new Zend_Pdf_Exception('Outlines cyclyc reference is detected.');
296  }
297 
298  if ($lastChild === null) {
299  $lastChild = $childOutline->dumpOutline($factory, true, $outlineDictionary, null, $processedOutlines);
300  $outlineDictionary->First = $lastChild;
301  } else {
302  $childOutlineDictionary = $childOutline->dumpOutline($factory, true, $outlineDictionary, $lastChild, $processedOutlines);
303  $lastChild->Next = $childOutlineDictionary;
304  $lastChild = $childOutlineDictionary;
305  }
306  }
307  $outlineDictionary->Last = $lastChild;
308 
309  if (count($this->childOutlines) != 0) {
310  $outlineDictionary->Count = new Zend_Pdf_Element_Numeric(($this->isOpen()? 1 : -1)*count($this->childOutlines));
311  }
312 
313  return $outlineDictionary;
314  }
315 }
$title
Definition: default.phtml:14
$target
Definition: skip.phtml:8
setOptions(array $options)
Definition: Outline.php:173
setColor(Zend_Pdf_Color_Rgb $color)
Definition: Created.php:174
setIsItalic($isItalic)
Definition: Created.php:128
setTarget($target=null)
Definition: Created.php:198
__construct($options=array())
Definition: Created.php:222
dumpOutline(Zend_Pdf_ElementFactory_Interface $factory, $updateNavigation, Zend_Pdf_Element $parent, Zend_Pdf_Element $prev=null, SplObjectStorage $processedOutlines=null)
Definition: Created.php:246