class ExternalModules (View source)

Class ExternalModules

Properties

int $no_page
int $per_page
int $categorie
$search
string $file_source_url
string $cache_file
string $url

// the url of this page

string $shop_url
string $lang
bool $debug_api
string $dolistore_api_url
string $dolistore_api_key
int $dolistoreApiStatus
string $dolistoreApiError
int $githubFileStatus
string $githubFileError
string $error
int $numberOfProviders
array<int, mixed>|null $products
int $numberTotalOfProducts
int $numberTotalOfPages
int $numberOfProducts

Methods

__construct(bool $debug = false)

Constructor

void
loadRemoteSources(bool $debug = false)

loadRemoteSources

array{status_code: int, response: null|string|array<string, mixed>}
callApi(string $resource, array<string, mixed>|false $options = false)

Test if we can access to remote Dolistore market place.

list<array<string, array<string, string|null>|string|null>>
fetchModulesFromFile(array<string, mixed> $options = array())

Fetch modules from a cache YAML file

string
getCategories(int $active = 0)

Generate HTML for categories and their children.

string|null
getProducts(array<string, mixed> $options)

Generate HTML for products.

buildSorter(string $key)

Sort an array by a key

int
versionCompare(string $v1, string $v2)

version compare

string
get_previous_link(string $text = '<<')

get previous link

string
get_next_link(string $text = '>>')

get next link

string
get_previous_url()

get previous url

string
get_next_url()

get next url

string
getPagination()

Generate pagination for navigating through pages of products.

string|null
checkStatusCode(array{status_code: int, response: null|string|array{curl_error_msg: string, errors: array<array{code: int, message: string}>}} $request)

Check the status code of the request

bool|string
getRemoteYamlFile(string $file_source_url, int $cache_time)

Get YAML file from remote source and put it into the cache file

list<array<string, array<string, string|null>|string|null>>
readYaml(string $yaml)

Read a YAML string and convert it to an array

list<array<string, array<string, string|null>|string|null>>
adaptData(array<string, mixed>|list<array<string, array<string, string|null>|string|null>> $data, string $source)

Adapter data fetched from github remote source to the expected format

array{total: int, data: list<array<string, mixed>>}
applyFilters(list<array<string, mixed>> $list, array<string, mixed> $options)

Apply filters to the data

int
checkApiStatus()

Check if an Dolistore API is up

string
libStatus(mixed $status, mixed $mode = 3, string $moretext = '')

Retrieve the status icon

Details

__construct(bool $debug = false)

Constructor

Parameters

bool $debug

Enable debug of request on screen

void loadRemoteSources(bool $debug = false)

loadRemoteSources

Parameters

bool $debug

Enable debug of request on screen

Return Value

void

array{status_code: int, response: null|string|array<string, mixed>} callApi(string $resource, array<string, mixed>|false $options = false)

Test if we can access to remote Dolistore market place.

Parameters

string $resource

Resource relative URL ('categories' or 'products')

array<string, mixed>|false $options

Options for the request

Return Value

array{status_code: int, response: null|string|array<string, mixed>}

list<array<string, array<string, string|null>|string|null>> fetchModulesFromFile(array<string, mixed> $options = array())

Fetch modules from a cache YAML file

Parameters

array<string, mixed> $options

Options for filter

Return Value

list<array<string, array<string, string|null>|string|null>>

List of modules

string getCategories(int $active = 0)

Generate HTML for categories and their children.

Parameters

int $active

The active category id

Return Value

string

HTML string representing the categories and their children.

string|null getProducts(array<string, mixed> $options)

Generate HTML for products.

Parameters

array<string, mixed> $options

Options for the request

Return Value

string|null

HTML string representing the products.

Closure buildSorter(string $key)

Sort an array by a key

Parameters

string $key

Key to sort by

Return Value

Closure

int versionCompare(string $v1, string $v2)

version compare

Parameters

string $v1

version 1

string $v2

version 2

Return Value

int

result of compare

get previous link

Parameters

string $text

symbol previous

Return Value

string

html previous link

get next link

Parameters

string $text

symbol next

Return Value

string

html next link

string get_previous_url()

get previous url

Return Value

string

previous url

string get_next_url()

get next url

Return Value

string

next url

string getPagination()

Generate pagination for navigating through pages of products.

Return Value

string

HTML string representing the pagination.

protected string|null checkStatusCode(array{status_code: int, response: null|string|array{curl_error_msg: string, errors: array<array{code: int, message: string}>}} $request)

Check the status code of the request

Parameters

array{status_code: int, response: null|string|array{curl_error_msg: string, errors: array<array{code: int, message: string}>}} $request

Response elements of CURL request

Return Value

string|null

bool|string getRemoteYamlFile(string $file_source_url, int $cache_time)

Get YAML file from remote source and put it into the cache file

Parameters

string $file_source_url

URL of the remote source

int $cache_time

Cache time

Return Value

bool|string

File content

list<array<string, array<string, string|null>|string|null>> readYaml(string $yaml)

Read a YAML string and convert it to an array

Parameters

string $yaml

YAML string

Return Value

list<array<string, array<string, string|null>|string|null>>

Parsed array representation

list<array<string, array<string, string|null>|string|null>> adaptData(array<string, mixed>|list<array<string, array<string, string|null>|string|null>> $data, string $source)

Adapter data fetched from github remote source to the expected format

Parameters

array<string, mixed>|list<array<string, array<string, string|null>|string|null>> $data

Data fetched from github remote source

string $source

Source of the data

Return Value

list<array<string, array<string, string|null>|string|null>>

Data adapted to the expected format

array{total: int, data: list<array<string, mixed>>} applyFilters(list<array<string, mixed>> $list, array<string, mixed> $options)

Apply filters to the data

Parameters

list<array<string, mixed>> $list

Data to filter

array<string, mixed> $options

Options for the filter

Return Value

array{total: int, data: list<array<string, mixed>>}

Filtered data

int checkApiStatus()

Check if an Dolistore API is up

Return Value

int

string libStatus(mixed $status, mixed $mode = 3, string $moretext = '')

Retrieve the status icon

Parameters

mixed $status Status
mixed $mode Mode
string $moretext

More text to show on tooltip

Return Value

string