/framework/vendor/zend/Zend/Pdf/Destination/Explicit.php
PHP | 122 lines | 48 code | 16 blank | 58 comment | 4 complexity | ef8782cc31e2ce11b6660ba6c61eb0f7 MD5 | raw file
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-2010 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 * @version $Id: Explicit.php 20096 2010-01-06 02:05:09Z bkarwin $ 21 */ 22 23 24/** Internally used classes */ 25require_once 'Zend/Pdf/Element.php'; 26 27 28/** Zend_Pdf_Destination */ 29require_once 'Zend/Pdf/Destination.php'; 30 31/** 32 * Abstract PDF explicit destination representation class 33 * 34 * @package Zend_Pdf 35 * @subpackage Destination 36 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 37 * @license http://framework.zend.com/license/new-bsd New BSD License 38 */ 39abstract class Zend_Pdf_Destination_Explicit extends Zend_Pdf_Destination 40{ 41 /** 42 * Destination description array 43 * 44 * @var Zend_Pdf_Element_Array 45 */ 46 protected $_destinationArray; 47 48 /** 49 * True if it's a remote destination 50 * 51 * @var boolean 52 */ 53 protected $_isRemote; 54 55 /** 56 * Explicit destination object constructor 57 * 58 * @param Zend_Pdf_Element $destinationArray 59 * @throws Zend_Pdf_Exception 60 */ 61 public function __construct(Zend_Pdf_Element $destinationArray) 62 { 63 if ($destinationArray->getType() != Zend_Pdf_Element::TYPE_ARRAY) { 64 require_once 'Zend/Pdf/Exception.php'; 65 throw new Zend_Pdf_Exception('Explicit destination resource Array must be a direct or an indirect array object.'); 66 } 67 68 $this->_destinationArray = $destinationArray; 69 70 switch (count($this->_destinationArray->items)) { 71 case 0: 72 require_once 'Zend/Pdf/Exception.php'; 73 throw new Zend_Pdf_Exception('Destination array must contain a page reference.'); 74 break; 75 76 case 1: 77 require_once 'Zend/Pdf/Exception.php'; 78 throw new Zend_Pdf_Exception('Destination array must contain a destination type name.'); 79 break; 80 81 default: 82 // Do nothing 83 break; 84 } 85 86 switch ($this->_destinationArray->items[0]->getType()) { 87 case Zend_Pdf_Element::TYPE_NUMERIC: 88 $this->_isRemote = true; 89 break; 90 91 case Zend_Pdf_Element::TYPE_DICTIONARY: 92 $this->_isRemote = false; 93 break; 94 95 default: 96 require_once 'Zend/Pdf/Exception.php'; 97 throw new Zend_Pdf_Exception('Destination target must be a page number or page dictionary object.'); 98 break; 99 } 100 } 101 102 /** 103 * Returns true if it's a remote destination 104 * 105 * @return boolean 106 */ 107 public function isRemote() 108 { 109 return $this->_isRemote; 110 } 111 112 /** 113 * Get resource 114 * 115 * @internal 116 * @return Zend_Pdf_Element 117 */ 118 public function getResource() 119 { 120 return $this->_destinationArray; 121 } 122}