TextImageLinkTransformationsPlugin.class.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the image link transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage ImageLink
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /* Get the transformations interface */
  13. require_once 'libraries/plugins/TransformationsPlugin.class.php';
  14. /* For PMA_Transformation_globalHtmlReplace */
  15. require_once 'libraries/transformations.lib.php';
  16. /**
  17. * Provides common methods for all of the image link transformations plugins.
  18. *
  19. * @package PhpMyAdmin
  20. */
  21. abstract class TextImageLinkTransformationsPlugin extends TransformationsPlugin
  22. {
  23. /**
  24. * Gets the transformation description of the specific plugin
  25. *
  26. * @return string
  27. */
  28. public static function getInfo()
  29. {
  30. return __(
  31. 'Displays an image and a link; the column contains the filename. The'
  32. . ' first option is a URL prefix like "http://www.example.com/". The'
  33. . ' second and third options are the width and the height in pixels.'
  34. );
  35. }
  36. /**
  37. * Does the actual work of each specific transformations plugin.
  38. *
  39. * @param string $buffer text to be transformed
  40. * @param array $options transformation options
  41. * @param string $meta meta information
  42. *
  43. * @return string
  44. */
  45. public function applyTransformation($buffer, $options = array(), $meta = '')
  46. {
  47. $transform_options = array (
  48. 'string' => '<a href="' . (isset($options[0]) ? $options[0] : '')
  49. . $buffer . '" target="_blank"><img src="'
  50. . (isset($options[0]) ? $options[0] : '') . $buffer
  51. . '" border="0" width="' . (isset($options[1]) ? $options[1] : 100)
  52. . '" height="' . (isset($options[2]) ? $options[2] : 50) . '" />'
  53. . $buffer . '</a>'
  54. );
  55. $buffer = PMA_Transformation_globalHtmlReplace(
  56. $buffer,
  57. $transform_options
  58. );
  59. return $buffer;
  60. }
  61. /**
  62. * This method is called when any PluginManager to which the observer
  63. * is attached calls PluginManager::notify()
  64. *
  65. * @param SplSubject $subject The PluginManager notifying the observer
  66. * of an update.
  67. *
  68. * @todo implement
  69. * @return void
  70. */
  71. public function update (SplSubject $subject)
  72. {
  73. ;
  74. }
  75. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  76. /**
  77. * Gets the transformation name of the specific plugin
  78. *
  79. * @return string
  80. */
  81. public static function getName()
  82. {
  83. return "Image Link";
  84. }
  85. }
  86. ?>