views.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * The views entry point 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) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package entries
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class viewsEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @access public
  18. * @return string
  19. */
  20. public function get()
  21. {
  22. $position = $this->param('position', '');
  23. $tab = $this->param('tab', '');
  24. $lite = $this->param('lite', '');
  25. if(empty($position)) return $this->sendError(400, 'Need position param.');
  26. if($position != 'header' and $position != 'footer') return $this->sendError(400, 'Value of position param only is header or footer.');
  27. if(!empty($lite)) $lite .= 'lite.';
  28. if($tab)
  29. {
  30. $_COOKIE['tab'] = $tab;
  31. $this->app->setOpenApp();
  32. }
  33. $viewFile = $this->app->moduleRoot . "common/view/{$position}.{$lite}html.php";
  34. if(!file_exists($viewFile)) return $this->sendError(400, 'This view file is not exists.');
  35. $controller = new control();
  36. $viewHookFiles = glob($this->app->moduleRoot . "common/ext/view/{$position}.*.html.hook.php");
  37. $output = '';
  38. if($position == 'header') $output .= $controller->printViewFile($viewFile);
  39. foreach($viewHookFiles as $hookFile) $output .= $controller->printViewFile($hookFile);
  40. if($position == 'footer') $output .= $controller->printViewFile($viewFile);
  41. $sysURL = common::getSysURL();
  42. $output = str_replace("href='{$this->config->webRoot}", "href='{$sysURL}{$this->config->webRoot}", $output);
  43. $output = str_replace("src='{$this->config->webRoot}", "src='{$sysURL}{$this->config->webRoot}", $output);
  44. return $this->send(200, array('html' => $output));
  45. }
  46. }