Authored by 郝肖肖

boys channel 接口返回数据 href 替换http

... ... @@ -943,6 +943,6 @@ class Helpers
*/
public static function getUrlSafe($url)
{
return '//' . strtr($url, array('http://' => '', 'https://' => ''));
return '//' . ltrim(strtr($url, array('http://' => '', 'https://' => '')), '//');
}
}
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
use WebPlugin\Helpers;
abstract class AbstractChannel
{
/* * *
... ... @@ -33,10 +33,10 @@ abstract class AbstractChannel
$temp['newArrivls']['name'] = $resource[$key]['data']['text'];
//textNav模版
foreach ($resource[$key + 1]['data'] as $val) {
$temp['newArrivls']['navs'][] = array('href' => $val['url'], 'name' => $val['name']);
$temp['newArrivls']['navs'][] = array('href' => Helpers::getUrlSafe($val['url']), 'name' => $val['name']);
}
//link模版
$temp['href'] = $resource[$key + 2]['data'][0]['url'];
$temp['href'] = Helpers::getUrlSafe($resource[$key + 2]['data'][0]['url']);
unset($resource[$key], $resource[$key + 1], $resource[$key + 2]);
$result[$key] = $temp;
}
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
use WebPlugin\Helpers;
class Girls extends AbstractChannel
{
... ... @@ -20,10 +20,10 @@ class Girls extends AbstractChannel
$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']);
$temp['newArrivls']['navs'][] = array('href' => Helpers::getUrlSafe($val['url']), 'name' => $val['name']);
}
$link = $resource[$key + 2]['data'][0];
$temp['newArrivls']['href'] = $link['url'];
$temp['newArrivls']['href'] = Helpers::getUrlSafe($link['url']);
unset($resource[$key], $resource[$key + 1]);
$result[$key] = $temp;
}
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
use WebPlugin\Helpers;
class Kids extends AbstractChannel
{
... ... @@ -24,7 +24,7 @@ class Kids extends AbstractChannel
$temp['newArrivls']['name'] = $resource[$key]['data']['text'];
//textNav模版
foreach ($resource[$key + 1]['data'] as $val) {
$temp['newArrivls']['navs'][] = array('href' => $val['url'], 'name' => $val['name']);
$temp['newArrivls']['navs'][] = array('href' => Helpers::getUrlSafe($val['url']), 'name' => $val['name']);
}
unset($resource[$key], $resource[$key + 1]);
$result[$key] = $temp;
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
use WebPlugin\Helpers;
class Lifestyle extends AbstractChannel
{
... ... @@ -24,7 +24,7 @@ class Lifestyle extends AbstractChannel
$temp['newArrivls']['name'] = '最新上架 NEW ARRIVALS';
//textNav模版
foreach ($resource[$key]['data'] as $val) {
$temp['newArrivls']['navs'][] = array('href' => $val['url'], 'name' => $val['name']);
$temp['newArrivls']['navs'][] = array('href' => Helpers::getUrlSafe($val['url']), 'name' => $val['name']);
}
unset($resource[$key], $resource[$key + 1]);
$result[$key] = $temp;
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
use WebPlugin\Images;
use WebPlugin\Helpers;
class PlusstarIndex extends AbstractChannel
{
... ... @@ -27,7 +28,7 @@ class PlusstarIndex extends AbstractChannel
if($key == 5 && $resource['template_name'] == 'floor') {//单品列表
foreach($resource['data'] as $pos => $val) {
$val['src'] = Images::getImageUrl($val['src'], 280, 374, 1);
$singleGoods['list'][] = array('href' => $val['url'],'name'=> $val['title'],'img' => $val['src']);
$singleGoods['list'][] = array('href' => Helpers::getUrlSafe($val['url']),'name'=> $val['title'],'img' => $val['src']);
}
$result[$key] = array('singlegoods' => $singleGoods);
}
... ... @@ -39,7 +40,7 @@ class PlusstarIndex extends AbstractChannel
if($key == 7 && $resource['template_name'] == 'floor') { //视频名称
foreach($resource['data'] as $pos => $val) {
$val['src'] = Images::getImageUrl($val['src'], 378, 241, 1);
$video['list'][] = array('href' => $val['url'],'name'=> $val['title'],'img' => $val['src']);
$video['list'][] = array('href' => Helpers::getUrlSafe($val['url']),'name'=> $val['title'],'img' => $val['src']);
}
$result[$key] = array('video' => $video);
}
... ... @@ -54,7 +55,7 @@ class PlusstarIndex extends AbstractChannel
foreach($resource['data'] as $val) {
if(is_numeric($val['name'])) {
$id = $val['name'];
$news['pics']['list'][$id] = array('id' => $id,'href' => $val['url'], 'img'=>'','tips'=>'');
$news['pics']['list'][$id] = array('id' => $id,'href' => Helpers::getUrlSafe($val['url']), 'img'=>'','tips'=>'');
}
}
$result[$key] = array('news' => $news);
... ... @@ -65,7 +66,7 @@ class PlusstarIndex extends AbstractChannel
foreach($resource['data'] as $pos => $val) {
if(is_numeric($val['name'])) {
$id = $val['name'];
$ads['list'][$id] = array('id' => $id,'href' => $val['url'],'img'=>'',);
$ads['list'][$id] = array('id' => $id,'href' => Helpers::getUrlSafe($val['url']),'img'=>'',);
}
}
$result[$key] = array('ads' => $ads);
... ...
... ... @@ -538,7 +538,7 @@ class Process
foreach ($data[$key + 2]['data'] as $val) {
$val['src'] = Images::getImageUrl($val['src'], 650, 400, 1);
$result['accordion']['slide'][] = array(
'href' => $val['url'],
'href' => Helpers::getUrlSafe($val['url']),
'img' => $val['src'],
'name' => $val['title']
);
... ...
... ... @@ -1098,6 +1098,6 @@ class Helpers
*/
public static function getUrlSafe($url)
{
return '//' . strtr($url, array('http://' => '', 'https://' => ''));
return '//' . ltrim(strtr($url, array('http://' => '', 'https://' => '')), '//');
}
}
... ...