From 4b9490452922184033f3f447f274d3133f4e5a82 Mon Sep 17 00:00:00 2001 From: Roland Mas Date: Tue, 6 Apr 2010 19:51:15 +0000 Subject: [PATCH] Added script used to help with the config API transition --- .gitattributes | 1 + tools/unify_config.sh | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 tools/unify_config.sh diff --git a/.gitattributes b/.gitattributes index 2e3c607..9b57686 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4091,4 +4091,5 @@ tools/tab2po/src/test/resources/translations/en.po.new -text tools/tab2po/src/test/resources/translations/fr.po -text tools/tab2po/src/test/resources/translations/fr.po.new -text tools/tab2po/src/test/resources/translations/gforge.pot -text +tools/unify_config.sh -text tools/update-gettext-files.sh -text diff --git a/tools/unify_config.sh b/tools/unify_config.sh new file mode 100755 index 0000000..39e71d6 --- /dev/null +++ b/tools/unify_config.sh @@ -0,0 +1,24 @@ +#! /bin/sh + +# Usage: unify_config.sh [
] +# Example: unify_config.sh sys_default_domain web_host + +old=$1 +new=$2 +sect=$3 + +if [ "$sect" = "" ] ; then + newstr="forge_get_config('$new')" +else + newstr="forge_get_config('$new', '$sect')" +fi + +find_files () { + ack-grep -l --php $old | grep -v www/include/pre.php +} + +find_files | xargs perl -pi -e"s/(\\s*global .*)\\\$$old, */\\1/" +find_files | xargs perl -pi -e"s/(\\s*global .*)\\\$$old *;//" +find_files | xargs perl -pi -e"s,\\\$GLOBALS\['$old'\](?"\!"\\s*=),$newstr,g" +find_files | xargs perl -pi -e"s,\\\$GLOBALS\[$old\](?"\!"\\s*=),$newstr,g" +find_files | xargs perl -pi -e"s,\\\$$old(?"\!"\\s*=),$newstr,g" -- 2.1.4