InlineTransformationsPlugin.class.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_globalHtmlReplace */
  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 string
  43. */
  44. public function applyTransformation($buffer, $options = array(), $meta = '')
  45. {
  46. if (PMA_IS_GD2) {
  47. $transform_options = array (
  48. 'string' => '<a href="transformation_wrapper.php'
  49. . $options['wrapper_link']
  50. . '" target="_blank"><img src="transformation_wrapper.php'
  51. . $options['wrapper_link'] . '&amp;resize=jpeg&amp;newWidth='
  52. . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight='
  53. . (isset($options[1]) ? $options[1] : 100)
  54. . '" alt="[__BUFFER__]" border="0" /></a>'
  55. );
  56. } else {
  57. $transform_options = array (
  58. 'string' => '<img src="transformation_wrapper.php'
  59. . $options['wrapper_link']
  60. . '" alt="[__BUFFER__]" width="320" height="240" />'
  61. );
  62. }
  63. return PMA_Transformation_globalHtmlReplace(
  64. $buffer,
  65. $transform_options
  66. );
  67. }
  68. /**
  69. * This method is called when any PluginManager to which the observer
  70. * is attached calls PluginManager::notify()
  71. *
  72. * @param SplSubject $subject The PluginManager notifying the observer
  73. * of an update.
  74. *
  75. * @todo implement
  76. * @return void
  77. */
  78. public function update (SplSubject $subject)
  79. {
  80. ;
  81. }
  82. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  83. /**
  84. * Gets the transformation name of the specific plugin
  85. *
  86. * @return string
  87. */
  88. public static function getName()
  89. {
  90. return "Inline";
  91. }
  92. }
  93. ?>