File structure ¶
All specific transformations for mimetypes are defined through class files in the directory 'libraries/classes/Plugins/Transformations/'. Each of them extends a certain transformation abstract class declared in libraries/classes/Plugins/Transformations/Abs.
They are stored in files to ease up customization and easy adding of new transformations.
Because the user cannot enter own mimetypes, it is kept sure that transformations always work. It makes no sense to apply a transformation to a mimetype the transform-function doesn't know to handle.
There is a file called 'transformations.lib.php' that provides some basic functions which can be included by any other transform function.
The file name convention is [Mimetype]_[Subtype]_[Transformation Name].class.php
, while the abtract class that it extends has the name [Transformation Name]TransformationsPlugin
. All of the methods that have to be implemented by a transformations plug-in are:
- getMIMEType() and getMIMESubtype() in the main class;
- getName(), getInfo() and applyTransformation() in the abstract class it extends.
The getMIMEType(), getMIMESubtype() and getName() methods return the name of the MIME type, MIME Subtype and transformation accordingly. getInfo() returns the transformation's description and possible options it may receive and applyTransformation() is the method that does the actual work of the transformation plug-in.
Please see the libraries/classes/Plugins/Transformations/TEMPLATE and libraries/classes/Plugins/Transformations/TEMPLATE_ABSTRACT files for adding your own transformation plug-in. You can also generate a new transformation plug-in (with or without the abstract transformation class), by using scripts/transformations_generator_plugin.sh
or scripts/transformations_generator_main_class.sh
.
The applyTransformation() method always gets passed three variables:
- $buffer - Contains the text inside of the column. This is the text, you want to transform.
- $options - Contains any user-passed options to a transform function as an array.
- $meta - Contains an object with information about your column. The data is drawn from the output of the mysql_fetch_field() function. This means, all object properties described on the manual page are available in this variable and can be used to transform a column accordingly to unsigned/zerofill/not_null/… properties. The $meta->mimetype variable contains the original MIME-type of the column (i.e. 'text/plain', 'image/jpeg' etc.)