File indexing completed on 2025-02-23 05:32:34

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Pdf
0017  * @subpackage Actions
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /** Internally used classes */
0024 // require_once 'Zend/Pdf/Destination.php';
0025 
0026 // require_once 'Zend/Pdf/Element/Dictionary.php';
0027 // require_once 'Zend/Pdf/Element/Name.php';
0028 
0029 
0030 /** Zend_Pdf_Action */
0031 // require_once 'Zend/Pdf/Action.php';
0032 
0033 /**
0034  * PDF 'Go to' action
0035  *
0036  * @package    Zend_Pdf
0037  * @subpackage Actions
0038  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0039  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0040  */
0041 class Zend_Pdf_Action_GoTo extends Zend_Pdf_Action
0042 {
0043     /**
0044      * GoTo Action destination
0045      *
0046      * @var Zend_Pdf_Destination
0047      */
0048     protected $_destination;
0049 
0050 
0051     /**
0052      * Object constructor
0053      *
0054      * @param Zend_Pdf_Element_Dictionary $dictionary
0055      * @param SplObjectStorage            $processedActions  list of already processed action dictionaries, used to avoid cyclic references
0056      */
0057     public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions)
0058     {
0059         parent::__construct($dictionary, $processedActions);
0060 
0061         $this->_destination = Zend_Pdf_Destination::load($dictionary->D);
0062     }
0063 
0064     /**
0065      * Create new Zend_Pdf_Action_GoTo object using specified destination
0066      *
0067      * @param Zend_Pdf_Destination|string $destination
0068      * @return Zend_Pdf_Action_GoTo
0069      */
0070     public static function create($destination)
0071     {
0072         if (is_string($destination)) {
0073             // require_once 'Zend/Pdf/Destination/Named.php';
0074             $destination = Zend_Pdf_Destination_Named::create($destination);
0075         }
0076 
0077         if (!$destination instanceof Zend_Pdf_Destination) {
0078             // require_once 'Zend/Pdf/Exception.php';
0079             throw new Zend_Pdf_Exception('$destination parameter must be a Zend_Pdf_Destination object or string.');
0080         }
0081 
0082         $dictionary = new Zend_Pdf_Element_Dictionary();
0083         $dictionary->Type = new Zend_Pdf_Element_Name('Action');
0084         $dictionary->S    = new Zend_Pdf_Element_Name('GoTo');
0085         $dictionary->Next = null;
0086         $dictionary->D    = $destination->getResource();
0087 
0088         return new Zend_Pdf_Action_GoTo($dictionary, new SplObjectStorage());
0089     }
0090 
0091     /**
0092      * Set goto action destination
0093      *
0094      * @param Zend_Pdf_Destination|string $destination
0095      * @return Zend_Pdf_Action_GoTo
0096      */
0097     public function setDestination(Zend_Pdf_Destination $destination)
0098     {
0099         $this->_destination = $destination;
0100 
0101         $this->_actionDictionary->touch();
0102         $this->_actionDictionary->D = $destination->getResource();
0103 
0104         return $this;
0105     }
0106 
0107     /**
0108      * Get goto action destination
0109      *
0110      * @return Zend_Pdf_Destination
0111      */
0112     public function getDestination()
0113     {
0114         return $this->_destination;
0115     }
0116 }