AppListController.class.php
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* 应用中心-获取应用列表接口
* CreateBy:原习斌
* Date:2016-07-29
*
* @update 2016-10-12 zhuxun37 修正程序中出现的常量
*/
namespace Apicp\Controller\AppCenter;
class AppListController extends AbstractController
{
protected $needCheckThePayment = false;
public function Index()
{
// SDK获取应用列表
$pluginList = $this->_pluginSDK->listAll(array(), 1, self::PERPAGE);
$this->_result = array();
// 循环列表,分离格式
foreach ($pluginList as $_plugin) {
$groupId = $_plugin['pgGroupid'];
// 分组数据
$this->_generateGroup($this->_result[$groupId], $_plugin);
// 应用信息
$this->_result[$groupId]['plugins'][] = $this->_generatePlugin($_plugin);
}
sort($this->_result);
$this->_result = [
'app_list' => $this->_result,
'contact_identifier' => $this->config['contactIdentifier'],
// 禁用任务中心
'taskcenter_disabled' => cfg('TASKCENTER_DISABLED') === true,
// 禁用线下培训
'train_disabled' => cfg('TRAIN_DISABLED') === true,
];
return true;
}
/**
* 重新组织应用分组信息
*
* @param array $group 分组信息
* @param array $plugin 应用信息
*
* @return bool
*/
protected function _generateGroup(&$group, $plugin)
{
// 如果分组信息不为空
if (! empty($group)) {
return true;
}
/**
* pg_name 分组(套件)名称
* pgGroupid 分组(套件)ID
* installUrl 分组(套件)安装Url
* plugins 当前分组(套件)下应用列表
*/
$group = array(
'pg_name' => $plugin['pgName'],
'pgGroupid' => $plugin['pgGroupid'],
'installUrl' => $this->_getInstallUrl(array('suiteId' => $plugin['qysSuiteid'])),
'plugins' => array(),
);
return true;
}
}