Field
extends AbstractElement
in package
Field element.
Tags
Table of Contents
Properties
- $collectionRelation : bool
- Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment.
- $commentsRangeEnd : Comments
- The end position for the linked comments.
- $commentsRangeStart : Comments
- The start position for the linked comments.
- $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 : Font|string
- Font style.
- $mediaRelation : bool
- Has media relation flag; true for Link, Image, and Object.
- $options : array<string|int, mixed>
- Field options.
- $phpWord : PhpWord|null
- PhpWord object.
- $properties : array<string|int, mixed>
- Field properties.
- $relationId : int
- Relation Id.
- $sectionId : int
- Section Id.
- $text : string|TextRun
- Field text.
- $type : string
- Field type.
- $nestedLevel : int
- Depth of table container nested level; Primarily used for RTF writer/reader.
- $parent : null|AbstractElement
- A reference to the parent.
- $parentContainer : string
- Parent container type.
- $trackChange : TrackChange
- changed element info.
Methods
- __construct() : mixed
- Create a new Field Element.
- getCommentRangeEnd() : Comment
- Get comment end.
- getCommentRangeStart() : Comment
- Get comment start.
- getCommentsRangeEnd() : Comments
- Get comments end.
- getCommentsRangeStart() : Comments
- Get comments start.
- getDocPart() : string
- Get doc part.
- getDocPartId() : int
- Get doc part Id.
- getElementId() : string
- Get element unique ID.
- getElementIndex() : int
- Get element index.
- getFontStyle() : Font|string
- Get Font style.
- getNestedLevel() : int
- Get nested level.
- getOptions() : array<string|int, mixed>
- Get Field properties.
- getParent() : null|AbstractElement
- Get parent element.
- getPhpWord() : PhpWord|null
- 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() : void
- Set changed.
- setCommentRangeEnd() : void
- Set comment end.
- setCommentRangeStart() : void
- Set comment start.
- setDocPart() : void
- Set doc part.
- setElementId() : void
- Set element unique ID from 6 first digit of md5.
- setElementIndex() : void
- Set element index.
- setFontStyle() : Font|string
- Set Font style.
- setOptions() : self
- Set Field options.
- setParentContainer() : void
- Set parent container.
- setPhpWord() : void
- Set PhpWord as reference.
- setProperties() : self
- Set Field properties.
- setRelationId() : void
- Set relation Id.
- setText() : null|string|TextRun
- Set Field text.
- setTrackChange() : void
- Sets the trackChange information.
- setType() : string
- Set Field type.
- setEnumVal() : null|string
- Set enum value.
- setNewStyle() : mixed
- Set new style value.
- getMediaPart() : string
- Return media element (image, object, link) container name.
- setCollectionRelation() : void
- Set relation Id for elements that will be registered in the Collection subnamespaces.
- setMediaRelation() : void
- 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
$commentsRangeEnd
The end position for the linked comments.
protected
Comments
$commentsRangeEnd
$commentsRangeStart
The start position for the linked comments.
protected
Comments
$commentsRangeStart
$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)
$elementId
Unique Id for element.
protected
string
$elementId
$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
= ['PAGE' => ['properties' => ['format' => ['Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN']], 'options' => ['PreserveFormat']], 'NUMPAGES' => ['properties' => ['format' => ['Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper'], 'numformat' => ['0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%']], 'options' => ['PreserveFormat']], 'DATE' => ['properties' => ['dateformat' => [
// 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' => ['PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat']], 'MACROBUTTON' => ['properties' => ['macroname' => '']], 'XE' => ['properties' => [], 'options' => ['Bold', 'Italic']], 'INDEX' => ['properties' => [], 'options' => ['PreserveFormat']], 'STYLEREF' => ['properties' => ['StyleIdentifier' => ''], 'options' => ['PreserveFormat']], 'FILENAME' => ['properties' => ['format' => ['Upper', 'Lower', 'FirstCap', 'Caps']], 'options' => ['Path', 'PreserveFormat']], 'REF' => ['properties' => ['name' => ''], 'options' => ['f', 'h', 'n', 'p', 'r', 't', 'w']]]
$fontStyle
Font style.
protected
Font|string
$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
= []
$phpWord
PhpWord object.
protected
PhpWord|null
$phpWord
$properties
Field properties.
protected
array<string|int, mixed>
$properties
= []
$relationId
Relation Id.
protected
int
$relationId
$sectionId
Section Id.
protected
int
$sectionId
$text
Field text.
protected
string|TextRun
$text
$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.
$parent
A reference to the parent.
private
null|AbstractElement
$parent
$parentContainer
Parent container type.
private
string
$parentContainer
$trackChange
changed element info.
private
TrackChange
$trackChange
Methods
__construct()
Create a new Field Element.
public
__construct([string $type = null ][, array<string|int, mixed> $properties = [] ][, array<string|int, mixed> $options = [] ][, null|string|TextRun $text = null ][, array<string|int, mixed>|Font|string $fontStyle = null ]) : mixed
Parameters
getCommentRangeEnd()
Get comment end.
public
getCommentRangeEnd() : Comment
Return values
CommentgetCommentRangeStart()
Get comment start.
public
getCommentRangeStart() : Comment
Return values
CommentgetCommentsRangeEnd()
Get comments end.
public
getCommentsRangeEnd() : Comments
Return values
CommentsgetCommentsRangeStart()
Get comments start.
public
getCommentsRangeStart() : Comments
Return values
CommentsgetDocPart()
Get doc part.
public
getDocPart() : string
Return values
stringgetDocPartId()
Get doc part Id.
public
getDocPartId() : int
Return values
intgetElementId()
Get element unique ID.
public
getElementId() : string
Return values
stringgetElementIndex()
Get element index.
public
getElementIndex() : int
Return values
intgetFontStyle()
Get Font style.
public
getFontStyle() : Font|string
Return values
Font|stringgetNestedLevel()
Get nested level.
public
getNestedLevel() : int
Return values
intgetOptions()
Get Field properties.
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getParent()
Get parent element.
public
getParent() : null|AbstractElement
Return values
null|AbstractElementgetPhpWord()
Get PhpWord.
public
getPhpWord() : PhpWord|null
Return values
PhpWord|nullgetProperties()
Get Field properties.
public
getProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>getRelationId()
Get relation Id.
public
getRelationId() : int
Return values
intgetSectionId()
Get section number.
public
getSectionId() : int
Return values
intgetText()
Get Field text.
public
getText() : string|TextRun
Return values
string|TextRungetTrackChange()
Gets the trackChange information.
public
getTrackChange() : TrackChange
Return values
TrackChangegetType()
Get Field type.
public
getType() : string
Return values
stringisInSection()
Check if element is located in Section doc part (as opposed to Header/Footer).
public
isInSection() : bool
Return values
boolsetChangeInfo()
Set changed.
public
setChangeInfo(string $type, string $author[, null|DateTime|int $date = null ]) : void
Parameters
- $type : string
-
INSERTED|DELETED
- $author : string
- $date : null|DateTime|int = null
-
allways in UTC
setCommentRangeEnd()
Set comment end.
public
setCommentRangeEnd(Comment $value) : void
Parameters
- $value : Comment
setCommentRangeStart()
Set comment start.
public
setCommentRangeStart(Comment $value) : void
Parameters
- $value : Comment
setDocPart()
Set doc part.
public
setDocPart(string $docPart[, int $docPartId = 1 ]) : void
Parameters
- $docPart : string
- $docPartId : int = 1
setElementId()
Set element unique ID from 6 first digit of md5.
public
setElementId() : void
setElementIndex()
Set element index.
public
setElementIndex(int $value) : void
Parameters
- $value : int
setFontStyle()
Set Font style.
public
setFontStyle([array<string|int, mixed>|Font|string $style = null ]) : Font|string
Parameters
- $style : array<string|int, mixed>|Font|string = null
Return values
Font|stringsetOptions()
Set Field options.
public
setOptions([array<string|int, mixed> $options = [] ]) : self
Parameters
- $options : array<string|int, mixed> = []
Return values
selfsetParentContainer()
Set parent container.
public
setParentContainer(self $container) : void
Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
Parameters
- $container : self
setPhpWord()
Set PhpWord as reference.
public
setPhpWord([PhpWord|null $phpWord = null ]) : void
Parameters
- $phpWord : PhpWord|null = null
setProperties()
Set Field properties.
public
setProperties([array<string|int, mixed> $properties = [] ]) : self
Parameters
- $properties : array<string|int, mixed> = []
Return values
selfsetRelationId()
Set relation Id.
public
setRelationId(int $value) : void
Parameters
- $value : int
setText()
Set Field text.
public
setText([null|string|TextRun $text = null ]) : null|string|TextRun
Parameters
- $text : null|string|TextRun = null
Return values
null|string|TextRunsetTrackChange()
Sets the trackChange information.
public
setTrackChange(TrackChange $trackChange) : void
Parameters
- $trackChange : TrackChange
setType()
Set Field type.
public
setType([string $type = null ]) : string
Parameters
- $type : string = null
Return values
stringsetEnumVal()
Set enum value.
protected
setEnumVal([null|string $value = null ][, array<string|int, string> $enum = [] ][, null|string $default = null ]) : null|string
Parameters
- $value : null|string = null
- $enum : array<string|int, string> = []
- $default : null|string = null
Tags
Return values
null|stringsetNewStyle()
Set new style value.
protected
setNewStyle(mixed $styleObject[, null|array<string|int, mixed>|string|Style $styleValue = null ][, bool $returnObject = false ]) : mixed
Parameters
- $styleObject : mixed
-
Style object
- $styleValue : null|array<string|int, mixed>|string|Style = null
-
Style value
- $returnObject : bool = false
-
Always return object
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() : void
setMediaRelation()
Set relation Id for media elements (link, image, object; legacy of OOXML).
private
setMediaRelation() : void
- Image element needs to be passed to Media object
- Icon needs to be set for Object element