ImageLinkTransformationsPlugin.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the link transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage Link
  8. */
  9. declare(strict_types=1);
  10. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  11. use PhpMyAdmin\Plugins\TransformationsPlugin;
  12. use stdClass;
  13. /**
  14. * Provides common methods for all of the link transformations plugins.
  15. *
  16. * @package PhpMyAdmin
  17. */
  18. abstract class ImageLinkTransformationsPlugin extends TransformationsPlugin
  19. {
  20. /**
  21. * Gets the transformation description of the specific plugin
  22. *
  23. * @return string
  24. */
  25. public static function getInfo()
  26. {
  27. return __(
  28. 'Displays a link to download this image.'
  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 stdClass|null $meta meta information
  37. *
  38. * @return string
  39. */
  40. public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
  41. {
  42. // must disable the page loader, see
  43. // https://wiki.phpmyadmin.net/pma/Page_loader#Bypassing_the_page_loader
  44. return '<a class="disableAjax" target="_blank" rel="noopener noreferrer" href="transformation_wrapper.php'
  45. . $options['wrapper_link'] . '" alt="[' . htmlspecialchars($buffer) . ']">[BLOB]</a>';
  46. }
  47. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  48. /**
  49. * Gets the transformation name of the specific plugin
  50. *
  51. * @return string
  52. */
  53. public static function getName()
  54. {
  55. return "ImageLink";
  56. }
  57. }