PreApPendTransformationsPlugin.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the prepend/append transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage PreApPend
  8. */
  9. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  10. use PhpMyAdmin\Plugins\TransformationsPlugin;
  11. /**
  12. * Provides common methods for all of the prepend/append transformations plugins.
  13. *
  14. * @package PhpMyAdmin-Transformations
  15. * @subpackage PreApPend
  16. */
  17. abstract class PreApPendTransformationsPlugin 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. 'Prepends and/or Appends text to a string. First option is text'
  28. . ' to be prepended, second is appended (enclosed in single'
  29. . ' quotes, default empty string).'
  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, array $options = array(), $meta = '')
  42. {
  43. $cfg = $GLOBALS['cfg'];
  44. $options = $this->getOptions($options, $cfg['DefaultTransformations']['PreApPend']);
  45. //just prepend and/or append the options to the original text
  46. return htmlspecialchars($options[0]) . htmlspecialchars($buffer)
  47. . htmlspecialchars($options[1]);
  48. }
  49. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  50. /**
  51. * Gets the transformation name of the specific plugin
  52. *
  53. * @return string
  54. */
  55. public static function getName()
  56. {
  57. return "PreApPend";
  58. }
  59. }