WIKINDX API 6.9.0

COMPONENT.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

readComponentsList()  : array<string|int, mixed>
Read and return the list of all components installed
writeComponentsList()  : mixed
Write a list of components from an array
refreshComponentsListCache()  : mixed
Refresh the components list if needed, or forced by the caller
isBuiltinComponent()  : bool
Is a component builtin?
checkComponentsList()  : array<string|int, mixed>
Return a structured list of installed components
computeComponentVersion()  : int
Compute a component version number from the current date
computeComponentSignature()  : string
Compute the hash signature of a component from its installed code
createComponentMetadataFile()  : mixed
Create the component.json file of a component
enableComponent()  : bool
Enable a component
disableComponent()  : bool
Disable a component
checkComponentIntegrity()  : int
Check the integrity of a component
componentIntegrityErrorMessage()  : string
Return the message of an error code of the function checkComponentIntegrity()
extractComponentPackage()  : bool
Extract a WIKINDX Component Package to a folder
extractComponentPackageDefinition()  : array<string|int, mixed>
Extract the component.json file of a WIKINDX Component Package to an array
listPluginComponents()  : array<string|int, mixed>
List all plugins enabled in WIKINDX_DIR_COMPONENT_PLUGINS with a sane configuration
listStyleComponents()  : array<string|int, mixed>
List all styles enabled in WIKINDX_DIR_COMPONENT_STYLES with a sane configuration
listTemplateComponents()  : array<string|int, mixed>
List all templates enabled in WIKINDX_DIR_COMPONENT_TEMPLATES with a sane configuration
checkPluginVersionCompatibility()  : bool
Check version compatibility of a plugin
loadStyleInfo()  : associative
Extract info entries from a JSON bibliographic style file and return an associative array of childnode's value of 'info' node.

Functions

readComponentsList()

Read and return the list of all components installed

readComponentsList([bool $force = FALSE ]) : array<string|int, mixed>

Status of activation are kept in /data/components.json file, other data are in /cache/components.json file because the status must be be persistent between two upgrades, or a component is uninstalled. This function merges status after reading the two files.

Use only this function to read the components list.

Parameters
$force : bool = FALSE

Forces the cache overwriting if it already exists (optional, FALSE by default)

Return values
array<string|int, mixed>

writeComponentsList()

Write a list of components from an array

writeComponentsList(array<string|int, mixed> $ComponentsList) : mixed

Status of activation are kept in /data/components.json file, other data are in /cache/components.json file because the status must be be persistent between two upgrades, or a component is uninstalled. This function separates the status from the other fields and saves them in separate files.

Use only this function to save the components list.

Parameters
$ComponentsList : array<string|int, mixed>

Components list (with activation status)

refreshComponentsListCache()

Refresh the components list if needed, or forced by the caller

refreshComponentsListCache([bool $force = FALSE ]) : mixed
Parameters
$force : bool = FALSE

Forces the file overwriting if it already exists (optional, FALSE by default)

isBuiltinComponent()

Is a component builtin?

isBuiltinComponent(string $component_type, string $component_id) : bool

A builtin component is packed with the core. It can be updated and cannot be disabled or uninstalled.

Parameters
$component_type : string
$component_id : string
Return values
bool

checkComponentsList()

Return a structured list of installed components

checkComponentsList() : array<string|int, mixed>

The list is extracted form the component.json file of each component and an integrity check is performed against the component. A default activation status is computed from this minimal integrity check and the configuration read.

Return values
array<string|int, mixed>

computeComponentVersion()

Compute a component version number from the current date

computeComponentVersion() : int

The component version number is the number of days elapsed since the launch of the system of components (v6 on 2020-01-12)

Return values
int

computeComponentSignature()

Compute the hash signature of a component from its installed code

computeComponentSignature(string $component_type, string $component_id) : string

The algorithm used is defined implicitly by the WIKINDX_PACKAGE_HASH_ALGO constant.

During the hashing a temp folder is created inside cache/cmpsigning/<type_id>

Parameters
$component_type : string

(plugin, style, template)

$component_id : string
Return values
string

createComponentMetadataFile()

Create the component.json file of a component

createComponentMetadataFile(string $component_type, string $component_id) : mixed

Do not overwrite the file if it already exists.

Parameters
$component_type : string

(plugin, style, template)

$component_id : string

enableComponent()

Enable a component

enableComponent(string $component_type, string $component_id) : bool
Parameters
$component_type : string

(plugin, style, template)

$component_id : string
Return values
bool

TRUE on success, FALSE otherwise

disableComponent()

Disable a component

disableComponent(string $component_type, string $component_id) : bool
Parameters
$component_type : string

(plugin, style, template)

$component_id : string
Return values
bool

TRUE on success, FALSE otherwise

checkComponentIntegrity()

Check the integrity of a component

checkComponentIntegrity(string $componentDirPath) : int
Parameters
$componentDirPath : string

A path to the folder of a component

Return values
int

Error code: 0 is for OK and others issues.

componentIntegrityErrorMessage()

Return the message of an error code of the function checkComponentIntegrity()

componentIntegrityErrorMessage(int $error_code) : string
Parameters
$error_code : int
Return values
string

An error message

extractComponentPackage()

Extract a WIKINDX Component Package to a folder

extractComponentPackage(string $ComponentPackageFile, string $DestinationFolder) : bool

Only Zip packages are supported.

If missing, the destination folder is created silently. otherwise its contents is overwritten and existing files that are not in the archive are deleted.

It is not necessary to delete the files of the previous component that occupies the same destination, which limits the loss of an already installed component if the operation does not complete.

However, it is always possible to end up in an inconsistent state if the operation failed between the decompression of two files. It should be very rare.

So a component should never create files and folders in its code directories otherwise they will be deleted. Use the private cache and data folders of a component for this task.*

BUGS: https://bugs.php.net/bug.php?id=79912 Phar crashs with an exception on Gzip/Bzip2 archives

Parameters
$ComponentPackageFile : string

Absolute or relative path to an archive file created with \FILE\createComponentPackage

$DestinationFolder : string

Absolute or relative path of a folder where the archive is extracted

Return values
bool

TRUE on success, FALSE otherwise

extractComponentPackageDefinition()

Extract the component.json file of a WIKINDX Component Package to an array

extractComponentPackageDefinition(string $ComponentPackageFile) : array<string|int, mixed>

Only Zip packages are supported.

The component.json file is read in memory before parsing.

Parameters
$ComponentPackageFile : string

Absolute or relative path to an archive file created with \FILE\createComponentPackage

Return values
array<string|int, mixed>

Structured definition of the component

listPluginComponents()

List all plugins enabled in WIKINDX_DIR_COMPONENT_PLUGINS with a sane configuration

listPluginComponents([bool $all = FALSE ]) : array<string|int, mixed>
Parameters
$all : bool = FALSE

If TRUE, lists also disabled components

Return values
array<string|int, mixed>

Sorted associative array - keys = component_id, values = component_longname.

listStyleComponents()

List all styles enabled in WIKINDX_DIR_COMPONENT_STYLES with a sane configuration

listStyleComponents([bool $all = FALSE ]) : array<string|int, mixed>
Parameters
$all : bool = FALSE

If TRUE, lists also disabled components

Return values
array<string|int, mixed>

Sorted associative array - keys = component_id, values = component_longname.

listTemplateComponents()

List all templates enabled in WIKINDX_DIR_COMPONENT_TEMPLATES with a sane configuration

listTemplateComponents([bool $all = FALSE ]) : array<string|int, mixed>
Parameters
$all : bool = FALSE

If TRUE, lists also disabled components

Return values
array<string|int, mixed>

checkPluginVersionCompatibility()

Check version compatibility of a plugin

checkPluginVersionCompatibility(mixed $dir) : bool
Parameters
$dir : mixed
Return values
bool

loadStyleInfo()

Extract info entries from a JSON bibliographic style file and return an associative array of childnode's value of 'info' node.

loadStyleInfo(string $file) : associative
Parameters
$file : string

Location of a StyleFile

Return values
associative

array - keys = name, description, styleLocalisation, citeLocalisation, osbibversion


        
On this page

Search results