AppendTransformationsPlugin.class.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the append transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage Append
  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 append transformations plugins.
  16. *
  17. * @package PhpMyAdmin-Transformations
  18. * @subpackage Append
  19. */
  20. abstract class AppendTransformationsPlugin 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. 'Appends text to a string. The only option is the text to be appended'
  31. . ' (enclosed in single quotes, default empty string).'
  32. );
  33. }
  34. /**
  35. * Does the actual work of each specific transformations plugin.
  36. *
  37. * @param string $buffer text to be transformed
  38. * @param array $options transformation options
  39. * @param string $meta meta information
  40. *
  41. * @return void
  42. */
  43. public function applyTransformation($buffer, $options = array(), $meta = '')
  44. {
  45. if (! isset($options[0]) || $options[0] == '') {
  46. $options[0] = '';
  47. }
  48. //just append the option to the original text
  49. $newtext = htmlspecialchars($buffer) . htmlspecialchars($options[0]);
  50. return $newtext;
  51. }
  52. /**
  53. * This method is called when any PluginManager to which the observer
  54. * is attached calls PluginManager::notify()
  55. *
  56. * @param SplSubject $subject The PluginManager notifying the observer
  57. * of an update.
  58. *
  59. * @todo implement
  60. * @return void
  61. */
  62. public function update (SplSubject $subject)
  63. {
  64. ;
  65. }
  66. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  67. /**
  68. * Gets the transformation name of the specific plugin
  69. *
  70. * @return string
  71. */
  72. public static function getName()
  73. {
  74. return "Append";
  75. }
  76. }
  77. ?>