CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.
This commit is contained in:
parent
514777e8d2
commit
b11cbd8159
4546 changed files with 138 additions and 51 deletions
315
airtime_mvc/library/Zend/Pdf/Outline/Created.php
Normal file
315
airtime_mvc/library/Zend/Pdf/Outline/Created.php
Normal file
|
@ -0,0 +1,315 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Created.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
require_once 'Zend/Pdf/Element/Array.php';
|
||||
require_once 'Zend/Pdf/Element/Dictionary.php';
|
||||
require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
require_once 'Zend/Pdf/Element/String.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Outline */
|
||||
require_once 'Zend/Pdf/Outline.php';
|
||||
|
||||
/**
|
||||
* PDF outline representation class
|
||||
*
|
||||
* @todo Implement an ability to associate an outline item with a structure element (PDF 1.3 feature)
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Outlines
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Outline_Created extends Zend_Pdf_Outline
|
||||
{
|
||||
/**
|
||||
* Outline title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_title;
|
||||
|
||||
/**
|
||||
* Color to be used for the outline entry’s text.
|
||||
|
||||
* It uses the DeviceRGB color space for color representation.
|
||||
* Null means default value - black ([0.0 0.0 0.0] in RGB representation).
|
||||
*
|
||||
* @var Zend_Pdf_Color_Rgb
|
||||
*/
|
||||
protected $_color = null;
|
||||
|
||||
/**
|
||||
* True if outline item is displayed in italic.
|
||||
* Default value is false.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_italic = false;
|
||||
|
||||
/**
|
||||
* True if outline item is displayed in bold.
|
||||
* Default value is false.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_bold = false;
|
||||
|
||||
/**
|
||||
* Target destination or action.
|
||||
* String means named destination
|
||||
*
|
||||
* Null means no target.
|
||||
*
|
||||
* @var Zend_Pdf_Destination|Zend_Pdf_Action
|
||||
*/
|
||||
protected $_target = null;
|
||||
|
||||
|
||||
/**
|
||||
* Get outline title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set outline title
|
||||
*
|
||||
* @param string $title
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->_title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if outline item is displayed in italic
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isItalic()
|
||||
{
|
||||
return $this->_italic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets 'isItalic' outline flag
|
||||
*
|
||||
* @param boolean $isItalic
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setIsItalic($isItalic)
|
||||
{
|
||||
$this->_italic = $isItalic;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if outline item is displayed in bold
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isBold()
|
||||
{
|
||||
return $this->_bold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets 'isBold' outline flag
|
||||
*
|
||||
* @param boolean $isBold
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setIsBold($isBold)
|
||||
{
|
||||
$this->_bold = $isBold;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get outline text color.
|
||||
*
|
||||
* @return Zend_Pdf_Color_Rgb
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set outline text color.
|
||||
* (null means default color which is black)
|
||||
*
|
||||
* @param Zend_Pdf_Color_Rgb $color
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setColor(Zend_Pdf_Color_Rgb $color)
|
||||
{
|
||||
$this->_color = $color;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get outline target.
|
||||
*
|
||||
* @return Zend_Pdf_Target
|
||||
*/
|
||||
public function getTarget()
|
||||
{
|
||||
return $this->_target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set outline target.
|
||||
* Null means no target
|
||||
*
|
||||
* @param Zend_Pdf_Target|string $target
|
||||
* @return Zend_Pdf_Outline
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function setTarget($target = null)
|
||||
{
|
||||
if (is_string($target)) {
|
||||
require_once 'Zend/Pdf/Destination/Named.php';
|
||||
$target = new Zend_Pdf_Destination_Named($target);
|
||||
}
|
||||
|
||||
if ($target === null || $target instanceof Zend_Pdf_Target) {
|
||||
$this->_target = $target;
|
||||
} else {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outline target has to be Zend_Pdf_Destination or Zend_Pdf_Action object or string');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*
|
||||
* @param array $options
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
if (!isset($options['title'])) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Title parameter is required.');
|
||||
}
|
||||
|
||||
$this->setOptions($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump Outline and its child outlines into PDF structures
|
||||
*
|
||||
* Returns dictionary indirect object or reference
|
||||
*
|
||||
* @internal
|
||||
* @param Zend_Pdf_ElementFactory $factory object factory for newly created indirect objects
|
||||
* @param boolean $updateNavigation Update navigation flag
|
||||
* @param Zend_Pdf_Element $parent Parent outline dictionary reference
|
||||
* @param Zend_Pdf_Element $prev Previous outline dictionary reference
|
||||
* @param SplObjectStorage $processedOutlines List of already processed outlines
|
||||
* @return Zend_Pdf_Element
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function dumpOutline(Zend_Pdf_ElementFactory_Interface $factory,
|
||||
$updateNavigation,
|
||||
Zend_Pdf_Element $parent,
|
||||
Zend_Pdf_Element $prev = null,
|
||||
SplObjectStorage $processedOutlines = null)
|
||||
{
|
||||
if ($processedOutlines === null) {
|
||||
$processedOutlines = new SplObjectStorage();
|
||||
}
|
||||
$processedOutlines->attach($this);
|
||||
|
||||
$outlineDictionary = $factory->newObject(new Zend_Pdf_Element_Dictionary());
|
||||
|
||||
$outlineDictionary->Title = new Zend_Pdf_Element_String($this->getTitle());
|
||||
|
||||
$target = $this->getTarget();
|
||||
if ($target === null) {
|
||||
// Do nothing
|
||||
} else if ($target instanceof Zend_Pdf_Destination) {
|
||||
$outlineDictionary->Dest = $target->getResource();
|
||||
} else if ($target instanceof Zend_Pdf_Action) {
|
||||
$outlineDictionary->A = $target->getResource();
|
||||
} else {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outline target has to be Zend_Pdf_Destination, Zend_Pdf_Action object or null');
|
||||
}
|
||||
|
||||
$color = $this->getColor();
|
||||
if ($color !== null) {
|
||||
$components = $color->getComponents();
|
||||
$colorComponentElements = array(new Zend_Pdf_Element_Numeric($components[0]),
|
||||
new Zend_Pdf_Element_Numeric($components[1]),
|
||||
new Zend_Pdf_Element_Numeric($components[2]));
|
||||
$outlineDictionary->C = new Zend_Pdf_Element_Array($colorComponentElements);
|
||||
}
|
||||
|
||||
if ($this->isItalic() || $this->isBold()) {
|
||||
$outlineDictionary->F = new Zend_Pdf_Element_Numeric(($this->isItalic()? 1 : 0) | // Bit 1 - Italic
|
||||
($this->isBold()? 2 : 0)); // Bit 2 - Bold
|
||||
}
|
||||
|
||||
|
||||
$outlineDictionary->Parent = $parent;
|
||||
$outlineDictionary->Prev = $prev;
|
||||
|
||||
$lastChild = null;
|
||||
foreach ($this->childOutlines as $childOutline) {
|
||||
if ($processedOutlines->contains($childOutline)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outlines cyclyc reference is detected.');
|
||||
}
|
||||
|
||||
if ($lastChild === null) {
|
||||
$lastChild = $childOutline->dumpOutline($factory, true, $outlineDictionary, null, $processedOutlines);
|
||||
$outlineDictionary->First = $lastChild;
|
||||
} else {
|
||||
$childOutlineDictionary = $childOutline->dumpOutline($factory, true, $outlineDictionary, $lastChild, $processedOutlines);
|
||||
$lastChild->Next = $childOutlineDictionary;
|
||||
$lastChild = $childOutlineDictionary;
|
||||
}
|
||||
}
|
||||
$outlineDictionary->Last = $lastChild;
|
||||
|
||||
if (count($this->childOutlines) != 0) {
|
||||
$outlineDictionary->Count = new Zend_Pdf_Element_Numeric(($this->isOpen()? 1 : -1)*count($this->childOutlines));
|
||||
}
|
||||
|
||||
return $outlineDictionary;
|
||||
}
|
||||
}
|
462
airtime_mvc/library/Zend/Pdf/Outline/Loaded.php
Normal file
462
airtime_mvc/library/Zend/Pdf/Outline/Loaded.php
Normal file
|
@ -0,0 +1,462 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Actions
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Loaded.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
|
||||
/** Internally used classes */
|
||||
require_once 'Zend/Pdf/Element.php';
|
||||
require_once 'Zend/Pdf/Element/Array.php';
|
||||
require_once 'Zend/Pdf/Element/Numeric.php';
|
||||
require_once 'Zend/Pdf/Element/String.php';
|
||||
|
||||
|
||||
/** Zend_Pdf_Outline */
|
||||
require_once 'Zend/Pdf/Outline.php';
|
||||
|
||||
/**
|
||||
* Traceable PDF outline representation class
|
||||
*
|
||||
* Instances of this class trace object update uperations. That allows to avoid outlines PDF tree update
|
||||
* which should be performed at each document update otherwise.
|
||||
*
|
||||
* @package Zend_Pdf
|
||||
* @subpackage Outlines
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Pdf_Outline_Loaded extends Zend_Pdf_Outline
|
||||
{
|
||||
/**
|
||||
* Outline dictionary object
|
||||
*
|
||||
* @var Zend_Pdf_Element_Dictionary|Zend_Pdf_Element_Object|Zend_Pdf_Element_Reference
|
||||
*/
|
||||
protected $_outlineDictionary;
|
||||
|
||||
/**
|
||||
* original array of child outlines
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_originalChildOutlines = array();
|
||||
|
||||
/**
|
||||
* Get outline title.
|
||||
*
|
||||
* @return string
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if ($this->_outlineDictionary->Title === null) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outline dictionary Title entry is required.');
|
||||
}
|
||||
return $this->_outlineDictionary->Title->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set outline title
|
||||
*
|
||||
* @param string $title
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->_outlineDictionary->Title->touch();
|
||||
$this->_outlineDictionary->Title = new Zend_Pdf_Element_String($title);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets 'isOpen' outline flag
|
||||
*
|
||||
* @param boolean $isOpen
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setIsOpen($isOpen)
|
||||
{
|
||||
parent::setIsOpen($isOpen);
|
||||
|
||||
if ($this->_outlineDictionary->Count === null) {
|
||||
// Do Nothing.
|
||||
return this;
|
||||
}
|
||||
|
||||
$childrenCount = $this->_outlineDictionary->Count->value;
|
||||
$isOpenCurrentState = ($childrenCount > 0);
|
||||
if ($isOpen != $isOpenCurrentState) {
|
||||
$this->_outlineDictionary->Count->touch();
|
||||
$this->_outlineDictionary->Count->value = ($isOpen? 1 : -1)*abs($childrenCount);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if outline item is displayed in italic
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isItalic()
|
||||
{
|
||||
if ($this->_outlineDictionary->F === null) {
|
||||
return false;
|
||||
}
|
||||
return $this->_outlineDictionary->F->value & 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets 'isItalic' outline flag
|
||||
*
|
||||
* @param boolean $isItalic
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setIsItalic($isItalic)
|
||||
{
|
||||
if ($this->_outlineDictionary->F === null) {
|
||||
$this->_outlineDictionary->touch();
|
||||
$this->_outlineDictionary->F = new Zend_Pdf_Element_Numeric($isItalic? 1 : 0);
|
||||
} else {
|
||||
$this->_outlineDictionary->F->touch();
|
||||
if ($isItalic) {
|
||||
$this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | 1;
|
||||
} else {
|
||||
$this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | ~1;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if outline item is displayed in bold
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isBold()
|
||||
{
|
||||
if ($this->_outlineDictionary->F === null) {
|
||||
return false;
|
||||
}
|
||||
return $this->_outlineDictionary->F->value & 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets 'isBold' outline flag
|
||||
*
|
||||
* @param boolean $isBold
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setIsBold($isBold)
|
||||
{
|
||||
if ($this->_outlineDictionary->F === null) {
|
||||
$this->_outlineDictionary->touch();
|
||||
$this->_outlineDictionary->F = new Zend_Pdf_Element_Numeric($isBold? 2 : 0);
|
||||
} else {
|
||||
$this->_outlineDictionary->F->touch();
|
||||
if ($isBold) {
|
||||
$this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | 2;
|
||||
} else {
|
||||
$this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | ~2;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get outline text color.
|
||||
*
|
||||
* @return Zend_Pdf_Color_Rgb
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
if ($this->_outlineDictionary->C === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$components = $this->_outlineDictionary->C->items;
|
||||
|
||||
require_once 'Zend/Pdf/Color/Rgb.php';
|
||||
return new Zend_Pdf_Color_Rgb($components[0], $components[1], $components[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set outline text color.
|
||||
* (null means default color which is black)
|
||||
*
|
||||
* @param Zend_Pdf_Color_Rgb $color
|
||||
* @return Zend_Pdf_Outline
|
||||
*/
|
||||
public function setColor(Zend_Pdf_Color_Rgb $color)
|
||||
{
|
||||
$this->_outlineDictionary->touch();
|
||||
|
||||
if ($color === null) {
|
||||
$this->_outlineDictionary->C = null;
|
||||
} else {
|
||||
$components = $color->getComponents();
|
||||
$colorComponentElements = array(new Zend_Pdf_Element_Numeric($components[0]),
|
||||
new Zend_Pdf_Element_Numeric($components[1]),
|
||||
new Zend_Pdf_Element_Numeric($components[2]));
|
||||
$this->_outlineDictionary->C = new Zend_Pdf_Element_Array($colorComponentElements);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get outline target.
|
||||
*
|
||||
* @return Zend_Pdf_Target
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function getTarget()
|
||||
{
|
||||
if ($this->_outlineDictionary->Dest !== null) {
|
||||
if ($this->_outlineDictionary->A !== null) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outline dictionary may contain Dest or A entry, but not both.');
|
||||
}
|
||||
|
||||
require_once 'Zend/Pdf/Destination.php';
|
||||
return Zend_Pdf_Destination::load($this->_outlineDictionary->Dest);
|
||||
} else if ($this->_outlineDictionary->A !== null) {
|
||||
require_once 'Zend/Pdf/Action.php';
|
||||
return Zend_Pdf_Action::load($this->_outlineDictionary->A);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set outline target.
|
||||
* Null means no target
|
||||
*
|
||||
* @param Zend_Pdf_Target|string $target
|
||||
* @return Zend_Pdf_Outline
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function setTarget($target = null)
|
||||
{
|
||||
$this->_outlineDictionary->touch();
|
||||
|
||||
if (is_string($target)) {
|
||||
require_once 'Zend/Pdf/Destination/Named.php';
|
||||
$target = Zend_Pdf_Destination_Named::create($target);
|
||||
}
|
||||
|
||||
if ($target === null) {
|
||||
$this->_outlineDictionary->Dest = null;
|
||||
$this->_outlineDictionary->A = null;
|
||||
} else if ($target instanceof Zend_Pdf_Destination) {
|
||||
$this->_outlineDictionary->Dest = $target->getResource();
|
||||
$this->_outlineDictionary->A = null;
|
||||
} else if ($target instanceof Zend_Pdf_Action) {
|
||||
$this->_outlineDictionary->Dest = null;
|
||||
$this->_outlineDictionary->A = $target->getResource();
|
||||
} else {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outline target has to be Zend_Pdf_Destination or Zend_Pdf_Action object or string');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set outline options
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Pdf_Actions_Traceable
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
parent::setOptions($options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create PDF outline object using specified dictionary
|
||||
*
|
||||
* @internal
|
||||
* @param Zend_Pdf_Element $dictionary (It's actually Dictionary or Dictionary Object or Reference to a Dictionary Object)
|
||||
* @param Zend_Pdf_Action $parentAction
|
||||
* @param SplObjectStorage $processedOutlines List of already processed Outline dictionaries,
|
||||
* used to avoid cyclic references
|
||||
* @return Zend_Pdf_Action
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedDictionaries = null)
|
||||
{
|
||||
if ($dictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('$dictionary mast be an indirect dictionary object.');
|
||||
}
|
||||
|
||||
if ($processedDictionaries === null) {
|
||||
$processedDictionaries = new SplObjectStorage();
|
||||
}
|
||||
$processedDictionaries->attach($dictionary);
|
||||
|
||||
$this->_outlineDictionary = $dictionary;
|
||||
|
||||
if ($dictionary->Count !== null) {
|
||||
if ($dictionary->Count->getType() != Zend_Pdf_Element::TYPE_NUMERIC) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outline dictionary Count entry must be a numeric element.');
|
||||
}
|
||||
|
||||
$childOutlinesCount = $dictionary->Count->value;
|
||||
if ($childOutlinesCount > 0) {
|
||||
$this->_open = true;
|
||||
}
|
||||
$childOutlinesCount = abs($childOutlinesCount);
|
||||
|
||||
$childDictionary = $dictionary->First;
|
||||
for ($count = 0; $count < $childOutlinesCount; $count++) {
|
||||
if ($childDictionary === null) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outline childs load error.');
|
||||
}
|
||||
|
||||
if (!$processedDictionaries->contains($childDictionary)) {
|
||||
$this->childOutlines[] = new Zend_Pdf_Outline_Loaded($childDictionary, $processedDictionaries);
|
||||
}
|
||||
|
||||
$childDictionary = $childDictionary->Next;
|
||||
}
|
||||
|
||||
if ($childDictionary !== null) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outline childs load error.');
|
||||
}
|
||||
|
||||
$this->_originalChildOutlines = $this->childOutlines;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump Outline and its child outlines into PDF structures
|
||||
*
|
||||
* Returns dictionary indirect object or reference
|
||||
*
|
||||
* @internal
|
||||
* @param Zend_Pdf_ElementFactory $factory object factory for newly created indirect objects
|
||||
* @param boolean $updateNavigation Update navigation flag
|
||||
* @param Zend_Pdf_Element $parent Parent outline dictionary reference
|
||||
* @param Zend_Pdf_Element $prev Previous outline dictionary reference
|
||||
* @param SplObjectStorage $processedOutlines List of already processed outlines
|
||||
* @return Zend_Pdf_Element
|
||||
* @throws Zend_Pdf_Exception
|
||||
*/
|
||||
public function dumpOutline(Zend_Pdf_ElementFactory_Interface $factory,
|
||||
$updateNavigation,
|
||||
Zend_Pdf_Element $parent,
|
||||
Zend_Pdf_Element $prev = null,
|
||||
SplObjectStorage $processedOutlines = null)
|
||||
{
|
||||
if ($processedOutlines === null) {
|
||||
$processedOutlines = new SplObjectStorage();
|
||||
}
|
||||
$processedOutlines->attach($this);
|
||||
|
||||
if ($updateNavigation) {
|
||||
$this->_outlineDictionary->touch();
|
||||
|
||||
$this->_outlineDictionary->Parent = $parent;
|
||||
$this->_outlineDictionary->Prev = $prev;
|
||||
$this->_outlineDictionary->Next = null;
|
||||
}
|
||||
|
||||
$updateChildNavigation = false;
|
||||
if (count($this->_originalChildOutlines) != count($this->childOutlines)) {
|
||||
// If original and current children arrays have different size then children list was updated
|
||||
$updateChildNavigation = true;
|
||||
} else if ( !(array_keys($this->_originalChildOutlines) === array_keys($this->childOutlines)) ) {
|
||||
// If original and current children arrays have different keys (with a glance to an order) then children list was updated
|
||||
$updateChildNavigation = true;
|
||||
} else {
|
||||
foreach ($this->childOutlines as $key => $childOutline) {
|
||||
if ($this->_originalChildOutlines[$key] !== $childOutline) {
|
||||
$updateChildNavigation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$lastChild = null;
|
||||
if ($updateChildNavigation) {
|
||||
$this->_outlineDictionary->touch();
|
||||
$this->_outlineDictionary->First = null;
|
||||
|
||||
foreach ($this->childOutlines as $childOutline) {
|
||||
if ($processedOutlines->contains($childOutline)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outlines cyclyc reference is detected.');
|
||||
}
|
||||
|
||||
if ($lastChild === null) {
|
||||
// First pass. Update Outlines dictionary First entry using corresponding value
|
||||
$lastChild = $childOutline->dumpOutline($factory, $updateChildNavigation, $this->_outlineDictionary, null, $processedOutlines);
|
||||
$this->_outlineDictionary->First = $lastChild;
|
||||
} else {
|
||||
// Update previous outline dictionary Next entry (Prev is updated within dumpOutline() method)
|
||||
$childOutlineDictionary = $childOutline->dumpOutline($factory, $updateChildNavigation, $this->_outlineDictionary, $lastChild, $processedOutlines);
|
||||
$lastChild->Next = $childOutlineDictionary;
|
||||
$lastChild = $childOutlineDictionary;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_outlineDictionary->Last = $lastChild;
|
||||
|
||||
if (count($this->childOutlines) != 0) {
|
||||
$this->_outlineDictionary->Count = new Zend_Pdf_Element_Numeric(($this->isOpen()? 1 : -1)*count($this->childOutlines));
|
||||
} else {
|
||||
$this->_outlineDictionary->Count = null;
|
||||
}
|
||||
} else {
|
||||
foreach ($this->childOutlines as $childOutline) {
|
||||
if ($processedOutlines->contains($childOutline)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Outlines cyclyc reference is detected.');
|
||||
}
|
||||
$lastChild = $childOutline->dumpOutline($factory, $updateChildNavigation, $this->_outlineDictionary, $lastChild, $processedOutlines);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_outlineDictionary;
|
||||
}
|
||||
|
||||
public function dump($level = 0)
|
||||
{
|
||||
printf(":%3d:%s:%s:%s%s :\n", count($this->childOutlines),$this->isItalic()? 'i':' ', $this->isBold()? 'b':' ', str_pad('', 4*$level), $this->getTitle());
|
||||
|
||||
if ($this->isOpen() || true) {
|
||||
foreach ($this->childOutlines as $child) {
|
||||
$child->dump($level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue