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 = [];
|
2018-08-11 15:37:38 +02:00
|
|
|
protected static $references = [];
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
/**
|
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)) {
|
|
|
|
$plugins = [];
|
2018-08-11 15:37:38 +02:00
|
|
|
$references = [];
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-08-11 15:37:38 +02:00
|
|
|
$modules = Modules::getModules();
|
|
|
|
foreach ($modules as $module) {
|
|
|
|
foreach ($module->plugins as $result) {
|
|
|
|
$plugins[$result['id']] = $result;
|
|
|
|
$references[$result['name']] = $result['id'];
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
self::$plugins = $plugins;
|
2018-08-11 15:37:38 +02:00
|
|
|
self::$references = $references;
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2018-08-11 15:37:38 +02:00
|
|
|
$plugins = self::getPlugins();
|
|
|
|
|
|
|
|
if (!is_numeric($plugin) && !empty(self::$references[$plugin])) {
|
2018-08-30 18:20:30 +02:00
|
|
|
$plugin = self::$references[$plugin];
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
2017-09-21 15:51:39 +02:00
|
|
|
|
2018-08-11 15:37:38 +02:00
|
|
|
return $plugins[$plugin];
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
2018-06-26 09:41:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Individua il percorso per il file.
|
|
|
|
*
|
|
|
|
* @param string|int $plugin
|
|
|
|
* @param string $file
|
|
|
|
*
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public static function filepath($plugin, $file)
|
|
|
|
{
|
|
|
|
$plugin = self::get($plugin);
|
|
|
|
$directory = 'plugins/'.$plugin['directory'].'|custom|';
|
|
|
|
|
|
|
|
return App::filepath($directory, $file);
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|