Channel.php
1.33 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
<?php
namespace WebPlugin\DataProcess;
use WebPlugin\Helpers;
class Channel
{
public static $formatChannel = array(
'boys' => '\WebPlugin\DataProcess\Channel\Boys',
'girls' => '\WebPlugin\DataProcess\Channel\Girls',
'kids' => '\WebPlugin\DataProcess\Channel\Kids',
'lifestyle' => '\WebPlugin\DataProcess\Channel\Lifestyle',
'plusstarIndex' => '\WebPlugin\DataProcess\Channel\PlusstarIndex'
);
/**
* 获取格式数据
*
* @param string $channel
* @param array $data
*/
public static function getFormat($channel, array $data)
{
if (empty($data)) {
return array();
}
$type = '';
if(in_array($channel, array('boys','girls','kids','lifestyle'))){
$type = $channel;
} else {
$type = Helpers::getChannelNameByCookie();
}
// 通用处理器
$result = Process::getContent($data, $type);
$channelResult = array();
if (isset(self::$formatChannel[$channel])) {
$class = self::$formatChannel[$channel];
$channelResult = $class::format($data);
}
// 组合数据
$result = $result + $channelResult;
ksort($result);
return array_values($result);
}
}