From f9ba34adc15162dcf52c6bf7fa366f966cb3bf99 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 2 Sep 2021 10:55:42 +0200 Subject: [PATCH] add modifier \u in phpheader --- CHANGELOG.md | 1 + README.md | 2 +- inc/lib.improve.action.phpheader.php | 33 ++++++++++++++++------------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50fcad7..7c506d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 0.0.2 - [ ] add global config for file size limit +- [x] add modifier _first upper case_ : _\u_ in bloc content 0.0.1 - First pre-release \ No newline at end of file diff --git a/README.md b/README.md index cea4eec..e34be53 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ **improve** is a plugin for the open-source web publishing software called Dotclear. -It helps dev to clean up his plugin or theme before publishing its code. +It helps dev to clean up plugin or theme before publishing code. * Open to third party plugin * Easy and fast to use diff --git a/inc/lib.improve.action.phpheader.php b/inc/lib.improve.action.phpheader.php index 15afcd1..5c2e769 100644 --- a/inc/lib.improve.action.phpheader.php +++ b/inc/lib.improve.action.phpheader.php @@ -156,20 +156,25 @@ class ImproveActionPhpheader extends ImproveAction } try { - $this->bloc = str_replace( - $this->bloc_wildcards, - [ - date('Y'), - $this->module['id'], - $this->module['name'], - $this->module['author'], - $this->module['type'], - $this->core->auth->getInfo('user_cn'), - $this->core->auth->getinfo('user_name'), - $this->core->auth->getInfo('user_email'), - $this->core->auth->getInfo('user_url') - ], - $bloc + $this->bloc = preg_replace_callback( + // use \u in bloc content for first_upper_case + '/(\\\u([a-z]{1}))/', + function($str) { return ucfirst($str[2]); }, + str_replace( + $this->bloc_wildcards, + [ + date('Y'), + $this->module['id'], + $this->module['name'], + $this->module['author'], + $this->module['type'], + $this->core->auth->getInfo('user_cn'), + $this->core->auth->getinfo('user_name'), + $this->core->auth->getInfo('user_email'), + $this->core->auth->getInfo('user_url') + ], + $bloc + ) ); } catch (Exception $e) { self::notice(__('failed to parse bloc'));