Bool2TextTransformationsPlugin.class.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the Bool2Text transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage Bool2Text
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /* Get the transformations interface */
  13. require_once 'libraries/plugins/TransformationsPlugin.class.php';
  14. /**
  15. * Provides common methods for all of the Bool2Text transformations plugins.
  16. *
  17. * @package PhpMyAdmin-Transformations
  18. * @subpackage Bool2Text
  19. */
  20. abstract class Bool2TextTransformationsPlugin extends TransformationsPlugin
  21. {
  22. /**
  23. * Gets the transformation description of the specific plugin
  24. *
  25. * @return string
  26. */
  27. public static function getInfo()
  28. {
  29. return __(
  30. 'Converts Boolean values to text (default \'T\' and \'F\').'
  31. . ' First option is for TRUE, second for FALSE. Nonzero=true.'
  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 void
  42. */
  43. public function applyTransformation($buffer, $options = array(), $meta = '')
  44. {
  45. error_log('apply');
  46. if (! isset($options[0])) {
  47. $options[0] = 'T'; // default true option
  48. }
  49. if (! isset($options[1])) {
  50. $options[1] = 'F'; // default false option
  51. }
  52. if ($buffer == '0') {
  53. return $options[1]; // return false label
  54. }
  55. return $options[0]; // or true one if nonzero
  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 "Bool2Text";
  80. }
  81. }
  82. ?>