editor.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * Constructor.
  17. *
  18. * @param object $elfinder
  19. * @param array $args
  20. */
  21. public function __construct($elfinder, $args)
  22. {
  23. $this->elfinder = $elfinder;
  24. $this->args = $args;
  25. }
  26. /**
  27. * Return boolean that this plugin is enabled.
  28. *
  29. * @return bool
  30. */
  31. public function enabled()
  32. {
  33. return true;
  34. }
  35. /**
  36. * Return boolean that $name method is allowed.
  37. *
  38. * @param string $name
  39. *
  40. * @return bool
  41. */
  42. public function isAllowedMethod($name)
  43. {
  44. $checker = array_flip($this->allowed);
  45. return isset($checker[$name]);
  46. }
  47. /**
  48. * Return $this->args value of the key
  49. *
  50. * @param string $key target key
  51. * @param string $empty empty value
  52. *
  53. * @return mixed
  54. */
  55. public function argValue($key, $empty = '')
  56. {
  57. return isset($this->args[$key])? $this->args[$key] : $empty;
  58. }
  59. }