From d8bbb678c1ce1d49f6a2444be093396295398f63 Mon Sep 17 00:00:00 2001 From: bazooka07 Date: Fri, 10 Jan 2020 23:16:19 +0100 Subject: [PATCH 1/2] Fix plxUtils::getLangs() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Retourne un tableau associatif comme dans les versions précèdentes --- core/lib/class.plx.utils.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/core/lib/class.plx.utils.php b/core/lib/class.plx.utils.php index e96b01b51..b578641ad 100644 --- a/core/lib/class.plx.utils.php +++ b/core/lib/class.plx.utils.php @@ -928,16 +928,21 @@ public static function rel2abs($base, $html) { /** * Méthode qui retourne la liste des langues disponibles dans un tableau * - * @return string chaine de caractères modifiée - * @author Stephane F. + * @return tableau associatif + * @author J.P. Pourrez, Stephane F. **/ public static function getLangs() { - $result = array_map( - function($dir1) { - return preg_replace('#.*/([a-z]{2})$#', '$1', $dir1); - }, - glob(PLX_CORE . 'lang/*', GLOB_ONLYDIR) - ); + $result = array(); + foreach( + array_map( + function($dir1) { + return preg_replace('#.*/([a-z]{2})$#', '$1', $dir1); + }, + glob(PLX_CORE . 'lang/*', GLOB_ONLYDIR) + ) as $lang + ) { + $result[$lang] = $lang; + } return $result; } From ef507a49f02469df55ef2ded5dd36dc27cc9f51d Mon Sep 17 00:00:00 2001 From: bazooka07 Date: Sat, 11 Jan 2020 11:12:51 +0100 Subject: [PATCH 2/2] Test Maj: Utilisation de Javascript si curl pas disponible --- core/admin/parametres_infos.php | 55 +++++++++++++++++++++++++++++++-- core/lib/class.plx.admin.php | 6 ++-- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/core/admin/parametres_infos.php b/core/admin/parametres_infos.php index 5c3c0c50b..4d596bd54 100644 --- a/core/admin/parametres_infos.php +++ b/core/admin/parametres_infos.php @@ -31,7 +31,7 @@

- checkMaj(); ?> + checkMaj(); echo $maj; ?>

@@ -114,7 +114,58 @@ header('Location: ' . basename(__FILE__)); exit; } - +if(preg_match('%class="[^"]*\bred\b[^"]*"%', $maj)) { + # checkMaj() has failed with curl or allow_url_fopen is off +?> + + diff --git a/core/lib/class.plx.admin.php b/core/lib/class.plx.admin.php index 51747a416..c3f0ddf87 100644 --- a/core/lib/class.plx.admin.php +++ b/core/lib/class.plx.admin.php @@ -12,6 +12,7 @@ class plxAdmin extends plxMotor { private static $instance = null; + public $update_link = PLX_URL_REPO; // overwritten by self::checmMaj() /** * Méthode qui se charger de créer le Singleton plxAdmin @@ -1216,10 +1217,9 @@ public function editTags() { **/ public function checkMaj() { - $caption='PluXml.org'; - $latest_version = 'L_PLUXML_UPDATE_ERR'; $className = ''; + $this->update_link = sprintf('%s : %s', L_PLUXML_UPDATE_AVAILABLE, PLX_URL_REPO, PLX_URL_REPO); $http_response_header = ''; # test avec allow_url_open ou file_get_contents ? @@ -1260,7 +1260,7 @@ public function checkMaj() { $className = 'green'; } else { - $msg = sprintf('%s %s', L_PLUXML_UPDATE_AVAILABLE, PLX_URL_REPO, $caption); + $msg = $this->update_link; $className = 'orange'; }