PreApPendTransformationsPlugin.class.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. 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 prepend/append transformations plugins.
  16. *
  17. * @package PhpMyAdmin-Transformations
  18. * @subpackage PreApPend
  19. */
  20. abstract class PreApPendTransformationsPlugin extends TransformationsPlugin
  21. {
  22. /**
  23. * Gets the transformation description of the specific plugin
  24. *
  25. * @return string
  26. */
  27. public static function getInfo()
  28. {
  29. return __(
  30. 'Prepends and/or Appends text to a string. First option is text'
  31. . ' to be prepended, second is appended (enclosed in single'
  32. . ' quotes, default empty string).'
  33. );
  34. }
  35. /**
  36. * Does the actual work of each specific transformations plugin.
  37. *
  38. * @param string $buffer text to be transformed
  39. * @param array $options transformation options
  40. * @param string $meta meta information
  41. *
  42. * @return void
  43. */
  44. public function applyTransformation($buffer, $options = array(), $meta = '')
  45. {
  46. if (! isset($options[0]) || $options[0] == '') {
  47. $options[0] = '';
  48. }
  49. if (! isset($options[1]) || $options[1] == '') {
  50. $options[1] = ''; // default empty strings
  51. }
  52. //just prepend and/or append the options to the original text
  53. $newtext = htmlspecialchars($options[0]) . $buffer
  54. . htmlspecialchars($options[1]);
  55. return $newtext;
  56. }
  57. /**
  58. * This method is called when any PluginManager to which the observer
  59. * is attached calls PluginManager::notify()
  60. *
  61. * @param SplSubject $subject The PluginManager notifying the observer
  62. * of an update.
  63. *
  64. * @todo implement
  65. * @return void
  66. */
  67. public function update (SplSubject $subject)
  68. {
  69. ;
  70. }
  71. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  72. /**
  73. * Gets the transformation name of the specific plugin
  74. *
  75. * @return string
  76. */
  77. public static function getName()
  78. {
  79. return "PreApPend";
  80. }
  81. }
  82. ?>