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.
11 # $3: Transformation Name
12 # $4: (optional) Description
15 if [ -n "$GATEWAY_INTERFACE" ] ; then
16 echo 'Can not invoke as CGI!'
21 if [ $# -ne 3 -a $# -ne 4 ]; then
22 echo -e "Usage: ./generator_plugin.sh MIMEType MIMESubtype TransformationName [Description]\n"
26 # make sure that the MIME Type, MIME Subtype and Transformation names
27 # are in the correct format
29 # make all names lowercase
30 MT
="`echo $1 | tr [:upper:] [:lower:]`"
31 MS
="`echo $2 | tr [:upper:] [:lower:]`"
32 TN
="`echo $3 | tr [:upper:] [:lower:]`"
33 # make first letter uppercase
37 # make the first letter after each underscore uppercase
39 MT
="`echo $MT | sed -e 's/_./\U&\E/g'`"
41 MS
="`echo $MS | sed -e 's/_./\U&\E/g'`"
43 TN
="`echo $TN | sed -e 's/_./\U&\E/g'`"
45 # define the name of the main class file and of its template
46 ClassFile
=$MT\_
$MS\_
$TN.php
48 # define the name of the abstract class file and its template
49 AbstractClassFile
=abs
/"$TN"TransformationsPlugin.php
50 AbstractTemplate
=TEMPLATE_ABSTRACT
51 # replace template names with argument names
52 sed "s/\[MIMEType]/$MT/; s/\[MIMESubtype\]/$MS/; s/\[TransformationName\]/$TN/;" < $Template > $ClassFile
53 echo "Created $ClassFile"
55 GenerateAbstractClass
=1
57 if [ "$4" == "--generate_only_main_class" ]; then
58 if [ -e $AbstractClassFile ]; then
59 GenerateAbstractClass
=0
64 if [ $GenerateAbstractClass -eq 1 ]; then
65 # replace template names with argument names
66 sed "s/\[TransformationName\]/$TN/; s/Description of the transformation./$4/;" < $AbstractTemplate > $AbstractClassFile
67 echo "Created $AbstractClassFile"