TextFileUploadTransformationsPlugin.class.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the text file upload input transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage TextFileUpload
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /* Get the transformations class */
  13. require_once 'libraries/plugins/IOTransformationsPlugin.class.php';
  14. /**
  15. * Provides common methods for all of the text file upload
  16. * input transformations plugins.
  17. *
  18. * @package PhpMyAdmin-Transformations
  19. * @subpackage TextFileUpload
  20. */
  21. abstract class TextFileUploadTransformationsPlugin extends IOTransformationsPlugin
  22. {
  23. /**
  24. * Gets the transformation description of the specific plugin
  25. *
  26. * @return string
  27. */
  28. public static function getInfo()
  29. {
  30. return __(
  31. 'File upload functionality for TEXT columns. '
  32. . 'It does not have a textarea for input.'
  33. );
  34. }
  35. /**
  36. * Does the actual work of each specific transformations plugin.
  37. *
  38. * @param string $buffer text to be transformed
  39. * @param array $options transformation options
  40. * @param string $meta meta information
  41. *
  42. * @return string
  43. */
  44. public function applyTransformation($buffer, $options = array(), $meta = '')
  45. {
  46. return $buffer;
  47. }
  48. /**
  49. * Returns the html for input field to override default textarea.
  50. * Note: Return empty string if default textarea is required.
  51. *
  52. * @param array $column column details
  53. * @param int $row_id row number
  54. * @param string $column_name_appendix the name attribute
  55. * @param array $options transformation options
  56. * @param string $value Current field value
  57. * @param string $text_dir text direction
  58. * @param int $tabindex tab index
  59. * @param int $tabindex_for_value offset for the values tabindex
  60. * @param int $idindex id index
  61. *
  62. * @return string the html for input field
  63. */
  64. public function getInputHtml(
  65. $column, $row_id, $column_name_appendix, $options, $value, $text_dir,
  66. $tabindex, $tabindex_for_value, $idindex
  67. ) {
  68. $html = '';
  69. if (!empty($value)) {
  70. $html = '<input type="hidden" name="fields_prev' . $column_name_appendix
  71. . '" value="' . htmlspecialchars($value) . '"/>';
  72. $html .= '<input type="hidden" name="fields' . $column_name_appendix
  73. . '" value="' . htmlspecialchars($value) . '"/>';
  74. }
  75. $html .= '<input type="file" name="fields_upload'
  76. . $column_name_appendix . '"/>';
  77. return $html;
  78. }
  79. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  80. /**
  81. * Gets the transformation name of the specific plugin
  82. *
  83. * @return string
  84. */
  85. public static function getName()
  86. {
  87. return "Text file upload";
  88. }
  89. }