PHPWord/src/PhpWord/Element/Footer.php

127 lines
2.4 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* PHPWord
2012-05-06 18:25:40 +02:00
*
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
2012-05-06 18:25:40 +02:00
*/
namespace PhpOffice\PhpWord\Element;
2013-12-16 06:40:30 -05:00
use PhpOffice\PhpWord\Element\Table;
/**
* Footer element
*/
class Footer extends AbstractContainer
{
/**
* Header/footer types constants
*
* @var string
* @link http://www.schemacentral.com/sc/ooxml/a-wtype-4.html Header or Footer Type
*/
2014-04-05 19:02:49 +07:00
const AUTO = 'default'; // default and odd pages
const FIRST = 'first';
const EVEN = 'even';
/**
* Container type
*
* @var string
*/
protected $container = 'footer';
2014-04-05 19:02:49 +07:00
/**
* Header type
*
* @var string
*/
protected $type = self::AUTO;
2014-04-05 19:02:49 +07:00
2013-12-16 06:40:30 -05:00
/**
2014-03-31 23:10:51 +07:00
* Create new instance
2013-12-16 06:40:30 -05:00
*
2014-03-31 23:10:51 +07:00
* @param int $sectionId
2014-04-05 19:02:49 +07:00
* @param int $footerId
* @param string $type
2013-12-16 06:40:30 -05:00
*/
public function __construct($sectionId, $containerId = 1, $type = self::AUTO)
2013-12-16 06:40:30 -05:00
{
2014-04-05 19:02:49 +07:00
$this->sectionId = $sectionId;
$this->setType($type);
$this->setDocPart($this->container, ($sectionId - 1) * 3 + $containerId);
2014-04-05 19:02:49 +07:00
}
/**
* Set type
*
* @param string $value
* @since 0.10.0
2014-04-05 19:02:49 +07:00
*/
public function setType($value = self::AUTO)
{
if (!in_array($value, array(self::AUTO, self::FIRST, self::EVEN))) {
$value = self::AUTO;
}
2014-04-05 19:02:49 +07:00
$this->type = $value;
}
/**
* Get type
*
* @return string
* @since 0.10.0
2014-04-05 19:02:49 +07:00
*/
public function getType()
{
return $this->type;
}
/**
* Reset type to default
*
* @return string
*/
public function resetType()
{
return $this->type = self::AUTO;
}
/**
* First page only header
*
* @return string
*/
public function firstPage()
{
return $this->type = self::FIRST;
}
/**
* Even numbered pages only
*
* @return string
*/
public function evenPage()
{
return $this->type = self::EVEN;
}
/**
* Add table element
*
* @param mixed $style
* @return \PhpOffice\PhpWord\Element\Table
* @todo Merge with the same function on Section
*/
public function addTable($style = null)
{
$table = new Table($this->getDocPart(), $this->getDocPartId(), $style);
$this->addElement($table);
return $table;
}
}