diff --git a/src/tomitomasEqLogicTrait.php b/src/tomitomasEqLogicTrait.php
index 76ab487..ce3a391 100644
--- a/src/tomitomasEqLogicTrait.php
+++ b/src/tomitomasEqLogicTrait.php
@@ -2,12 +2,29 @@
trait tomitomasEqLogicTrait {
- public function createCommands(string $file, string $type) {
- $configFile = self::getFileContent($file);
- $dict = $configFile['dictionary'];
+ private static function getConfigFileContent($filePath) {
+ if (!file_exists($filePath)) {
+ throw new Exception(__("Fichier de configuration non trouvé", __FILE__) . ' ' . $filePath);
+ }
+ $content = file_get_contents($filePath);
+ if (!is_json($content)) {
+ throw new Exception(__("Fichier de configuration incorrecte", __FILE__) . ' ' . $filePath);
+ }
+ $content = translate::exec($content, realpath($filePath));
+ return json_decode($content, true);
+ }
+
+ public function createCommands($filePath, $type = null) {
try {
- if (isset($configFile['cmds'][$type])) {
- $this->createCommandsFromConfigFile($configFile['cmds'][$type], $dict);
+
+ // on traduit le fichier de configuration
+ $configFile = self::getConfigFileContent($filePath);
+
+ // on lance la création des commandes (déjà traduites)
+ if ($type == null) {
+ $this->createCommandsFromConfig($configFile['cmds']);
+ } elseif (isset($configFile['cmds'][$type])) {
+ $this->createCommandsFromConfig($configFile['cmds'][$type]);
} else {
self::error($type . ' not found in config');
}
@@ -32,7 +49,7 @@ public static function getFileContent($path) {
return $content;
}
- public function createCommandsFromConfigFile($commands, $dict) {
+ public function createCommandsFromConfig($commands) {
$cmd_updated_by = array();
foreach ($commands as $cmdData) {
$cmd = $this->getCmd(null, $cmdData["logicalId"]);
@@ -72,10 +89,6 @@ public function createCommandsFromConfigFile($commands, $dict) {
if (isset($cmdData['configuration'])) {
foreach ($cmdData['configuration'] as $key => $value) {
- if ($key == 'listValueToCreate') {
- $key = 'listValue';
- $value = self::createListOption(explode(";", $value), $dict);
- }
$cmd->setConfiguration($key, $value);
}
}
@@ -131,8 +144,36 @@ public static function getPlurial($nb) {
return ($nb > 1) ? 's' : '';
}
- /**
+ public static function getConfigForCommunity($withQuote = true) {
+
+ $infoPlugin = 'Version OS : ' . system::getDistrib() . ' ' . system::getOsVersion() . '
';
+
+ $infoPlugin .= 'Version PHP : ' . phpversion();
+
+ if ($withQuote) {
+ return self::getPreformattedText($infoPlugin);
+ }
+
+ return $infoPlugin;
+ }
+
+ public static function getPreformattedText($string) {
+ return '
```text
' . str_replace(array('', '', ' '), array('', '', ' '), $string) . '
```
';
+ }
+
+ public static function backupExclude() {
+ return [
+ 'resources/venv'
+ ];
+ }
+
+
+ /*******************************
* From @Mips2648
+ ******************************* /
+
+
+ /**
* Allow to perform a // task exec : now or later
*
* @param string $_method
@@ -163,29 +204,6 @@ public static function executeAsync(string $_method, $_option = null, $_date = '
}
}
- public static function getConfigForCommunity($withQuote = true) {
-
- $infoPlugin = 'Version OS : ' . system::getDistrib() . ' ' . system::getOsVersion() . '
';
-
- $infoPlugin .= 'Version PHP : ' . phpversion();
-
- if ($withQuote) {
- return self::getPreformattedText($infoPlugin);
- }
-
- return $infoPlugin;
- }
-
- public static function getPreformattedText($string) {
- return '
```text
' . str_replace(array('', '', ' '), array('', '', ' '), $string) . '
```
';
- }
-
- public static function backupExclude() {
- return [
- 'resources/venv'
- ];
- }
-
private static function pythonRequirementsInstalled(string $pythonPath, string $requirementsPath) {
if (!file_exists($pythonPath) || !file_exists($requirementsPath)) {
return false;