SQLTransformationsPlugin.class.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 string
  40. */
  41. public function applyTransformation($buffer, $options = array(), $meta = '')
  42. {
  43. // see PMA_highlightSQL()
  44. $result = PMA_Util::formatSql($buffer);
  45. // Need to clear error state not to break subsequent queries display.
  46. PMA_SQP_resetError();
  47. return $result;
  48. }
  49. /**
  50. * This method is called when any PluginManager to which the observer
  51. * is attached calls PluginManager::notify()
  52. *
  53. * @param SplSubject $subject The PluginManager notifying the observer
  54. * of an update.
  55. *
  56. * @todo implement
  57. * @return void
  58. */
  59. public function update (SplSubject $subject)
  60. {
  61. ;
  62. }
  63. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  64. /**
  65. * Gets the transformation name of the specific plugin
  66. *
  67. * @return string
  68. */
  69. public static function getName()
  70. {
  71. return "SQL";
  72. }
  73. }
  74. ?>