transformations.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Transformations &#8212; phpMyAdmin 4.9.10 documentation</title>
  7. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/classic.css" type="text/css" />
  9. <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  10. <script src="_static/jquery.js"></script>
  11. <script src="_static/underscore.js"></script>
  12. <script src="_static/doctools.js"></script>
  13. <link rel="index" title="Index" href="genindex.html" />
  14. <link rel="search" title="Search" href="search.html" />
  15. <link rel="copyright" title="Copyright" href="copyright.html" />
  16. <link rel="next" title="Bookmarks" href="bookmarks.html" />
  17. <link rel="prev" title="Two-factor authentication" href="two_factor.html" />
  18. </head><body>
  19. <div class="related" role="navigation" aria-label="related navigation">
  20. <h3>Navigation</h3>
  21. <ul>
  22. <li class="right" style="margin-right: 10px">
  23. <a href="genindex.html" title="General Index"
  24. accesskey="I">index</a></li>
  25. <li class="right" >
  26. <a href="bookmarks.html" title="Bookmarks"
  27. accesskey="N">next</a> |</li>
  28. <li class="right" >
  29. <a href="two_factor.html" title="Two-factor authentication"
  30. accesskey="P">previous</a> |</li>
  31. <li class="nav-item nav-item-0"><a href="index.html">phpMyAdmin 4.9.10 documentation</a> &#187;</li>
  32. <li class="nav-item nav-item-1"><a href="user.html" accesskey="U">User Guide</a> &#187;</li>
  33. <li class="nav-item nav-item-this"><a href="">Transformations</a></li>
  34. </ul>
  35. </div>
  36. <div class="document">
  37. <div class="documentwrapper">
  38. <div class="bodywrapper">
  39. <div class="body" role="main">
  40. <div class="section" id="transformations">
  41. <span id="id1"></span><h1>Transformations<a class="headerlink" href="#transformations" title="Permalink to this headline">¶</a></h1>
  42. <div class="admonition note">
  43. <p class="admonition-title">Note</p>
  44. <p>You need to have configured the <a class="reference internal" href="setup.html#linked-tables"><span class="std std-ref">phpMyAdmin configuration storage</span></a> for using transformations
  45. feature.</p>
  46. </div>
  47. <div class="section" id="introduction">
  48. <span id="transformationsintro"></span><h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
  49. <p>To enable transformations, you have to setup the <code class="docutils literal notranslate"><span class="pre">column_info</span></code>
  50. table and the proper directives. Please see the <a class="reference internal" href="config.html#config"><span class="std std-ref">Configuration</span></a> on how to do so.</p>
  51. <p>You can apply different transformations to the contents of each
  52. column. The transformation will take the content of each column and
  53. transform it with certain rules defined in the selected
  54. transformation.</p>
  55. <p>Say you have a column ‘filename’ which contains a filename. Normally
  56. you would see in phpMyAdmin only this filename. Using transformations
  57. you can transform that filename into a HTML link, so you can click
  58. inside of the phpMyAdmin structure on the column’s link and will see
  59. the file displayed in a new browser window. Using transformation
  60. options you can also specify strings to append/prepend to a string or
  61. the format you want the output stored in.</p>
  62. <p>For a general overview of all available transformations and their
  63. options, you can consult your <em>&lt;www.your-host.com&gt;/&lt;your-install-
  64. dir&gt;/transformation_overview.php</em> installation.</p>
  65. <p>For a tutorial on how to effectively use transformations, see our
  66. <a class="reference external" href="https://www.phpmyadmin.net/docs/">Link section</a> on the
  67. official phpMyAdmin homepage.</p>
  68. </div>
  69. <div class="section" id="usage">
  70. <span id="transformationshowto"></span><h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
  71. <p>Go to your <em>tbl_structure.php</em> page (i.e. reached through clicking on
  72. the ‘Structure’ link for a table). There click on “Change” (or change
  73. icon) and there you will see three new fields at the end of the line.
  74. They are called ‘MIME-type’, ‘Browser transformation’ and
  75. ‘Transformation options’.</p>
  76. <ul class="simple">
  77. <li><p>The field ‘MIME-type’ is a drop-down field. Select the MIME-type that
  78. corresponds to the column’s contents. Please note that transformations
  79. are inactive as long as no MIME-type is selected.</p></li>
  80. <li><p>The field ‘Browser transformation’ is a drop-down field. You can
  81. choose from a hopefully growing amount of pre-defined transformations.
  82. See below for information on how to build your own transformation.
  83. There are global transformations and mimetype-bound transformations.
  84. Global transformations can be used for any mimetype. They will take
  85. the mimetype, if necessary, into regard. Mimetype-bound
  86. transformations usually only operate on a certain mimetype. There are
  87. transformations which operate on the main mimetype (like ‘image’),
  88. which will most likely take the subtype into regard, and those who
  89. only operate on a specific subtype (like ‘image/jpeg’). You can use
  90. transformations on mimetypes for which the function was not defined
  91. for. There is no security check for you selected the right
  92. transformation, so take care of what the output will be like.</p></li>
  93. <li><p>The field ‘Transformation options’ is a free-type textfield. You have
  94. to enter transform-function specific options here. Usually the
  95. transforms can operate with default options, but it is generally a
  96. good idea to look up the overview to see which options are necessary.
  97. Much like the ENUM/SET-Fields, you have to split up several options
  98. using the format ‘a’,’b’,’c’,…(NOTE THE MISSING BLANKS). This is
  99. because internally the options will be parsed as an array, leaving the
  100. first value the first element in the array, and so forth. If you want
  101. to specify a MIME character set you can define it in the
  102. transformation_options. You have to put that outside of the pre-
  103. defined options of the specific mime-transform, as the last value of
  104. the set. Use the format “’; charset=XXX’”. If you use a transform, for
  105. which you can specify 2 options and you want to append a character
  106. set, enter “‘first parameter’,’second parameter’,’charset=us-ascii’”.
  107. You can, however use the defaults for the parameters: “’’,’’,’charset
  108. =us-ascii’”. The default options can be configured using
  109. <span class="target" id="index-0"></span><a class="reference internal" href="config.html#cfg_DefaultTransformations"><code class="xref config config-option docutils literal notranslate"><span class="pre">$cfg['DefaultTransformations']</span></code></a></p></li>
  110. </ul>
  111. </div>
  112. <div class="section" id="file-structure">
  113. <span id="transformationsfiles"></span><h2>File structure<a class="headerlink" href="#file-structure" title="Permalink to this headline">¶</a></h2>
  114. <p>All specific transformations for mimetypes are defined through class
  115. files in the directory ‘libraries/classes/Plugins/Transformations/’. Each of
  116. them extends a certain transformation abstract class declared in
  117. libraries/classes/Plugins/Transformations/Abs.</p>
  118. <p>They are stored in files to ease up customization and easy adding of
  119. new transformations.</p>
  120. <p>Because the user cannot enter own mimetypes, it is kept sure that
  121. transformations always work. It makes no sense to apply a
  122. transformation to a mimetype the transform-function doesn’t know to
  123. handle.</p>
  124. <p>There is a file called ‘<em>transformations.lib.php</em>’ that provides some
  125. basic functions which can be included by any other transform function.</p>
  126. <p>The file name convention is <code class="docutils literal notranslate"><span class="pre">[Mimetype]_[Subtype]_[Transformation</span>
  127. <span class="pre">Name].class.php</span></code>, while the abtract class that it extends has the
  128. name <code class="docutils literal notranslate"><span class="pre">[Transformation</span> <span class="pre">Name]TransformationsPlugin</span></code>. All of the
  129. methods that have to be implemented by a transformations plug-in are:</p>
  130. <ol class="arabic simple">
  131. <li><p>getMIMEType() and getMIMESubtype() in the main class;</p></li>
  132. <li><p>getName(), getInfo() and applyTransformation() in the abstract class
  133. it extends.</p></li>
  134. </ol>
  135. <p>The getMIMEType(), getMIMESubtype() and getName() methods return the
  136. name of the MIME type, MIME Subtype and transformation accordingly.
  137. getInfo() returns the transformation’s description and possible
  138. options it may receive and applyTransformation() is the method that
  139. does the actual work of the transformation plug-in.</p>
  140. <p>Please see the libraries/classes/Plugins/Transformations/TEMPLATE and
  141. libraries/classes/Plugins/Transformations/TEMPLATE_ABSTRACT files for adding
  142. your own transformation plug-in. You can also generate a new
  143. transformation plug-in (with or without the abstract transformation
  144. class), by using
  145. <code class="file docutils literal notranslate"><span class="pre">scripts/transformations_generator_plugin.sh</span></code> or
  146. <code class="file docutils literal notranslate"><span class="pre">scripts/transformations_generator_main_class.sh</span></code>.</p>
  147. <p>The applyTransformation() method always gets passed three variables:</p>
  148. <ol class="arabic simple">
  149. <li><p><strong>$buffer</strong> - Contains the text inside of the column. This is the
  150. text, you want to transform.</p></li>
  151. <li><p><strong>$options</strong> - Contains any user-passed options to a transform
  152. function as an array.</p></li>
  153. <li><p><strong>$meta</strong> - Contains an object with information about your column. The
  154. data is drawn from the output of the <a class="reference external" href="https://www.php.net/mysql_fetch_field">mysql_fetch_field()</a> function. This means, all
  155. object properties described on the <a class="reference external" href="https://www.php.net/mysql_fetch_field">manual page</a> are available in this
  156. variable and can be used to transform a column accordingly to
  157. unsigned/zerofill/not_null/… properties. The $meta-&gt;mimetype
  158. variable contains the original MIME-type of the column (i.e.
  159. ‘text/plain’, ‘image/jpeg’ etc.)</p></li>
  160. </ol>
  161. </div>
  162. </div>
  163. <div class="clearer"></div>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  168. <div class="sphinxsidebarwrapper">
  169. <h3><a href="index.html">Table of Contents</a></h3>
  170. <ul>
  171. <li><a class="reference internal" href="#">Transformations</a><ul>
  172. <li><a class="reference internal" href="#introduction">Introduction</a></li>
  173. <li><a class="reference internal" href="#usage">Usage</a></li>
  174. <li><a class="reference internal" href="#file-structure">File structure</a></li>
  175. </ul>
  176. </li>
  177. </ul>
  178. <h4>Previous topic</h4>
  179. <p class="topless"><a href="two_factor.html"
  180. title="previous chapter">Two-factor authentication</a></p>
  181. <h4>Next topic</h4>
  182. <p class="topless"><a href="bookmarks.html"
  183. title="next chapter">Bookmarks</a></p>
  184. <div role="note" aria-label="source link">
  185. <h3>This Page</h3>
  186. <ul class="this-page-menu">
  187. <li><a href="_sources/transformations.rst.txt"
  188. rel="nofollow">Show Source</a></li>
  189. </ul>
  190. </div>
  191. <div id="searchbox" style="display: none" role="search">
  192. <h3 id="searchlabel">Quick search</h3>
  193. <div class="searchformwrapper">
  194. <form class="search" action="search.html" method="get">
  195. <input type="text" name="q" aria-labelledby="searchlabel" />
  196. <input type="submit" value="Go" />
  197. </form>
  198. </div>
  199. </div>
  200. <script>$('#searchbox').show(0);</script>
  201. </div>
  202. </div>
  203. <div class="clearer"></div>
  204. </div>
  205. <div class="related" role="navigation" aria-label="related navigation">
  206. <h3>Navigation</h3>
  207. <ul>
  208. <li class="right" style="margin-right: 10px">
  209. <a href="genindex.html" title="General Index"
  210. >index</a></li>
  211. <li class="right" >
  212. <a href="bookmarks.html" title="Bookmarks"
  213. >next</a> |</li>
  214. <li class="right" >
  215. <a href="two_factor.html" title="Two-factor authentication"
  216. >previous</a> |</li>
  217. <li class="nav-item nav-item-0"><a href="index.html">phpMyAdmin 4.9.10 documentation</a> &#187;</li>
  218. <li class="nav-item nav-item-1"><a href="user.html" >User Guide</a> &#187;</li>
  219. <li class="nav-item nav-item-this"><a href="">Transformations</a></li>
  220. </ul>
  221. </div>
  222. <div class="footer" role="contentinfo">
  223. &#169; <a href="copyright.html">Copyright</a> 2012 - 2018, The phpMyAdmin devel team.
  224. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.4.3.
  225. </div>
  226. </body>
  227. </html>