Kids.php
1.23 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
<?php
namespace WebPlugin\DataProcess\Channel;
use WebPlugin\Helpers;
class Kids extends AbstractChannel
{
/**
* 格式化数据
*
* @param array $resource
* @return
*/
public static function format($resource)
{
$result = array();
$result += self::getFormatNewArrivals($resource);
foreach ($resource as $key => $val) {//老版处理
if (isset($resource[$key]) && isset($resource[$key + 1])) {
$temp = array('newArrivls' => array('name' => '', 'navs' => array()));
//newArrivals
if ($resource[$key]['template_name'] == 'text' && $resource[$key + 1]['template_name'] == 'textNav') {
//text模版
$temp['newArrivls']['name'] = $resource[$key]['data']['text'];
//textNav模版
foreach ($resource[$key + 1]['data'] as $val) {
$temp['newArrivls']['navs'][] = array('href' => Helpers::getUrlSafe($val['url']), 'name' => $val['name']);
}
unset($resource[$key], $resource[$key + 1]);
$result[$key] = $temp;
}
}
}
return $result;
}
}