zen.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * The zen file of editor module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Yidong Wang <yidong@easycorp.ltd>
  8. * @package editor
  9. * @link https://www.zentao.net
  10. */
  11. class editorZen extends editor
  12. {
  13. /**
  14. * @param string $filePath
  15. * @param string $action
  16. * @param string $isExtends
  17. */
  18. protected function buildContentByAction($filePath, $action, $isExtends = '')
  19. {
  20. if(empty($filePath)) return '';
  21. if($action == 'extendModel') return $this->editor->extendModel($filePath);
  22. if($action == 'newPage') return $this->editor->newControl($filePath);
  23. if($action == 'extendControl' && !empty($isExtends)) return $this->editor->extendControl($filePath, $isExtends);
  24. if(($action == 'edit' or $action == 'override') && file_exists($filePath))
  25. {
  26. $fileContent = file_get_contents($filePath);
  27. if($action == 'override')
  28. {
  29. $fileContent = str_replace("'../../", '$this->app->getModuleRoot() . \'', $fileContent);
  30. $fileContent = str_replace(array('\'./', '"./'), array('\'../../view/', '"../../view'), $fileContent);
  31. }
  32. return $fileContent;
  33. }
  34. if(strrpos(basename($filePath), '.php') !== false) return "<?php\n";
  35. return '';
  36. }
  37. }