PHPWord/src/PhpWord/Element/Footer.php

116 lines
2.5 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
2012-05-06 18:25:40 +02:00
*
2014-03-27 23:55:06 +07:00
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2014 PHPWord contributors
2014-05-04 21:03:28 +04:00
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
2012-05-06 18:25:40 +02:00
*/
namespace PhpOffice\PhpWord\Element;
2013-12-16 06:40:30 -05:00
/**
* 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';
/**
2014-05-11 22:54:51 +07:00
* @var string Container type
*/
2014-05-11 22:54:51 +07:00
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-05-04 15:13:31 +07:00
* @param int $containerId
2014-04-05 19:02:49 +07:00
* @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;
}
}