Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2016-07-26 17:38:30 +0300
committerMichal Čihař <michal@cihar.com>2016-07-26 17:38:30 +0300
commit47d00af08a90c5aa47c23f5eaa7b31818bffe9d6 (patch)
tree2951eb6dc4449897185d24227549f24ebf89be70 /scripts
parenteec14404a738b1259ee7dfc4fbdf17b47e497f1d (diff)
Move generator scripts out of the code
Signed-off-by: Michal Čihař <michal@cihar.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/transformations_generator_main_class.sh16
-rwxr-xr-xscripts/transformations_generator_plugin.sh64
2 files changed, 80 insertions, 0 deletions
diff --git a/scripts/transformations_generator_main_class.sh b/scripts/transformations_generator_main_class.sh
new file mode 100755
index 0000000000..05876671ac
--- /dev/null
+++ b/scripts/transformations_generator_main_class.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Shell script that creates only the main class for a new transformation
+# plug-in, using a template
+#
+# $1: MIMEType
+# $2: MIMESubtype
+# $3: Transformation Name
+
+if [ $# != 3 ]
+then
+ echo -e "Usage: ./generator_main_class.sh MIMEType MIMESubtype TransformationName\n"
+ exit 65
+fi
+
+./generator_plugin.sh "$1" "$2" "$3" "--generate_only_main_class" \ No newline at end of file
diff --git a/scripts/transformations_generator_plugin.sh b/scripts/transformations_generator_plugin.sh
new file mode 100755
index 0000000000..225a2cb98a
--- /dev/null
+++ b/scripts/transformations_generator_plugin.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Shell script that creates a new transformation plug-in (both main and
+# abstract class) using a template.
+#
+# The 'description' parameter will add a new entry in the language file.
+# Watch out for special escaping.
+#
+# $1: MIMEType
+# $2: MIMESubtype
+# $3: Transformation Name
+# $4: (optional) Description
+
+echo $#
+if [ $# -ne 3 -a $# -ne 4 ]; then
+ echo -e "Usage: ./generator_plugin.sh MIMEType MIMESubtype TransformationName [Description]\n"
+ exit 65
+fi
+
+# make sure that the MIME Type, MIME Subtype and Transformation names
+# are in the correct format
+
+# make all names lowercase
+MT="`echo $1 | tr [:upper:] [:lower:]`"
+MS="`echo $2 | tr [:upper:] [:lower:]`"
+TN="`echo $3 | tr [:upper:] [:lower:]`"
+# make first letter uppercase
+MT="${MT^}"
+MS="${MS^}"
+TN="${TN^}"
+# make the first letter after each underscore uppercase
+MT="`echo $MT`"
+MT="`echo $MT | sed -e 's/_./\U&\E/g'`"
+MS="`echo $MS`"
+MS="`echo $MS | sed -e 's/_./\U&\E/g'`"
+TN="`echo $TN`"
+TN="`echo $TN | sed -e 's/_./\U&\E/g'`"
+
+# define the name of the main class file and of its template
+ClassFile=$MT\_$MS\_$TN.class.php
+Template=TEMPLATE
+# define the name of the abstract class file and its template
+AbstractClassFile=abstract/"$TN"TransformationsPlugin.class.php
+AbstractTemplate=TEMPLATE_ABSTRACT
+# replace template names with argument names
+sed "s/\[MIMEType]/$MT/; s/\[MIMESubtype\]/$MS/; s/\[TransformationName\]/$TN/;" < $Template > $ClassFile
+echo "Created $ClassFile"
+
+GenerateAbstractClass=1
+if [ -n $4 ]; then
+ if [ "$4" == "--generate_only_main_class" ]; then
+ if [ -e $AbstractClassFile ]; then
+ GenerateAbstractClass=0
+ fi
+ fi
+fi
+
+if [ $GenerateAbstractClass -eq 1 ]; then
+ # replace template names with argument names
+ sed "s/\[TransformationName\]/$TN/; s/Description of the transformation./$4/;" < $AbstractTemplate > $AbstractClassFile
+ echo "Created $AbstractClassFile"
+fi
+
+echo "" \ No newline at end of file