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