DocImport
in package
Abstract class with additional stuff for the document importer system
The document importer loads docuemnts and returns XML files These files can then be processed by other parts of the CMS. The term "xmldoc" is referring to the intermediate XML file produced by the import libraries
Table of Contents
Methods
- getHeadingsTree() : Treenode
- For a given XML document, return a tree of headings
- getHtml() : string|null
- For a given XML doc file, return the HTML version.
- getResources() : array<string|int, mixed>|null
- For a given XML doc file, return an array of resources, in name => data format.
- instance() : mixed
- Return a `DocImport` object instance for converting a file with a given original name Throws an exception on error
- load() : string|DOMDocument
- The main load function for a document.
Methods
getHeadingsTree()
For a given XML document, return a tree of headings
public
static getHeadingsTree(string|DOMDocument $filename, int $max_depth[, bool $include_body = false ]) : Treenode
Any heading level past the max_depth option is treated like body text.
Parameters
- $filename : string|DOMDocument
-
The XML file to load; this can also be passed as a DOMDocument object
- $max_depth : int
-
The maximum depth of headings to return
- $include_body : bool = false
-
True to include the body XML as a parameter on the node. Default false
Return values
Treenode —The tree of headings
getHtml()
For a given XML doc file, return the HTML version.
public
static getHtml(string|DOMDocument $filename[, array<string|int, mixed> $images = array() ][, array<string|int, mixed> $headings = array() ]) : string|null
Parameters
- $filename : string|DOMDocument
-
The file to load; this can also be passed as a DOMDocument object
- $images : array<string|int, mixed> = array()
-
Mapping of rel => filename for images
- $headings : array<string|int, mixed> = array()
-
Mapping of old to new level for headings (e.g. 3 => 2 for H3 -> H2)
Return values
string|null —The HTML, or NULL on error
getResources()
For a given XML doc file, return an array of resources, in name => data format.
public
static getResources(string $filename) : array<string|int, mixed>|null
Parameters
- $filename : string
-
The file to load
Return values
array<string|int, mixed>|null —The resources, or null on error
instance()
Return a `DocImport` object instance for converting a file with a given original name Throws an exception on error
public
static instance(mixed $orig_filename) : mixed
Parameters
- $orig_filename : mixed
load()
The main load function for a document.
public
abstract load(string $filename) : string|DOMDocument
Throw an exception on error.
Parameters
- $filename : string
-
The file. The file will exist, but may not be valid
Return values
string|DOMDocument —Resultant XML data as a string or DOMDocument element