Lifestyle.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 Lifestyle 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'] == 'textNav' && $resource[$key + 1]['template_name'] == 'link') {
//text模版
$temp['newArrivls']['name'] = '最新上架 NEW ARRIVALS';
//textNav模版
foreach ($resource[$key]['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;
}
}