Girls.php
1.4 KB
<?php
namespace Plugin\DataProcess\WebChannel\Channel;
class Girls extends AbstractChannel
{
public static function format($resource)
{
$result = array();
$result += self::getFormatNewArrivals($resource);
foreach($resource as $key => $val)//老版是title模版
{
if(isset($resource[$key]) && isset($resource[$key + 2]))
{
$temp = array('newArrivls' => array('name' => '', 'navs' => array(), 'href' => ''));
if($resource[$key]['template_name'] == 'text' &&
$resource[$key + 1]['template_name'] == 'title' && //老版是title模版
$resource[$key + 2]['template_name'] == 'link'
)
{
//text模版
$temp['newArrivls']['name'] = $resource[$key]['data']['text'];
//title模版
foreach($resource[$key + 1]['data']['nav'] as $val)
{
$temp['newArrivls']['navs'][] = array('href' => $val['url'],'name' => $val['name']);
}
$link = $resource[$key + 2]['data'][0];
$temp['newArrivls']['href'] = $link['url'];
unset($resource[$key], $resource[$key + 1]);
$result[$key] = $temp;
}
}
}
return $result;
}
}