You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.4 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  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-2014 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /** Internally used classes */
  23. // require_once 'Zend/Pdf/Destination.php';
  24. // require_once 'Zend/Pdf/Element/Dictionary.php';
  25. // require_once 'Zend/Pdf/Element/Name.php';
  26. /** Zend_Pdf_Action */
  27. // require_once 'Zend/Pdf/Action.php';
  28. /**
  29. * PDF 'Go to' action
  30. *
  31. * @package Zend_Pdf
  32. * @subpackage Actions
  33. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. class Zend_Pdf_Action_GoTo extends Zend_Pdf_Action
  37. {
  38. /**
  39. * GoTo Action destination
  40. *
  41. * @var Zend_Pdf_Destination
  42. */
  43. protected $_destination;
  44. /**
  45. * Object constructor
  46. *
  47. * @param Zend_Pdf_Element_Dictionary $dictionary
  48. * @param SplObjectStorage $processedActions list of already processed action dictionaries, used to avoid cyclic references
  49. */
  50. public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions)
  51. {
  52. parent::__construct($dictionary, $processedActions);
  53. $this->_destination = Zend_Pdf_Destination::load($dictionary->D);
  54. }
  55. /**
  56. * Create new Zend_Pdf_Action_GoTo object using specified destination
  57. *
  58. * @param Zend_Pdf_Destination|string $destination
  59. * @return Zend_Pdf_Action_GoTo
  60. */
  61. public static function create($destination)
  62. {
  63. if (is_string($destination)) {
  64. // require_once 'Zend/Pdf/Destination/Named.php';
  65. $destination = Zend_Pdf_Destination_Named::create($destination);
  66. }
  67. if (!$destination instanceof Zend_Pdf_Destination) {
  68. // require_once 'Zend/Pdf/Exception.php';
  69. throw new Zend_Pdf_Exception('$destination parameter must be a Zend_Pdf_Destination object or string.');
  70. }
  71. $dictionary = new Zend_Pdf_Element_Dictionary();
  72. $dictionary->Type = new Zend_Pdf_Element_Name('Action');
  73. $dictionary->S = new Zend_Pdf_Element_Name('GoTo');
  74. $dictionary->Next = null;
  75. $dictionary->D = $destination->getResource();
  76. return new Zend_Pdf_Action_GoTo($dictionary, new SplObjectStorage());
  77. }
  78. /**
  79. * Set goto action destination
  80. *
  81. * @param Zend_Pdf_Destination|string $destination
  82. * @return Zend_Pdf_Action_GoTo
  83. */
  84. public function setDestination(Zend_Pdf_Destination $destination)
  85. {
  86. $this->_destination = $destination;
  87. $this->_actionDictionary->touch();
  88. $this->_actionDictionary->D = $destination->getResource();
  89. return $this;
  90. }
  91. /**
  92. * Get goto action destination
  93. *
  94. * @return Zend_Pdf_Destination
  95. */
  96. public function getDestination()
  97. {
  98. return $this->_destination;
  99. }
  100. }