docs.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * The docs 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 docsEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @access public
  18. * @return string
  19. */
  20. public function get($libID = 0)
  21. {
  22. if(empty($libID)) $libID = $this->param('lib', 0);
  23. if(empty($libID)) return $this->sendError(400, 'Need lib id.');
  24. $docTree = $this->loadModel('doc')->getDocTree($libID);
  25. foreach($docTree as $i => $module)
  26. {
  27. if(empty($module->id))
  28. {
  29. unset($docTree[$i]);
  30. foreach($module->children as $doc) $docTree[] = $doc;
  31. }
  32. }
  33. return $this->send(200, array('docs' => array_values($docTree)));
  34. }
  35. }