ImageLinkTransformationsPlugin.class.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. 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 link transformations plugins.
  18. *
  19. * @package PhpMyAdmin
  20. */
  21. abstract class ImageLinkTransformationsPlugin 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 link to download this image.'
  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 string
  42. */
  43. public function applyTransformation($buffer, $options = array(), $meta = '')
  44. {
  45. // must disable the page loader, see
  46. // https://wiki.phpmyadmin.net/pma/Page_loader#Bypassing_the_page_loader
  47. $transform_options = array (
  48. 'string' => '<a class="disableAjax"'
  49. . ' target="_new" href="transformation_wrapper.php'
  50. . $options['wrapper_link'] . '" alt="[__BUFFER__]">[BLOB]</a>'
  51. );
  52. return PMA_Transformation_globalHtmlReplace(
  53. $buffer,
  54. $transform_options
  55. );
  56. }
  57. /**
  58. * This method is called when any PluginManager to which the observer
  59. * is attached calls PluginManager::notify()
  60. *
  61. * @param SplSubject $subject The PluginManager notifying the observer
  62. * of an update.
  63. *
  64. * @todo implement
  65. * @return void
  66. */
  67. public function update (SplSubject $subject)
  68. {
  69. ;
  70. }
  71. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  72. /**
  73. * Gets the transformation name of the specific plugin
  74. *
  75. * @return string
  76. */
  77. public static function getName()
  78. {
  79. return "ImageLink";
  80. }
  81. }
  82. ?>