CodeMirrorEditorTransformationPlugin.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for syntax highlighted editors using CodeMirror
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. */
  8. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  9. use PhpMyAdmin\Plugins\IOTransformationsPlugin;
  10. /**
  11. * Provides common methods for all the CodeMirror syntax highlighted editors
  12. *
  13. * @package PhpMyAdmin-Transformations
  14. */
  15. abstract class CodeMirrorEditorTransformationPlugin extends IOTransformationsPlugin
  16. {
  17. /**
  18. * Does the actual work of each specific transformations plugin.
  19. *
  20. * @param string $buffer text to be transformed
  21. * @param array $options transformation options
  22. * @param string $meta meta information
  23. *
  24. * @return string
  25. */
  26. public function applyTransformation($buffer, array $options = array(), $meta = '')
  27. {
  28. return $buffer;
  29. }
  30. /**
  31. * Returns the html for input field to override default textarea.
  32. * Note: Return empty string if default textarea is required.
  33. *
  34. * @param array $column column details
  35. * @param int $row_id row number
  36. * @param string $column_name_appendix the name attribute
  37. * @param array $options transformation options
  38. * @param string $value Current field value
  39. * @param string $text_dir text direction
  40. * @param int $tabindex tab index
  41. * @param int $tabindex_for_value offset for the values tabindex
  42. * @param int $idindex id index
  43. *
  44. * @return string the html for input field
  45. */
  46. public function getInputHtml(
  47. array $column,
  48. $row_id,
  49. $column_name_appendix,
  50. array $options,
  51. $value,
  52. $text_dir,
  53. $tabindex,
  54. $tabindex_for_value,
  55. $idindex
  56. ) {
  57. $html = '';
  58. if (!empty($value)) {
  59. $html = '<input type="hidden" name="fields_prev' . $column_name_appendix
  60. . '" value="' . htmlspecialchars($value) . '"/>';
  61. }
  62. $class = 'transform_' . strtolower(static::getName()) . '_editor';
  63. $html .= '<textarea name="fields' . $column_name_appendix . '"'
  64. . ' dir="' . $text_dir . '" class="' . $class . '">'
  65. . htmlspecialchars($value) . '</textarea>';
  66. return $html;
  67. }
  68. }