edit.html.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * The editor view file of dir module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL (http://zpl.pub/page/zplv12.html)
  7. * @author Yidong Wang <yidong@cnezsoft.com>
  8. * @package editor
  9. * @version $Id$
  10. * @link https://www.zentao.net
  11. */
  12. namespace zin;
  13. set::zui(true);
  14. if(empty($filePath)) return;
  15. $jsRoot = $config->webRoot . 'js/';
  16. h::importJs($jsRoot . 'monaco-editor/min/vs/loader.js');
  17. $showFileBox = ($action and $action != 'edit' and $action != 'newPage' and $action != 'override' and $action != 'extendControl');
  18. $fileSuffix = $lang->editor->examplePHP;
  19. if($action == 'newHook') $fileSuffix = $lang->editor->exampleHook;
  20. if($action and $action == 'extendOther' and strpos(basename($filePath), '.js') !== false or $action == 'newJS') $fileSuffix = $lang->editor->exampleJs;
  21. if($action and $action == 'extendOther' and strpos(basename($filePath), '.css') !== false or $action == 'newCSS') $fileSuffix = $lang->editor->exampleCss;
  22. jsVar('jsRoot', $jsRoot);
  23. jsVar('clientLang', $app->clientLang);
  24. jsVar('isShowContent', !empty($showContent));
  25. jsVar('showContent', !empty($showContent) ? $showContent : '');
  26. jsVar('fileContent', $fileContent);
  27. jsVar('language', $fileExtension == 'js' ? 'javascript' : $fileExtension);
  28. formPanel
  29. (
  30. set::actions(false),
  31. set::url(inlink('save', "filePath=$safeFilePath&action=$action")),
  32. div
  33. (
  34. setClass('heading'),
  35. icon('edit'),
  36. $filePath ? span(span(setClass('font-bold pl-2'), $lang->editor->filePath), h::code($filePath)) : null
  37. ),
  38. empty($showContent) ? null : div(p(setClass('font-bold'), $lang->editor->sourceFile), div(setID('showContentEditor'))),
  39. div(div(setID('fileContentEditor')), input(setID('fileContent'), set::name('fileContent'), set::type('hidden'))),
  40. $showFileBox ? div
  41. (
  42. setID('fileNameBox'),
  43. inputControl
  44. (
  45. set::prefix($lang->editor->fileName),
  46. input(set::name('fileName')),
  47. set::suffix($fileSuffix)
  48. )
  49. ) : input(setID('fileName'), set::name('fileName'), set::type('hidden'), set::value(basename($filePath))),
  50. div
  51. (
  52. setClass('flex items-center form-actions'),
  53. btn(set('btnType', 'submit'), setClass('primary'), set::onclick('syncFileContent()'), $lang->save),
  54. ($action and $action != 'edit' and $action != 'newPage') ? checkbox(set::name('override'), set::value(1), set::text($lang->editor->isOverride)) : null
  55. )
  56. );
  57. render('pagebase');