Authored by hf

do feature wap 1.2

Too many changes to show.

To preserve performance only 37 of 37+ files are displayed.

... ... @@ -15,7 +15,7 @@
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpaceBeforeSemicolon": true,
"disallowSpacesInCallExpression": true,
"disallowSpacesInFunctionDeclaration": {
"disallowSpacesInFunction": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideArrayBrackets": true,
... ...
存放模板预编译文件
\ No newline at end of file
<?php return function ($in, $debugopt = 1) {
$cx = array(
'flags' => array(
'jstrue' => false,
'jsobj' => false,
'spvar' => true,
'prop' => false,
'method' => false,
'mustlok' => true,
'echo' => false,
'debug' => $debugopt,
),
'constants' => array(),
'helpers' => array(),
'blockhelpers' => array(),
'hbhelpers' => array(),
'partials' => array(),
'scopes' => array(),
'sp_vars' => array('root' => $in),
'lcrun' => 'Plugin\LCRun3',
);
return ''.'<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('title')), ENT_QUOTES, 'UTF-8').'</title>
<meta name="keywords" content="'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('keywords')), ENT_QUOTES, 'UTF-8').'">
<meta name="description" content="'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('description')), ENT_QUOTES, 'UTF-8').'">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="cleartype" content="on">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" />
<script type="text/javascript">
(function(doc, win) {
var docEl = doc.documentElement;
(function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) {
return;
}
docEl.style.fontSize = 20 * (clientWidth / 320) + \'px\';
}());
})(document, window);
</script>
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
<link rel="dns-prefetch" href="//img12.static.yhbimg.com">
<link rel="dns-prefetch" href="//img13.static.yhbimg.com">
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('rlsEnv')))) ? '<link rel="stylesheet" href="http://cdn.yoho.cn/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/index.css">
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('preEnv')))) ? '<link rel="stylesheet" href="http://cdn.yoho.cn/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/index.css">
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('testEnv')))) ? '<link rel="stylesheet" href="http://static.buy.test.yoho.cn/dist/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/index.css">
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('devEnv')))) ? '<link rel="stylesheet" href="http://static.dev.yohobuy.com/css/index.css">
' : '').'<link rel="apple-touch-icon-precomposed" href="http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png">
<link rel="apple-touch-startup-image" sizes="640x920" href="http://static.yohobuy.com/m/v1/img/startup/startup-retina.png" media="screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2)">
<link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)">
</head>
<body '.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('isPassportPage')))) ? 'class=passport-body' : '').'>
'.''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('pageHeader')), $in, false, function($cx, $in) {return '<header class="yoho-header'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('boys')))) ? ' boys' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('girls')))) ? ' girls' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('kids')))) ? ' kids' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('lifeStyle')))) ? ' life-style' : '').'">
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('navBack')))) ? ' <a href="javascript:history.go(-1);" class="iconfont nav-back">&#xe610;</a>
' : '').''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('navHome')), $in, false, function($cx, $in) {return ' <a href="'.htmlentities((string)$in, ENT_QUOTES, 'UTF-8').'" class="iconfont nav-home">&#xe611;</a>
';}).''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('navTitle')), $in, false, function($cx, $in) {return ' <p class="nav-title">'.htmlentities((string)$in, ENT_QUOTES, 'UTF-8').'</p>
';}).'</header>
';}).''.''.'<div class="discount-page yoho-page">
'.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('headerBanner')), $in, false, function($cx, $in) {return ''.''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('list')))) ? ' <div class="banner-top">
<div class="banner-swiper swiper-container">
<ul class="swiper-wrapper">
'.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('list')), $in, false, function($cx, $in) {return ' <li class="swiper-slide">
<a href="'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('url')), ENT_QUOTES, 'UTF-8').'">
<img class="swiper-lazy" data-src="'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('img')), ENT_QUOTES, 'UTF-8').'">
</a>
<div class="swiper-lazy-preloader"></div>
</li>
';}).' </ul>
</div>
<div class="swiper-pagination">
<div class="pagination-inner">
</div>
</div>
</div>
' : ' <div class="banner-top-single">
<a href='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('url')), ENT_QUOTES, 'UTF-8').'>
<img class="img" src='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('img')), ENT_QUOTES, 'UTF-8').'>
</a>
</div>
').'
'.'';}).'
<ul id="list-nav" class="list-nav clearfix">
<li class="new active">
<a href="javascript:void(0);">
<span class="spanTest">最新</span>
<span class="iconfont cur">&#xe616;</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
<span class="spanTest">价格</span>
<span class="icon">
<i class="iconfont up">&#xe615;</i>
<i class="iconfont down cur">&#xe616;</i>
</span>
</a>
</li>
<li class="discount">
<a href="javascript:void(0);">
<span class="spanTest">折扣</span>
<span class="icon">
<i class="iconfont up">&#xe615;</i>
<i class="iconfont down cur">&#xe616;</i>
</span>
</a>
</li>
<li class="filter">
<a href="javascript:void(0);">
<span class="spanTest">筛选</span>
<span class="iconfont">&#xe613;</span>
</a>
</li>
</ul>
<div id="goods-container" class="goods-container">
<div class="new-goods container clearfix">
'.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('goods')), $in, false, function($cx, $in) {return ''.' '.((Plugin\LCRun3::ifvar($cx, $in)) ? '
<div class="good-info" data-id="'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('id')), ENT_QUOTES, 'UTF-8').'">
<div class="tag-container clearfix">
'.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('tags')), $in, false, function($cx, $in) {return ''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('is_new')), $in, false, function($cx, $in) {return ' <p class="good-tag new-tag">NEW</p>
';}).''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('is_advance')), $in, false, function($cx, $in) {return ' <p class="good-tag renew-tag">再到着</p>
';}).''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('is_discount')), $in, false, function($cx, $in) {return ' <p class="good-tag sale-tag">SALE</p>
';}).''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('is_yohoood')), $in, false, function($cx, $in) {return ' <div class="good-tag yohood-tag"></div>
';}).''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('is_limited')), $in, false, function($cx, $in) {return ' <p class="good-tag limit-tag">限量商品</p>
';}).'';}).' </div>
<div class="good-detail-img">
<a class="good-thumb" href="'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('url')), ENT_QUOTES, 'UTF-8').'">
<img class="lazy" data-original="'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('thumb')), ENT_QUOTES, 'UTF-8').'">
</a>
'.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('is_soon_sold_out')), $in, false, function($cx, $in) {return ' <p class="few-tag">即将售罄</p>
';}).' </div>
<div class="good-detail-text">
<div class="name">
<a href="'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('url')), ENT_QUOTES, 'UTF-8').'">'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('name')), ENT_QUOTES, 'UTF-8').'</a>
</div>
<div class="price">
<span class="sale-price '.((Plugin\LCRun3::isec($cx, Plugin\LCRun3::v($cx, $in, array('price')))) ? 'no-price' : '').'">¥'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('salePrice')), ENT_QUOTES, 'UTF-8').'</span>
'.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('price')), $in, false, function($cx, $in) {return ' <span class="market-price">¥'.htmlentities((string)$in, ENT_QUOTES, 'UTF-8').'</span>
';}).' </div>
</div>
</div>
' : '').''.'';}).' </div>
<div class="price-goods container hide clearfix"></div>
<div class="discount-goods container hide clearfix"></div>
'.''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('filter')), $in, false, function($cx, $in) {return ' <div class="filter-mask hide">
<div class="filter-body">
<ul class="classify">
'.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('classify')), $in, true, function($cx, $in) {return ' <li class="classify-item'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $cx['sp_vars'], array('first')))) ? ' active' : '').'">
<p class="shower'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('default')))) ? ' default' : '').'">
<span class="title">'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('title')), ENT_QUOTES, 'UTF-8').':</span>
'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('name')), ENT_QUOTES, 'UTF-8').'
</p>
<ul class="sub-classify" data-type='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('dataType')), ENT_QUOTES, 'UTF-8').'>
'.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('subs')), $in, false, function($cx, $in) {return ' <li class="sub-item'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('chosed')))) ? ' chosed' : '').'" data-id='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('dataId')), ENT_QUOTES, 'UTF-8').'>
'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('name')), ENT_QUOTES, 'UTF-8').'
<i class="iconfont chosed-icon">&#xe617;</i>
</li>
';}).' </ul>
</li>
';}).' </ul>
</div>
</div>
';}).''.' </div>
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('brand')))) ? ' <input id="brand" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('brand')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('gender')))) ? ' <input id="gender" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('gender')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('sort')))) ? ' <input id="sort" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('sort')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('msort')))) ? ' <input id="msort" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('msort')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('misort')))) ? ' <input id="misort" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('misort')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('color')))) ? ' <input id="color" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('color')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('size')))) ? ' <input id="size" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('size')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('price')))) ? ' <input id="price" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('price')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('p_d')))) ? ' <input id="p_d" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('p_d')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('channel')))) ? ' <input id="channel" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('channel')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('limit')))) ? ' <input id="limit" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('limit')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('page')))) ? ' <input id="page" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('page')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('discount')))) ? ' <input id="discount" type="hidden" value='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('discount')), ENT_QUOTES, 'UTF-8').'>
' : '').'
'.' <div id="suspend-cart" class="suspend-cart">
<a href='.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('cartUrl')), ENT_QUOTES, 'UTF-8').'>
<span class="iconfont">&#xe62c;</span>
</a>
<span class="cart-count hide">0</span>
</div>'.'</div>
'.''.''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('pageFooter')), $in, false, function($cx, $in) {return '<footer id="yoho-footer" class="yoho-footer hide">
<p class="op-row">
<span class="back-to-top">
Back to top
<i class="iconfont">&#xe608;</i>
</span>
</p>
<address class="copyright">
CopyRight©2007-2016 南京新与力文化传播有限公司
</address>
</footer>
';}).'
'.''.''.Plugin\LCRun3::sec($cx, Plugin\LCRun3::v($cx, $in, array('showDownloadApp')), $in, false, function($cx, $in) {return '<div class="float-layer hide" id="float-layer-app">
<div class="float-layer-left">
<span class="yoho-icon iconfont">&#xe60d;</span>
<p>新用户送千元礼包</p>
</div>
<a href="javascript:void(0);" id="float-layer-close" >
<i class="close-icon iconfont">&#xe623;</i>
<div class="circle-rightbottom"></div>
</a>
<a href="http://m.yohobuy.com/download/hyapp" id="float-layer-btn">
立即下载
</a>
</div>
';}).'
'.''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('hasWxShare')))) ? '<script type="text/javascript" charset="utf-8" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('rlsEnv')))) ? '<script src="http://cdn.yoho.cn/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/lib.js"></script>
<script src="http://cdn.yoho.cn/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/index.js"></script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('preEnv')))) ? '<script src="http://cdn.yoho.cn/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/lib.js"></script>
<script src="http://cdn.yoho.cn/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/index.js"></script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('testEnv')))) ? '<script src="http://static.buy.test.yoho.cn/dist/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/lib.js"></script>
<script src="http://static.buy.test.yoho.cn/dist/myohobuy/'.htmlentities((string)Plugin\LCRun3::v($cx, $in, array('version')), ENT_QUOTES, 'UTF-8').'/index-debug.js"></script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('devEnv')))) ? '<script src="http://localhost:8000/static/js/sea.js?nowrap"></script>
<script>seajs.config({base: \'http://localhost:8000/\'});</script>
' : '').'<script type="text/javascript">
(function(w,d,s,j,f){
w[\'YohoAcquisitionObject\']=f;
w[f]=function(){w[f].p=arguments;};
var a=d.createElement(s);
var m=d.getElementsByTagName(s)[0];
a.async=1;
a.src=j;
m.parentNode.insertBefore(a,m);
})(window,document,\'script\',\'http://cdn.yoho.cn/yas-jssdk/1.0.8/yas.js\',\'_yas\');
</script>
'.'<script>
seajs.use(\'js/common\');
</script>
'.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('psList')))) ? '<script>
seajs.use(\'js/guang/plus-star/list\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('psDetail')))) ? '<script>
seajs.use(\'js/guang/plus-star/detail\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('guangHome')))) ? '<script>
seajs.use(\'js/guang/home\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('guangList')))) ? '<script>
seajs.use(\'js/guang/list\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('guangDetail')))) ? '<script>
seajs.use(\'js/guang/detail\', function(d) {
d.i(true);
});
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('guangEzine')))) ? '<script>
seajs.use(\'js/guang/detail\', function(d) {
d.i(false);
});
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('regIndex')))) ? '<script>
seajs.use(\'js/passport/register/register\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('regCode')))) ? '<script>
seajs.use(\'js/passport/register/code\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('regPwd')))) ? '<script>
seajs.use(\'js/passport/register/password\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('loginIndex')))) ? '<script>
seajs.use(\'js/passport/login/login\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('loginInternational')))) ? '<script>
seajs.use(\'js/passport/login/international\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('backEmail')))) ? '<script>
seajs.use(\'js/passport/back/email\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('backEmailSuccess')))) ? '<script>
seajs.use(\'js/passport/back/email-success\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('backMobile')))) ? '<script>
seajs.use(\'js/passport/back/mobile\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('backCode')))) ? '<script>
seajs.use(\'js/passport/back/code\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('backNewPwd')))) ? '<script>
seajs.use(\'js/passport/back/new-password\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('channelPage')))) ? '<script>
seajs.use(\'js/index/channel\');
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('grilsHomePage')))) ? '<script>
seajs.use(\'js/home/home\', function(h) {
h.set(\'girls\');
});
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('boysHomePage')))) ? '<script>
seajs.use(\'js/home/home\', function(h) {
h.set(\'boys\');
});
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('kidsHomePage')))) ? '<script>
seajs.use(\'js/home/home\', function(h) {
h.set(\'kids\');
});
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('lifestyleHomePage')))) ? '<script>
seajs.use(\'js/home/home\', function(h) {
h.set(\'lifestyle\');
});
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('newArrivalPage')))) ? '<script>
seajs.use(\'js/product/newsale/newarrival\');
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('discountPage')))) ? '<script>
seajs.use(\'js/product/newsale/discount\');
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('goodListPage')))) ? '<script>
seajs.use(\'js/product/list\');
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('goodsDetailPage')))) ? '<script>
seajs.use(\'js/product/detail/detail\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('categoryPage')))) ? '<script>
seajs.use(\'js/category/index\');
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('brandPage')))) ? '<script>
seajs.use(\'js/category/brand\');
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('searchPage')))) ? '<script>
seajs.use(\'js/index/search\');
seajs.use(\'js/index/footer\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('shoppingCartPage')))) ? '<script>
seajs.use(\'js/shopping-cart/cart\');
</script>
' : '').''.((Plugin\LCRun3::ifvar($cx, Plugin\LCRun3::v($cx, $in, array('giftAdvancePage')))) ? '<script>
seajs.use(\'js/shopping-cart/gift-advance\');
</script>
' : '').''.''.'<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-W958MG" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':
new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=
\'//www.googletagmanager.com/gtm.js?id=\'+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,\'script\',\'dataLayer\',\'GTM-W958MG\');
</script>
<!-- End Google Tag Manager -->
<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?c6ee7218b8321cb65fb2e98f284d8311";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="http://static.yohobuy.com/js/analytics/analysis.js"></script>
<script src="http://static.yohobuy.com/m/v1/js/om_code.js"></script>
'.'</body>
</html>'.'';
}
?>
\ No newline at end of file
... ...
... ... @@ -21,3 +21,23 @@ DATA:
---------------
{"code":200,"message":"Last Search List.","data":{"product_list":[{"brand_id":144,"market_price":590,"vip_price":0,"sales_price":590,"vip_discount_type":1,"product_id":"150783","max_sort_id":3,"storage_num":38,"product_name":"VANS M JT CARGO\t ","cn_alphabet":"VANSMJTCARGOVN02NJCMA","product_skn":51088175,"brand_name":"VANS","is_new":"Y","is_discount":"N","is_advance":"N","is_soon_sold_out":"N","is_limited":"N","is_yohood":"N","sales_phrase":"","goods_list":[{"goods_id":"207531","color_name":"\u7eff\u8272","color_id":"6","color_code":"#47ba17","color_value":"","images_url":"http:\/\/img13.static.yhbimg.com\/goodsimg\/2015\/09\/25\/10\/02b2ed1aad22f35ed07f7d98a9de5d6ebf.jpg?imageMogr2\/thumbnail\/{width}x{height}\/extent\/{width}x{height}\/background\/d2hpdGU=\/position\/center\/quality\/90","product_skc":"202881","is_default":"N"}],"tags":[],"default_images":"http:\/\/img13.static.yhbimg.com\/goodsimg\/2015\/09\/25\/10\/02b2ed1aad22f35ed07f7d98a9de5d6ebf.jpg?imageMogr2\/thumbnail\/{width}x{height}\/extent\/{width}x{height}\/background\/d2hpdGU=\/position\/center\/quality\/90"},{"brand_id":144,"market_price":490,"vip_price":0,"sales_price":490,"vip_discount_type":1,"product_id":"150781","max_sort_id":3,"storage_num":3,"product_name":"VANS M WARRICK\t ","cn_alphabet":"VANSMWARRICKVN02NIBHH","product_skn":51088174,"brand_name":"VANS","is_new":"Y","is_discount":"N","is_advance":"N","is_soon_sold_out":"N","is_limited":"N","is_yohood":"N","sales_phrase":"","goods_list":[{"goods_id":"207529","color_name":"\u9ed1\u8272","color_id":"2","color_code":"#333333","color_value":"","images_url":"http:\/\/img13.static.yhbimg.com\/goodsimg\/2015\/09\/25\/10\/02f401305cc7af370a894d7a094bd6f64c.jpg?imageMogr2\/thumbnail\/{width}x{height}\/extent\/{width}x{height}\/background\/d2hpdGU=\/position\/center\/quality\/90","product_skc":"202880","is_default":"N"}],"tags":[],"default_images":"http:\/\/img13.static.yhbimg.com\/goodsimg\/2015\/09\/25\/10\/02f401305cc7af370a894d7a094bd6f64c.jpg?imageMogr2\/thumbnail\/{width}x{height}\/extent\/{width}x{height}\/background\/d2hpdGU=\/position\/center\/quality\/90"}],"page_total":2,"total":52,"page":1,"content_code":""},"md5":"b66258633f505562a520e0fccf0b8803"}
## 检测是否嵌入APP, APP里直接使用浏览器打开HTML5页面
URL:
---------------
正式: http://m.yohobuy.com/appembed
测试: http://buy.test.yoho.cn/appembed
DATA:
---------------
{
"open": "Y",
"url": "http://m.yohobuy.com"
}
{
"open": "N",
"url": "http://m.yohobuy.com"
}
\ No newline at end of file
... ...
... ... @@ -107,7 +107,7 @@
}
## 首页
{
headerDownload: {
img: '',
... ... @@ -249,7 +249,7 @@
## 逛
### 资讯(公用)
{
id: 1,
showTags: true/false, //是否显示标签
... ... @@ -305,17 +305,11 @@
}
### 逛列表页
{
infos:
infos:
[
{
show: true,
info: [
{...}, //标签
...
]
},
{...}, //标签
...
]
}
... ... @@ -730,7 +724,7 @@
},
...
]
}
## 商品列表页
... ... @@ -758,13 +752,548 @@
],
filter: {
.. //筛选数据结构
}
}
}
## 购物车
{
shoppingCart: {
cartNav: true, //显示预售和普通switch导航
commonGoodsCount: 2,
presellGoodsCount: 2, //普通商品和预售商品数目,显示在导航中
showLoginInfo: true, //是否显示登录提示
commonCart: {
goods: [
//购物车商品(见下),
...
],
freebieOrAdvanceBuy: true, //是否显示赠品和加价购
freebie: {
url: '',
count: 2
},
advanceBuy: {
url: '',
count: 1
},
price: 322,
activityPrice: 223, //活动价
count: 8,
sumPrice: 400
},
brand: '',
gender: '',
sort: '',
color: '',
size: '',
price: '',
discount: ''
preSellCart: {
//同普通购物车
...
}
}
}
\ No newline at end of file
}
### 选择尺码、数目、颜色面板
{
thumb: '',
name: '',
price: '',
salePrice: '',
colors: [
{
id: 1,
chosed: true,
name: '黄色'
},
...
],
sizes: [
{
id: 2,
chosed: true,
name: 'X'
},
...
],
num: 2
}
### 购物车商品
{
id: 1,
thumb: '',
name: '',
color: '黄色',
size: 'L',
appearDate: '12月', //上市期
price: 200,
count: 2,
soldOut: true, //售罄
lowStocks: true, //库存不足
}
### 赠品和加价购
{
shoppingCart: {
gift: [
//赠品(见下)
],
//or
advance: [
{
title: '',
goods: [
//加价购商品(见下)
]
}
]
}
}
### 赠品和加价购商品
{
id: 1,
thumb: '',
name: '',
color: '黄色',
size: 'L', //颜色和尺寸需要显示就传,不显示不传
price: 562,
count: 3
}
### 订单确认
{
orderEnsure: {
name: '',
phoneName: '',
address: '',
dispatchMode: [
{
id: 1,
name: '普通快递'
},
...
],
dispatchTime: [
{
id: 1,
name: '只工作日配送'
},
...
],
goods: [
{
... //订单商品
}
],
coupon: {
count: 3, //N张优惠券可用
notUsed: true,
value: 10 //使用优惠券后优惠额,notUsed为true的情况下可不传
},
yohoCoin: '0', //String
invoice: true, //发票
sumPrice: 900,
salePrice: 90,
freight: 0,
price: 800
}
}
## 个人中心
### 会员等级
{
vipGrade: {
//会员等级页面
vip3: true, //vip等级(3,2,1,0),对应等级传true;
name: '', //user name
costOfThisYear: 3000,
percent: 80, //当前消费等级进度条
costGap: 300, //距离升级所需消费金额(白金会员不传)
sumCost: 600,
privilege: [
{
pic: '',
title: '',
description: ''
},
...
]
}
}
### 我的订单
{
order: {
navs: [
{
name: '',
active: true,
typeId: 1,
url: ''
},
...
]
}
}
//订单列表
{
orders: [
{
...//订单
}
]
//当无订单时,不传order,返回walkwayUrl
walkWayUrl: ''
}
//订单
{
detailUrl: '',
orderNum: '',
orderStatus: '',
goods: [
{
thumb: '',
gift: true, //是否赠品
advanceBuy: true, //是否加价购
name: '',
color: '黄色',
size: 'X',
price: '588',
count: 2
},
...
],
count: 1,
sumCost: '199.00',
//status
completed: true, //已完成
canceled: true, //已取消
unpaid: true, //or 未支付
unreceived: '', //or 待收货(未发货/未收货),查看物流URL
//待收货时传递物流参数
logisticsUrl: ''
}
### 订单详情页
{
orderDetail: {
orderNum: '', //订单号
name: '', //收货人姓名
phoneNum: '',
address: '',
orderStatus: '订单成功', //订单取消...等订单状态
orderNum: '',
orderTime: '',
//订单状态
canceled: true, //是否是取消的订单
completed: true, //是否是已完成订单
unpaid: true, //是否是未支付订单
unreceived: true, //是否是未收货订单
//如果是待收货(未发货和未收货),传物流信息参数
logisticsUrl: '',
logisticsCompany: '',
logisticsNum: '',
//end
goods: [
{
... //订单商品
}
],
sumPrice: '',
salePrice: '',
freight: '',
yohoCoin: '',
price: ''
}
}
### YOHO币
{
yohoCoin: {
coinNum: 10
}
}
### 我的逛
{
myGuang: {
infos: [
{...} //逛资讯
..
],
//若无收藏则不传infos
}
}
### 商品详情页
{
'goodsDetailPage': true,
'pageHeader': {
'navBack': 'sss ',
'navHome': 'sss ',
'navTitle': '商品详情'
},
'bannerTop': {
'list': [
{
'img' : ''
},
...
]
},
tags: [
{
is_new: true //NEW
},
{
is_discount: true //SALE
},
{
is_limited: false //限量商品
},
{
is_yohood: // YOHOOD
},
{
is_advance: true //再到着
},
{
is_soon_sold_out: true //即将售罄
}
],
'goodsName' : 'Stussy No. 4 BOX TEE ',
'goodsSubtitle' : '【全民拼抢购】经典印花T恤,满4件免一件!',
'goodsPrice' : {
'currentPrice' : '¥298.00',
'previousPrice' : '¥598.00'
},
'periodOfMarket' : '11月',
'goodsTitle' : '¥298.00',
'vipLevel' : {
'list' : [
{
'text' : '¥284.00',
'currentLevel':true
},
...
]
},
'goodsDiscount' : {
'list' : [
{
'text' : '【BACK TO SCHOOL】满¥499赠送Paul Franke帽子一个,多买多送!'
},
...
]
},
'feedbacks' : {
'commentsNum' : 0,
'consultsNum' : 1,
'link' : '',
'comments' : [
{
'userName' : 'Lynnic',
'desc' : '购买了白色Mate7',
'content' : '活动时买的',
'time' : '2014-08-12 10:24:26'
},
...
],
'consults' : [
{
'question' : '您好 我一米七七 140斤 穿M的行吗',
'time' : '2014-08-12 10:24:26',
'answer' : ''
},
...
]
},
'enterStore' : {
'img' : '',
'storeName' : 'Stussy',
'url' : 'http://stussy.m.yohobuy.com/'
},
'goodsDescription' : {
'title' : '商品描述',
'enTitle' : 'DESCRIPTON',
'detail' : {
'list':[
{
'param' : '编号: 51018059'
},
...
]
},
'desc': 'balabala'
},
'sizeInfo' : {
'title' : '尺码信息',
'enTitle' : '',
'detail' : {
'list' : [
{
'params' : [
{
'param' : '尺寸'
},
...
]
},
...
]
}
},
'measurementMethod' : {
'title': '测量方式',
'enTitle': 'MEASUREMENT METHOD',
'img' : '',
},
'reference' : {
'title' : '模特试穿',
'enTitle' : '',
'detail' : {
'list' : [
{
'params':[
{
'param' =>'头像'
},
...
]
},
...
]
}
},
'materials' : {
'title' : '商品材质',
'enTitle' : '',
list:[
{
'img' : '',
'desc' : '用各种洗涤剂',//remark
}
...
]
},
'washTips' : {
'list' : [
{
"caption":"不可干洗",
"img":"http://static.yohobuy.com/images/wash_5.png"
}
...
]
}
'productDetail' : {
'title' : '商品详情',
'enTitle' : '',
'desc' : 'Married to the MOB是由Leah McSweeney创立的女装品牌,一向标榜不羁、大胆的女性streetwear设计',
'list' : [
{
'img':''
}
...
]
},
'cartInfo' : {
'cartUrl':'购物车url',
'addToCartUrl':'添加购物车url',
'soldOut':'已售罄',
'notForSale':'非卖品'
},
'introUrl' : '',
'id' : '',
'preferenceUrl' :''
}
### 咨询列表页面
{
'link' : '咨询表单跳转url',
'consults':{
'list' : [
{
'question':'',
'time':'',
'answer':''
}
...
]
}
}
### 支付中心
{
'payAppInfo' : [
{
'appIcon' : 'http://static.yohobuy.com/images/icon.png',
'payLink' : '/weixin/pay/',
'appId': 'weixin',
'app' : '微信支付',
'hint' : '需下载微信客户端',
'subHint' : '推荐使用'
},{
'appIcon' : 'http://static.yohobuy.com/images/icon.png',
'payLink' : '/weixin/pay/',
'appId': 'alipay',
'app' : '支付宝支付',
'hint' : '需下载支付宝客户端',
'subHint' : '推荐使用'
}
]
}
### 物流详情
{
'logisticImg' : 'http://static.yohobuy.com/images/icon.png',
'logisticUrl' : 'http://www.shunfeng.com',
'logisticCompany' : '顺丰',
'logisticNumber' : '1231231231',
'logisticDetail' : [
{
'status' : '南京市 派送中',
'date' : '2015-12-03'
}, {
'status' : '南京市 准备中',
'date' : '2015-12-03'
}
]
}
... ...

guang.m.yohobuy.com/guang/index/clear?type=boys
guang.m.yohobuy.com/guang/index/clear?type=girls
guang.m.yohobuy.com/guang/index/clear?type=kids
guang.m.yohobuy.com/guang/index/clear?type=lifestyle
http://new.yohobuy.com/cache/clear?key=Default_Kids_index&token=yoho9646abcdef
http://new.yohobuy.com/cache/clear?key=Default_Lifestyle_index&token=yoho9646abcdef
http://new.yohobuy.com/cache/clear?key=Default_Woman_index&token=yoho9646abcdef
##http://new.yohobuy.com/cache/clear?key=Default_Default_index&token=yoho9646abcdef
其中token就按照上述中去填写,key代表具体要清的缓存的键
具体key的对应关系如下:
key 说明
Default_Kids_index 潮童页面缓存
Default_Lifestyle_index 创意生活页面缓存
Default_Woman_index 女生页面缓存
Default_Default_index 男生
\ No newline at end of file
... ...
No preview for this file type
{
"arrivalTime": 1309514897,
"attribute": 1,
"auditingTime": 0,
"brand": {
"brandAlif": "R",
"brandBanner": "/2011/06/26/14/02d2214a0a7feb6112a8ebbd39de301192.jpg",
"brandCertificate": "",
"brandCss": "",
"brandDomain": "REVELATOR",
"brandGroupId": 0,
"brandIco": "http://img13.static.yhbimg.com/brandLogo/2011/06/26/14/020b083d91ebd1ff9a0600a8421fdbb388.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90",
"brandInitials": "",
"brandKeyword": "REVELATOR",
"brandLevel": 1,
"brandName": "REVELATOR",
"brandNameCn": "",
"brandNameEn": "REVELATOR",
"brandOutline": "所有围绕在我们身边并且默默在对这个世界付出的人,都是我们所认知的启示者。",
"brandScale": 3,
"brandSign": "",
"brandStyle": "个性,潮流,嘻哈,街头,",
"brandTemplate": 1,
"brandTypeId": 3,
"brandUrl": "",
"hotKeyword": "REVELATOR",
"id": 119,
"isHot": "N",
"isIndependent": "N",
"orderBy": 0,
"parentId": 0,
"relateBrandIds": "",
"shelvesBrandTime": 0,
"staticContentCode": "",
"status": 0
},
"brandId": 119,
"categoryBoList": [
{
"categoryId": 1,
"categoryName": "上衣",
"isleaf": true,
"level": 1
},
{
"categoryId": 11,
"categoryName": "T恤",
"isleaf": true,
"level": 2
},
{
"categoryId": 114,
"categoryName": "T恤",
"isleaf": true,
"level": 3
}
],
"cnAlphabet": "REVELATORTHERDuanXiuTXu",
"createTime": 1308726112,
"editTime": 0,
"erpProductId": 50004331,
"expectArrivalTime": 1309514897,
"firstShelveTime": 1309514897,
"folderId": 0,
"gender": "1",
"goodsList": [
{
"colorId": 1,
"colorImage": "http://img12.static.yhbimg.com/goodsimg/2012/03/02/14/02ea70da41df2d162fe1ec1c5d53367086.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90",
"colorName": "白",
"factorySn": "",
"firstShelveTime": 1309514897,
"goodsImagesList": [
{
"angle": 0,
"genderCover": 0,
"goodsId": 3241,
"id": 131463,
"imageName": "",
"imageUrl": "http://img12.static.yhbimg.com/goodsimg/2012/03/02/14/02ea70da41df2d162fe1ec1c5d53367086.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90",
"intro": 0,
"isDefault": "Y",
"orderBy": 1,
"productId": 2631,
"status": 1
},
{
"angle": 0,
"genderCover": 0,
"goodsId": 3241,
"id": 131462,
"imageName": "",
"imageUrl": "http://img13.static.yhbimg.com/goodsimg/2012/03/02/14/02df4081143c563f1d0ea8192a316f40fd.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90",
"intro": 0,
"isDefault": "N",
"orderBy": 0,
"productId": 2631,
"status": 1
}
],
"goodsName": "THE R TEE",
"goodsSizeBoList": [
{
"createTime": 0,
"goodsId": 3241,
"goodsSizeSkuId": 102000,
"goodsSizeStorageNum": 0,
"id": 203,
"orderBy": 1175,
"sizeName": "M",
"sortId": 0,
"updateTime": 0
},
{
"createTime": 0,
"goodsId": 3241,
"goodsSizeSkuId": 102001,
"goodsSizeStorageNum": 0,
"id": 201,
"orderBy": 1169,
"sizeName": "L",
"sortId": 0,
"updateTime": 0
}
],
"id": 3241,
"isDefault": "N",
"isDown": "N",
"matchExplain": "",
"productId": 2631,
"productSkc": 3241,
"status": 1,
"viewNum": 0
}
],
"id": 2631,
"isAdvance": "N",
"isAuditing": "Y",
"isDown": "N",
"isEdit": 1,
"isHot": "N",
"isJit": "N",
"isLimited": "N",
"isNew": "N",
"isOutlets": "N",
"isPromotion": 0,
"isRecommend": "N",
"isReplenishment": 0,
"isRetrieval": "N",
"isSales": "Y",
"isSpecial": "N",
"maxSortId": 1,
"middleSortId": 11,
"phrase": "以品牌字首R字母為设计重点,环绕式轮廓线营造渐层视觉 ",
"productName": "REVELATORTHER 短袖T恤",
"productPriceBo": {
"formatMarketPrice": "¥255.0",
"formatSalesPrice": "¥99.0",
"formatSpecialPrice": "¥99.0",
"marketPrice": 255,
"productId": 2631,
"salesPrice": 99,
"specialPrice": 99,
"vipPrice": "¥0.0",
"vipPrices": [
{
"vipLevel": 1,
"vipPrice": "¥94",
"vipTitle": "银卡"
},
{
"vipLevel": 2,
"vipPrice": "¥89",
"vipTitle": "金卡"
},
{
"vipLevel": 3,
"vipPrice": "¥87",
"vipTitle": "白金"
}
]
},
"productTagBoList": [
{
"tagLabel": "is_discount",
"tagValue": "Y"
},
{
"tagLabel": "is_soon_sold_out",
"tagValue": "Y"
}
],
"promotionBoList": [
{
"promotionTitle": "【秋冬热促】满¥2188减¥800",
"promotionType": "满减"
},
{
"promotionTitle": "【秋冬热促】满¥1488减¥500",
"promotionType": "满减"
}
],
"consultBoWrapper": {
"consultBoList": [
{
"answer": "您好,我们会联系品牌尽快补货,目前没有办法给您确切的答复,建议您进行到货通知的登记,补货到了,会第一时间短信联系您的。感谢您对yoho!有货的关注。",
"answerTime": "2012-05-02 15:10:08",
"ask": "请问 这件的灰色的L码还会不会补货?",
"askTime": "2012-05-02 14:23:09",
"id": 68252
}
],
"consultTotal": 5
},
"commentBoWrapper": {
"commentBoList": [
{
"productId": "您好,我们会联系品牌尽快补货,目前没有办法给您确切的答复,建议您进行到货通知的登记,补货到了,会第一时间短信联系您的。感谢您对yoho!有货的关注。",
"id": "2012-05-02 15:10:08",
"uid": "请问 这件的灰色的L码还会不会补货?",
"content": "2012-05-02 14:23:09",
"createTime": "2012-05-02 14:23:09",
"sizeName":"L",
"colorName":"red",
"nickName":"xieyong",
"headIcon":"http://dddd"
}
],
"commentTotal": 5
}
"productUrl": "http://m.yohobuy.com/product/pro_2631_3241/REVELATORTHERDuanXiuTXu.html",
"salableTime": "0",
"salesPhrase": "",
"seasons": "summer",
"sellChannels": "0",
"seriesId": 0,
"shelveTime": 1325135169,
"shopId": 0,
"smallSortId": 114,
"sortId": 0,
"status": 1,
"storage": 0,
"style": "",
"supplierId": 0,
"vipDiscountType": 1
}
\ No newline at end of file
... ...
{
"modelBos": [],
"null": false,
"productDescBo": {
"colorName": "灰色",
"erpProductId": "50002468",
"gender": 1,
"null": false,
"standardBos": []
},
"productExtra": {
"null": true
},
"productIntroBo": {
"productId": 10,
"productIntro": "<p>\r\n\t破壳小队长印花笔记本,夸张而卡通的设计,简单白皙的纸张,配有手缝带,味道十足。<br />\r\n\t<br />\r\n\t<br />\r\n\t<img src=\"http://img04.static.yohobuy.com/thumb/2011/06/23/04/02efe1bb1bc80d0ffd2911dc2f160c7974-0750x1500-1-goodsimg.jpg\" /><br />\r\n\t<br />\r\n\t<br />\r\n\t<img src=\"http://img04.static.yohobuy.com/thumb/2011/06/23/04/02b741288ddc8095598bbc7c487c8bc892-0750x1500-1-goodsimg.jpg\" /><br />\r\n\t<br />\r\n\t<br />\r\n\t<img src=\"http://img04.static.yohobuy.com/thumb/2011/06/23/04/028c47cc3002d40c42f35120007f13ff17-0750x1500-1-goodsimg.jpg\" /><br />\r\n\t<br />\r\n\t<br />\r\n\t<img src=\"http://img04.static.yohobuy.com/thumb/2011/06/23/04/026c9a61457a93c0473e4674f85344c8f0-0750x1500-1-goodsimg.jpg\" /><br />\r\n\t<br />\r\n\t<br />\r\n\t<img src=\"http://img04.static.yohobuy.com/thumb/2011/06/23/04/02da50cfde3d6cf203d8cb3df1eaa29353-0750x1500-1-goodsimg.jpg\" /><br />\r\n\t<br />\r\n\t&nbsp;</p>"
},
"productMaterialList": [],
"sizeImage": "http://static.yohobuy.com/images/1.jpg",
"sizeInfoBo": {
"sizeAttributeBos": [
{
"attributeName": "后衣长",
"id": 49
},
{
"attributeName": "前衣长",
"id": 48
},
{
"attributeName": "袖长",
"id": 5
},
{
"attributeName": "胸围",
"id": 4
},
{
"attributeName": "肩宽",
"id": 3
},
{
"attributeName": "后中长",
"id": 1
}
],
"sizeBoList": [
{
"id": 201,
"sizeName": "L",
"sortAttributes": [
{
"id": 49,
"sizeValue": ""
},
{
"id": 48,
"sizeValue": ""
},
{
"id": 5,
"sizeValue": "64"
},
{
"id": 4,
"sizeValue": "108"
},
{
"id": 3,
"sizeValue": "49"
},
{
"id": 1,
"sizeValue": "67"
}
]
},
{
"id": 203,
"sizeName": "M",
"sortAttributes": [
{
"id": 5,
"sizeValue": "62"
},
{
"id": 4,
"sizeValue": "102"
},
{
"id": 3,
"sizeValue": "46"
},
{
"id": 1,
"sizeValue": "64"
},
{
"id": 49,
"sizeValue": ""
},
{
"id": 48,
"sizeValue": ""
}
]
}
]
},
"washTipsBoList": [
{
"caption": "不可转笼翻转干燥",
"img": "http://static.yohobuy.com/images/wash_2.png"
},
{
"caption": "30度水温弱速洗",
"img": "http://static.yohobuy.com/images/wash_3.png"
},
{
"caption": "分色洗涤",
"img": "http://static.yohobuy.com/images/wash_7.png"
}
]
}
\ No newline at end of file
... ...
No preview for this file type
... ... @@ -33,6 +33,8 @@ class AbstractAction extends Controller_Abstract
*/
protected $_uid = 0;
protected $_uname = '';
protected $_vip;
protected $_useSession = true;
/**
* 存放模板数据
... ... @@ -52,16 +54,20 @@ class AbstractAction extends Controller_Abstract
switch (APPLICATION_ENV) {
case 'production': // 生产
$this->_view->assign('rlsEnv', true);
$this->_useSession = true;
break;
case 'preview': // 预览
$this->_view->assign('preEnv', true);
$this->_useSession = true;
break;
case 'testing': // 测试
$this->_view->assign('testEnv', true);
$this->_useSession = true;
break;
case 'develop': // 开发
default:
$this->_view->assign('devEnv', true);
$this->_useSession = false;
break;
}
}
... ... @@ -260,34 +266,57 @@ class AbstractAction extends Controller_Abstract
*/
public function setSession($name, $value)
{
Session::start('yohobuy_session', null, 'yohobuy.com')->__set($name, $value);
if ($this->_useSession) {
Session::start('yohobuy_session', null, 'yohobuy.com')->__set($name, $value);
}
}
/**
* 获取Session
*
* @param string $name 名称
* @return mixed
*/
public function getSession($name)
{
return Session::start('yohobuy_session', null, 'yohobuy.com')->__get($name);
if ($this->_useSession) {
return Session::start('yohobuy_session', null, 'yohobuy.com')->__get($name);
} else {
return '';
}
}
/**
* 获取当前登录的用户ID
*
* @param bool $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @return int
* @todo
*/
protected function getUid()
protected function getUid($useSession = false)
{
// 控制是否启用SESSION
if (!$this->_useSession) {
$useSession = false;
}
if (!$this->_uid) {
$cookie = $this->getCookie('_UID');
$cookie = $this->getCookie('_UID');
if (!empty($cookie)) {
$cookieList = explode('::', $cookie);
$cookieList = explode('::', $cookie);
if (isset($cookieList[1]) && is_numeric($cookieList[1])) {
$this->_uid = $cookieList[1];
if ($useSession) {
$token = $this->getSession('_TOKEN');
if (empty($token)) {
$token = $this->getCookie('_TOKEN');
}
if ($token === Helpers::makeToken($cookieList[1])) {
$this->_uid = $cookieList[1];
}
} else {
$this->_uid = $cookieList[1];
}
$this->_uname = $cookieList[0];
$this->_vip = $cookieList[2];
}
}
}
... ... @@ -322,6 +351,7 @@ class AbstractAction extends Controller_Abstract
* @param bool $showMore 是否显示更多内容
* @return void
*/
protected function setTitle($title, $showMore = true, $sign = ' | ')
{
$this->_view->assign('title_more', $showMore);
... ... @@ -357,11 +387,11 @@ class AbstractAction extends Controller_Abstract
* 设置网站导航头部信息
*
* @param string $title 头部标题
* @param string $backUrl 返回的链接
* @param mixed $backUrl 返回的链接
* @param string $homeUrl 返回首页的链接
* @return void
*/
protected function setNavHeader($title = '', $backUrl = true, $homeUrl = '/')
protected function setNavHeader($title = '', $backUrl = true, $homeUrl = '/', $navBtn = false)
{
$header = array();
... ... @@ -372,6 +402,9 @@ class AbstractAction extends Controller_Abstract
if ($backUrl) {
$header['navBack'] = true;
if (is_string($backUrl) && $backUrl != '') {
$header['backUrl'] = $backUrl;
}
}
if (!empty($title)) {
$header['navTitle'] = $title;
... ... @@ -379,23 +412,29 @@ class AbstractAction extends Controller_Abstract
if (!empty($homeUrl)) {
$header['navHome'] = $homeUrl . '?go=1&t=' . time();
}
if ($navBtn) {
$header['navBtn'] = true;
}
// 根据COOKIE记录的频道进行导航定位
$channel = Helpers::getChannelByCookie();
switch ($channel) {
default:
case 1:
$header['boys'] = true;
break;
case 2:
$header['girls'] = true;
break;
case 3:
$header['kids'] = true;
break;
case 4:
$header['lifeStyle'] = true;
break;
$controller = $this->getRequest()->getControllerName();
if ($controller !== 'Home') {
// 根据COOKIE记录的频道进行导航定位
$channel = Helpers::getChannelByCookie();
switch ($channel) {
default:
case 1:
$header['boys'] = true;
break;
case 2:
$header['girls'] = true;
break;
case 3:
$header['kids'] = true;
break;
case 4:
$header['lifeStyle'] = true;
break;
}
}
$this->_view->assign('pageHeader', $header);
... ...
... ... @@ -2,7 +2,7 @@
/**
* 有货相关接口类
*
*
* @name Yohobuy
* @package library/Api
* @copyright yoho.inc
... ... @@ -17,19 +17,26 @@ use Plugin\Cache;
class Yohobuy
{
/* 正式环境 */
const API_URL = 'http://api2.open.yohobuy.com/';
const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const API_URL = 'http://api2.open.yohobuy.com/';
// const API_URL2 = 'http://api.open.yohobuy.com/';
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_URL = 'http://apih5.yoho.cn/';
const API_URL2 = 'http://apih5.yoho.cn/';
const SERVICE_URL = 'http://serviceh5.yoho.cn/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
// /* 测试环境 */
// const API_URL = 'http://test2.open.yohobuy.com/';
// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
// const API_URL = 'http://testapi.yoho.cn:28078/';
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
* 私钥列表
*
* @var array
*
* @var array
*/
private static $privateKeyList = array(
'android' => 'fd4ad5fcfa0de589ef238c0e7331b585',
... ... @@ -57,8 +64,27 @@ class Yohobuy
}
/**
* 取得当前的IP地址
*
* @param bool $int 返回int类型的ip地址,默认是
* @return mixed 当前的IP地址
*/
public static function ip($int = true)
{
if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP']) {
$onlineip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
$onlineip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$onlineip = $_SERVER['REMOTE_ADDR'];
}
return $int ? ip2long($onlineip) : $onlineip;
}
/**
* 取得公共的参数
*
*
* @return array
*/
public static function param()
... ... @@ -77,7 +103,7 @@ class Yohobuy
/**
* 构建URL
*
*
* @param string $url
* @param array $data
* @return string
... ... @@ -98,7 +124,7 @@ class Yohobuy
/**
* get方式调用接口
*
*
* @param string $url 接口URL
* @param array $data 参数列表
* @parma mixed $cache 控制是否启用接口数据的缓存(时间单位为秒). 如3600表示缓存1小时, false表示不缓存
... ... @@ -153,7 +179,7 @@ class Yohobuy
/**
* post提交数据
*
*
* @param string $url 接口URL
* @param array $data 参数列表
* @param bool $returnJson 控制是否返回json格式数据
... ... @@ -162,7 +188,7 @@ class Yohobuy
* @param array $cookie
* @return mixed
*/
public static function post($url, $data = array(), $returnJson = false, $timeout = 5, $header = array(), $cookie = array())
public static function post($url, $data = array(), $returnJson = false, $timeout = 10, $header = array(), $cookie = array())
{
$ch = curl_init($url);
... ... @@ -188,7 +214,10 @@ class Yohobuy
unset($data['private_key']);
}
if (!empty($data)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$str = http_build_query($data, null, '&');
// 新加支持application/x-www-form-urlencoded调用方式
//curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
}
$result = curl_exec($ch);
if (!$returnJson && !empty($result)) {
... ... @@ -202,7 +231,7 @@ class Yohobuy
/**
* 批量调用接口
*
*
* @param array $urlList 接口列表
* @param array $options CURL设置项
* @parma mixed $cache 控制是否启用接口数据的缓存(时间单位为秒). 如3600表示缓存1小时, false表示不缓存
... ... @@ -213,7 +242,7 @@ class Yohobuy
{
/* 开启缓存的情况 */
if ($cache && USE_CACHE) {
$key = md5(implode(',', array_values($urlList)));
$key = md5(implode(',', array_values($urlList)));
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
... ... @@ -306,7 +335,7 @@ class Yohobuy
/**
* rpc调用远程服务(YAR)
*
*
* @see http://php.net/manual/zh/yar-client.setopt.php
* @param string $uri
* @param string $method
... ... @@ -355,7 +384,7 @@ class Yohobuy
/**
* 并行(异步)调用远程服务
*
*
* @see http://php.net/manual/zh/class.yar-concurrent-client.php
* @param string $uri
* @param string $method
... ... @@ -378,4 +407,51 @@ class Yohobuy
\Yar_Concurrent_Client::loop($callback);
}
/**
* 提交json格式数据请求java有关接口
*
* @param string $url 接口URL
* @param array $data 参数列表
* @param bool $returnJson 控制是否返回json格式数据
* @param int $timeout 超时时间
* @param array $cookie
* @return mixed
*/
public static function jsonPost($url, $data = array(), $returnJson = false, $timeout = 10, $cookie = array())
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
if (!empty($cookie)) {
$cookie_str = array();
foreach ($cookie as $key => $val) {
$cookie_str[] = urlencode($key) . '=' . urlencode($val);
}
curl_setopt($ch, CURLOPT_COOKIE, implode(';', $cookie_str));
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (!empty($data)) {
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
// 设置json的Header
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)
));
}
$result = curl_exec($ch);
if (!$returnJson && !empty($result)) {
$result = json_decode($result, true);
}
curl_close($ch);
$data = array();
return $result;
}
}
... ...
... ... @@ -22,9 +22,15 @@ class CacheConfig
const KEY_ACTION_BOYS_BOTTOM_BANNER = 'key_action_boys_bottom_banner'; // 男生首页底部banner
const KEY_ACTION_GRILS_BOTTOM_BANNER = 'key_action_girls_bottom_banner';// 女生首页底部banner
const KEY_ACTION_PRODUCT_NEWSALE_INDEX = 'key_action_product_newsale_index'; // 新品到着
const KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT = 'key_action_product_newsale_discount'; // 热卖排行
const KEY_ACTION_PRODUCT_NEWSALE_INDEX_BOYS = 'key_action_product_newsale_index_boys'; // 男生新品到着
const KEY_ACTION_PRODUCT_NEWSALE_INDEX_GIRLS = 'key_action_product_newsale_index_girls'; // 女生新品到着
const KEY_ACTION_PRODUCT_NEWSALE_INDEX_KIDS = 'key_action_product_newsale_index_kids'; // 潮童新品到着
const KEY_ACTION_PRODUCT_NEWSALE_INDEX_LIFESTYLE = 'key_action_product_newsale_index_lifestyle'; // 创意生活新品到着
const KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_BOYS = 'key_action_product_newsale_discount_boys'; // 男生热卖排行
const KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_GIRLS = 'key_action_product_newsale_discount_girls'; // 女生热卖排行
const KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_KIDS = 'key_action_product_newsale_discount_kids'; // 潮童热卖排行
const KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT_LIFESTYLE = 'key_action_product_newsale_discount_lifestyle'; // 创意生活热卖排行
const KEY_ACTION_PRODUCT_INDEX = 'key_action_product_index'; // 品类商品列表
const KEY_ACTION_PRODUCT_BRAND = 'key_action_product_brand'; // 品类商品列表
const KEY_ACTION_PRODUCT_BRAND_DOMAINS = 'key_action_product_brand_domains'; // 所有品牌域名列表
... ... @@ -35,10 +41,16 @@ class CacheConfig
const KEY_ACTION_SEARCH_SEARCH = 'key_action_search_search'; // 搜索的数据
const KEY_ACTION_SEARCH_FILTER = 'key_action_search_filter'; // 搜索的过滤条件
const KEY_ACTION_HOME_GRADE = 'key_action_home_grade';//会员等级
const KEY_ACTION_HOME_PREFERENTIAL = 'key_action_home_preferential';//会员特权详情
const KEY_ACTION_HOME_ORDER_ORDER = 'key_action_home_order_order';//订单列表
const KEY_ACTION_GUANG_PLUSSTAR_INDEX = 'key_action_guang_plusstar_index'; // 国际优选
const KEY_ACTION_GUANG_PLUSSTAR_LIST = 'key_action_guang_plusstar_list'; // 明星原创
const KEY_ACTION_GUANG_PLUSTAR_DATA = 'key_action_guang_plustar_data'; // 逛PLUSTAR
const KEY_ACTION_GUANG_DETAIL_DATA = 'key_action_guang_detail_data'; // 逛内容详情
const KEY_ACTION_GUANG_RSS_DATA = 'key_action_guang_detail_data'; // 逛订阅内容
const KEY_ACTION_ADDRESS_LIST_DATA = 'key_action_address_list_data'; // 地址树数据
}
... ...
... ... @@ -21,8 +21,8 @@ use LibModels\Wap\Product\SearchData;
class PlusstarData
{
const URI_BRANDLIST = 'guang/api/v1/plustar/getlist';
const URI_BRANDINFO_PLUSSTAR = 'guang/service/v1/plustar/';
const URI_BRANDLIST = 'guang/api/v3/plustar/getlist';
const URI_BRANDINFO_PLUSSTAR = 'guang/service/v3/plustar/'; // 'guang/service/v3/plustar/'
const URI_BRANDINFO_FAVORITE = 'shops/service/v1/favorite/';
const URI_BRANDINFO_ARTICLE = 'guang/service/v1/article/';
... ... @@ -45,19 +45,20 @@ class PlusstarData
// 公共的参数
$param = Yohobuy::param();
$param['brand_type'] = '1';
$param['gender'] = $gender;
$param['yh_channel'] = $channel;
// 构建推荐的品牌参数及调用接口的URL
$build = $param;
$build['is_recommend'] = '1';
$build['brand_type'] = '4';
//$build['is_recommend'] = '1';
$build['client_secret'] = Sign::getSign($build);
$urlList['recom'] = Yohobuy::httpBuildQuery($url, $build);
// 构建所有的品牌参数及调用接口的URL
$build = $param;
$build['is_recommend'] = '0';
$build['brand_type'] = '1';
//$build['is_recommend'] = '0';
$build['client_secret'] = Sign::getSign($build);
$urlList['all'] = Yohobuy::httpBuildQuery($url, $build);
... ...
<?php
namespace LibModels\Wap\Home;
use Api\Sign;
use Api\Yohobuy;
/**
* 购物车的数据模型
*
* @name CartData
* @package LibModels/Wap/Home
* @copyright yoho.inc
* @version 1.0 (2015-11-09 13:58:27)
* @author Gtskk <tttt6399998@126.com>
*/
class CartData
{
/**
* 购物车数据
*
* @return array 购物车接口返回的数据
*/
public static function cartData($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.cart';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.remove';
$param['product_sku_list'] = $sku;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.addfavorite';
$param['product_sku_list'] = $sku;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn)
{
$param = Yohobuy::param();
$param['method'] = 'app.product.data';
$param['product_skn'] = $skn;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $swapData 商品数据
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $swapData)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.swap';
$param['swap_data'] = $swapData;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
<?php
namespace LibModels\Wap\Home;
use Api\Yohobuy;
use Api\Sign;
/*
* 个人中心-会员等级接口操作类
*/
class GradeData
{
/**
* 获取会员等级数据
* @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他
* @param string $uid 用户id
* @return array 接口返回的会员等级数据
*/
public static function getGradeData($channel, $uid) {
$urlList = array();
//获取会员等级数据
$param = Yohobuy::param();
$param['yh_channel'] = $channel;
$param['uid'] = $uid;
$param['method'] = 'app.Passport.vip';
$param['client_secret'] = Sign::getSign($param);
$urlList['grade'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
//获取用户基本信息数据(用来得到username)
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['method'] = 'app.passport.profile';
$param['client_secret'] = Sign::getSign($param);
$urlList['userProfile'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
return Yohobuy::getMulti($urlList);
}
/**
* 获取会员特权详情数据
* @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他
* @param string $uid 用户id
* @return array 接口返回的会员特权详情数据
*/
public static function getPreferentialData($channel, $uid) {
$param = Yohobuy::param();
$param['yh_channel'] = $channel;
$param['uid'] = $uid;
$param['method'] = 'app.passport.getPrivilege';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
<?php
namespace LibModels\Wap\Home;
use Api\Sign;
use Api\Yohobuy;
/**
* 我的逛数据模型
*
* @name GuangData
* @package LibModels/Wap/Home
* @copyright yoho.inc
* @version 1.0 (2015-11-13)
* @author xiaowei
*/
class GuangData
{
const GUANG_URI = 'guang/api/v1/favorite/';
//我的guang
public static function getGuangInfo($uid, $page, $yh_channel = 1, $gender = '1,3', $limit = 10)
{
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['page'] = $page;
$param['gender'] = $gender;
$param['limit'] = $limit;
$param['yh_channel'] = $yh_channel;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::SERVICE_URL . self::GUANG_URI . 'getUserFavArticleList', $param);
}
}
... ...
<?php
namespace LibModels\Wap\Home;
use Api\Yohobuy;
/**
* 在线客服数据模型
*
* @name OnlineData
* @package LibModels/Wap/Home
* @copyright yoho.inc
* @version 1.0 (2015-11-13)
* @author xiaowei
*/
class OnlineData
{
const ONLINE_URI = 'operations/api/v1/help/';
/*
* 获取帮助列表(分类),缓存1h
* clientType客户端
*/
public static function getOnlineServiceInfo($clientType='iphone')
{
return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getCategory', array('client_type'=>$clientType),3600);
}
/*
* 获取问题详情,缓存1h
* cateId问题分类ID
* clientType客户端
*/
public static function getOnlineServiceDetail($cateId, $clientType = 'iphone')
{
return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getHelp', array('category_id'=>$cateId,'client_type'=>$clientType),3600);
}
}
... ...
<?php
namespace LibModels\Wap\Home;
use Api\Yohobuy;
use Api\Sign;
/**
* Description of OrderData
*
* @author Administrator
*/
class OrderData
{
/*
* 获取订单数据
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function getOrderData($type, $page, $limit, $gender, $yh_channel, $uid)
{
//构建必传参数
$param = Yohobuy::param();
$param['gender'] = $gender;
$param['limit'] = $limit;
$param['method'] = 'app.SpaceOrders.get';
$param['page'] = $page;
$param['type'] = $type;
$param['uid'] = $uid;
$param['yh_channel'] = $yh_channel;
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/*
* 取消订单
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function cancelOrderData($order_code, $uid, $gender, $yh_channel)
{
//构建必传参数
$param = Yohobuy::param();
$param['order_code'] = $order_code;
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['yh_channel'] = $yh_channel;
$param['method'] = 'app.SpaceOrders.close';
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/*
* 删除订单
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function deleteOrderData($order_code, $uid, $gender, $yh_channel)
{
//构建必传参数
$param = Yohobuy::param();
$param['order_code'] = $order_code;
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['yh_channel'] = $yh_channel;
$param['method'] = 'app.SpaceOrders.delOrderByCode';
$param['client_secret'] = Sign::getSign($param);
//调用接口删除订单
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/*
* 我的订单-查看物流
*
* @param int $orderCode 订单号
* @param int $uid 用户ID
* @return array
*/
public static function LogisticsData($orderCode, $uid)
{
//构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.express.li';
$param['order_code'] = $orderCode;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/*
* 支付页面的资源位
* To change this template file, choose Tools | Templates
*/
public static function paymentData($gender, $yh_channel, $code)
{
//构建必传参数
$param = Yohobuy::param();
$param['content_code'] = $code;
$param['gender'] = $gender;
$param['yh_channel'] = $yh_channel;
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
return Yohobuy::get(Yohobuy::SERVICE_URL . '/operations/api/v5/resource/get', $param);
}
/*
* 随便逛逛url
*
* 备注:暂不使用
*/
public static function strollData($gender, $yh_channel, $code)
{
//构建必传参数
$param = Yohobuy::param();
$param['content_code'] = $code;
$param['gender'] = $gender;
$param['yh_channel'] = $yh_channel;
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
return Yohobuy::get(Yohobuy::SERVICE_URL . '/operations/api/v5/resource/get', $param);
}
}
... ...
<?php
namespace LibModels\Wap\Home;
use Api\Sign;
use Api\Yohobuy;
/**
* 个人中心的数据模型
*
* @name UserData
* @package LibModels/Wap/Home
* @copyright yoho.inc
* @version 1.0 (2015-11-09 16:30:27)
* @author Gtskk <tttt6399998@126.com>
*/
class UserData
{
/**
* 个人详情数据
*
* @param int $uid 用户ID
* @param int $udid 客户端唯一标识
* @return array 个人详情接口返回的数据
*/
public static function userData($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.profile';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, 3600); // 缓存1小时
}
/**
* 个人中心页面优惠券,收藏的商品等的数目数据
*
* @param int $uid 用户ID
* @return array 接口返回的数据
*/
public static function infoNum($uid, $udid)
{
$param = Yohobuy::param();
$param['method'] = 'app.home.getInfoNum';
$param['uid'] = $uid;
$param['udid'] = $udid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 个人中心页面优选新品数据
*
* @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
* @return array 接口返回的数据
*/
public static function preference($yh_channel)
{
$param = Yohobuy::param();
$param['method'] = 'app.home.preference';
$param['yh_channel'] = $yh_channel;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 订单数据
*
* @param int $uid 用户ID
* @param int $type 订单类型,1表示全部,2表示待付款,3表示待发货,4表示待收货,5表示待评价
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 订单接口返回的数据
*/
public static function orderData($uid, $type, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.SpaceOrders.get';
$param['uid'] = $uid;
$param['type'] = $type;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 收藏的商品数据
*
* @param int $uid 用户ID
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 收藏的商品接口返回的数据
*/
public static function favoriteProductData($uid, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.product';
$param['uid'] = $uid;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 收藏的品牌数据
*
* @param int $uid 用户ID
* @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 收藏的品牌接口返回的数据
*/
public static function favoriteBrandData($uid, $gender, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.brand';
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 取消收藏的商品数据
*
* @param int $uid 用户ID
* @param int $fav_id 要取消的收藏id
* @return array 接口返回的数据
*/
public static function favoriteDelete($uid, $fav_id)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.cancel';
$param['type'] = 'product';
$param['uid'] = $uid;
$param['fav_id'] = $fav_id;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 浏览记录数据
*
* @param int $uid 用户ID
* @param int $udid 客户端唯一标识
* @param int $page 第几页,默认为1
* @param int $limit 限制多少条,默认100
* @return array 接口返回的数据
*/
public static function browseRecord($uid, $udid, $page = 1, $limit = 100)
{
$param = Yohobuy::param();
$param['method'] = 'app.browse.product';
$param['uid'] = $uid;
$param['udid'] = $udid;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 删除浏览记录
*
* @param int $uid 用户ID
* @param int $skn 商品SKN
* @return array 接口返回的数据
*/
public static function delRecord($uid, $skn)
{
$param = Yohobuy::param();
$param['method'] = 'app.browse.delete';
$param['uid'] = $uid;
$param['skn'] = $skn;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* YOHO币总数
*
* @param int $uid 用户ID
* @return array YOHO币接口返回的数据
*/
public static function yohoCoinTotal($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.yohocoin.total';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* YOHO币列表数据
*
* @param int $uid 用户ID
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array YOHO币接口返回的数据
*/
public static function yohoCoinData($uid, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.yohocoin.lists';
$param['uid'] = $uid;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 优惠券数据
*
* @param int $uid 用户ID
* @param int $status 优惠券状态,0表示未使用,1表示已使用
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 优惠券接口返回的数据
*/
public static function couponData($uid, $status, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.coupons.li';
$param['uid'] = $uid;
$param['status'] = $status;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 地址数据
*
* @param int $uid 用户ID
* @return array 地址接口返回的数据
*/
public static function addressData($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.address.get';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取三级地址列表数据
*
* @param int $uid 用户ID
* @return array 地址接口返回的数据
*/
public static function addressListData($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.address.getlist';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 保存地址数据
*
* @param int $uid 用户ID
* @param string $address 地址信息
* @param int $area_code 城市码
* @param string $consignee 收货人
* @param string $email 邮箱地址
* @param int $id 地址唯一标识符id
* @param string $mobile 手机号码
* @param string $zip_code 邮编
* @return array 地址接口返回的数据
*/
public static function saveAddressData($uid, $address, $area_code, $consignee, $email, $id, $mobile, $zip_code)
{
$param = Yohobuy::param();
$param['address'] = $address;
$param['area_code'] = $area_code;
$param['consignee'] = $consignee;
$param['email'] = $email;
if (!empty($id)) { // 修改
$param['id'] = $id;
$param['method'] = 'app.address.update';
} else { // 添加
$param['method'] = 'app.address.add';
}
$param['mobile'] = $mobile;
$param['zip_code'] = $zip_code;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 设置默认地址
*
* @param int $uid 用户ID
* @param int $id 地址唯一标识符id
* @return array 接口返回的数据
*/
public static function setDefaultAddress($uid, $id)
{
$param = Yohobuy::param();
$param['id'] = $id;
$param['method'] = 'app.address.setdefault';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 删除地址
*
* @param int $uid 用户ID
* @param int $id 地址唯一标识符id
* @return array 接口返回的数据
*/
public static function deleteAddress($uid, $id)
{
$param = Yohobuy::param();
$param['id'] = $id;
$param['method'] = 'app.address.del';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 意见反馈数据
*
* @param string $udid 客户端唯一标识
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 意见反馈接口返回的数据
*/
public static function suggestData($udid, $page = 1, $limit = 30)
{
$param = Yohobuy::param();
$param['udid'] = $udid;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/getList', $param);
}
/**
* 意见靠谱,不靠谱接口
*
* @param int $uid 用户ID
* @param string $udid 客户端唯一标识
* @param int $suggest_id 意见id
* @param int $reliable 是否靠谱,1表示靠谱,2表示不靠谱
* @return array 接口返回的数据
*/
public static function upAndDown($uid, $udid, $suggest_id, $reliable)
{
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['udid'] = $udid;
$param['is_reliable'] = $reliable;
$param['suggest_id'] = $suggest_id;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/is_reliable', $param);
}
/**
* 提交意见反馈接口
*
* @param int $uid 用户ID
* @param string $content 意见内容
* @param mixed $image 图片地址
* @param int $suggest_type 意见类型
* @return array 意见反馈接口返回的数据
*/
public static function savesuggestData($uid, $content, $image, $suggest_type)
{
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['content'] = $content;
if ($image !== null) {
$param['image'] = $image;
}
$param['suggest_type'] = $suggest_type;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/saveSuggest', $param);
}
/**
* 我的消息接口
*
* @param int $uid 用户ID
* @param int $page 获取第一页,默认是1
* @param int $size 获取数目,默认是10
* @return array 消息接口返回的数据
*/
public static function messageData($uid, $page = 1, $size = 10)
{
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['size'] = $size;
$param['page'] = $page;
$param['method'] = 'app.inbox.getlist';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 在线客服接口
*
* @return array 消息接口返回的数据
*/
public static function onlineServiceData()
{
$param = Yohobuy::param();
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v1/help/getCategory', $param);
}
/**
* 帮助中心列表接口
*
* @return array 接口返回的数据
*/
public static function helpListData()
{
$param = Yohobuy::param();
$param['method'] = 'app.help.li';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 帮助详情接口
*
* @param string $code 具体一条帮助的code
* @return array 接口返回的数据
*/
public static function helpDetailData($code)
{
$param = Yohobuy::param();
$param['method'] = 'app.help.detail';
$param['return_type'] = 'html';
$param['code'] = $code;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, true, true);
}
}
... ...
<?php
namespace LibModels\Wap\Passport;
use Api\Sign;
use Api\Yohobuy;
use Plugin\Helpers;
/**
* 登录的数据模型
... ... @@ -15,7 +17,7 @@ use Api\Yohobuy;
*/
class LoginData
{
/**
* 登录
*
... ... @@ -32,10 +34,10 @@ class LoginData
$param['profile'] = $profile;
$param['password'] = $password;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
* 用户信息
*
... ... @@ -48,7 +50,7 @@ class LoginData
$param['method'] = 'app.passport.profile';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
... ... @@ -64,11 +66,14 @@ class LoginData
// 构建必传参数
$param = Yohobuy::param();
$param['v'] = '4'; // 只有早期的V4版本才有直接生成UID
$param['method'] = 'app.passport.signinByOpenID';
$param['openId'] = $openId;
$param['source_type'] = $sourceType;
$param['nickname'] = $nickname;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -165,7 +165,7 @@ class RegData
$param['password'] = $password;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -22,15 +22,16 @@ class BrandData
*
* @param int $id 品牌ID
* @param int $uid 用户ID
* @param bool $isBrand 是品牌还是商品
* @return array
*/
public static function favorite($id, $uid)
public static function favorite($id, $uid, $isBrand = true)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.add';
$param['id'] = $id;
$param['uid'] = $uid;
$param['type'] = 'brand';
$param['type'] = $isBrand ? 'brand' : 'product';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
... ... @@ -41,15 +42,16 @@ class BrandData
*
* @param int $id 品牌ID
* @param int $uid 用户ID
* @param bool $isBrand 是品牌还是商品
* @return array
*/
public static function favoriteCancel($id, $uid)
public static function favoriteCancel($id, $uid, $isBrand = true)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.cancel';
$param['fav_id'] = $id;
$param['uid'] = $uid;
$param['type'] = 'brand';
$param['type'] = $isBrand ? 'brand' : 'product';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
... ...
... ... @@ -17,4 +17,113 @@ use Api\Yohobuy;
class DetailData
{
const PRODUCT_BASE_INFO = 'product/queryProductDetailByProductId';
const PRODUCT_SIZE_INFO = 'product/queryProductIntroBySkn';
const PRODUCT_CONSULT_LIST = 'consult/queryConsults';
const PRODUCT_COMMENT_LIST = 'sns/comments/commentList';
/**
* 商品基本信息
*
* @param int $productId 商品ID
* @param int $uid 用户ID
* @return array
*/
public static function baseInfo($productId, $uid)
{
$param = Yohobuy::param();
$param['method'] = 'h5.product.data';
$param['productId'] = $productId;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 商品尺码信息
*
* @param int $productSkn 商品SKN号
* @return array
*/
public static function sizeInfo($productSkn)
{
$param = Yohobuy::param();
$param['method'] = 'h5.product.intro';
$param['productskn'] = $productSkn;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 咨询内容列表
*
* @param int $productId 产品ID
* @param int $pageNum 页码数
* @param int $pageSize 每页显示个数
* @return array
*/
public static function consultList($productId, $pageNum, $pageSize)
{
$param = Yohobuy::param();
$param['method'] = 'h5.consult.li';
$param['product_id'] = $productId;
$param['page'] = $pageNum;
$param['limit'] = $pageSize;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 评论内容列表
*
* @param int $productId 产品ID
* @param int $pageNum 页码数
* @param int $pageSize 每页显示个数
* @return array
*/
public static function commentList($productId, $pageNum, $pageSize)
{
// 暂未提供提口
}
/**
* 为你优选的商品列表
*
* @param int $productSkn 商品SKN号
* @return array
*/
public static function preference($productSkn, $channel, $brandId)
{
$param = Yohobuy::param();
$param['method'] = 'h5.preference.Search';
$param['productskn'] = $productSkn;
$param['yhchannel'] = $channel;
$param['brandId'] = $brandId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, 3600); // 缓存1小时
}
/**
* 添加咨询
*
* @param int $uid 用户ID
* @param int $productId 商品ID
* @return array
*/
public static function addConsult($uid, $productId, $content)
{
$param = Yohobuy::param();
$param['method'] = 'h5.consult.add';
$param['product_id'] = $productId;
$param['content'] = $content;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -45,9 +45,6 @@ class NewsaleData
*/
public static function getNewProducts($gender, $channel, $order = 's_t_desc', $limit = 60, $page = 1)
{
// 构建url地址列表
$urlList = array();
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['gender'] = $gender;
... ... @@ -82,7 +79,6 @@ class NewsaleData
*/
public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 60, $page = 1, $order = 's_t_desc')
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
... ... @@ -99,17 +95,17 @@ class NewsaleData
});
$param = Yohobuy::param();
if(!is_null($dayLimit)) {
if (!is_null($dayLimit)) {
$param['method'] = 'app.search.newProduct';
}else {
} else {
$param['method'] = 'app.search.sales';
$param['p_d'] = '0.1,0.9';
}
$param['page'] = $page;
$param['limit'] = $limit;
$param['order'] = $order;
$param['yh_channel'] = $channel;
$param = array_merge($param, $queriedParams);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, 600); // 缓存10分钟
... ... @@ -182,4 +178,31 @@ class NewsaleData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取热销排行榜商品数据
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* $param integer $channel 1表示男,2表示女,3表示潮童,4表示创意生活
* @param string|null $sort 品类ID查询参数
* @param integer|null $tab_id Tab的ID
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 新品到着商品数据
*/
public static function getTopProducts($gender, $channel, $sort = null, $tab_id = null, $limit = 50, $page = 1)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.top';
$param['gender'] = $gender;
$param['yh_channel'] = $gender;
!empty($sort) && $param['sort'] = $sort;
!empty($tab_id) && $param['tab_id'] = $tab_id;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -16,7 +16,7 @@ use Api\Sign;
*/
class SearchData
{
/**
* 获取搜索的服务地址
*
... ... @@ -29,9 +29,9 @@ class SearchData
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
switch (APPLICATION_ENV) {
case 'release':
case 'test':
case 'preview':
return 'http://100.98.132.63/yohosearch/search.json';
case 'test':
case 'preview':
case 'developer':
default:
return 'http://101.200.31.165/yohosearch/search.json';
... ... @@ -144,11 +144,12 @@ class SearchData
$param = array();
$param['status'] = 1; // 是否上架,1表示在架,2表示不在
$param['sales'] = 'Y'; // 只搜索销售的产品
$param['stocknumber'] = 1; // 过滤掉已售罄的商品
// $param['needFilter'] = 1; // 是否需要返回筛选条件
if (!isset($condition['order'])) {
$param['order'] = $orderMaps['s_t_desc'];
} else {
$param['order'] = $orderMaps[ $condition['order'] ];
$param['order'] = $orderMaps[$condition['order']];
}
if (!isset($condition['page'])) {
$param['page'] = 1;
... ...
... ... @@ -9,6 +9,7 @@ use Plugin\Helpers;
*/
class FloorProcess
{
/**
* 频道参数
*
... ... @@ -34,6 +35,10 @@ class FloorProcess
$build = array();
foreach ($data['list'] as $v) {
if (empty($v)) {
continue;
}
$fun = $v['template_name'];
if (empty($v['data']) || !is_callable("self::$fun")) {
continue;
... ... @@ -203,7 +208,7 @@ class FloorProcess
foreach ($data['list'] as &$one) {
if (isset($one['url'])) {
$one['url'] = Helpers::getFilterUrl($one['url']);
isset(self::$channel[$type]) && $one['url'] .= '?gender='.self::$channel[$type];
isset(self::$channel[$type]) && $one['url'] .= '?gender=' . self::$channel[$type];
}
$one['img'] = Helpers::getImageUrl($one['src'], 158, 174);
unset($one['src']);
... ... @@ -264,7 +269,9 @@ class FloorProcess
foreach ($data as $key => &$value) {
if ($key == 'title') {
$value['more_url'] = Helpers::url('', array('id' => 4, 'gender' => self::$channel[$type]), 'guang');
$urlParam = array('id' => 4);
isset(self::$channel[$type]) && $urlParam['gender'] = self::$channel[$type];
$value['more_url'] = Helpers::url('', $urlParam, 'guang');
}
if ($key == 'list') {
foreach ($value as &$one) {
... ... @@ -298,7 +305,12 @@ class FloorProcess
$one['img'] = Helpers::getImageUrl($one['src'], 640, 403);
unset($one['src']);
}
$result['big_image']['list'] = $data['big_image'];
// 区别多张图与一张图
if (count($data['big_image']) > 1) {
$result['big_image']['big_list'] = $data['big_image'];
unset($data['big_image']);
}
foreach ($data['list'] as $kk => &$one) {
if ($kk == 0) {
... ... @@ -318,8 +330,6 @@ class FloorProcess
$data['title']['more_url'] = Helpers::getFilterUrl($data['title']['more_url']);
}
unset($data['big_image']);
$result['goodsCategory'] = $data;
return $result;
... ...
... ... @@ -42,7 +42,7 @@ class ListProcess
$products = array();
foreach ($data as $value) {
$products[] = Helpers::formatProduct($value, true, true, true);
$products[] = Helpers::formatProduct($value, true, true, true, 235, 314);
}
return $products;
... ... @@ -53,9 +53,10 @@ class ListProcess
*
* @param $data
* @param string | integer $gender 默认选择的性别,默认1,2,3表示所有
* @param null|string $exclude 需要排除的字段
* @return array 处理之后的筛选数据
*/
public static function getFilterData($data, $gender = '1,2,3')
public static function getFilterData($data, $gender = '1,2,3', $exclude = null)
{
// 过滤条件数据
$filters = array('classify' => array());
... ... @@ -65,12 +66,10 @@ class ListProcess
$num = 1;
foreach ($data as $key => $val) {
if (empty($val)) {
continue;
}
if (!is_callable("self::$key")) {
if ($key === $exclude || empty($val) || !is_callable("self::$key")) {
continue;
}
$build = self::$key($val, $gender);
if ($num === 1) {
$build['active'] = true;
... ... @@ -248,6 +247,9 @@ class ListProcess
private static function priceRange($data)
{
// 首先对价格进行排序
ksort($data, SORT_NUMERIC);
$result = array(
'title' => '价格',
'name' => '所有价格',
... ... @@ -313,7 +315,7 @@ class ListProcess
{
$fieldArr = array();
foreach ($array as $k => $v) {
$fieldArr[$k] = $v[$field];
$fieldArr[$k] = isset($v[$field]) ? $v[$field] : '';
}
$sort = $desc == false ? SORT_ASC : SORT_DESC;
array_multisort($fieldArr, $sort, $array);
... ...
... ... @@ -43,7 +43,51 @@ class NewSaleProcess
// 处理商品
if (isset($products['product_list'])) {
foreach ($products['product_list'] as $single) {
$result['goods'][] = Helpers::formatProduct($single, true, false, false, 290, 388);
$result['goods'][] = Helpers::formatProduct($single, true, false, false, 235, 314);
}
}
return $result;
}
/**
* 处理热销排行榜数据
*
* @param array $products 接口传回的数据
* @param boolean $notab 是否传回tab数据
* @param int $limit 查询返回的最大限制数
* @param int $page 分页第几页
* @return array 处理之后的数据
*/
public static function topData($products, $notab, $limit, $page)
{
$result = array();
// 处理Tabs
if (!$notab && isset($products['tabs'])) {
$result['tabs'] = array();
foreach ($products['tabs'] as $key => $one) {
$tabItem = array();
$tabItem['title'] = $one;
$tabItem['dataId'] = $key;
if ($key === 0) {
$tabItem['focus'] = true;
}
$result['tabs'][] = $tabItem;
}
}
// 处理商品
if (isset($products['product_list'])) {
$count = count($products['product_list']);
$one = array();
foreach ($products['product_list'] as $key => $single) {
$one = Helpers::formatProduct($single, true, false, false, 75, 114);
$one['rank'] = $limit * ($page -1) + $key + 1;
!empty($single['sales_phrase']) && $one['sales_phrase'] = $single['sales_phrase'];
$result['goods'][] = $one;
}
}
... ...
... ... @@ -181,9 +181,10 @@ class Helpers
* @param int $width 图片的宽度
* @param int $height 图片的高度
* @param bool $isApp 判断是不是APP访问
* @param bool $showPoint 商品价格是否显示小数位,默认显示
* @return array | false
*/
public static function formatProduct($productData, $showTags = true, $showNew = true, $showSale = true, $width = 290, $height = 388, $isApp = false)
public static function formatProduct($productData, $showTags = true, $showNew = true, $showSale = true, $width = 290, $height = 388, $isApp = false, $showPoint = true)
{
// 商品信息有问题,则不显示
if (!isset($productData['product_skn']) || !isset($productData['goods_list'][0])) {
... ... @@ -205,8 +206,12 @@ class Helpers
$result['product_id'] = $productData['product_id'];
$result['thumb'] = Images::getImageUrl($productData['default_images'], $width, $height);
$result['name'] = $productData['product_name'];
$result['price'] = empty($productData['market_price']) ? false : $productData['market_price'] . '.00';
$result['salePrice'] = $productData['sales_price'] . '.00';
$result['price'] = empty($productData['market_price']) ? false : $productData['market_price'];
$result['salePrice'] = $productData['sales_price'];
if ($showPoint) {
$result['price'] && $result['price'] .= '.00';
$result['salePrice'] && $result['salePrice'] .= '.00';
}
$result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
$result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_'
. $productData['goods_list'][0]['goods_id']
... ... @@ -214,7 +219,7 @@ class Helpers
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if ($isApp) {
$result['url'] .= '?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'.$productData['product_skn'].'}}';
$result['url'] .= '?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' . $productData['product_skn'] . '}}';
}
if ($showTags) {
... ... @@ -226,21 +231,19 @@ class Helpers
$result['tags']['midYear'] = isset($productData['mid-year']) && $productData['mid-year'] === 'Y'; // 年中
$result['tags']['yearEnd'] = isset($productData['year-end']) && $productData['year-end'] === 'Y'; // 年末
$result['tags']['is_advance'] = isset($productData['is_advance']) && $productData['is_advance'] === 'Y'; // 再到着
// 打折与即将售完组合显示打折
if ($result['is_soon_sold_out'] && $result['tags']['is_discount']) {
$result['tags']['is_new'] = false;
}
// 打折与其它组合则隐藏打折
elseif ($result['tags']['is_discount'] &&
($result['tags']['is_new'] || $result['tags']['is_limited'] || $result['tags']['is_yohood'] || $result['tags']['is_advance']) ) {
elseif ($result['tags']['is_discount'] &&
($result['tags']['is_new'] || $result['tags']['is_limited'] || $result['tags']['is_yohood'] || $result['tags']['is_advance'])) {
$result['tags']['is_discount'] = false;
}
}
// YOHOOD和新品组合显示YOHOOD
elseif ($result['tags']['is_yohood'] && $result['tags']['is_new']) {
$result['tags']['is_new'] = false;
}
}
return $result;
... ... @@ -285,7 +288,7 @@ class Helpers
$result['like']['count'] = $articleData['praise_num'];
$result['like']['isLiked'] = isset($articleData['isPraise']) && $articleData['isPraise'] === 'Y';
}
// 分享链接
$result['share'] = $isApp && isset($articleData['share']['url']) ? $articleData['share']['url'] : false;
... ... @@ -491,4 +494,139 @@ class Helpers
return false;
}
/**
* 格式化订单商品
*/
public static function formatOrderGoods($orderGoods, &$count = 0)
{
$arr = array();
foreach ($orderGoods as $key => $vo) {
$arr[$key]['thumb'] = Helpers::getImageUrl($vo['goods_image'], 90, 120);
$arr[$key]['name'] = $vo['product_name'];
$arr[$key]['color'] = $vo['color_name'];
$arr[$key]['size'] = $vo['size_name'];
$arr[$key]['price'] = $vo['goods_price'];
$arr[$key]['count'] = $vo['buy_number'];
//gift=>是否赠品,advanceBuy=>是否加价购;
if ($vo['goods_type'] == 'gift') {
$arr[$key]['gift'] = true;
} elseif ($vo['goods_type'] == 'price_gift') {
$arr[$key]['advanceBuy'] = true;
}
// 上市期
if (!empty($vo['expect_arrival_time'])) {
$arr[$key]['appearDate'] = $vo['expect_arrival_time'];
}
// 累计购买数
$count += intval($vo['buy_number']);
}
return $arr;
}
/**
* 订单状态,按订单支付类型和订单状态
* @var array
*/
public static function getOrderStatus()
{
return array(
'1' => array(//在线支付
0 => '待付款',
1 => '已付款',
2 => '已付款',
3 => '已付款',
4 => '已发货',
5 => '已发货',
6 => '交易成功'
),
'2' => array(//货到付款
0 => '备货中',
1 => '已付款',
2 => '已付款',
3 => '已付款',
4 => '已发货',
5 => '已发货',
6 => '交易成功'
),
'3' => array(//现金支付
0 => '待付款',
1 => '已付款',
2 => '已付款',
3 => '已付款',
4 => '已发货',
5 => '已发货',
6 => '交易成功'
),
'4' => array(//抵消支付
0 => '待付款',
1 => '已付款',
2 => '已付款',
3 => '已付款',
4 => '已发货',
5 => '已发货',
6 => '交易成功'
)
);
}
/**
* 获取会员的级别
*
* @param string $vipInfo
* @return int
*/
public static function getVipLevel($vipInfo)
{
$vipLevel = 0;
switch ($vipInfo) {
case '普通会员':
$vipLevel = 0;
break;
case '银卡会员':
$vipLevel = 1;
break;
case '金卡会员':
$vipLevel = 2;
break;
case '白金会员':
$vipLevel = 3;
break;
}
return $vipLevel;
}
/**
* 同步用户的会话
*
* 转向老的PHP服务器上处理, 因购物车相关的操作会依赖SESSION
*
* @param int $uid 用户ID
* @param string $refer 访问来源
* @param string $callback 回调方法名
* @return string
*/
public static function syncUserSession($uid, $refer = '', $callback = 'call')
{
return 'http://mapi.yohobuy.com/Passport/session/index?callback=' . $callback
. '&sign=' . md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer;
}
/**
* 退出清除用户的会话
*
* 转向老的PHP服务器上处理, 因购物车相关的操作会依赖SESSION
*
* @param int $uid 用户ID
* @param string $refer 访问来源
* @param string $callback 回调方法名
* @return string
*/
public static function logoutSession($token, $refer = '', $callback = 'call')
{
return 'http://mapi.yohobuy.com/Passport/session/logout?callback=' . $callback
. '&sign=' . md5(md5('Js8Yn0!EwPM45-ws')) . '&token=' . $token . '&go=' . $refer;
}
}
... ...
... ... @@ -24,9 +24,6 @@ class Images
),
'yhb-head' => 'head.static.yhbimg.com'
);
private static $staticDomain = array(
'bucket' => ''
);
private static $qiniuDomain = 'yhfair.qiniudn.com';
/**
... ... @@ -106,6 +103,115 @@ class Images
return $domain;
}
/**
* 图片上传
* @param string $name 文件表单name, 即用于$_FILES[$name]
*/
public static function saveImage($name)
{
if (empty($_FILES[$name]))
{
return array();
}
$files = $_FILES[$name];
$images = array();
if (is_array($files['tmp_name']))
{
foreach ($files['tmp_name'] as $k => $tmp_name)
{
if(!empty($tmp_name))
{
$images[$files['name'][$k]] = $tmp_name;
}
}
}
else
{
$images[$files['name']] = $files['tmp_name'];
}
return self::uploadStreamImage($images);
}
/**
* 上传图片[图片上传域名限制于http://test.service.api.yohobuy.com]
*
* @param string | array(filename => absolute file path) $file
* url:http://upload.static.yohobuy.com?project=sns&fileData=xxx
* @return mixed
*/
public static function uploadStreamImage($file)
{
$end ="\r\n";
$twoHyphens ="--";
$boundary = "*****";
$stream = '';
$files = is_array($file) ? $file : array($file);
foreach($files as $name => $filename)
{
if(!file_exists($filename))
{
continue;
}
$name = is_numeric($name) ? name.'.jpg' : $name;
$stream .= $twoHyphens.$boundary.$end;
$stream .="Content-Disposition: form-data; "."name=\"fileData\";filename=\"".$name ."\"".$end; // form file element name :fileData
$stream .= $end;
$stream .= file_get_contents($filename);
$stream .= $end;
}
if(empty($stream))
{
return false;
}
$stream .= $twoHyphens.$boundary.$end;
$stream .="Content-Disposition: form-data; "."name=\"project\"".$end;
$stream .= $end;
$stream .= "suggest";//project sns
$stream .= $end;
$stream .= $twoHyphens .$boundary .$twoHyphens .$end;
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'content-type:multipart/form-data;boundary='.$boundary,
'content' => $stream
)
);
$context = stream_context_create($opts);
$result = json_decode(file_get_contents('http://upload.static.yohobuy.com', false, $context), true);
if(!empty($result['data']['imagesList']))
{
$imgExtra = '?imageMogr2/thumbnail/130x130/extent/130x130/background/d2hpdGU=/position/center/quality/90';
$imgList = array('imgList'=>array());
if(count($file) == 1 || !is_array($file))
{
$imgRelUrl = current($result['data']['imagesList']);
$imgList['imgList'][] = array(
'imgUrl' => self::getSourceUrl($imgRelUrl, 'suggest') . $imgExtra,
'imgRelUrl' => $imgRelUrl
);
}
else
{
$img = array();
foreach ($result['data']['imagesList'] as $val) {
$img = array();
$img['imgUrl'] = self::getSourceUrl($val, 'suggest') . $imgExtra;
$img['imgRelUrl'] = $val;
$imgList['imgList'][] = $img;
}
}
return $imgList;
}
else
{
return false;
}
}
/**
* 获取模板的图片地址
* @param $fileName
... ...
... ... @@ -49,8 +49,8 @@ abstract class Factory
{
// require dirname(__FILE__) . DS . $apiName . DS . 'Call.class.php';
$apiNameCase = ucfirst($apiName);
$apiClass = "Plugin\Partner\\{$apiNameCase}\\Call";
//$apiNameCase = ucfirst($apiName);
$apiClass = "Plugin\Partner\\{$apiName}\Call";
self::$apiObjs[$apiName] = new $apiClass();
self::$apiObjs[$apiName]->apiName = $apiName;
... ...
... ... @@ -52,14 +52,15 @@ class Call extends Factory
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = $this->apiConfig['appCallbackUrl'];
try
{
$token = $this->oauth->getAccessToken('code', $keys);
}
catch (Exception $e)
{
// do nothing
}
$token = $this->oauth->getAccessToken('code', $keys);
// try
// {
// $token = $this->oauth->getAccessToken('code', $keys);
// }
// catch (Exception $e)
// {
// // do nothing
// }
}
return $token;
... ... @@ -77,7 +78,7 @@ class Call extends Factory
if (is_array($token) && isset($token['uid']))
{
$this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$userInfo = $this->client->show_user_by_id($token['uid']);
... ... @@ -108,7 +109,7 @@ class Call extends Factory
if (is_array($token) && isset($token['access_token']))
{
$this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$result = $this->client->friends_by_id($params['uid'], $params['cursor'], $params['count']);
... ... @@ -133,7 +134,7 @@ class Call extends Factory
if (is_array($token) && isset($token['access_token']))
{
$this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$result = $this->client->bilateral($params['uid'], $params['page'], $params['count']);
... ... @@ -163,7 +164,7 @@ class Call extends Factory
{
$content .= $link;
$this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$response = $this->client->upload($content, $image);
... ... @@ -190,7 +191,7 @@ class Call extends Factory
if (is_array($token) && isset($token['access_token']))
{
$this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
if ($uid !== null)
{
... ... @@ -218,7 +219,7 @@ class Call extends Factory
if (is_array($token) && isset($token['access_token']) && is_string($content))
{
$this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client->update($content);
}
... ... @@ -238,7 +239,7 @@ class Call extends Factory
{
if (is_array($token) && isset($token['access_token']) && isset($uid))
{
$this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
$this->client->send_dm_by_id($uid, $content, $id);
}
}
... ...
... ... @@ -2,7 +2,7 @@
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '2707954749',
'appKey' => '431730e25a8a0983964a740731c3cb7d',
'appId' => '3739328910',
'appKey' => '9d44cded26d048e23089e5e975c93df1',
'appCallbackUrl' => SITE_MAIN . '/passport/login/sinacallback',
);
\ No newline at end of file
... ...
<?php
/**
* Spyc -- A Simple PHP YAML Class
* @version 0.5.1
* @author Vlad Andersen <vlad.andersen@gmail.com>
* @author Chris Wanstrath <chris@ozmm.org>
* @link http://code.google.com/p/spyc/
* @copyright Copyright 2005-2006 Chris Wanstrath, 2006-2011 Vlad Andersen
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @package Spyc
*/
namespace Plugin;
if (!function_exists('spyc_load')) {
/**
* Parses YAML to array.
* @param string $string YAML string.
* @return array
*/
function spyc_load ($string) {
return Spyc::YAMLLoadString($string);
}
}
if (!function_exists('spyc_load_file')) {
/**
* Parses YAML to array.
* @param string $file Path to YAML file.
* @return array
*/
function spyc_load_file ($file) {
return Spyc::YAMLLoad($file);
}
}
/**
* The Simple PHP YAML Class.
*
* This class can be used to read a YAML file and convert its contents
* into a PHP array. It currently supports a very limited subsection of
* the YAML spec.
*
* Usage:
* <code>
* $Spyc = new Spyc;
* $array = $Spyc->load($file);
* </code>
* or:
* <code>
* $array = Spyc::YAMLLoad($file);
* </code>
* or:
* <code>
* $array = spyc_load_file($file);
* </code>
* @package Spyc
*/
class Spyc {
// SETTINGS
const REMPTY = "\0\0\0\0\0";
/**
* Setting this to true will force YAMLDump to enclose any string value in
* quotes. False by default.
*
* @var bool
*/
public $setting_dump_force_quotes = false;
/**
* Setting this to true will forse YAMLLoad to use syck_load function when
* possible. False by default.
* @var bool
*/
public $setting_use_syck_is_possible = false;
/**#@+
* @access private
* @var mixed
*/
private $_dumpIndent;
private $_dumpWordWrap;
private $_containsGroupAnchor = false;
private $_containsGroupAlias = false;
private $path;
private $result;
private $LiteralPlaceHolder = '___YAML_Literal_Block___';
private $SavedGroups = array();
private $indent;
/**
* Path modifier that should be applied after adding current element.
* @var array
*/
private $delayedPath = array();
/**#@+
* @access public
* @var mixed
*/
public $_nodeId;
/**
* Load a valid YAML string to Spyc.
* @param string $input
* @return array
*/
public function load ($input) {
return $this->__loadString($input);
}
/**
* Load a valid YAML file to Spyc.
* @param string $file
* @return array
*/
public function loadFile ($file) {
return $this->__load($file);
}
/**
* Load YAML into a PHP array statically
*
* The load method, when supplied with a YAML stream (string or file),
* will do its best to convert YAML in a file into a PHP array. Pretty
* simple.
* Usage:
* <code>
* $array = Spyc::YAMLLoad('lucky.yaml');
* print_r($array);
* </code>
* @access public
* @return array
* @param string $input Path of YAML file or string containing YAML
*/
public static function YAMLLoad($input) {
$Spyc = new Spyc;
return $Spyc->__load($input);
}
/**
* Load a string of YAML into a PHP array statically
*
* The load method, when supplied with a YAML string, will do its best
* to convert YAML in a string into a PHP array. Pretty simple.
*
* Note: use this function if you don't want files from the file system
* loaded and processed as YAML. This is of interest to people concerned
* about security whose input is from a string.
*
* Usage:
* <code>
* $array = Spyc::YAMLLoadString("---\n0: hello world\n");
* print_r($array);
* </code>
* @access public
* @return array
* @param string $input String containing YAML
*/
public static function YAMLLoadString($input) {
$Spyc = new Spyc;
return $Spyc->__loadString($input);
}
/**
* Dump YAML from PHP array statically
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML. Pretty simple. Feel free to
* save the returned string as nothing.yaml and pass it around.
*
* Oh, and you can decide how big the indent is and what the wordwrap
* for folding is. Pretty cool -- just pass in 'false' for either if
* you want to use the default.
*
* Indent's default is 2 spaces, wordwrap's default is 40 characters. And
* you can turn off wordwrap by passing in 0.
*
* @access public
* @return string
* @param array $array PHP array
* @param int $indent Pass in false to use the default, which is 2
* @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
*/
public static function YAMLDump($array,$indent = false,$wordwrap = false) {
$spyc = new Spyc;
return $spyc->dump($array,$indent,$wordwrap);
}
/**
* Dump PHP array to YAML
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML. Pretty simple. Feel free to
* save the returned string as tasteful.yaml and pass it around.
*
* Oh, and you can decide how big the indent is and what the wordwrap
* for folding is. Pretty cool -- just pass in 'false' for either if
* you want to use the default.
*
* Indent's default is 2 spaces, wordwrap's default is 40 characters. And
* you can turn off wordwrap by passing in 0.
*
* @access public
* @return string
* @param array $array PHP array
* @param int $indent Pass in false to use the default, which is 2
* @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
*/
public function dump($array,$indent = false,$wordwrap = false) {
// Dumps to some very clean YAML. We'll have to add some more features
// and options soon. And better support for folding.
// New features and options.
if ($indent === false or !is_numeric($indent)) {
$this->_dumpIndent = 2;
} else {
$this->_dumpIndent = $indent;
}
if ($wordwrap === false or !is_numeric($wordwrap)) {
$this->_dumpWordWrap = 40;
} else {
$this->_dumpWordWrap = $wordwrap;
}
// New YAML document
$string = "---\n";
// Start at the base of the array and move through it.
if ($array) {
$array = (array)$array;
$previous_key = -1;
foreach ($array as $key => $value) {
if (!isset($first_key)) $first_key = $key;
$string .= $this->_yamlize($key,$value,0,$previous_key, $first_key, $array);
$previous_key = $key;
}
}
return $string;
}
/**
* Attempts to convert a key / value array item to YAML
* @access private
* @return string
* @param $key The name of the key
* @param $value The value of the item
* @param $indent The indent of the current node
*/
private function _yamlize($key,$value,$indent, $previous_key = -1, $first_key = 0, $source_array = null) {
if (is_array($value)) {
if (empty ($value))
return $this->_dumpNode($key, array(), $indent, $previous_key, $first_key, $source_array);
// It has children. What to do?
// Make it the right kind of item
$string = $this->_dumpNode($key, self::REMPTY, $indent, $previous_key, $first_key, $source_array);
// Add the indent
$indent += $this->_dumpIndent;
// Yamlize the array
$string .= $this->_yamlizeArray($value,$indent);
} elseif (!is_array($value)) {
// It doesn't have children. Yip.
$string = $this->_dumpNode($key, $value, $indent, $previous_key, $first_key, $source_array);
}
return $string;
}
/**
* Attempts to convert an array to YAML
* @access private
* @return string
* @param $array The array you want to convert
* @param $indent The indent of the current level
*/
private function _yamlizeArray($array,$indent) {
if (is_array($array)) {
$string = '';
$previous_key = -1;
foreach ($array as $key => $value) {
if (!isset($first_key)) $first_key = $key;
$string .= $this->_yamlize($key, $value, $indent, $previous_key, $first_key, $array);
$previous_key = $key;
}
return $string;
} else {
return false;
}
}
/**
* Returns YAML from a key and a value
* @access private
* @return string
* @param $key The name of the key
* @param $value The value of the item
* @param $indent The indent of the current node
*/
private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0, $source_array = null) {
// do some folding here, for blocks
if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false ||
strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || strpos ($value, ' ') !== false ||
strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || strpos($value,"&") !== false || strpos($value, "'") !== false || strpos($value, "!") === 0 ||
substr ($value, -1, 1) == ':')
) {
$value = $this->_doLiteralBlock($value,$indent);
} else {
$value = $this->_doFolding($value,$indent);
}
if ($value === array()) $value = '[ ]';
if (in_array ($value, array ('true', 'TRUE', 'false', 'FALSE', 'y', 'Y', 'n', 'N', 'null', 'NULL'), true)) {
$value = $this->_doLiteralBlock($value,$indent);
}
if (trim ($value) != $value)
$value = $this->_doLiteralBlock($value,$indent);
if (is_bool($value)) {
$value = ($value) ? "true" : "false";
}
if ($value === null) $value = 'null';
if ($value === "'" . self::REMPTY . "'") $value = null;
$spaces = str_repeat(' ',$indent);
//if (is_int($key) && $key - 1 == $previous_key && $first_key===0) {
if (is_array ($source_array) && array_keys($source_array) === range(0, count($source_array) - 1)) {
// It's a sequence
$string = $spaces.'- '.$value."\n";
} else {
// if ($first_key===0) throw new Exception('Keys are all screwy. The first one was zero, now it\'s "'. $key .'"');
// It's mapped
if (strpos($key, ":") !== false || strpos($key, "#") !== false) { $key = '"' . $key . '"'; }
$string = rtrim ($spaces.$key.': '.$value)."\n";
}
return $string;
}
/**
* Creates a literal block for dumping
* @access private
* @return string
* @param $value
* @param $indent int The value of the indent
*/
private function _doLiteralBlock($value,$indent) {
if ($value === "\n") return '\n';
if (strpos($value, "\n") === false && strpos($value, "'") === false) {
return sprintf ("'%s'", $value);
}
if (strpos($value, "\n") === false && strpos($value, '"') === false) {
return sprintf ('"%s"', $value);
}
$exploded = explode("\n",$value);
$newValue = '|';
$indent += $this->_dumpIndent;
$spaces = str_repeat(' ',$indent);
foreach ($exploded as $line) {
$newValue .= "\n" . $spaces . ($line);
}
return $newValue;
}
/**
* Folds a string of text, if necessary
* @access private
* @return string
* @param $value The string you wish to fold
*/
private function _doFolding($value,$indent) {
// Don't do anything if wordwrap is set to 0
if ($this->_dumpWordWrap !== 0 && is_string ($value) && strlen($value) > $this->_dumpWordWrap) {
$indent += $this->_dumpIndent;
$indent = str_repeat(' ',$indent);
$wrapped = wordwrap($value,$this->_dumpWordWrap,"\n$indent");
$value = ">\n".$indent.$wrapped;
} else {
if ($this->setting_dump_force_quotes && is_string ($value) && $value !== self::REMPTY)
$value = '"' . $value . '"';
}
return $value;
}
// LOADING FUNCTIONS
private function __load($input) {
$Source = $this->loadFromSource($input);
return $this->loadWithSource($Source);
}
private function __loadString($input) {
$Source = $this->loadFromString($input);
return $this->loadWithSource($Source);
}
private function loadWithSource($Source) {
if (empty ($Source)) return array();
if ($this->setting_use_syck_is_possible && function_exists ('syck_load')) {
$array = syck_load (implode ('', $Source));
return is_array($array) ? $array : array();
}
$this->path = array();
$this->result = array();
$cnt = count($Source);
for ($i = 0; $i < $cnt; $i++) {
$line = $Source[$i];
$this->indent = strlen($line) - strlen(ltrim($line));
$tempPath = $this->getParentPathByIndent($this->indent);
$line = self::stripIndent($line, $this->indent);
if (self::isComment($line)) continue;
if (self::isEmpty($line)) continue;
$this->path = $tempPath;
$literalBlockStyle = self::startsLiteralBlock($line);
if ($literalBlockStyle) {
$line = rtrim ($line, $literalBlockStyle . " \n");
$literalBlock = '';
$line .= $this->LiteralPlaceHolder;
$literal_block_indent = strlen($Source[$i+1]) - strlen(ltrim($Source[$i+1]));
while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) {
$literalBlock = $this->addLiteralLine($literalBlock, $Source[$i], $literalBlockStyle, $literal_block_indent);
}
$i--;
}
// Strip out comments
if (strpos ($line, '#')) {
$line = preg_replace('/\s*#([^"\']+)$/','',$line);
}
while (++$i < $cnt && self::greedilyNeedNextLine($line)) {
$line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t");
}
$i--;
$lineArray = $this->_parseLine($line);
if ($literalBlockStyle)
$lineArray = $this->revertLiteralPlaceHolder ($lineArray, $literalBlock);
$this->addArray($lineArray, $this->indent);
foreach ($this->delayedPath as $indent => $delayedPath)
$this->path[$indent] = $delayedPath;
$this->delayedPath = array();
}
return $this->result;
}
private function loadFromSource ($input) {
if (!empty($input) && strpos($input, "\n") === false && file_exists($input))
return file($input);
return $this->loadFromString($input);
}
private function loadFromString ($input) {
$lines = explode("\n",$input);
foreach ($lines as $k => $_) {
$lines[$k] = rtrim ($_, "\r");
}
return $lines;
}
/**
* Parses YAML code and returns an array for a node
* @access private
* @return array
* @param string $line A line from the YAML file
*/
private function _parseLine($line) {
if (!$line) return array();
$line = trim($line);
if (!$line) return array();
$array = array();
$group = $this->nodeContainsGroup($line);
if ($group) {
$this->addGroup($line, $group);
$line = $this->stripGroup ($line, $group);
}
if ($this->startsMappedSequence($line))
return $this->returnMappedSequence($line);
if ($this->startsMappedValue($line))
return $this->returnMappedValue($line);
if ($this->isArrayElement($line))
return $this->returnArrayElement($line);
if ($this->isPlainArray($line))
return $this->returnPlainArray($line);
return $this->returnKeyValuePair($line);
}
/**
* Finds the type of the passed value, returns the value as the new type.
* @access private
* @param string $value
* @return mixed
*/
private function _toType($value) {
if ($value === '') return null;
$first_character = $value[0];
$last_character = substr($value, -1, 1);
$is_quoted = false;
do {
if (!$value) break;
if ($first_character != '"' && $first_character != "'") break;
if ($last_character != '"' && $last_character != "'") break;
$is_quoted = true;
} while (0);
if ($is_quoted)
return strtr(substr ($value, 1, -1), array ('\\"' => '"', '\'\'' => '\'', '\\\'' => '\''));
if (strpos($value, ' #') !== false && !$is_quoted)
$value = preg_replace('/\s+#(.+)$/','',$value);
if (!$is_quoted) $value = str_replace('\n', "\n", $value);
if ($first_character == '[' && $last_character == ']') {
// Take out strings sequences and mappings
$innerValue = trim(substr ($value, 1, -1));
if ($innerValue === '') return array();
$explode = $this->_inlineEscape($innerValue);
// Propagate value array
$value = array();
foreach ($explode as $v) {
$value[] = $this->_toType($v);
}
return $value;
}
if (strpos($value,': ')!==false && $first_character != '{') {
$array = explode(': ',$value);
$key = trim($array[0]);
array_shift($array);
$value = trim(implode(': ',$array));
$value = $this->_toType($value);
return array($key => $value);
}
if ($first_character == '{' && $last_character == '}') {
$innerValue = trim(substr ($value, 1, -1));
if ($innerValue === '') return array();
// Inline Mapping
// Take out strings sequences and mappings
$explode = $this->_inlineEscape($innerValue);
// Propagate value array
$array = array();
foreach ($explode as $v) {
$SubArr = $this->_toType($v);
if (empty($SubArr)) continue;
if (is_array ($SubArr)) {
$array[key($SubArr)] = $SubArr[key($SubArr)]; continue;
}
$array[] = $SubArr;
}
return $array;
}
if ($value == 'null' || $value == 'NULL' || $value == 'Null' || $value == '' || $value == '~') {
return null;
}
if ( is_numeric($value) && preg_match ('/^(-|)[1-9]+[0-9]*$/', $value) ){
$intvalue = (int)$value;
if ($intvalue != PHP_INT_MAX)
$value = $intvalue;
return $value;
}
if (in_array($value,
array('true', 'on', '+', 'yes', 'y', 'True', 'TRUE', 'On', 'ON', 'YES', 'Yes', 'Y'))) {
return true;
}
if (in_array(strtolower($value),
array('false', 'off', '-', 'no', 'n'))) {
return false;
}
if (is_numeric($value)) {
if ($value === '0') return 0;
if (rtrim ($value, 0) === $value)
$value = (float)$value;
return $value;
}
return $value;
}
/**
* Used in inlines to check for more inlines or quoted strings
* @access private
* @return array
*/
private function _inlineEscape($inline) {
// There's gotta be a cleaner way to do this...
// While pure sequences seem to be nesting just fine,
// pure mappings and mappings with sequences inside can't go very
// deep. This needs to be fixed.
$seqs = array();
$maps = array();
$saved_strings = array();
// Check for strings
$regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/';
if (preg_match_all($regex,$inline,$strings)) {
$saved_strings = $strings[0];
$inline = preg_replace($regex,'YAMLString',$inline);
}
unset($regex);
$i = 0;
do {
// Check for sequences
while (preg_match('/\[([^{}\[\]]+)\]/U',$inline,$matchseqs)) {
$seqs[] = $matchseqs[0];
$inline = preg_replace('/\[([^{}\[\]]+)\]/U', ('YAMLSeq' . (count($seqs) - 1) . 's'), $inline, 1);
}
// Check for mappings
while (preg_match('/{([^\[\]{}]+)}/U',$inline,$matchmaps)) {
$maps[] = $matchmaps[0];
$inline = preg_replace('/{([^\[\]{}]+)}/U', ('YAMLMap' . (count($maps) - 1) . 's'), $inline, 1);
}
if ($i++ >= 10) break;
} while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false);
$explode = explode(',',$inline);
$explode = array_map('trim', $explode);
$stringi = 0; $i = 0;
while (1) {
// Re-add the sequences
if (!empty($seqs)) {
foreach ($explode as $key => $value) {
if (strpos($value,'YAMLSeq') !== false) {
foreach ($seqs as $seqk => $seq) {
$explode[$key] = str_replace(('YAMLSeq'.$seqk.'s'),$seq,$value);
$value = $explode[$key];
}
}
}
}
// Re-add the mappings
if (!empty($maps)) {
foreach ($explode as $key => $value) {
if (strpos($value,'YAMLMap') !== false) {
foreach ($maps as $mapk => $map) {
$explode[$key] = str_replace(('YAMLMap'.$mapk.'s'), $map, $value);
$value = $explode[$key];
}
}
}
}
// Re-add the strings
if (!empty($saved_strings)) {
foreach ($explode as $key => $value) {
while (strpos($value,'YAMLString') !== false) {
$explode[$key] = preg_replace('/YAMLString/',$saved_strings[$stringi],$value, 1);
unset($saved_strings[$stringi]);
++$stringi;
$value = $explode[$key];
}
}
}
$finished = true;
foreach ($explode as $key => $value) {
if (strpos($value,'YAMLSeq') !== false) {
$finished = false; break;
}
if (strpos($value,'YAMLMap') !== false) {
$finished = false; break;
}
if (strpos($value,'YAMLString') !== false) {
$finished = false; break;
}
}
if ($finished) break;
$i++;
if ($i > 10)
break; // Prevent infinite loops.
}
return $explode;
}
private function literalBlockContinues ($line, $lineIndent) {
if (!trim($line)) return true;
if (strlen($line) - strlen(ltrim($line)) > $lineIndent) return true;
return false;
}
private function referenceContentsByAlias ($alias) {
do {
if (!isset($this->SavedGroups[$alias])) { echo "Bad group name: $alias."; break; }
$groupPath = $this->SavedGroups[$alias];
$value = $this->result;
foreach ($groupPath as $k) {
$value = $value[$k];
}
} while (false);
return $value;
}
private function addArrayInline ($array, $indent) {
$CommonGroupPath = $this->path;
if (empty ($array)) return false;
foreach ($array as $k => $_) {
$this->addArray(array($k => $_), $indent);
$this->path = $CommonGroupPath;
}
return true;
}
private function addArray ($incoming_data, $incoming_indent) {
// print_r ($incoming_data);
if (count ($incoming_data) > 1)
return $this->addArrayInline ($incoming_data, $incoming_indent);
$key = key ($incoming_data);
$value = isset($incoming_data[$key]) ? $incoming_data[$key] : null;
if ($key === '__!YAMLZero') $key = '0';
if ($incoming_indent == 0 && !$this->_containsGroupAlias && !$this->_containsGroupAnchor) { // Shortcut for root-level values.
if ($key || $key === '' || $key === '0') {
$this->result[$key] = $value;
} else {
$this->result[] = $value; end ($this->result); $key = key ($this->result);
}
$this->path[$incoming_indent] = $key;
return;
}
$history = array();
// Unfolding inner array tree.
$history[] = $_arr = $this->result;
foreach ($this->path as $k) {
$history[] = $_arr = $_arr[$k];
}
if ($this->_containsGroupAlias) {
$value = $this->referenceContentsByAlias($this->_containsGroupAlias);
$this->_containsGroupAlias = false;
}
// Adding string or numeric key to the innermost level or $this->arr.
if (is_string($key) && $key == '<<') {
if (!is_array ($_arr)) { $_arr = array (); }
$_arr = array_merge ($_arr, $value);
} else if ($key || $key === '' || $key === '0') {
if (!is_array ($_arr))
$_arr = array ($key=>$value);
else
$_arr[$key] = $value;
} else {
if (!is_array ($_arr)) { $_arr = array ($value); $key = 0; }
else { $_arr[] = $value; end ($_arr); $key = key ($_arr); }
}
$reverse_path = array_reverse($this->path);
$reverse_history = array_reverse ($history);
$reverse_history[0] = $_arr;
$cnt = count($reverse_history) - 1;
for ($i = 0; $i < $cnt; $i++) {
$reverse_history[$i+1][$reverse_path[$i]] = $reverse_history[$i];
}
$this->result = $reverse_history[$cnt];
$this->path[$incoming_indent] = $key;
if ($this->_containsGroupAnchor) {
$this->SavedGroups[$this->_containsGroupAnchor] = $this->path;
if (is_array ($value)) {
$k = key ($value);
if (!is_int ($k)) {
$this->SavedGroups[$this->_containsGroupAnchor][$incoming_indent + 2] = $k;
}
}
$this->_containsGroupAnchor = false;
}
}
private static function startsLiteralBlock ($line) {
$lastChar = substr (trim($line), -1);
if ($lastChar != '>' && $lastChar != '|') return false;
if ($lastChar == '|') return $lastChar;
// HTML tags should not be counted as literal blocks.
if (preg_match ('#<.*?>$#', $line)) return false;
return $lastChar;
}
private static function greedilyNeedNextLine($line) {
$line = trim ($line);
if (!strlen($line)) return false;
if (substr ($line, -1, 1) == ']') return false;
if ($line[0] == '[') return true;
if (preg_match ('#^[^:]+?:\s*\[#', $line)) return true;
return false;
}
private function addLiteralLine ($literalBlock, $line, $literalBlockStyle, $indent = -1) {
$line = self::stripIndent($line, $indent);
if ($literalBlockStyle !== '|') {
$line = self::stripIndent($line);
}
$line = rtrim ($line, "\r\n\t ") . "\n";
if ($literalBlockStyle == '|') {
return $literalBlock . $line;
}
if (strlen($line) == 0)
return rtrim($literalBlock, ' ') . "\n";
if ($line == "\n" && $literalBlockStyle == '>') {
return rtrim ($literalBlock, " \t") . "\n";
}
if ($line != "\n")
$line = trim ($line, "\r\n ") . " ";
return $literalBlock . $line;
}
function revertLiteralPlaceHolder ($lineArray, $literalBlock) {
foreach ($lineArray as $k => $_) {
if (is_array($_))
$lineArray[$k] = $this->revertLiteralPlaceHolder ($_, $literalBlock);
else if (substr($_, -1 * strlen ($this->LiteralPlaceHolder)) == $this->LiteralPlaceHolder)
$lineArray[$k] = rtrim ($literalBlock, " \r\n");
}
return $lineArray;
}
private static function stripIndent ($line, $indent = -1) {
if ($indent == -1) $indent = strlen($line) - strlen(ltrim($line));
return substr ($line, $indent);
}
private function getParentPathByIndent ($indent) {
if ($indent == 0) return array();
$linePath = $this->path;
do {
end($linePath); $lastIndentInParentPath = key($linePath);
if ($indent <= $lastIndentInParentPath) array_pop ($linePath);
} while ($indent <= $lastIndentInParentPath);
return $linePath;
}
private function clearBiggerPathValues ($indent) {
if ($indent == 0) $this->path = array();
if (empty ($this->path)) return true;
foreach ($this->path as $k => $_) {
if ($k > $indent) unset ($this->path[$k]);
}
return true;
}
private static function isComment ($line) {
if (!$line) return false;
if ($line[0] == '#') return true;
if (trim($line, " \r\n\t") == '---') return true;
return false;
}
private static function isEmpty ($line) {
return (trim ($line) === '');
}
private function isArrayElement ($line) {
if (!$line) return false;
if ($line[0] != '-') return false;
if (strlen ($line) > 3)
if (substr($line,0,3) == '---') return false;
return true;
}
private function isHashElement ($line) {
return strpos($line, ':');
}
private function isLiteral ($line) {
if ($this->isArrayElement($line)) return false;
if ($this->isHashElement($line)) return false;
return true;
}
private static function unquote ($value) {
if (!$value) return $value;
if (!is_string($value)) return $value;
if ($value[0] == '\'') return trim ($value, '\'');
if ($value[0] == '"') return trim ($value, '"');
return $value;
}
private function startsMappedSequence ($line) {
return ($line[0] == '-' && substr ($line, -1, 1) == ':');
}
private function returnMappedSequence ($line) {
$array = array();
$key = self::unquote(trim(substr($line,1,-1)));
$array[$key] = array();
$this->delayedPath = array(strpos ($line, $key) + $this->indent => $key);
return array($array);
}
private function returnMappedValue ($line) {
$array = array();
$key = self::unquote (trim(substr($line,0,-1)));
$array[$key] = '';
return $array;
}
private function startsMappedValue ($line) {
return (substr ($line, -1, 1) == ':');
}
private function isPlainArray ($line) {
return ($line[0] == '[' && substr ($line, -1, 1) == ']');
}
private function returnPlainArray ($line) {
return $this->_toType($line);
}
private function returnKeyValuePair ($line) {
$array = array();
$key = '';
if (strpos ($line, ':')) {
// It's a key/value pair most likely
// If the key is in double quotes pull it out
if (($line[0] == '"' || $line[0] == "'") && preg_match('/^(["\'](.*)["\'](\s)*:)/',$line,$matches)) {
$value = trim(str_replace($matches[1],'',$line));
$key = $matches[2];
} else {
// Do some guesswork as to the key and the value
$explode = explode(':',$line);
$key = trim($explode[0]);
array_shift($explode);
$value = trim(implode(':',$explode));
}
// Set the type of the value. Int, string, etc
$value = $this->_toType($value);
if ($key === '0') $key = '__!YAMLZero';
$array[$key] = $value;
} else {
$array = array ($line);
}
return $array;
}
private function returnArrayElement ($line) {
if (strlen($line) <= 1) return array(array()); // Weird %)
$array = array();
$value = trim(substr($line,1));
$value = $this->_toType($value);
$array[] = $value;
return $array;
}
private function nodeContainsGroup ($line) {
$symbolsForReference = 'A-z0-9_\-';
if (strpos($line, '&') === false && strpos($line, '*') === false) return false; // Please die fast ;-)
if ($line[0] == '&' && preg_match('/^(&['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1];
if ($line[0] == '*' && preg_match('/^(\*['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1];
if (preg_match('/(&['.$symbolsForReference.']+)$/', $line, $matches)) return $matches[1];
if (preg_match('/(\*['.$symbolsForReference.']+$)/', $line, $matches)) return $matches[1];
if (preg_match ('#^\s*<<\s*:\s*(\*[^\s]+).*$#', $line, $matches)) return $matches[1];
return false;
}
private function addGroup ($line, $group) {
if ($group[0] == '&') $this->_containsGroupAnchor = substr ($group, 1);
if ($group[0] == '*') $this->_containsGroupAlias = substr ($group, 1);
//print_r ($this->path);
}
private function stripGroup ($line, $group) {
$line = trim(str_replace($group, '', $line));
return $line;
}
}
// Enable use of Spyc from command line
// The syntax is the following: php Spyc.php spyc.yaml
define ('SPYC_FROM_COMMAND_LINE', false);
do {
if (!SPYC_FROM_COMMAND_LINE) break;
if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break;
if (empty ($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'Spyc.php') break;
$file = $argv[1];
printf ("Spyc loading file: %s\n", $file);
print_r (spyc_load_file ($file));
} while (0);
... ...
... ... @@ -119,6 +119,10 @@ class TemplateLayout implements View_Interface
}
// 应用版本号
$tpl_vars['version'] = $config->version;
// JS统计代码的版本号
if (isset($config->yas->version)) {
$tpl_vars['yas_version'] = $config->yas->version;
}
// SEO相关的标题、关键词、描述内容信息
if (!empty($tpl_vars['title_more'])) {
... ... @@ -156,7 +160,7 @@ class TemplateLayout implements View_Interface
$template = file_get_contents($viewName, false, null);
$phpStr = LightnCandy::compile($template, array(
// DEBUG: LightnCandy::FLAG_RENDER_DEBUG | LightnCandy::FLAG_ERROR_EXCEPTION
'flags' => LightnCandy::FLAG_MUSTACHE | LightnCandy::FLAG_HANDLEBARS, // 使用MUSTACHE和HANDLEBARS的模板格式
'flags' => LightnCandy::FLAG_RENDER_DEBUG | LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_MUSTACHE | LightnCandy::FLAG_HANDLEBARS, // 使用MUSTACHE和HANDLEBARS的模板格式
'basedir' => array($config->template->partials), // 模板里使用 {{> partial_name}} 时查找的目录
'fileext' => array($tplExt), // 允许查找文件的后缀
'lcrun' => 'Plugin\LCRun3', // 指定编译模板的runtime
... ...