Documentation

Field extends AbstractElement

Field element

Tags
since
0.11.0
see
http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html

Table of Contents

$collectionRelation  : bool
Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment
$commentRangeEnd  : Comment
The end position for the linked comment
$commentRangeStart  : Comment
The start position for the linked comment
$docPart  : string
Document part type: Section|Header|Footer|Footnote|Endnote
$docPartId  : int
Document part Id
$elementId  : string
Unique Id for element
$elementIndex  : int
Index of element in the elements collection (start with 1)
$fieldsArray  : array<string|int, mixed>
Field properties and options. Depending on type, a field can have different properties and options
$fontStyle  : string|Font
Font style
$mediaRelation  : bool
Has media relation flag; true for Link, Image, and Object
$options  : array<string|int, mixed>
Field options
$phpWord  : PhpWord
PhpWord object
$properties  : array<string|int, mixed>
Field properties
$relationId  : int
Relation Id
$sectionId  : int
Section Id
$text  : TextRun|string
Field text
$type  : string
Field type
$nestedLevel  : int
Depth of table container nested level; Primarily used for RTF writer/reader
$parent  : AbstractElement|null
A reference to the parent
$parentContainer  : string
Parent container type
$trackChange  : TrackChange
changed element info
__construct()  : mixed
Create a new Field Element
getCommentRangeEnd()  : Comment
Get comment end
getCommentRangeStart()  : Comment
Get comment start
getDocPart()  : string
Get doc part
getDocPartId()  : int
Get doc part Id
getElementId()  : string
Get element unique ID
getElementIndex()  : int
Get element index
getFontStyle()  : string|Font
Get Font style
getNestedLevel()  : int
Get nested level
getOptions()  : array<string|int, mixed>
Get Field properties
getParent()  : AbstractElement|null
Get parent element
getPhpWord()  : PhpWord
Get PhpWord
getProperties()  : array<string|int, mixed>
Get Field properties
getRelationId()  : int
Get relation Id
getSectionId()  : int
Get section number
getText()  : string|TextRun
Get Field text
getTrackChange()  : TrackChange
Gets the trackChange information
getType()  : string
Get Field type
isInSection()  : bool
Check if element is located in Section doc part (as opposed to Header/Footer)
setChangeInfo()  : mixed
Set changed
setCommentRangeEnd()  : mixed
Set comment end
setCommentRangeStart()  : mixed
Set comment start
setDocPart()  : mixed
Set doc part.
setElementId()  : mixed
Set element unique ID from 6 first digit of md5.
setElementIndex()  : mixed
Set element index.
setFontStyle()  : string|Font
Set Font style
setOptions()  : self
Set Field options
setParentContainer()  : mixed
Set parent container
setPhpWord()  : mixed
Set PhpWord as reference.
setProperties()  : self
Set Field properties
setRelationId()  : mixed
Set relation Id.
setText()  : null|string|TextRun
Set Field text
setTrackChange()  : mixed
Sets the trackChange information
setType()  : string
Set Field type
setEnumVal()  : string|null
Set enum value
setNewStyle()  : mixed
Set new style value
getMediaPart()  : string
Return media element (image, object, link) container name
setCollectionRelation()  : mixed
Set relation Id for elements that will be registered in the Collection subnamespaces.
setMediaRelation()  : mixed
Set relation Id for media elements (link, image, object; legacy of OOXML)

Properties

$collectionRelation

Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment

protected bool $collectionRelation = false

$docPart

Document part type: Section|Header|Footer|Footnote|Endnote

protected string $docPart = 'Section'

Used by textrun and cell container to determine where the element is located because it will affect the availability of other element, e.g. footnote will not be available when $docPart is header or footer.

$docPartId

Document part Id

protected int $docPartId = 1

For header and footer, this will be = ($sectionId - 1) * 3 + $index because the max number of header/footer in every page is 3, i.e. AUTO, FIRST, and EVEN (AUTO = ODD)

$elementIndex

Index of element in the elements collection (start with 1)

protected int $elementIndex = 1

$fieldsArray

Field properties and options. Depending on type, a field can have different properties and options

protected array<string|int, mixed> $fieldsArray = array('PAGE' => array('properties' => array('format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN')), 'options' => array('PreserveFormat')), 'NUMPAGES' => array('properties' => array('format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper'), 'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%')), 'options' => array('PreserveFormat')), 'DATE' => array('properties' => array('dateformat' => array( /* Generic formats */ 'yyyy-MM-dd', 'yyyy-MM', 'MMM-yy', 'MMM-yyyy', 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss', /* Day-Month-Year formats */ 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-MMM-yy', 'd MMM. yy', 'd-M-yy', 'd-M-yy h:mm', 'd-M-yy h:mm:ss', 'd-M-yy h:mm am/pm', 'd-M-yy h:mm:ss am/pm', 'd-M-yy HH:mm', 'd-M-yy HH:mm:ss', 'd/M/yy', 'd/M/yy h:mm', 'd/M/yy h:mm:ss', 'd/M/yy h:mm am/pm', 'd/M/yy h:mm:ss am/pm', 'd/M/yy HH:mm', 'd/M/yy HH:mm:ss', 'd-M-yyyy', 'd-M-yyyy h:mm', 'd-M-yyyy h:mm:ss', 'd-M-yyyy h:mm am/pm', 'd-M-yyyy h:mm:ss am/pm', 'd-M-yyyy HH:mm', 'd-M-yyyy HH:mm:ss', 'd/M/yyyy', 'd/M/yyyy h:mm', 'd/M/yyyy h:mm:ss', 'd/M/yyyy h:mm am/pm', 'd/M/yyyy h:mm:ss am/pm', 'd/M/yyyy HH:mm', 'd/M/yyyy HH:mm:ss', /* Month-Day-Year formats */ 'dddd, MMMM d yyyy', 'MMMM d yyyy', 'MMM-d-yy', 'MMM. d yy', 'M-d-yy', 'M-d-yy h:mm', 'M-d-yy h:mm:ss', 'M-d-yy h:mm am/pm', 'M-d-yy h:mm:ss am/pm', 'M-d-yy HH:mm', 'M-d-yy HH:mm:ss', 'M/d/yy', 'M/d/yy h:mm', 'M/d/yy h:mm:ss', 'M/d/yy h:mm am/pm', 'M/d/yy h:mm:ss am/pm', 'M/d/yy HH:mm', 'M/d/yy HH:mm:ss', 'M-d-yyyy', 'M-d-yyyy h:mm', 'M-d-yyyy h:mm:ss', 'M-d-yyyy h:mm am/pm', 'M-d-yyyy h:mm:ss am/pm', 'M-d-yyyy HH:mm', 'M-d-yyyy HH:mm:ss', 'M/d/yyyy', 'M/d/yyyy h:mm', 'M/d/yyyy h:mm:ss', 'M/d/yyyy h:mm am/pm', 'M/d/yyyy h:mm:ss am/pm', 'M/d/yyyy HH:mm', 'M/d/yyyy HH:mm:ss', )), 'options' => array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat')), 'MACROBUTTON' => array('properties' => array('macroname' => '')), 'XE' => array('properties' => array(), 'options' => array('Bold', 'Italic')), 'INDEX' => array('properties' => array(), 'options' => array('PreserveFormat')), 'STYLEREF' => array('properties' => array('StyleIdentifier' => ''), 'options' => array('PreserveFormat')))

$fontStyle

Font style

protected string|Font $fontStyle

$mediaRelation

Has media relation flag; true for Link, Image, and Object

protected bool $mediaRelation = false

$options

Field options

protected array<string|int, mixed> $options = array()

$properties

Field properties

protected array<string|int, mixed> $properties = array()

$type

Field type

protected string $type

$nestedLevel

Depth of table container nested level; Primarily used for RTF writer/reader

private int $nestedLevel = 0

0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc.

$parentContainer

Parent container type

private string $parentContainer

Methods

__construct()

Create a new Field Element

public __construct([string $type = null ][, array<string|int, mixed> $properties = array() ][, array<string|int, mixed> $options = array() ][, TextRun|string|null $text = null ][, string|array<string|int, mixed>|Font $fontStyle = null ]) : mixed
Parameters
$type : string = null
$properties : array<string|int, mixed> = array()
$options : array<string|int, mixed> = array()
$text : TextRun|string|null = null
$fontStyle : string|array<string|int, mixed>|Font = null
Return values
mixed

getDocPart()

Get doc part

public getDocPart() : string
Return values
string

getDocPartId()

Get doc part Id

public getDocPartId() : int
Return values
int

getElementId()

Get element unique ID

public getElementId() : string
Return values
string

getElementIndex()

Get element index

public getElementIndex() : int
Return values
int

getFontStyle()

Get Font style

public getFontStyle() : string|Font
Return values
string|Font

getNestedLevel()

Get nested level

public getNestedLevel() : int
Return values
int

getOptions()

Get Field properties

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getProperties()

Get Field properties

public getProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRelationId()

Get relation Id

public getRelationId() : int
Return values
int

getSectionId()

Get section number

public getSectionId() : int
Return values
int

getType()

Get Field type

public getType() : string
Return values
string

isInSection()

Check if element is located in Section doc part (as opposed to Header/Footer)

public isInSection() : bool
Return values
bool

setChangeInfo()

Set changed

public setChangeInfo(string $type, string $author[, null|int|DateTime $date = null ]) : mixed
Parameters
$type : string

INSERTED|DELETED

$author : string
$date : null|int|DateTime = null

allways in UTC

Return values
mixed

setCommentRangeEnd()

Set comment end

public setCommentRangeEnd(Comment $value) : mixed
Parameters
$value : Comment
Return values
mixed

setCommentRangeStart()

Set comment start

public setCommentRangeStart(Comment $value) : mixed
Parameters
$value : Comment
Return values
mixed

setDocPart()

Set doc part.

public setDocPart(string $docPart[, int $docPartId = 1 ]) : mixed
Parameters
$docPart : string
$docPartId : int = 1
Return values
mixed

setElementId()

Set element unique ID from 6 first digit of md5.

public setElementId() : mixed
Return values
mixed

setElementIndex()

Set element index.

public setElementIndex(int $value) : mixed
Parameters
$value : int
Return values
mixed

setFontStyle()

Set Font style

public setFontStyle([string|array<string|int, mixed>|Font $style = null ]) : string|Font
Parameters
$style : string|array<string|int, mixed>|Font = null
Return values
string|Font

setOptions()

Set Field options

public setOptions([array<string|int, mixed> $options = array() ]) : self
Parameters
$options : array<string|int, mixed> = array()
Tags
throws
InvalidArgumentException
Return values
self

setParentContainer()

Set parent container

public setParentContainer(AbstractElement $container) : mixed

Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)

Parameters
$container : AbstractElement
Return values
mixed

setPhpWord()

Set PhpWord as reference.

public setPhpWord([PhpWord $phpWord = null ]) : mixed
Parameters
$phpWord : PhpWord = null
Return values
mixed

setProperties()

Set Field properties

public setProperties([array<string|int, mixed> $properties = array() ]) : self
Parameters
$properties : array<string|int, mixed> = array()
Tags
throws
InvalidArgumentException
Return values
self

setRelationId()

Set relation Id.

public setRelationId(int $value) : mixed
Parameters
$value : int
Return values
mixed

setText()

Set Field text

public setText([string|TextRun $text = null ]) : null|string|TextRun
Parameters
$text : string|TextRun = null
Tags
throws
InvalidArgumentException
Return values
null|string|TextRun

setType()

Set Field type

public setType([string $type = null ]) : string
Parameters
$type : string = null
Tags
throws
InvalidArgumentException
Return values
string

setEnumVal()

Set enum value

protected setEnumVal([string|null $value = null ][, array<string|int, string> $enum = array() ][, string|null $default = null ]) : string|null
Parameters
$value : string|null = null
$enum : array<string|int, string> = array()
$default : string|null = null
Tags
throws
InvalidArgumentException
todo

Merge with the same method in AbstractStyle

Return values
string|null

setNewStyle()

Set new style value

protected setNewStyle(mixed $styleObject[, mixed $styleValue = null ][, bool $returnObject = false ]) : mixed
Parameters
$styleObject : mixed

Style object

$styleValue : mixed = null

Style value

$returnObject : bool = false

Always return object

Return values
mixed

getMediaPart()

Return media element (image, object, link) container name

private getMediaPart() : string
Return values
string

section|headerx|footerx|footnote|endnote

setCollectionRelation()

Set relation Id for elements that will be registered in the Collection subnamespaces.

private setCollectionRelation() : mixed
Return values
mixed

setMediaRelation()

Set relation Id for media elements (link, image, object; legacy of OOXML)

private setMediaRelation() : mixed
  • Image element needs to be passed to Media object
  • Icon needs to be set for Object element
Return values
mixed

Search results