From 7d4d305cfa60d0a0f9e42b6e49cff1d0d31f8a4d Mon Sep 17 00:00:00 2001 From: engel <> Date: Fri, 25 Mar 2022 08:02:00 +0000 Subject: [PATCH] simplification gestion logo FossilOrigin-Name: b87bde43d3a8108761b33901f1555143153c30819b16f5ddf5120f9e968da491 --- install.php | 6 ------ uninstall.php | 6 ------ upgrade.php | 5 ----- www/admin/config.php | 5 +---- www/admin/generer_activites.php | 16 ++++++++++------ www/admin/generer_personnes.php | 22 +++++++++++++++------- 6 files changed, 26 insertions(+), 34 deletions(-) diff --git a/install.php b/install.php index a5bedd9..1117fa6 100644 --- a/install.php +++ b/install.php @@ -8,9 +8,3 @@ $default_signature_file = (new File)->createAndStore('skel/plugin/recusfiscaux', 'default_signature.png', $path, null); -// « logo » par défaut -$path = __DIR__ . '/data/default_logo.png'; -$default_logo_file = (new File)->createAndStore('skel/plugin/recusfiscaux', - 'default_logo.png', - $path, - null); diff --git a/uninstall.php b/uninstall.php index 84fda2a..86e35bf 100644 --- a/uninstall.php +++ b/uninstall.php @@ -10,12 +10,6 @@ if (null !== $default_signature_file) { $default_signature_file->delete(); } -// logo par défaut -$default_logo_file = \Garradin\Files\Files::get('skel/plugin/recusfiscaux/default_logo.png'); -if (null !== $default_logo_file) { - $default_logo_file->delete(); -} - // signature réelle $signature = $plugin->getConfig('signature'); if (null !== $signature) { diff --git a/upgrade.php b/upgrade.php index cece83e..a0a8751 100644 --- a/upgrade.php +++ b/upgrade.php @@ -10,9 +10,4 @@ $old_version = $plugin->getInfos('version'); if (version_compare($old_version, '0.6.0', '<')) { - $path = __DIR__ . '/data/default_logo.png'; - $default_logo_file = (new File)->createAndStore('skel/plugin/recusfiscaux', - 'default_logo.png', - $path, - null); } diff --git a/www/admin/config.php b/www/admin/config.php index ec15380..64c0506 100644 --- a/www/admin/config.php +++ b/www/admin/config.php @@ -27,10 +27,6 @@ if (! isset($confNoms)) $plugin->setConfig('nomChamps', $nomChamps); } -$path = qg('path') ?: File::CONTEXT_CONFIG; -$context = Files::getContext($path); -$context_ref = Files::getContextRef($path); - if (f('save') && $form->check('recusfiscaux_config')) { try { @@ -111,6 +107,7 @@ uasort($nomChamps, function ($a, $b) }); $tpl->assign('ok', qg('ok') !== null); +$path = qg('path') ?: File::CONTEXT_CONFIG; $tpl->assign('path', $path); $tpl->assign('default_signature', \Garradin\WWW_URL . "plugin/recusfiscaux/default_signature.png"); $tpl->assign('plugin_config', $plugin->getConfig()); diff --git a/www/admin/generer_activites.php b/www/admin/generer_activites.php index 0c3853d..8420719 100644 --- a/www/admin/generer_activites.php +++ b/www/admin/generer_activites.php @@ -2,6 +2,9 @@ namespace Garradin; +use Garradin\Files\Files; +use Garradin\Entities\Files\File; + use Garradin\Plugin\RecusFiscaux\RecusHTML; use Garradin\Plugin\RecusFiscaux\Utils; use Garradin\Plugin\RecusFiscaux\Personne; @@ -18,18 +21,19 @@ foreach ($lesLignes as $ligne) { $totalPersonnes = cumulerVersements($versementsSelectionnes); // informations pour les reçus -$nomAsso = Utils::getNomAsso(); -$adresseAsso = Utils::getAdresseAsso(); +$nomAsso = $config->get('nom_asso'); +$adresseAsso = $config->get('adresse_asso'); $signature = (null !== $plugin->getConfig('signature')) ? - \Garradin\Files\Files::get($plugin->getConfig('signature'))->fullpath() : + Files::get($plugin->getConfig('signature'))->fullpath() : ""; // logo +$logo_file = Files::get(File::CONTEXT_CONFIG . '/logo.png'); $logoAsso = - (null !== $config->fileURL('logo')) ? - $config->fileURL('logo') : - \Garradin\Files\Files::get('skel/plugin/recusfiscaux/default_logo.png'); + (null !== $logo_file) ? + Files::get($logo_file->path)->fullpath() : + ""; // articles du CGI $articlesCGI = array(); diff --git a/www/admin/generer_personnes.php b/www/admin/generer_personnes.php index af9daa3..bd0a99c 100644 --- a/www/admin/generer_personnes.php +++ b/www/admin/generer_personnes.php @@ -2,6 +2,9 @@ namespace Garradin; +use Garradin\Files\Files; +use Garradin\Entities\Files\File; + use Garradin\Plugin\RecusFiscaux\RecusHTML; use Garradin\Plugin\RecusFiscaux\Utils; use Garradin\Plugin\RecusFiscaux\Personne; @@ -16,17 +19,22 @@ foreach ($lesLignes as $ligne) { } // informations pour les reçus -$nomAsso = Utils::getNomAsso(); -$adresseAsso = Utils::getAdresseAsso(); +$nomAsso = $config->get('nom_asso'); +$adresseAsso = $config->get('adresse_asso'); $signature = - (null !== $plugin->getConfig('signature')) ? - \Garradin\Files\Files::get($plugin->getConfig('signature'))->fullpath() : + (null !== $plugin->getConfig('signature')) + ? + Files::get($plugin->getConfig('signature'))->fullpath() + : ""; // logo +$logo_file = Files::get(File::CONTEXT_CONFIG . '/logo.png'); $logoAsso = - (null !== $config->fileURL('logo')) ? - $config->fileURL('logo') : - \Garradin\Files\Files::get('skel/plugin/recusfiscaux/default_logo.png'); + (null !== $logo_file) + ? + Files::get($logo_file->path)->fullpath() + : + ""; // articles du CGI $articlesCGI = array();