*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Pdf / Target.php
blob45e4973ef8f5336fe91593bdcb6f1b4ca28603e6
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
16 * @package Zend_Pdf
17 * @subpackage Actions
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id$
23 /** Zend_Pdf_ElementFactory */
24 require_once 'Zend/Pdf/ElementFactory.php';
27 /**
28 * PDF target (action or destination)
30 * @package Zend_Pdf
31 * @subpackage Actions
32 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
33 * @license http://framework.zend.com/license/new-bsd New BSD License
35 abstract class Zend_Pdf_Target
37 /**
38 * Parse resource and return it as an Action or Explicit Destination
40 * $param Zend_Pdf_Element $resource
41 * @return Zend_Pdf_Destination|
42 * @throws Zend_Pdf_Exception
44 public static function load(Zend_Pdf_Element $resource) {
45 if ($resource->getType() == Zend_Pdf_Element::TYPE_DICTIONARY) {
46 if (($resource->Type === null || $resource->Type->value =='Action') && $resource->S !== null) {
47 // It's a well-formed action, load it
48 return Zend_Pdf_Action::load($resource);
49 } else if ($resource->D !== null) {
50 // It's a destination
51 $resource = $resource->D;
52 } else {
53 require_once 'Zend/Pdf/Exception.php';
54 throw new Zend_Pdf_Exception('Wrong resource type.');
58 if ($resource->getType() == Zend_Pdf_Element::TYPE_ARRAY ||
59 $resource->getType() == Zend_Pdf_Element::TYPE_NAME ||
60 $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
61 // Resource is an array, just treat it as an explicit destination array
62 return Zend_Pdf_Destination::load($resource);
63 } else {
64 require_once 'Zend/Pdf/Exception.php';
65 throw new Zend_Pdf_Exception( 'Wrong resource type.' );
69 /**
70 * Get resource
72 * @internal
73 * @return Zend_Pdf_Element
75 abstract public function getResource();