editor.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Abstract class of editor plugins.
  4. *
  5. * @author Naoki Sawada
  6. */
  7. class elFinderEditor
  8. {
  9. /**
  10. * Array of allowed method by request from client side.
  11. *
  12. * @var array
  13. */
  14. protected $allowed = array();
  15. /**
  16. * elFinder instance
  17. *
  18. * @var object elFinder instance
  19. */
  20. protected $elfinder;
  21. /**
  22. * Arguments
  23. *
  24. * @var array argValues
  25. */
  26. protected $args;
  27. /**
  28. * Constructor.
  29. *
  30. * @param object $elfinder
  31. * @param array $args
  32. */
  33. public function __construct($elfinder, $args)
  34. {
  35. $this->elfinder = $elfinder;
  36. $this->args = $args;
  37. }
  38. /**
  39. * Return boolean that this plugin is enabled.
  40. *
  41. * @return bool
  42. */
  43. public function enabled()
  44. {
  45. return true;
  46. }
  47. /**
  48. * Return boolean that $name method is allowed.
  49. *
  50. * @param string $name
  51. *
  52. * @return bool
  53. */
  54. public function isAllowedMethod($name)
  55. {
  56. $checker = array_flip($this->allowed);
  57. return isset($checker[$name]);
  58. }
  59. /**
  60. * Return $this->args value of the key
  61. *
  62. * @param string $key target key
  63. * @param string $empty empty value
  64. *
  65. * @return mixed
  66. */
  67. public function argValue($key, $empty = '')
  68. {
  69. return isset($this->args[$key]) ? $this->args[$key] : $empty;
  70. }
  71. }