control.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * The control file of store 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) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Jianhua Wang <wangjianhua@easycorp.ltd>
  8. * @package store
  9. * @link https://www.zentao.net
  10. */
  11. class store extends control
  12. {
  13. /**
  14. * Contruct function, load cne model.
  15. *
  16. * @access public
  17. * @return void
  18. */
  19. public function __construct()
  20. {
  21. parent::__construct();
  22. $this->loadModel('cne');
  23. $this->app->loadLang('instance');
  24. }
  25. /**
  26. * 应用市场应用列表。
  27. * Browse departments and users of a store.
  28. *
  29. * @param string $sortType
  30. * @param int $categoryID
  31. * @param string $keyword
  32. * @param int $recTotal
  33. * @param int $recPerPage
  34. * @param int $pageID
  35. * @access public
  36. * @return void
  37. */
  38. public function browse($sortType = 'create_time', $categoryID = 0, $keyword = '', $recPerPage = 0, $pageID = 1)
  39. {
  40. if(empty($recPerPage)) $recPerPage = $this->cookie->pagerStoreBrowse ? $this->cookie->pagerStoreBrowse : 12;
  41. $pagedApps = $this->store->searchApps($sortType, $keyword, $categoryID, $pageID, (int)$recPerPage);
  42. if($recPerPage * ($pageID - 1) > $pagedApps->total)
  43. {
  44. $pageID = 1;
  45. $pagedApps = $this->store->searchApps($sortType, $keyword, $categoryID, $pageID, (int)$recPerPage);
  46. }
  47. $this->app->loadClass('pager', true);
  48. $pager = pager::init($pagedApps->total, $recPerPage, $pageID);
  49. $pagedCategories = $this->store->getCategories();
  50. $categories = array_combine(helper::arrayColumn($pagedCategories->categories, 'id'), helper::arrayColumn($pagedCategories->categories, 'alias'));
  51. $this->view->title = $this->lang->store->common;
  52. $this->view->cloudApps = $pagedApps->apps;
  53. $this->view->installedApps = $this->storeZen->getInstalledApps();
  54. $this->view->categories = $categories;
  55. $this->view->keyword = $keyword;
  56. $this->view->currentCategoryID = $categoryID;
  57. $this->view->sortType = $sortType;
  58. $this->view->pager = $pager;
  59. $this->display();
  60. }
  61. /**
  62. * 展示应用详情。
  63. * Show app detail.
  64. *
  65. * @param int $appID
  66. * @param int $pageID
  67. * @param int $recPerPage
  68. * @access public
  69. * @return void
  70. */
  71. public function appView($appID, $pageID = 1, $recPerPage = 20)
  72. {
  73. if(!commonModel::hasPriv('space', 'browse')) $this->loadModel('common')->deny('space', 'browse', false);
  74. $appInfo = $this->store->getAppInfo($appID, true);
  75. $dynamicResult = $this->store->appDynamic($appInfo, $pageID, $recPerPage);
  76. $articles = array();
  77. $totalArticle = 0;
  78. if(!empty($dynamicResult))
  79. {
  80. $articles = $dynamicResult->articles;
  81. $totalArticle = $dynamicResult->recTotal;
  82. }
  83. $this->view->dynamicArticles = $articles;
  84. $this->app->loadClass('pager', true);
  85. $pager = pager::init($totalArticle, $recPerPage, $pageID);
  86. $this->view->pager = $pager;
  87. $this->view->title = $appInfo->alias;
  88. $this->view->position[] = $appInfo->alias;
  89. $this->view->cloudApp = $appInfo;
  90. $this->view->components = null; // Hide custom installation in version 1.0. If want, opened by: $this->store->getAppSettings($appID);
  91. $this->display();
  92. }
  93. }