Ueditor.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\common\extend\editor;
  3. class Ueditor {
  4. public $name = 'Ueditor';
  5. public $ver = '1.0';
  6. public function front($param)
  7. {
  8. if (isset($param['action']) && $param['action'] == 'config') {
  9. $configFile = './static/ueditor/config.json';
  10. if (!empty($param['ueditor_theme']) && $param['ueditor_theme'] === 'new') {
  11. $configFile = './static_new/ueditor/config.json';
  12. }
  13. $raw = @file_get_contents($configFile);
  14. if ($raw === false || $raw === '') {
  15. $raw = file_get_contents('./static/ueditor/config.json');
  16. }
  17. $UE_CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", $raw), true);
  18. echo json_encode($UE_CONFIG);
  19. exit;
  20. }
  21. }
  22. public function back($info='',$status=0,$data=[])
  23. {
  24. $arr=[];
  25. if ($status == 0) {
  26. $arr['message'] = $info;
  27. $arr['state'] = 'ERROR';
  28. } else {
  29. $arr['message'] = $info;
  30. $arr['url'] = $data['file'];
  31. $arr['state'] = 'SUCCESS';
  32. }
  33. echo json_encode($arr, 1);
  34. exit;
  35. }
  36. }