repos.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * The repos 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 reposEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @access public
  18. * @return string
  19. */
  20. public function get()
  21. {
  22. $control = $this->loadController('repo', 'maintain');
  23. $repoUrl = $this->param('repoUrl', '');
  24. if(empty($repoUrl))
  25. {
  26. $control->maintain(0, $this->param('order', 'id_desc'), 0, $this->param('limit', 100), $this->param('page', 1));
  27. /* Response */
  28. $data = $this->getData();
  29. }
  30. else
  31. {
  32. $data = (object)$this->loadModel('repo')->getRepoListByUrl($repoUrl);
  33. }
  34. if(isset($data->status) and $data->status == 'success')
  35. {
  36. if(empty($repoUrl))
  37. {
  38. $result = array();
  39. $pager = $data->data->pager;
  40. $repos = $data->data->repoList;
  41. foreach($repos as $repo) $result[] = $this->format($repo, 'deleted:bool,lastSync:datetime,synced:bool,product:idList');
  42. return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'repos' => $result));
  43. }
  44. else
  45. {
  46. return $this->send(200, array('repos' => $data->repos));
  47. }
  48. }
  49. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  50. return $this->sendError(400, 'error');
  51. }
  52. }