UTILS.php
Table of Contents
- listCoreMandatoryPHPExtensions() : array<string|int, string>
- Return an array of mandatory PHP extensions used by the WIKINDX core
- listCoreOptionalPHPExtensions() : array<string|int, string>
- Return an array of optional PHP extensions used by the WIKINDX core
- OSName() : string
- Return the normalized name of the current os
- matchPrefix() : bool
- Check if a prefix match against a string
- matchSuffix() : bool
- Check if a suffix match against a string
- 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
- checkComponentsList() : array<string|int, mixed>
- Return a structured list of installed components
- 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()
- hash_path() : string
- Generates a hash of a file or directory at the given path with the specified algo.
- download_sf_file() : bool
- Download a file from SourceForge with curl
- uuid() : mixed
- checkFoldersPerms() : mixed
- Check the permissions of various folders and files which must be writable
- splitDate() : array<string|int, mixed>
- Take input from HTML FORM <input type=date> and split into separate fields.
- writeUserPassword() : mixed
- verifyUserPassword() : mixed
- array_value_select() : mixed
- createHelpTopicLink() : string
- Create a popup link for a Help Topic on the website
Functions
listCoreMandatoryPHPExtensions()
Return an array of mandatory PHP extensions used by the WIKINDX core
listCoreMandatoryPHPExtensions() : array<string|int, string>
The name of each extension is the value of an array entry. An extension name use the same casing as get_loaded_extensions().
listCoreOptionalPHPExtensions()
Return an array of optional PHP extensions used by the WIKINDX core
listCoreOptionalPHPExtensions() : array<string|int, string>
The name of each extension is the value of an array entry. An extension name use the same casing as get_loaded_extensions().
OSName()
Return the normalized name of the current os
OSName() : string
Values can be:
- "windows" for Cygwin, mingw, msys, or Windows
- "mac" forall version of MAC OSX
- The raw name in lowercase (a-z chars only) for others
matchPrefix()
Check if a prefix match against a string
matchPrefix( $string, $prefix) : bool
Parameters
matchSuffix()
Check if a suffix match against a string
matchSuffix( $string, $suffix) : bool
Parameters
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)
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)
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.
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, or vendor)
- $component_id : string
enableComponent()
Enable a component
enableComponent(string $component_type, string $component_id) : bool
Parameters
- $component_type : string
-
(plugin, style, template, or vendor)
- $component_id : string
disableComponent()
Disable a component
disableComponent(string $component_type, string $component_id) : bool
Parameters
- $component_type : string
-
(plugin, style, template, or vendor)
- $component_id : string
checkComponentIntegrity()
Check the integrity of a component
checkComponentIntegrity(string $componentDirPath) : int
Parameters
- $componentDirPath : string
-
A path to the folder of a component
componentIntegrityErrorMessage()
Return the message of an error code of the function checkComponentIntegrity()
componentIntegrityErrorMessage(int $error_code) : string
Parameters
- $error_code : int
hash_path()
Generates a hash of a file or directory at the given path with the specified algo.
hash_path(string $path[, string $algo = WIKINDX_PACKAGE_HASH_ALGO ]) : string
If the path is to a single file, it uses sha1_file. Otherwise, it recursively loops through all files in a directory to generate the hash.
Parameters
- $path : string
-
- the path of the folder or file
- $algo : string = WIKINDX_PACKAGE_HASH_ALGO
-
- the hash algo used (WIKINDX_PACKAGE_HASH_ALGO by default)
Tags
download_sf_file()
Download a file from SourceForge with curl
download_sf_file(string $url, string $file) : bool
Curl is configured to track SF redirects to the nearest server.
Parameters
- $url : string
-
- the url of a resource on SF
- $file : string
-
- the path of a file on the server
uuid()
uuid([int $length = 16 ]) : mixed
Parameters
- $length : int = 16
checkFoldersPerms()
Check the permissions of various folders and files which must be writable
checkFoldersPerms() : mixed
splitDate()
Take input from HTML FORM <input type=date> and split into separate fields.
splitDate(string $dateInput) : array<string|int, mixed>
Date comes in as 'yyyy-mm-dd' (but displayed on web form as 'dd / mm / yyyy'). All three fields must have a valid value else the form input is FALSE. This should be tested before calling this function.
Parameters
- $dateInput : string
writeUserPassword()
writeUserPassword(mixed $dbo, mixed $usersId, mixed $usersPassword) : mixed
Parameters
- $dbo : mixed
- $usersId : mixed
- $usersPassword : mixed
verifyUserPassword()
verifyUserPassword(mixed $dbo, mixed $usersId, mixed $usersPassword) : mixed
Parameters
- $dbo : mixed
- $usersId : mixed
- $usersPassword : mixed
array_value_select()
array_value_select(mixed $array, mixed $key[, mixed $defaultKey = NULL ][, mixed $defaultValue = NULL ]) : mixed
Parameters
- $array : mixed
- $key : mixed
- $defaultKey : mixed = NULL
- $defaultValue : mixed = NULL
createHelpTopicLink()
Create a popup link for a Help Topic on the website
createHelpTopicLink(mixed $helpTopic) : string
Parameters
- $helpTopic : mixed