SQLTransformationsPlugin.class.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /* Get the transformations interface */
  13. require_once 'libraries/plugins/TransformationsPlugin.class.php';
  14. /**
  15. * Provides common methods for all of the SQL transformations plugins.
  16. *
  17. * @package PhpMyAdmin
  18. */
  19. abstract class SQLTransformationsPlugin extends TransformationsPlugin
  20. {
  21. /**
  22. * Gets the transformation description of the specific plugin
  23. *
  24. * @return string
  25. */
  26. public static function getInfo()
  27. {
  28. return __(
  29. 'Formats text as SQL query with syntax highlighting.'
  30. );
  31. }
  32. /**
  33. * Does the actual work of each specific transformations plugin.
  34. *
  35. * @param string $buffer text to be transformed
  36. * @param array $options transformation options
  37. * @param string $meta meta information
  38. *
  39. * @return void
  40. */
  41. public function applyTransformation($buffer, $options = array(), $meta = '')
  42. {
  43. $result = PMA_SQP_formatHtml(PMA_SQP_parse($buffer));
  44. // Need to clear error state not to break subsequent queries display.
  45. PMA_SQP_resetError();
  46. return $result;
  47. }
  48. /**
  49. * This method is called when any PluginManager to which the observer
  50. * is attached calls PluginManager::notify()
  51. *
  52. * @param SplSubject $subject The PluginManager notifying the observer
  53. * of an update.
  54. *
  55. * @todo implement
  56. * @return void
  57. */
  58. public function update (SplSubject $subject)
  59. {
  60. ;
  61. }
  62. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  63. /**
  64. * Gets the transformation name of the specific plugin
  65. *
  66. * @return string
  67. */
  68. public static function getName()
  69. {
  70. return "SQL";
  71. }
  72. }
  73. ?>