|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Pdf |
|
17 * @subpackage Actions |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: GoTo.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 /** Internally used classes */ |
|
24 require_once 'Zend/Pdf/Destination.php'; |
|
25 |
|
26 require_once 'Zend/Pdf/Element/Dictionary.php'; |
|
27 require_once 'Zend/Pdf/Element/Name.php'; |
|
28 |
|
29 |
|
30 /** Zend_Pdf_Action */ |
|
31 require_once 'Zend/Pdf/Action.php'; |
|
32 |
|
33 /** |
|
34 * PDF 'Go to' action |
|
35 * |
|
36 * @package Zend_Pdf |
|
37 * @subpackage Actions |
|
38 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
39 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
40 */ |
|
41 class Zend_Pdf_Action_GoTo extends Zend_Pdf_Action |
|
42 { |
|
43 /** |
|
44 * GoTo Action destination |
|
45 * |
|
46 * @var Zend_Pdf_Destination |
|
47 */ |
|
48 protected $_destination; |
|
49 |
|
50 |
|
51 /** |
|
52 * Object constructor |
|
53 * |
|
54 * @param Zend_Pdf_Element_Dictionary $dictionary |
|
55 * @param SplObjectStorage $processedActions list of already processed action dictionaries, used to avoid cyclic references |
|
56 */ |
|
57 public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions) |
|
58 { |
|
59 parent::__construct($dictionary, $processedActions); |
|
60 |
|
61 $this->_destination = Zend_Pdf_Destination::load($dictionary->D); |
|
62 } |
|
63 |
|
64 /** |
|
65 * Create new Zend_Pdf_Action_GoTo object using specified destination |
|
66 * |
|
67 * @param Zend_Pdf_Destination|string $destination |
|
68 * @return Zend_Pdf_Action_GoTo |
|
69 */ |
|
70 public static function create($destination) |
|
71 { |
|
72 if (is_string($destination)) { |
|
73 require_once 'Zend/Pdf/Destination/Named.php'; |
|
74 $destination = Zend_Pdf_Destination_Named::create($destination); |
|
75 } |
|
76 |
|
77 if (!$destination instanceof Zend_Pdf_Destination) { |
|
78 require_once 'Zend/Pdf/Exception.php'; |
|
79 throw new Zend_Pdf_Exception('$destination parameter must be a Zend_Pdf_Destination object or string.'); |
|
80 } |
|
81 |
|
82 $dictionary = new Zend_Pdf_Element_Dictionary(); |
|
83 $dictionary->Type = new Zend_Pdf_Element_Name('Action'); |
|
84 $dictionary->S = new Zend_Pdf_Element_Name('GoTo'); |
|
85 $dictionary->Next = null; |
|
86 $dictionary->D = $destination->getResource(); |
|
87 |
|
88 return new Zend_Pdf_Action_GoTo($dictionary, new SplObjectStorage()); |
|
89 } |
|
90 |
|
91 /** |
|
92 * Set goto action destination |
|
93 * |
|
94 * @param Zend_Pdf_Destination|string $destination |
|
95 * @return Zend_Pdf_Action_GoTo |
|
96 */ |
|
97 public function setDestination(Zend_Pdf_Destination $destination) |
|
98 { |
|
99 $this->_destination = $destination; |
|
100 |
|
101 $this->_actionDictionary->touch(); |
|
102 $this->_actionDictionary->D = $destination->getResource(); |
|
103 |
|
104 return $this; |
|
105 } |
|
106 |
|
107 /** |
|
108 * Get goto action destination |
|
109 * |
|
110 * @return Zend_Pdf_Destination |
|
111 */ |
|
112 public function getDestination() |
|
113 { |
|
114 return $this->_destination; |
|
115 } |
|
116 } |