Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / plugins / transformations / generator_plugin.sh
blob225a2cb98a9a875857e63e490b0d76ba7ae54d8f
1 #!/bin/bash
3 # Shell script that creates a new transformation plug-in (both main and
4 # abstract class) using a template.
6 # The 'description' parameter will add a new entry in the language file.
7 # Watch out for special escaping.
9 # $1: MIMEType
10 # $2: MIMESubtype
11 # $3: Transformation Name
12 # $4: (optional) Description
14 echo $#
15 if [ $# -ne 3 -a $# -ne 4 ]; then
16 echo -e "Usage: ./generator_plugin.sh MIMEType MIMESubtype TransformationName [Description]\n"
17 exit 65
20 # make sure that the MIME Type, MIME Subtype and Transformation names
21 # are in the correct format
23 # make all names lowercase
24 MT="`echo $1 | tr [:upper:] [:lower:]`"
25 MS="`echo $2 | tr [:upper:] [:lower:]`"
26 TN="`echo $3 | tr [:upper:] [:lower:]`"
27 # make first letter uppercase
28 MT="${MT^}"
29 MS="${MS^}"
30 TN="${TN^}"
31 # make the first letter after each underscore uppercase
32 MT="`echo $MT`"
33 MT="`echo $MT | sed -e 's/_./\U&\E/g'`"
34 MS="`echo $MS`"
35 MS="`echo $MS | sed -e 's/_./\U&\E/g'`"
36 TN="`echo $TN`"
37 TN="`echo $TN | sed -e 's/_./\U&\E/g'`"
39 # define the name of the main class file and of its template
40 ClassFile=$MT\_$MS\_$TN.class.php
41 Template=TEMPLATE
42 # define the name of the abstract class file and its template
43 AbstractClassFile=abstract/"$TN"TransformationsPlugin.class.php
44 AbstractTemplate=TEMPLATE_ABSTRACT
45 # replace template names with argument names
46 sed "s/\[MIMEType]/$MT/; s/\[MIMESubtype\]/$MS/; s/\[TransformationName\]/$TN/;" < $Template > $ClassFile
47 echo "Created $ClassFile"
49 GenerateAbstractClass=1
50 if [ -n $4 ]; then
51 if [ "$4" == "--generate_only_main_class" ]; then
52 if [ -e $AbstractClassFile ]; then
53 GenerateAbstractClass=0
58 if [ $GenerateAbstractClass -eq 1 ]; then
59 # replace template names with argument names
60 sed "s/\[TransformationName\]/$TN/; s/Description of the transformation./$4/;" < $AbstractTemplate > $AbstractClassFile
61 echo "Created $AbstractClassFile"
64 echo ""