transformations.html 12 KB

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