2012-05-06 18:25:40 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
2014-03-26 16:33:20 +07:00
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
namespace PhpOffice\PhpWord\Container;
|
2014-03-22 10:06:08 +04:00
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
use PhpOffice\PhpWord\Element\Image;
|
2013-12-16 06:40:30 -05:00
|
|
|
|
2014-03-24 00:26:10 +07:00
|
|
|
/**
|
|
|
|
|
* Header element
|
|
|
|
|
*/
|
2014-03-31 23:10:51 +07:00
|
|
|
class Header extends Container
|
2014-03-22 10:06:08 +04:00
|
|
|
{
|
2013-12-16 06:40:30 -05:00
|
|
|
/**
|
2014-03-31 23:10:51 +07:00
|
|
|
* Header types constants
|
2013-12-16 06:40:30 -05:00
|
|
|
*
|
|
|
|
|
* @var string
|
2014-03-31 23:10:51 +07:00
|
|
|
* @link http://www.schemacentral.com/sc/ooxml/a-wheaderType-4.html Header or Footer Type
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
|
|
|
|
const AUTO = 'default'; // Did not use DEFAULT because it is a PHP keyword
|
2014-03-31 23:10:51 +07:00
|
|
|
const EVEN = 'even';
|
2013-12-16 06:40:30 -05:00
|
|
|
const FIRST = 'first';
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-31 23:10:51 +07:00
|
|
|
* Header type
|
2013-12-16 06:40:30 -05:00
|
|
|
*
|
2014-03-31 23:10:51 +07:00
|
|
|
* @var string
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
2014-03-31 23:10:51 +07:00
|
|
|
private $headerType = self::AUTO;
|
2012-11-08 17:14:15 -06:00
|
|
|
|
2013-12-16 06:40:30 -05:00
|
|
|
/**
|
2014-03-31 23:10:51 +07:00
|
|
|
* Create new instance
|
2014-03-24 00:26:10 +07:00
|
|
|
*
|
|
|
|
|
* @param int $sectionCount
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
2014-03-31 23:10:51 +07:00
|
|
|
public function __construct($sectionId)
|
2013-12-16 06:40:30 -05:00
|
|
|
{
|
2014-04-02 09:01:44 +07:00
|
|
|
$this->container = 'header';
|
|
|
|
|
$this->containerId = $sectionId;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
2012-11-08 17:14:15 -06:00
|
|
|
|
2013-12-16 06:40:30 -05:00
|
|
|
/**
|
|
|
|
|
* Add a Watermark Element
|
|
|
|
|
*
|
|
|
|
|
* @param string $src
|
|
|
|
|
* @param mixed $style
|
2014-03-31 23:10:51 +07:00
|
|
|
* @return Image
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
|
|
|
|
public function addWatermark($src, $style = null)
|
|
|
|
|
{
|
2014-03-31 23:10:51 +07:00
|
|
|
return $this->addImage($src, $style, true);
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-31 23:10:51 +07:00
|
|
|
* Get header type
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
|
|
|
|
public function getType()
|
|
|
|
|
{
|
2014-03-31 23:10:51 +07:00
|
|
|
return $this->headerType;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-31 23:10:51 +07:00
|
|
|
* Reset type to default
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
|
|
|
|
public function resetType()
|
|
|
|
|
{
|
2014-03-31 23:10:51 +07:00
|
|
|
return $this->headerType = self::AUTO;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* First page only header
|
|
|
|
|
*/
|
|
|
|
|
public function firstPage()
|
|
|
|
|
{
|
2014-03-31 23:10:51 +07:00
|
|
|
return $this->headerType = self::FIRST;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-31 23:10:51 +07:00
|
|
|
* Even numbered pages only
|
2013-12-16 06:40:30 -05:00
|
|
|
*/
|
|
|
|
|
public function evenPage()
|
|
|
|
|
{
|
2014-03-31 23:10:51 +07:00
|
|
|
return $this->headerType = self::EVEN;
|
2013-12-16 06:40:30 -05:00
|
|
|
}
|
2014-03-11 19:26:56 +07:00
|
|
|
}
|