IOTransformationsPlugin.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the I/O transformations plugins
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. declare(strict_types=1);
  9. namespace PhpMyAdmin\Plugins;
  10. use PhpMyAdmin\Plugins\TransformationsPlugin;
  11. /**
  12. * Provides a common interface that will have to be implemented
  13. * by all of the Input/Output transformations plugins.
  14. *
  15. * @package PhpMyAdmin
  16. */
  17. abstract class IOTransformationsPlugin extends TransformationsPlugin
  18. {
  19. // specifies whether transformation was successful or not
  20. protected $success = true;
  21. // to store the error message in case of failed transformations
  22. protected $error = '';
  23. /**
  24. * Returns the html for input field to override default textarea.
  25. * Note: Return empty string if default textarea is required.
  26. *
  27. * @param array $column column details
  28. * @param int $row_id row number
  29. * @param string $column_name_appendix the name attribute
  30. * @param array $options transformation options
  31. * @param string $value Current field value
  32. * @param string $text_dir text direction
  33. * @param int $tabindex tab index
  34. * @param int $tabindex_for_value offset for the values tabindex
  35. * @param int $idindex id index
  36. *
  37. * @return string the html for input field
  38. */
  39. public function getInputHtml(
  40. array $column,
  41. $row_id,
  42. $column_name_appendix,
  43. array $options,
  44. $value,
  45. $text_dir,
  46. $tabindex,
  47. $tabindex_for_value,
  48. $idindex
  49. ) {
  50. return '';
  51. }
  52. /**
  53. * Returns the array of scripts (filename) required for plugin
  54. * initialization and handling
  55. *
  56. * @return array javascripts to be included
  57. */
  58. public function getScripts()
  59. {
  60. return [];
  61. }
  62. /**
  63. * Returns the error message
  64. *
  65. * @return string error
  66. */
  67. public function getError()
  68. {
  69. return $this->error;
  70. }
  71. /**
  72. * Returns the success status
  73. *
  74. * @return bool
  75. */
  76. public function isSuccess()
  77. {
  78. return $this->success;
  79. }
  80. /**
  81. * Resets the object properties
  82. *
  83. * @return void
  84. */
  85. public function reset()
  86. {
  87. $this->success = true;
  88. $this->error = '';
  89. }
  90. }