SQLTransformationsPlugin.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the SQL transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage SQL
  8. */
  9. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  10. use PhpMyAdmin\Plugins\TransformationsPlugin;
  11. use PhpMyAdmin\Util;
  12. /**
  13. * Provides common methods for all of the SQL transformations plugins.
  14. *
  15. * @package PhpMyAdmin
  16. */
  17. abstract class SQLTransformationsPlugin extends TransformationsPlugin
  18. {
  19. /**
  20. * Gets the transformation description of the specific plugin
  21. *
  22. * @return string
  23. */
  24. public static function getInfo()
  25. {
  26. return __(
  27. 'Formats text as SQL query with syntax highlighting.'
  28. );
  29. }
  30. /**
  31. * Does the actual work of each specific transformations plugin.
  32. *
  33. * @param string $buffer text to be transformed
  34. * @param array $options transformation options
  35. * @param string $meta meta information
  36. *
  37. * @return string
  38. */
  39. public function applyTransformation($buffer, array $options = array(), $meta = '')
  40. {
  41. // see PMA_highlightSQL()
  42. $result = Util::formatSql($buffer);
  43. return $result;
  44. }
  45. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  46. /**
  47. * Gets the transformation name of the specific plugin
  48. *
  49. * @return string
  50. */
  51. public static function getName()
  52. {
  53. return "SQL";
  54. }
  55. }