PHPWord/src/PhpWord/Footnotes.php

166 lines
3.1 KiB
PHP
Raw Normal View History

<?php
/**
* PHPWord
*
2014-03-27 23:55:06 +07:00
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/
namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Media;
2014-04-09 21:35:55 +07:00
use PhpOffice\PhpWord\Element\Footnote;
/**
2014-04-09 21:35:55 +07:00
* Footnote collection
*/
2014-04-09 21:35:55 +07:00
class Footnotes
{
/**
* Elements
*
* @var array
*/
private static $elements = array();
/**
* Add new element
*
2014-04-09 21:35:55 +07:00
* @param Footnote $element
* @return integer Reference ID
* @since 0.9.2
*/
2014-04-09 21:35:55 +07:00
public static function addElement($element)
{
$rId = self::countElements() + 1;
2014-04-09 21:35:55 +07:00
self::$elements[$rId] = $element;
return $rId;
}
/**
* Set element
*
* @param integer $index
2014-04-09 21:35:55 +07:00
* @param Footnote $element
* @since 0.9.2
*/
2014-04-09 21:35:55 +07:00
public static function setElement($index, $element)
{
2014-04-09 18:47:10 +07:00
if (array_key_exists($index, self::$elements)) {
2014-04-09 21:35:55 +07:00
self::$elements[$index] = $element;
2014-04-09 18:47:10 +07:00
}
}
/**
* Get element by index
*
2014-04-09 18:47:10 +07:00
* @param integer $index
2014-04-09 21:35:55 +07:00
* @return Footnote
* @since 0.9.2
*/
public static function getElement($index)
{
if (array_key_exists($index, self::$elements)) {
return self::$elements[$index];
} else {
return null;
}
}
/**
* Get elements
*
* @return array
* @since 0.9.2
*/
public static function getElements()
{
return self::$elements;
}
/**
* Get element count
*
* @return integer
* @since 0.9.2
*/
public static function countElements()
{
return count(self::$elements);
}
/**
* Reset elements
*
* @since 0.9.2
*/
public static function resetElements()
{
self::$elements = array();
}
/**
* Add new footnote
*
2014-04-09 21:35:55 +07:00
* @param Footnote $element
* @return integer Reference ID
* @deprecated 0.9.2
* @codeCoverageIgnore
*/
2014-04-09 21:35:55 +07:00
public static function addFootnoteElement($element)
{
2014-04-09 21:35:55 +07:00
return self::addElement($element);
}
/**
* Get Footnote Elements
*
* @return array
* @deprecated 0.9.2
* @codeCoverageIgnore
*/
public static function getFootnoteElements()
{
return self::getElements();
}
/**
* Get Footnote Elements Count
*
* @return integer
* @deprecated 0.9.2
* @codeCoverageIgnore
*/
public static function countFootnoteElements()
{
return self::countElements();
}
/**
* Add new Footnote Link Element
*
2014-03-17 07:26:25 +07:00
* @param string $linkSrc
* @return integer Reference ID
* @deprecated 0.9.2
* @codeCoverageIgnore
*/
public static function addFootnoteLinkElement($linkSrc)
{
2014-04-05 19:02:49 +07:00
return Media::addElement('footnotes', 'link', $linkSrc);
}
/**
* Get Footnote Link Elements
*
* @return array
* @deprecated 0.9.2
* @codeCoverageIgnore
*/
public static function getFootnoteLinkElements()
{
2014-04-05 19:02:49 +07:00
return Media::getElements('footnotes', 'link');
}
}