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.

122 lines
3.4 KiB

11 years ago
9 years ago
11 years ago
10 years ago
11 years ago
9 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 Destination
  18. * @copyright Copyright (c) 2005-2015 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/Element.php';
  24. /** Zend_Pdf_Destination */
  25. // require_once 'Zend/Pdf/Destination.php';
  26. /**
  27. * Abstract PDF explicit destination representation class
  28. *
  29. * @package Zend_Pdf
  30. * @subpackage Destination
  31. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. abstract class Zend_Pdf_Destination_Explicit extends Zend_Pdf_Destination
  35. {
  36. /**
  37. * Destination description array
  38. *
  39. * @var Zend_Pdf_Element_Array
  40. */
  41. protected $_destinationArray;
  42. /**
  43. * True if it's a remote destination
  44. *
  45. * @var boolean
  46. */
  47. protected $_isRemote;
  48. /**
  49. * Explicit destination object constructor
  50. *
  51. * @param Zend_Pdf_Element $destinationArray
  52. * @throws Zend_Pdf_Exception
  53. */
  54. public function __construct(Zend_Pdf_Element $destinationArray)
  55. {
  56. if ($destinationArray->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
  57. // require_once 'Zend/Pdf/Exception.php';
  58. throw new Zend_Pdf_Exception('Explicit destination resource Array must be a direct or an indirect array object.');
  59. }
  60. $this->_destinationArray = $destinationArray;
  61. switch (count($this->_destinationArray->items)) {
  62. case 0:
  63. // require_once 'Zend/Pdf/Exception.php';
  64. throw new Zend_Pdf_Exception('Destination array must contain a page reference.');
  65. break;
  66. case 1:
  67. // require_once 'Zend/Pdf/Exception.php';
  68. throw new Zend_Pdf_Exception('Destination array must contain a destination type name.');
  69. break;
  70. default:
  71. // Do nothing
  72. break;
  73. }
  74. switch ($this->_destinationArray->items[0]->getType()) {
  75. case Zend_Pdf_Element::TYPE_NUMERIC:
  76. $this->_isRemote = true;
  77. break;
  78. case Zend_Pdf_Element::TYPE_DICTIONARY:
  79. $this->_isRemote = false;
  80. break;
  81. default:
  82. // require_once 'Zend/Pdf/Exception.php';
  83. throw new Zend_Pdf_Exception('Destination target must be a page number or page dictionary object.');
  84. break;
  85. }
  86. }
  87. /**
  88. * Returns true if it's a remote destination
  89. *
  90. * @return boolean
  91. */
  92. public function isRemote()
  93. {
  94. return $this->_isRemote;
  95. }
  96. /**
  97. * Get resource
  98. *
  99. * @internal
  100. * @return Zend_Pdf_Element
  101. */
  102. public function getResource()
  103. {
  104. return $this->_destinationArray;
  105. }
  106. }