FormattedTransformationsPlugin.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the formatted transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage Formatted
  8. */
  9. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  10. use PhpMyAdmin\Plugins\TransformationsPlugin;
  11. /**
  12. * Provides common methods for all of the formatted transformations plugins.
  13. *
  14. * @package PhpMyAdmin
  15. */
  16. abstract class FormattedTransformationsPlugin extends TransformationsPlugin
  17. {
  18. /**
  19. * Gets the transformation description of the specific plugin
  20. *
  21. * @return string
  22. */
  23. public static function getInfo()
  24. {
  25. return __(
  26. 'Displays the contents of the column as-is, without running it'
  27. . ' through htmlspecialchars(). That is, the column is assumed'
  28. . ' to contain valid HTML.'
  29. );
  30. }
  31. /**
  32. * Does the actual work of each specific transformations plugin.
  33. *
  34. * @param string $buffer text to be transformed
  35. * @param array $options transformation options
  36. * @param string $meta meta information
  37. *
  38. * @return string
  39. */
  40. public function applyTransformation($buffer, array $options = array(), $meta = '')
  41. {
  42. return '<iframe srcdoc="'
  43. . strtr($buffer, '"', '\'')
  44. . '" sandbox=""></iframe>';
  45. }
  46. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  47. /**
  48. * Gets the transformation name of the specific plugin
  49. *
  50. * @return string
  51. */
  52. public static function getName()
  53. {
  54. return "Formatted";
  55. }
  56. }