InlineTransformationsPlugin.class.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the inline transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage Inline
  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_global_html_replace */
  15. require_once 'libraries/transformations.lib.php';
  16. /**
  17. * Provides common methods for all of the inline transformations plugins.
  18. *
  19. * @package PhpMyAdmin
  20. */
  21. abstract class InlineTransformationsPlugin 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 a clickable thumbnail. The options are the maximum width'
  32. . ' and height in pixels. The original aspect ratio is preserved.'
  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 (PMA_IS_GD2) {
  47. return '<a href="transformation_wrapper.php'
  48. . $options['wrapper_link']
  49. . '" rel="noopener noreferrer" target="_blank"><img src="transformation_wrapper.php'
  50. . $options['wrapper_link'] . '&amp;resize=jpeg&amp;newWidth='
  51. . (isset($options[0]) ? intval($options[0]) : '100') . '&amp;newHeight='
  52. . (isset($options[1]) ? intval($options[1]) : 100)
  53. . '" alt="' . htmlspecialchars($buffer) . '" border="0" /></a>';
  54. } else {
  55. return '<img src="transformation_wrapper.php'
  56. . $options['wrapper_link']
  57. . '" alt="' . htmlspecialchars($buffer) . '" width="320" height="240" />';
  58. }
  59. }
  60. /**
  61. * This method is called when any PluginManager to which the observer
  62. * is attached calls PluginManager::notify()
  63. *
  64. * @param SplSubject $subject The PluginManager notifying the observer
  65. * of an update.
  66. *
  67. * @todo implement
  68. * @return void
  69. */
  70. public function update (SplSubject $subject)
  71. {
  72. ;
  73. }
  74. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  75. /**
  76. * Gets the transformation name of the specific plugin
  77. *
  78. * @return string
  79. */
  80. public static function getName()
  81. {
  82. return "Inline";
  83. }
  84. }
  85. ?>