Other
- Full name:
\SebLucas\EPubMeta\Other
- Parent class:
\SebLucas\EPubMeta\EPub
Methods
setMeta
A simple setter for simple meta attributes
protected setMeta(string $item, string $value, bool|string $attribute = false, bool|string $attributeValue = false, bool $caseSensitive = true): mixed
It should only be used for attributes that are expected to be unique
Parameters:
Parameter | Type | Description |
---|---|---|
$item |
string | XML node to set |
$value |
string | New node value |
$attribute |
bool|string | Attribute name |
$attributeValue |
bool|string | Attribute value |
$caseSensitive |
bool |
getMeta
A simple getter for simple meta attributes
protected getMeta(string $item, bool|string $att = false, bool|string $aval = false, bool $caseSensitive = true): string
It should only be used for attributes that are expected to be unique
Parameters:
Parameter | Type | Description |
---|---|---|
$item |
string | XML node to get |
$att |
bool|string | Attribute name |
$aval |
bool|string | Attribute value |
$caseSensitive |
bool |
sync
Sync XPath object with updated DOM.
Inherited methods
__construct
Constructor
Parameters:
Parameter | Type | Description |
---|---|---|
$file |
string | path to epub file to work on |
$zipClass |
string | class to handle zip - ZipFile is read-only |
Throws:
if metadata could not be loaded
openZipFile
Summary of openZipFile
Parameters:
Parameter | Type | Description |
---|---|---|
$zipClass |
string |
Throws:
loadMetadata
Summary of loadMetadata
Throws:
loadXmlData
Summary of loadXmlData
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
string |
initSpineComponent
Summary of initSpineComponent
Throws:
loadNavData
Summary of loadNavData
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
string |
loadTocData
Summary of loadTocData
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
string |
getEpubVersion
Get the ePub version
Return Value:
The number of the ePub version (2 or 3 for now) or 0 if not found
file
file name getter
meta
meta file getter
close
Close the epub file
cleanITunesCrap
Remove iTunes files
save
Writes back all meta data changes
download
Get the updated epub
Parameters:
Parameter | Type | Description |
---|---|---|
$file |
mixed | |
$sendHeaders |
bool |
components
Get the components list as an array
component
Get the component content
Parameters:
Parameter | Type | Description |
---|---|---|
$comp |
mixed |
getComponentName
Summary of getComponentName
Parameters:
Parameter | Type | Description |
---|---|---|
$comp |
mixed | |
$elementPath |
mixed |
encodeComponentName
Encode the component name (to replace / and -)
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$src |
mixed |
decodeComponentName
Decode the component name (to replace / and -)
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$src |
mixed |
componentContentType
Get the component content type
Parameters:
Parameter | Type | Description |
---|---|---|
$comp |
mixed |
getComponentSize
Summary of getComponentSize
Parameters:
Parameter | Type | Description |
---|---|---|
$comp |
mixed |
getNavPointDetail
EPUB 2 navigation control file (NCX format) See https://idpf.org/epub/20/spec/OPF_2.0_latest.htm#Section2.4.1
Parameters:
Parameter | Type | Description |
---|---|---|
$node |
mixed |
getNavTocListItem
EPUB 3 navigation document (toc nav element) See https://www.w3.org/TR/epub-33/#sec-nav-toc
Parameters:
Parameter | Type | Description |
---|---|---|
$node |
mixed |
contents
Get the Epub content (TOC) as an array
For each chapter there is a "title" and a "src", and optional "children" See https://github.com/joseph/Monocle/wiki/Book-data-object for details
setAuthors
Set the book author(s)
Authors should be given with a "file-as" and a real name. The file as is used for sorting in e-readers.
Example:
array( 'Pratchett, Terry' => 'Terry Pratchett', 'Simpson, Jacqueline' => 'Jacqueline Simpson', )
Parameters:
Parameter | Type | Description |
---|---|---|
$authors |
mixed |
getAuthors
Get the book author(s)
Set or get the Google Books ID
Parameters:
Parameter | Type | Description |
---|---|---|
$google |
string|bool |
Amazon
Set or get the Amazon ID of the book
Parameters:
Parameter | Type | Description |
---|---|---|
$amazon |
string|bool |
setSeries
Set the Series of the book
Parameters:
Parameter | Type | Description |
---|---|---|
$serie |
string |
getSeries
Get the Series of the book
setSeriesIndex
Set the Series Index of the book
Parameters:
Parameter | Type | Description |
---|---|---|
$seriesIndex |
string |
getSeriesIndex
Get the Series Index of the book
setSubjects
Set the book's subjects (aka. tags)
Subject should be given as array, but a comma separated string will also be accepted.
Parameters:
Parameter | Type | Description |
---|---|---|
$subjects |
string[]|string |
getSubjects
Get the book's subjects (aka. tags)
setCoverInfo
Update the cover data
When adding a new image this function return no or old data because the image contents are not in the epub file, yet. The image will be added when the save() method is called.
Parameters:
Parameter | Type | Description |
---|---|---|
$path |
string | local filesystem path to a new cover image |
$mime |
string | mime type of the given file |
getCoverInfo
Read the cover data
Returns an associative array with the following keys:
mime - filetype (usually image/jpeg) data - the binary image data found - the internal path, or false if no image is set in epub
When no image is set in the epub file, the binary data for a transparent GIF pixel is returned.
getCoverId
Summary of getCoverId
getCoverItem
Summary of getCoverItem
getCoverPath
Get the internal path of the cover image file.
Combine
Summary of Combine
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$a |
mixed | |
$b |
mixed |
Throws:
getFullPath
Summary of getFullPath
Parameters:
Parameter | Type | Description |
---|---|---|
$file |
mixed | |
$context |
mixed |
updateForKepub
Summary of updateForKepub
setCoverFile
Summary of setCoverFile
Parameters:
Parameter | Type | Description |
---|---|---|
$path |
string | |
$mime |
string |
getAttr
Summary of getAttr
protected static getAttr(\DOMNodeList<\SebLucas\EPubMeta\Dom\Element> $nodes, string $att): string
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$nodes |
\DOMNodeList<\SebLucas\EPubMeta\Dom\Element> | list of Element items |
$att |
string | Attribute name |
deleteNodes
Summary of deleteNodes
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$nodes |
\DOMNodeList<\SebLucas\EPubMeta\Dom\Element> | list of Element items |
getset
A simple getter/setter for simple meta attributes
protected getset(string $item, string|bool $value = false, string|bool $att = false, string|bool|array $aval = false, string|bool $datt = false): string|void
It should only be used for attributes that are expected to be unique
Parameters:
Parameter | Type | Description |
---|---|---|
$item |
string | XML node to set/get |
$value |
string|bool | New node value |
$att |
string|bool | Attribute name |
$aval |
string|bool|array | Attribute value |
$datt |
string|bool | Destination attribute |
no_cover
Return a not found response for Cover()
reparse
Reparse the DOM tree
I had to rely on this because otherwise xpath failed to find the newly added nodes
setMeta
A simple setter for simple meta attributes
protected setMeta(string $item, string $value, bool|string $attribute = false, bool|string $attributeValue = false, bool $caseSensitive = true): mixed
It should only be used for attributes that are expected to be unique
Parameters:
Parameter | Type | Description |
---|---|---|
$item |
string | XML node to set |
$value |
string | New node value |
$attribute |
bool|string | Attribute name |
$attributeValue |
bool|string | Attribute value |
$caseSensitive |
bool |
getMeta
A simple getter for simple meta attributes
protected getMeta(string $item, bool|string $att = false, bool|string $aval = false, bool $caseSensitive = true): string
It should only be used for attributes that are expected to be unique
Parameters:
Parameter | Type | Description |
---|---|---|
$item |
string | XML node to get |
$att |
bool|string | Attribute name |
$aval |
bool|string | Attribute value |
$caseSensitive |
bool |
setMetaDestination
A simple setter for simple meta attributes - with destination attribute (for Serie)
protected setMetaDestination(string $item, string $attribute, string $attributeValue, string $datt, string $value): mixed
It should only be used for attributes that are expected to be unique
Parameters:
Parameter | Type | Description |
---|---|---|
$item |
string | XML node to set |
$attribute |
string | Attribute name |
$attributeValue |
string | Attribute value |
$datt |
string | Destination attribute |
$value |
string | New node value |
getMetaDestination
A simple getter for simple meta attributes - with destination attribute (for Serie)
It should only be used for attributes that are expected to be unique
Parameters:
Parameter | Type | Description |
---|---|---|
$item |
string | XML node to get |
$att |
string | Attribute name |
$aval |
string | Attribute value |
$datt |
string | Destination attribute |
setTitle
Set the book title
Parameters:
Parameter | Type | Description |
---|---|---|
$title |
string |
getTitle
Get the book title
setLanguage
Set the book's language
Parameters:
Parameter | Type | Description |
---|---|---|
$lang |
string |
getLanguage
Get the book's language
setPublisher
Set the book's publisher info
Parameters:
Parameter | Type | Description |
---|---|---|
$publisher |
string |
getPublisher
Get the book's publisher info
setCopyright
Set the book's copyright info
Parameters:
Parameter | Type | Description |
---|---|---|
$rights |
string |
getCopyright
Get the book's copyright info
setDescription
Set the book's description
Parameters:
Parameter | Type | Description |
---|---|---|
$description |
string |
getDescription
Get the book's description
setEventDate
Set a date for an event in the package file’s meta section.
Parameters:
Parameter | Type | Description |
---|---|---|
$event |
string | |
$date |
string | Date eg: 2012-05-19T12:54:25Z |
getEventDate
Get a date for an event in the package file’s meta section.
Parameters:
Parameter | Type | Description |
---|---|---|
$event |
string |
setCreationDate
Set the book's creation date
Parameters:
Parameter | Type | Description |
---|---|---|
$date |
string | Date eg: 2012-05-19T12:54:25Z |
getCreationDate
Get the book's creation date
setModificationDate
Set the book's modification date
Parameters:
Parameter | Type | Description |
---|---|---|
$date |
string | Date eg: 2012-05-19T12:54:25Z |
getModificationDate
Get the book's modification date
setIdentifier
Set an identifier in the package file’s meta section.
Parameters:
Parameter | Type | Description |
---|---|---|
$idScheme |
string|string[] | The identifier’s scheme. If an array is given all matching identifiers are replaced by one with the first value as scheme. |
$value |
string | |
$caseSensitive |
bool |
getIdentifier
Set an identifier from the package file’s meta section.
Parameters:
Parameter | Type | Description |
---|---|---|
$idScheme |
string|string[] | The identifier’s scheme. If an array is given the scheme can be any of its values. |
$caseSensitive |
bool | - @todo changed to true here |
Return Value:
The value of the first matching element.
setUniqueIdentifier
Set the book's unique identifier
Parameters:
Parameter | Type | Description |
---|---|---|
$value |
string |
getUniqueIdentifier
Get the book's unique identifier
Parameters:
Parameter | Type | Description |
---|---|---|
$normalize |
bool |
setUuid
Set the book's UUID - @todo pick one + case sensitive
Parameters:
Parameter | Type | Description |
---|---|---|
$uuid |
string |
getUuid
Get the book's UUID - @todo pick one + case sensitive
setUri
Set the book's URI
Parameters:
Parameter | Type | Description |
---|---|---|
$uri |
string |
getUri
Get the book's URI
setIsbn
Set the book's ISBN
Parameters:
Parameter | Type | Description |
---|---|---|
$isbn |
string |
getIsbn
Get the book's ISBN
setCalibre
Set the Calibre UUID of the book
Parameters:
Parameter | Type | Description |
---|---|---|
$uuid |
string |
getCalibre
Get the Calibre UUID of the book
clearCover
Remove the cover image
If the actual image file was added by this library it will be removed. Otherwise only the reference to it is removed from the metadata, since the same image might be referenced by other parts of the EPUB file.
setCover
Set the cover image
Parameters:
Parameter | Type | Description |
---|---|---|
$path |
string | local filesystem path to a new cover image |
$mime |
string | mime type of the given file |
getCover
Get the cover image
Return Value:
The binary image data or null if no image exists.
hasCover
Whether a cover image meta entry does exist.
addCoverImageTitlePage
Add a title page with the cover image to the EPUB.
public addCoverImageTitlePage(string $templatePath = __DIR__ . '/../templates/titlepage.xhtml'): void
Parameters:
Parameter | Type | Description |
---|---|---|
$templatePath |
string | The path to the template file. Defaults to an XHTML file contained in this library. |
removeTitlePage
Remove the title page added by this library (determined by a certain manifest item ID).
getCalibreAnnotations
Get the Calibre book annotations from opf:metadata (if saved)
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
?string |
getCalibreBookmarks
Get the Calibre bookmarks from META-INF/calibre_bookmarks.txt (if saved)
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
?string |
getManifest
Get the manifest of this EPUB.
Throws:
getSpine
Get the spine structure of this EPUB.
Throws:
getToc
Get the table of contents structure of this EPUB.
Throws:
loadNavPoints
Load navigation points from TOC XML DOM into TOC object structure.
protected static loadNavPoints(\DOMNodeList<\SebLucas\EPubMeta\EPubDomElement> $navPointNodes, \SebLucas\EPubMeta\Contents\NavPointList $navPointList, \SebLucas\EPubMeta\Dom\XPath $xp): void
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$navPointNodes |
\DOMNodeList<\SebLucas\EPubMeta\EPubDomElement> | List of nodes to load from. |
$navPointList |
\SebLucas\EPubMeta\Contents\NavPointList | List structure to load into. |
$xp |
\SebLucas\EPubMeta\Dom\XPath | The XPath of the TOC document. |
getNav
Summary of getNav
loadNavList
Load navigation points from NAV XML DOM into NAV object structure.
protected static loadNavList(\DOMNodeList<\SebLucas\EPubMeta\EPubDomElement> $navListNodes, \SebLucas\EPubMeta\Contents\NavPointList $navPointList, \SebLucas\EPubMeta\Dom\XPath $xp, int $depth, int $order): void
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$navListNodes |
\DOMNodeList<\SebLucas\EPubMeta\EPubDomElement> | List of nodes to load from. |
$navPointList |
\SebLucas\EPubMeta\Contents\NavPointList | List structure to load into. |
$xp |
\SebLucas\EPubMeta\Dom\XPath | The XPath of the NAV document. |
$depth |
int | Current depth of this list (recursive) |
$order |
int | Current start order for this list |
getContents
Extract the contents of this EPUB.
This concatenates contents of items according to their order in the spine.
Parameters:
Parameter | Type | Description |
---|---|---|
$keepMarkup |
bool | Whether to keep the XHTML markup rather than extracted plain text. |
$fraction |
float | If less than 1, only the respective part from the beginning of the book is extracted. |
Return Value:
The contents of this EPUB.
Throws:
buildMetaXPath
Build an XPath expression to select certain nodes in the metadata section.
protected static buildMetaXPath(string $element, string $attribute, string|string[] $value, bool $caseSensitive = true): string
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$element |
string | The node name of the elements to select. |
$attribute |
string | If set, the attribute required in the element. |
$value |
string|string[] | If set, the value of the above named attribute. If an array is given all of its values will be allowed in the selector. |
$caseSensitive |
bool | If false, attribute values are matched case insensitively. (This is not completely true, as only full upper or lower case strings are matched, not mixed case. A lower-case function is missing in XPath 1.0.) |
loadXPathFromItem
Load an XML file from the EPUB/ZIP archive into a new XPath object.
Parameters:
Parameter | Type | Description |
---|---|---|
$path |
string | The XML file to load from the ZIP archive. |
Return Value:
The XPath representation of the XML file.
Throws:
If the given path could not be read.
getZipEntries
Get the stat entries for all files in a ZIP file
Parameters:
Parameter | Type | Description |
---|---|---|
$file |
string | |null Path to a ZIP file or null for current file |
Return Value:
(filename => details of the entry)
loadSizeMap
Map the items of a ZIP file to their respective file sizes.
Parameters:
Parameter | Type | Description |
---|---|---|
$file |
string | |null Path to a ZIP file or null for current ZIP file |
Return Value:
(filename => file size)
getImageCount
Automatically generated on 2025-03-18