2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2017-09-21 15:51:39 +02:00
|
|
|
* Classe per la gestione delle informazioni relative ai plugin installati.
|
2017-08-04 16:28:16 +02:00
|
|
|
*
|
|
|
|
* @since 2.3
|
|
|
|
*/
|
|
|
|
class Plugins
|
|
|
|
{
|
2017-08-31 11:32:49 +02:00
|
|
|
/** @var array Elenco dei plugin disponibili */
|
2017-08-04 16:28:16 +02:00
|
|
|
protected static $plugins = [];
|
2017-08-31 11:32:49 +02:00
|
|
|
/** @var array Elenco delle query generiche dei plugin */
|
2017-08-04 16:28:16 +02:00
|
|
|
protected static $queries = [];
|
|
|
|
|
|
|
|
/**
|
2017-09-21 15:51:39 +02:00
|
|
|
* Restituisce tutte le informazioni di tutti i plugin installati.
|
2017-08-04 16:28:16 +02:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function getPlugins()
|
|
|
|
{
|
|
|
|
if (empty(self::$plugins)) {
|
|
|
|
$database = Database::getConnection();
|
|
|
|
|
|
|
|
$results = $database->fetchArray('SELECT *, (SELECT directory FROM zz_modules WHERE id=idmodule_from) AS module_dir FROM zz_plugins');
|
|
|
|
|
|
|
|
$plugins = [];
|
|
|
|
|
|
|
|
foreach ($results as $result) {
|
2018-02-14 11:10:03 +01:00
|
|
|
$result['options'] = App::replacePlaceholder($result['options'], filter('id_parent'));
|
|
|
|
$result['options2'] = App::replacePlaceholder($result['options2'], filter('id_parent'));
|
|
|
|
|
|
|
|
$result['option'] = empty($result['options2']) ? $result['options'] : $result['options2'];
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
$plugins[$result['id']] = $result;
|
|
|
|
$plugins[$result['name']] = $result['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
self::$plugins = $plugins;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::$plugins;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restituisce le informazioni relative a un singolo modulo specificato.
|
|
|
|
*
|
2017-09-21 15:51:39 +02:00
|
|
|
* @param string|int $plugin
|
2017-08-04 16:28:16 +02:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2017-09-22 15:19:59 +02:00
|
|
|
public static function get($plugin)
|
2017-08-04 16:28:16 +02:00
|
|
|
{
|
2017-09-22 15:19:59 +02:00
|
|
|
if (!is_numeric($plugin) && !empty(self::getPlugins()[$plugin])) {
|
2017-09-21 15:51:39 +02:00
|
|
|
$plugin = self::getPlugins()[$plugin];
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
2017-09-21 15:51:39 +02:00
|
|
|
|
|
|
|
return self::getPlugins()[$plugin];
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
}
|