ImageLinkTransformationsPlugin.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  10. use PhpMyAdmin\Plugins\TransformationsPlugin;
  11. if (!defined('PHPMYADMIN')) {
  12. exit;
  13. }
  14. /**
  15. * Provides common methods for all of the link transformations plugins.
  16. *
  17. * @package PhpMyAdmin
  18. */
  19. abstract class ImageLinkTransformationsPlugin extends TransformationsPlugin
  20. {
  21. /**
  22. * Gets the transformation description of the specific plugin
  23. *
  24. * @return string
  25. */
  26. public static function getInfo()
  27. {
  28. return __(
  29. 'Displays a link to download this image.'
  30. );
  31. }
  32. /**
  33. * Does the actual work of each specific transformations plugin.
  34. *
  35. * @param string $buffer text to be transformed
  36. * @param array $options transformation options
  37. * @param string $meta meta information
  38. *
  39. * @return string
  40. */
  41. public function applyTransformation($buffer, array $options = array(), $meta = '')
  42. {
  43. // must disable the page loader, see
  44. // https://wiki.phpmyadmin.net/pma/Page_loader#Bypassing_the_page_loader
  45. return '<a class="disableAjax" target="_blank" rel="noopener noreferrer" href="transformation_wrapper.php'
  46. . $options['wrapper_link'] . '" alt="[' . htmlspecialchars($buffer) . ']">[BLOB]</a>';
  47. }
  48. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  49. /**
  50. * Gets the transformation name of the specific plugin
  51. *
  52. * @return string
  53. */
  54. public static function getName()
  55. {
  56. return "ImageLink";
  57. }
  58. }