Translated using Weblate (German)
[phpmyadmin.git] / doc / transformations.rst
blobbe60b33c80ea5ea9478d35d553a6f35cd7ac0842
1 .. _transformations:
3 Transformations
4 ===============
6 .. note:: 
8     You need to have configured the :ref:`linked-tables` for using transformations
9     feature.
11 .. _transformationsintro:
13 Introduction
14 ++++++++++++
16 To enable transformations, you have to setup the ``column_info``
17 table and the proper directives. Please see the :ref:`config` on how to do so.
19 You can apply different transformations to the contents of each
20 column. The transformation will take the content of each column and
21 transform it with certain rules defined in the selected
22 transformation.
24 Say you have a column 'filename' which contains a filename. Normally
25 you would see in phpMyAdmin only this filename. Using transformations
26 you can transform that filename into a HTML link, so you can click
27 inside of the phpMyAdmin structure on the column's link and will see
28 the file displayed in a new browser window. Using transformation
29 options you can also specify strings to append/prepend to a string or
30 the format you want the output stored in.
32 For a general overview of all available transformations and their
33 options, you can consult your *<www.your-host.com>/<your-install-
34 dir>/transformation\_overview.php* installation.
36 For a tutorial on how to effectively use transformations, see our
37 `Link section <https://www.phpmyadmin.net/docs/>`_ on the
38 official phpMyAdmin homepage.
40 .. _transformationshowto:
42 Usage
43 +++++
45 Go to your *tbl\_structure.php* page (i.e. reached through clicking on
46 the 'Structure' link for a table). There click on "Change" (or change
47 icon) and there you will see three new fields at the end of the line.
48 They are called 'MIME-type', 'Browser transformation' and
49 'Transformation options'.
51 * The field 'MIME-type' is a drop-down field. Select the MIME-type that
52   corresponds to the column's contents. Please note that transformations
53   are inactive as long as no MIME-type is selected.
54 * The field 'Browser transformation' is a drop-down field. You can
55   choose from a hopefully growing amount of pre-defined transformations.
56   See below for information on how to build your own transformation.
57   There are global transformations and mimetype-bound transformations.
58   Global transformations can be used for any mimetype. They will take
59   the mimetype, if necessary, into regard. Mimetype-bound
60   transformations usually only operate on a certain mimetype. There are
61   transformations which operate on the main mimetype (like 'image'),
62   which will most likely take the subtype into regard, and those who
63   only operate on a specific subtype (like 'image/jpeg'). You can use
64   transformations on mimetypes for which the function was not defined
65   for. There is no security check for you selected the right
66   transformation, so take care of what the output will be like.
67 * The field 'Transformation options' is a free-type textfield. You have
68   to enter transform-function specific options here. Usually the
69   transforms can operate with default options, but it is generally a
70   good idea to look up the overview to see which options are necessary.
71   Much like the ENUM/SET-Fields, you have to split up several options
72   using the format 'a','b','c',...(NOTE THE MISSING BLANKS). This is
73   because internally the options will be parsed as an array, leaving the
74   first value the first element in the array, and so forth. If you want
75   to specify a MIME character set you can define it in the
76   transformation\_options. You have to put that outside of the pre-
77   defined options of the specific mime-transform, as the last value of
78   the set. Use the format "'; charset=XXX'". If you use a transform, for
79   which you can specify 2 options and you want to append a character
80   set, enter "'first parameter','second parameter','charset=us-ascii'".
81   You can, however use the defaults for the parameters: "'','','charset
82   =us-ascii'".
84 .. _transformationsfiles:
86 File structure
87 ++++++++++++++
89 All specific transformations for mimetypes are defined through class
90 files in the directory 'libraries/plugins/transformations/'. Each of
91 them extends a certain transformation abstract class declared in
92 libraries/plugins/transformations/abstract.
94 They are stored in files to ease up customization and easy adding of
95 new transformations.
97 Because the user cannot enter own mimetypes, it is kept sure that
98 transformations always work. It makes no sense to apply a
99 transformation to a mimetype the transform-function doesn't know to
100 handle.
102 There is a file called '*transformations.lib.php*' that provides some
103 basic functions which can be included by any other transform function.
105 The file name convention is ``[Mimetype]_[Subtype]_[Transformation
106 Name].class.php``, while the abtract class that it extends has the
107 name ``[Transformation Name]TransformationsPlugin``. All of the
108 methods that have to be implemented by a transformations plug-in are:
110 #. getMIMEType() and getMIMESubtype() in the main class;
111 #. getName(), getInfo() and applyTransformation() in the abstract class
112    it extends.
114 The getMIMEType(), getMIMESubtype() and getName() methods return the
115 name of the MIME type, MIME Subtype and transformation accordingly.
116 getInfo() returns the transformation's description and possible
117 options it may receive and applyTransformation() is the method that
118 does the actual work of the transformation plug-in.
120 Please see the libraries/plugins/transformations/TEMPLATE and
121 libraries/plugins/transformations/TEMPLATE\_ABSTRACT files for adding
122 your own transformation plug-in. You can also generate a new
123 transformation plug-in (with or without the abstract transformation
124 class), by using
125 :file:`scripts/transformations_generator_plugin.sh` or
126 :file:`scripts/transformations_generator_main_class.sh`.
128 The applyTransformation() method always gets passed three variables:
130 #. **$buffer** - Contains the text inside of the column. This is the
131    text, you want to transform.
132 #. **$options** - Contains any user-passed options to a transform
133    function as an array.
134 #. **$meta** - Contains an object with information about your column. The
135    data is drawn from the output of the `mysql\_fetch\_field()
136    <https://secure.php.net/mysql_fetch_field>`_ function. This means, all
137    object properties described on the `manual page
138    <https://secure.php.net/mysql_fetch_field>`_ are available in this
139    variable and can be used to transform a column accordingly to
140    unsigned/zerofill/not\_null/... properties. The $meta->mimetype
141    variable contains the original MIME-type of the column (i.e.
142    'text/plain', 'image/jpeg' etc.)