transformations.html 13 KB

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