WIKINDX API trunk

RTF.php

WIKINDX : Bibliographic Management system.

Tags
see
https://wikindx.sourceforge.io/

The WIKINDX SourceForge project

author

The WIKINDX Team

license

https://www.isc.org/licenses/ ISC License

Table of Contents

Functions

header()  : string
Set some defaults and create the RTF opening tag
footer()  : string
Create the RTF closing tag
footnotes()  : mixed
Set RTF headers regarding footnotes/endnotes
citation()  : mixed
Citation stuff The options for $citeStyle are: 'inText' In-text citations (needs bibliography appended) 'ftInc' Footnotes: the footnotes order increments from 1 (needs bibliography appended) 'endInc' Endnotes: the endnotes order increments from 1 'endSameId' Endnotes using the same ID for the same resource: the endnotes order increments from 1 'endSameIdOrdered' Endnotes using the same ID for the same resource: the endnotes order is set in the bibliography settings
documentSettings()  : mixed
Deal with document defaults. This function has various roles depending on the value of $method Must be called before traverseDOM()
cleanHtml()  : string
Clean up HTML before parsing and do some initial conversion
specialCharsToRTF()  : string
Convert special characters.
cleanBlockquotes()  : string
TinyMCE always puts p tags within blockquote—remove them!
fonts()  : mixed
Deal with fonts. This function has various roles depending on the value of $method
colours()  : mixed
Deal with colours. This function has various roles depending on the value of $method
lists()  : mixed
Deal with lists. This function has various roles depending on the value of $method
listToRTF()  : string
Convert lists to RTF (deals with nested lists too and recognizes unordered or ordered)
newListTableItem()  : string
Create new listtable item
textDecoration()  : mixed
text-decoration styling
fontWeight()  : string
Convert font-weight
fontSize()  : string
Convert font size to RTF
traverseDOM()  : string
Traverse the DOM and produce RTF code
nodeAttributes()  : mixed
Convert attributes
tables()  : mixed
Deal with tables and their elements. This function has various roles depending on the value of $method
setCellEdgeDefaults()  : array<string|int, mixed>
Set cell edge defaults in the table matrix.
tableCellToRTF()  : array<string|int, mixed>
Convert table cell to RTF cell property string
inheritParentBorders()  : array<string|int, mixed>
Transfer the parent's border properties to a spanned child
getCellBorderParams()  : array<string|int, mixed>
Get cell border parameters
updateCellEdges()  : array<string|int, mixed>
Update cell edge in the table matrix for one cell. i.e. border has been set for this table cell
cellBordersToString()  : string
Create a string of cell border properties from an array
calculateTableMatrix()  : array<string|int, mixed>
We need to set up a table matrix counting number of rows and number of their children so we can deal with various properties.
getCellWidth()  : string
Get cell width
startCellToRTF()  : array<string|int, mixed>
Start the process of converting a td or th element
utf8_2_rtfansicpg1252()  : string
UTF-8 to ANSI Windows 1252 strings for RTF only
domImageToRtfImagePlaceholders()  : string
Replace HTML image src attribut by a placeholder pointing to a cached file on disk
domNodeAttributes2Array()  : array<string|int, string>
Convert attributes of a DOMNode to an array of attributes

Functions

header()

Set some defaults and create the RTF opening tag

header() : string
Return values
string

Create the RTF closing tag

footer() : string
Return values
string

footnotes()

Set RTF headers regarding footnotes/endnotes

footnotes(string $method[, mixed $extra = FALSE ]) : mixed

See notes at the beginning of this file. But especially remember that endSameId and endSameIdOrdered are fake endnotes (span data-wikindxbib is removed in RTFEXPORT::parseHTML())

Parameters
$method : string
$extra : mixed = FALSE

Default FALSE

citation()

Citation stuff The options for $citeStyle are: 'inText' In-text citations (needs bibliography appended) 'ftInc' Footnotes: the footnotes order increments from 1 (needs bibliography appended) 'endInc' Endnotes: the endnotes order increments from 1 'endSameId' Endnotes using the same ID for the same resource: the endnotes order increments from 1 'endSameIdOrdered' Endnotes using the same ID for the same resource: the endnotes order is set in the bibliography settings

citation(string $method[, mixed $extra1 = FALSE ][, mixed $extra2 = FALSE ]) : mixed

Most of the formatting of citations is accomplished by the citation engine and formatting in HTML and a bibliography is appended where appropriate.

Parameters
$method : string
$extra1 : mixed = FALSE

Default FALSE

$extra2 : mixed = FALSE

Default FALSE

documentSettings()

Deal with document defaults. This function has various roles depending on the value of $method Must be called before traverseDOM()

documentSettings(string $method[, mixed $extra = FALSE ][, string $paperSize = 'A4' ][, string $lineSpacing = 'singleSpace' ]) : mixed
Parameters
$method : string
$extra : mixed = FALSE

Default FALSE

$paperSize : string = 'A4'

Default 'A4'

$lineSpacing : string = 'singleSpace'

Default 'singleSpace'

cleanHtml()

Clean up HTML before parsing and do some initial conversion

cleanHtml(string $text) : string
Parameters
$text : string
Return values
string

specialCharsToRTF()

Convert special characters.

specialCharsToRTF(string $text, bool $protectCurlyBrace) : string

For RTF, for escaping special characters used to build control words, it is recommended to convert to hex

Parameters
$text : string
$protectCurlyBrace : bool
Return values
string

cleanBlockquotes()

TinyMCE always puts p tags within blockquote—remove them!

cleanBlockquotes(string $text) : string
Parameters
$text : string
Return values
string

fonts()

Deal with fonts. This function has various roles depending on the value of $method

fonts(string $method[, string $font = '' ]) : mixed
Parameters
$method : string
$font : string = ''

Default ''

colours()

Deal with colours. This function has various roles depending on the value of $method

colours(string $method[, string $colour = '' ]) : mixed
Parameters
$method : string
$colour : string = ''

Default ''

lists()

Deal with lists. This function has various roles depending on the value of $method

lists(string $method[, string $string = '' ]) : mixed
Parameters
$method : string
$string : string = ''

Default ''

listToRTF()

Convert lists to RTF (deals with nested lists too and recognizes unordered or ordered)

listToRTF(array<string|int, mixed> $stack, string $listType) : string

Although list items might have style attributes such as align right, these are ignored by RTF so ignore them here too.

Parameters
$stack : array<string|int, mixed>
$listType : string
Return values
string

newListTableItem()

Create new listtable item

newListTableItem(int $levelnfc, int $listIndex) : string
Parameters
$levelnfc : int
$listIndex : int
Return values
string

textDecoration()

text-decoration styling

textDecoration(string $style) : mixed
Parameters
$style : string

fontWeight()

Convert font-weight

fontWeight(string $style) : string
Parameters
$style : string
Return values
string

fontSize()

Convert font size to RTF

fontSize(string $size) : string
Parameters
$size : string
Return values
string

traverseDOM()

Traverse the DOM and produce RTF code

traverseDOM(DOMNode $domNode[, mixed $listLevel = 0 ][, int $tableNestLevel = 0 ]) : string
Parameters
$domNode : DOMNode
$listLevel : mixed = 0
$tableNestLevel : int = 0

Default = 0

Return values
string

nodeAttributes()

Convert attributes

nodeAttributes(DOMNode $node[, bool $wantArray = FALSE ]) : mixed
Parameters
$node : DOMNode
$wantArray : bool = FALSE

Default = FALSE

tables()

Deal with tables and their elements. This function has various roles depending on the value of $method

tables(string $method[, mixed $extra = FALSE ][, mixed $extra2 = FALSE ]) : mixed

For each table, there is a $tableObject, and each nested table gets a new $tableObject

Parameters
$method : string
$extra : mixed = FALSE

Default = FALSE

$extra2 : mixed = FALSE

Default FALSE

setCellEdgeDefaults()

Set cell edge defaults in the table matrix.

setCellEdgeDefaults(array<string|int, mixed> $tableMatrix, string $key, mixed $value) : array<string|int, mixed>

Done when first encountering a table tag.

Also used to set the table parameter 'cellpadding' on all cells.

Parameters
$tableMatrix : array<string|int, mixed>
$key : string
$value : mixed
Return values
array<string|int, mixed>

tableCellToRTF()

Convert table cell to RTF cell property string

tableCellToRTF(array<string|int, mixed> $attributes, array<string|int, mixed> $cellArray, int $thisRowNumber, int $thisCellNumber[, bool $th = FALSE ]) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed>
$cellArray : array<string|int, mixed>
$thisRowNumber : int
$thisCellNumber : int
$th : bool = FALSE

(Default FALSE)

Return values
array<string|int, mixed>

inheritParentBorders()

Transfer the parent's border properties to a spanned child

inheritParentBorders(array<string|int, mixed> $childCell, int $childRowNumber) : array<string|int, mixed>

Child can never have top edge

Parameters
$childCell : array<string|int, mixed>
$childRowNumber : int
Return values
array<string|int, mixed>

getCellBorderParams()

Get cell border parameters

getCellBorderParams(string $key, string $value[, array<string|int, mixed> $attributes = [] ]) : array<string|int, mixed>
Parameters
$key : string
$value : string
$attributes : array<string|int, mixed> = []

Default [] (used only if $key == 'border-style')

Return values
array<string|int, mixed>

updateCellEdges()

Update cell edge in the table matrix for one cell. i.e. border has been set for this table cell

updateCellEdges(array<string|int, mixed> $cellArray, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$cellArray : array<string|int, mixed>
$params : array<string|int, mixed>

($style, $width, $color)

Return values
array<string|int, mixed>

cellBordersToString()

Create a string of cell border properties from an array

cellBordersToString(array<string|int, mixed> $cellArray, array<string|int, mixed> $edges) : string

We also deal with rowspans where there may or may not be padding and borders

Parameters
$cellArray : array<string|int, mixed>
$edges : array<string|int, mixed>
Return values
string

calculateTableMatrix()

We need to set up a table matrix counting number of rows and number of their children so we can deal with various properties.

calculateTableMatrix(DOMNode $domNode) : array<string|int, mixed>

Need to count max row cells in a table before we can set up the matrix. Note that the HTML code for vertical spanning ('rowspan') is likely to have uneven numbers of cells. Where there are gaps, we must insert the child cell. Note the relationship (Parent/Child) row no./cell no. for each member of a spanned group to be able to deal with inserted cell properties later on. Cell borders, background colours, properties and so on inherit from the table properties but can override them with individual cell settings. This function is called on an opening table or tbody tag, so, here, we first set up the table matrix consisting of rows where the key is the row count for the table and the value is an array comprising an array of default properties for each cell. These properties can then be overriden in tableCellToRTF().

Parameters
$domNode : DOMNode
Return values
array<string|int, mixed>

getCellWidth()

Get cell width

getCellWidth(array<string|int, mixed> $attributes) : string
Parameters
$attributes : array<string|int, mixed>
Return values
string

startCellToRTF()

Start the process of converting a td or th element

startCellToRTF(DOMNode $domNode, bool $rowSpanParent, int $tableNestLevel) : array<string|int, mixed>
Parameters
$domNode : DOMNode
$rowSpanParent : bool
$tableNestLevel : int

// > 1 == nested

Return values
array<string|int, mixed>

utf8_2_rtfansicpg1252()

UTF-8 to ANSI Windows 1252 strings for RTF only

utf8_2_rtfansicpg1252(string $string) : string

Returns a string encoded accordingly to Rich Text Format (RTF) Specification Version 1.9.1.

Parameters
$string : string

UTF-8 encoded string

Tags
see
https://www.microsoft.com/en-us/download/details.aspx?id=10725
Return values
string

plain ASCII with RTF specific sequences for others characters

domImageToRtfImagePlaceholders()

Replace HTML image src attribut by a placeholder pointing to a cached file on disk

domImageToRtfImagePlaceholders(DOMNode $domNode) : string

The file is hex encoded in cache/files and its filename is inserted inside src, using a pattern as "##.img.hex##"

Online resources are dwnloaded and included like others images.

The real insertion is postponed and delegated to \UTILS\insertExportImages() that consumes less memory.

Parameters
$domNode : DOMNode
Return values
string

domNodeAttributes2Array()

Convert attributes of a DOMNode to an array of attributes

domNodeAttributes2Array(DOMNode $domNode) : array<string|int, string>
Parameters
$domNode : DOMNode
Return values
array<string|int, string>

        
On this page

Search results