Authored by unknown

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohood into develop

<?php
/**
* 默认控制器
*/
class Controller_Brand extends Controller_Abstract
{
public function indexAction()
{
$banners = Facade_Index::getIndex(3);
$this->_view['banners'] = $banners;
$this->_view['brandTotal'] = Facade_Brand::getBrandTotal(1);
}
/**
* 详情页
*/
public function detailAction()
{
$id = intval($this->_request->id);
$info = Facade_Brand::getBrandbyID($id);
$client = $this->_request->query('client', 0);
if($client || $this->_platform != 'web')
{
$signBrands = Facade_Brand::getSignBrand();
$yohobuyBrandId = '0';
foreach($signBrands as $signBrand)
{
$signBrand['brand_name'] = trim(strtolower($signBrand['brand_name']));
if(strtolower($info['name']) == $signBrand['brand_name'])
{
$yohobuyBrandId = $signBrand['brand_id'];
break;
}
}
if($client)
{
$info['link'] = 'openby:'.urlencode('yohobuy={"action":"go.brand","params":{"brand_id":"'.$yohobuyBrandId.'"}}');
}
}
$relas = Facade_Brand::getBrandNewsRelaByBrandID($id);
$news = array();
foreach ($relas as $rela)
{
$new = Facade_News::getOneById($rela['news_id']);
if($new)
{
$news[] = $new;
}
}
$news = array_slice($news, 0, 3);
$this->_view['info'] = $info;
$this->_view['news'] = $news;
}
/**
* 获取品牌
*
* @return json
*/
public function getbrandAction()
{
$brand = trim($this->_request->query('brand', ''));
$brand = str_replace(array('%'), array('\%'), $brand);
$brands = $list = array();
if($brand == '')
{
$brands = Facade_Brand::getBrandByState(0, 200, 1);
}
else
{
$brands = Facade_Brand::getBrandByName($brand, 1);
}
foreach($brands as $key => $brand)
{
$list[$key] = array('id' => $brand['id'], 'name' => $brand['name'],'logo'=> $brand['logo']);
}
return $this->returnJson(true, 200, array_values($list));
}
}
<?php
/**
* 默认控制器
*/
class Controller_Brand extends Controller_Abstract
{
public function indexAction()
{
$banners = Facade_Index::getIndex(3);
$this->_view['banners'] = $banners;
$this->_view['brandTotal'] = Facade_Brand::getBrandTotal(1);
}
/**
* 详情页
*/
public function detailAction()
{
$id = intval($this->_request->id);
$info = Facade_Brand::getBrandbyID($id);
$client = $this->_request->query('client', 0);
if($client || $this->_platform != 'web')
{
$yohobuyBrands = Facade_Brand::getYohobuyBrand();
$yohobuyBrandId = '0';
foreach($yohobuyBrands as $yohobuyBrand)
{
$yohobuyBrand['brand_name'] = trim(strtolower($yohobuyBrand['brand_name']));
if(strtolower($info['name']) == $yohobuyBrand['brand_name'])
{
$yohobuyBrandId = $yohobuyBrand['brand_id'];
break;
}
}
if($client)
{
$info['link'] = 'openby:'.urlencode('yohobuy={"action":"go.brand","params":{"brand_id":"'.$yohobuyBrandId.'"}}');
}
}
$relas = Facade_Brand::getBrandNewsRelaByBrandID($id);
$news = array();
foreach ($relas as $rela)
{
$new = Facade_News::getOneById($rela['news_id']);
if($new)
{
$news[] = $new;
}
}
$news = array_slice($news, 0, 3);
$this->_view['info'] = $info;
$this->_view['news'] = $news;
}
/**
* 获取品牌
*
* @return json
*/
public function getbrandAction()
{
$brand = trim($this->_request->query('brand', ''));
$brand = str_replace(array('%'), array('\%'), $brand);
$brands = $list = array();
if($brand == '')
{
$brands = Facade_Brand::getBrandByState(0, 200, 1);
}
else
{
$brands = Facade_Brand::getBrandByName($brand, 1);
}
foreach($brands as $key => $brand)
{
$list[$key] = array('id' => $brand['id'], 'name' => $brand['name'],'logo'=> $brand['logo']);
}
return $this->returnJson(true, 200, array_values($list));
}
}
... ...
<?php $this->_extends('layout/default_layout');?>
<?php $this->_block('main');?>
<?php
$this->_widget('activity_nav', array('channel'=> 'partner'));
?>
<div class="activity-main">
<div class="activity-content content-main">
<div class="activity-cooperation">
<?php if(empty($this->view->partnerGroups)): ?>
<img src="<?php echo SITE_RES.'/images/yohood/comingsoon.jpg';?>" style="width:100%;"/>
<?php else: ?>
<?php foreach($this->view->partnerGroups as $type => $group): ?>
<div class="section">
<h2><?php echo $type;?></h2>
<ul class="cooperation-list clearfix">
<?php foreach ($group as $partner):?>
<li>
<a href="<?php echo $partner['url'];?>" title="<?php echo $partner['name'];?>" target="_blank">
<div class="img-box">
<img src="<?php echo Lib_Images::getImageUrl($partner['pic'], 'source','fragmentimg'); ?>" alt="">
</div>
</a>
</li>
<?php endforeach;?>
</ul>
</div>
<?php endforeach;?>
<?php endif;?>
</div>
</div>
</div>
<?php $this->_extends('layout/default_layout');?>
<?php $this->_block('main');?>
<?php
$this->_widget('activity_nav', array('channel'=> 'partner'));
?>
<div class="activity-main">
<div class="activity-content content-main">
<div class="activity-cooperation">
<?php if(empty($this->view->partnerGroups)): ?>
<img src="<?php echo SITE_RES.'/images/yohood/comingsoon.jpg';?>" style="width:100%;"/>
<?php else: ?>
<?php foreach($this->view->partnerGroups as $type => $group): ?>
<div class="section">
<h2><?php echo $type;?></h2>
<ul class="cooperation-list clearfix">
<?php foreach ($group as $partner):?>
<li>
<a href="<?php echo $partner['url'];?>" title="<?php echo $partner['name'];?>" target="_blank">
<div class="img-box">
<img src="<?php echo Lib_Images::getImageUrl($partner['pic'], 'source','fragmentimg'); ?>" alt="" width="138" height="92">
</div>
</a>
</li>
<?php endforeach;?>
</ul>
</div>
<?php endforeach;?>
<?php endif;?>
</div>
</div>
</div>
<?php $this->_endblock();?>
\ No newline at end of file
... ...
<?php $this->_extends('layout/default_layout_mobile');?>
<?php $this->_block('main');?>
<?php
$this->_widget('activity_nav', array('channel'=> 'partner'));
?>
<div class="activity-main">
<div class="activity-content content-main" style="display: block;">
<div class="activity-cooperation">
<?php if(empty($this->view->partnerGroups)): ?>
<img src="<?php echo SITE_RES.'/images/yohood/comingsoon.jpg';?>" style="width:100%;"/>
<?php else: ?>
<?php foreach($this->view->partnerGroups as $type => $group): ?>
<div class="section">
<h2><?php echo $type;?></h2>
<ul class="cooperation-list clearfix">
<?php foreach ($group as $partner):?>
<li>
<a href="<?php echo $partner['url'];?>" title="<?php echo $partner['name'];?>" target="_blank">
<div class="img-box">
<img src="<?php echo Lib_Images::getImageUrl($partner['pic'], 'source','fragmentimg'); ?>" alt="">
</div>
</a>
</li>
<?php endforeach;?>
</ul>
</div>
<?php endforeach;?>
<?php endif;?>
</div>
</div>
</div>
<?php $this->_endblock();?>
<?php $this->_extends('layout/default_layout_mobile');?>
<?php $this->_block('main');?>
<?php
$this->_widget('activity_nav', array('channel'=> 'partner'));
?>
<div class="activity-main">
<div class="activity-content content-main" style="display: block;">
<div class="activity-cooperation">
<?php if(empty($this->view->partnerGroups)): ?>
<img src="<?php echo SITE_RES.'/images/yohood/comingsoon.jpg';?>" style="width:100%;"/>
<?php else: ?>
<?php foreach($this->view->partnerGroups as $type => $group): ?>
<div class="section">
<h2><?php echo $type;?></h2>
<ul class="cooperation-list clearfix">
<?php foreach ($group as $partner):?>
<li>
<a href="<?php echo $partner['url'];?>" title="<?php echo $partner['name'];?>" target="_blank">
<div class="img-box">
<img src="<?php echo Lib_Images::getImageUrl($partner['pic'], 'source','fragmentimg'); ?>" alt="" >
</div>
</a>
</li>
<?php endforeach;?>
</ul>
</div>
<?php endforeach;?>
<?php endif;?>
</div>
</div>
</div>
<?php $this->_endblock();?>
... ...
<?php $this->_extends('layout/default_layout');?>
<?php $this->_block('main');?>
<div class="slide-main">
<div class="slide-box">
<div class="slide-wrap clearfix">
<?php foreach($this->view->banners as $banner):?>
<div class="box">
<a href="<?php echo $banner['url'];?>" target="_blank" title="<?php echo $banner['text'];?>">
<img src="<?php echo Lib_Images::getImageUrl($banner['res'],'0980x0474','fragmentimg');?>" alt=""/>
</a>
</div>
<?php endforeach;?>
</div>
</div>
<div class="slide-navigator">
<div class="dib clearfix">
<?php echo '<a href="javascript:;" class="on"></a>'.str_repeat('<a href="javascript:;"></a>', count($this->view->banners) - 1);?>
</div>
</div>
<div class="slide-control">
<a class="slide-prev iconfont" href="javascript:void(0);">&#xe601;</a>
<a class="slide-next iconfont" href="javascript:void(0);">&#xe603;</a>
</div>
</div>
<div class="content-wrap clearfix">
<div class="fluid-list">
<div class="fluid-list-inner main-layout clearfix" id="img_flow">
<?php
$this->_widget('news_list', array('list'=> $this->view->news));
?>
</div>
<div id="pageContent" style="text-align: center;" class="pagination">
<?php $this->_component('Common_Pagination',array(
'pagination' => $this->view->pagination,'next_label' => '>>','prev_label' => '<<','current_class' => 'current',
'page_class'=>'pagination-inner', 'id'=>'img_page'
));?>
</div>
</div>
</div>
<?php if(count($this->view->partnerList)):?>
<div class="cooperation clearfix">
<div class="cooperation-slide-box">
<div class="slide-wrap clearfix">
<?php
$partnerGroups = array();
foreach($this->view->partnerList as $partner)
{
foreach($this->view->partnerTypes as $key => $type)
{
if($partner['type'] == $key)
{
$partnerGroups[$type][] = $partner;
}
}
}
$groupNum = 0;
$groupLen = 0;
$template = '';
$html = '';
foreach($partnerGroups as $type => $group)
{
foreach ($group as $key => $partner)
{
$pic = Lib_Images::getImageUrl($partner['pic'], 'source','fragmentimg');
$html.= <<<EOL
<li>
<a href="{$partner['url']}" title="{$partner['name']}" target="_blank">
<img src="{$pic}" alt="" style="height:70px;width:70px;"/>
</a>
</li>
EOL;
$groupLen ++;
if($groupLen>= 6)
{
$templates[] ='<div class="{class}"><h2>'.$type.'</h2><ul class="clearfix">'.$html.'</ul></div>';
$html = '';
$groupLen = 0;
$groupNum = 0;
}
}
if(!empty($html))
{
$templates[] ='<div class="{class}"><h2>'.$type.'</h2><ul class="clearfix">'.$html.'</ul></div>';
$html = '';
}
$groupNum ++;
if($groupNum == 2 && !empty($html))
{
$templates[] ='<div class="{class}"><h2>'.$type.'</h2><ul class="clearfix">'.$html.'</ul></div>';
$html = '';
$groupNum = 0;
$groupLen = 0;
}
}
$pos = 0;
foreach($templates as $temp)
{
if($pos % 2 == 0)
{
$temp = str_replace('{class}','partner', $temp);
}
else
{
$temp = str_replace('{class}','media', $temp);
}
preg_match_all("/<li>/i", $temp, $liLen, PREG_SET_ORDER);
if(count($liLen) >= 6)
{
$temp = preg_replace('@<div class="(\w+)">(.+)<\/div>@isU', "\\2", $temp);
$template .='<div class="box clearfix">'.$temp.'</div>';
$pos = -1;
}
else
{
if($pos % 2 == 0)
{
$template .='<div class="box clearfix">';
}
$template .= $temp;
if(($pos+1) % 2 == 0)
{
$template .='</div>';
}
}
$pos++;
}
if($pos % 2 == 1)
{
$template .='</div>';
}
echo $template;
?>
</div>
</div>
<div class="cooperation-slide-control">
<a class="cooperation-slide-prev iconfont" href="javascript:void(0);">&#xe600;</a>
<a class="cooperation-slide-next iconfont" href="javascript:void(0);">&#xe602;</a>
</div>
</div>
<?php endif;?>
<div id="right_banner" style="display:none;" num="<?php echo count($this->view->rightBanners);?>">
<div class="fluid-item layout-item tiled">
<?php
$banners = $this->view->rightBanners;
$temp = array();
$len = count($banners);
if($len >=3)
{
$temp = array_slice($banners, 0, 1);
$pos = rand(1, $len - 1);
$banners = array_merge($temp, array_slice($banners, $pos, 1));
}
foreach($banners as $banner):
$res_size = json_decode($banner['res_size'], true);
if($res_size['height'] < 308 && $res_size['width']< 308)
{
$height = $res_size['height'];
}
else
{
$height = ceil($res_size['height'] * (308 / $res_size['width']));
}
$width = 308;
?>
<div class="image-box" style="padding-bottom: 30px;">
<a href="<?php echo $banner['url']?>" target="_blank" style="<?php echo sprintf("height:%spx;width:%spx;overflow:hidden;", $height, $width);?>">
<img disopen="1" src="<?php echo Lib_Images::getImageUrl($banner['res'], 'source','fragmentimg');?>" style="<?php echo sprintf("height:%spx;width:%spx;", $height, $width);?>"/>
</a>
</div>
<?php endforeach;?>
</div>
</div>
<?php $this->_endblock();?>
<?php $this->_block('js');?>
<script type="text/javascript">
seajs.use('yohood',function(yohood){
yohood.index();
})
</script>
<?php $this->_endblock();?>
<?php $this->_extends('layout/default_layout');?>
<?php $this->_block('main');?>
<div class="slide-main">
<div class="slide-box">
<div class="slide-wrap clearfix">
<?php foreach($this->view->banners as $banner):?>
<div class="box">
<a href="<?php echo $banner['url'];?>" target="_blank" title="<?php echo $banner['text'];?>">
<img src="<?php echo Lib_Images::getImageUrl($banner['res'],'0980x0474','fragmentimg');?>" alt=""/>
</a>
</div>
<?php endforeach;?>
</div>
</div>
<div class="slide-navigator">
<div class="dib clearfix">
<?php echo '<a href="javascript:;" class="on"></a>'.str_repeat('<a href="javascript:;"></a>', count($this->view->banners) - 1);?>
</div>
</div>
<div class="slide-control">
<a class="slide-prev iconfont" href="javascript:void(0);">&#xe601;</a>
<a class="slide-next iconfont" href="javascript:void(0);">&#xe603;</a>
</div>
</div>
<div class="content-wrap clearfix">
<div class="fluid-list">
<div class="fluid-list-inner main-layout clearfix" id="img_flow">
<?php
$this->_widget('news_list', array('list'=> $this->view->news));
?>
</div>
<div id="pageContent" style="text-align: center;" class="pagination">
<?php $this->_component('Common_Pagination',array(
'pagination' => $this->view->pagination,'next_label' => '>>','prev_label' => '<<','current_class' => 'current',
'page_class'=>'pagination-inner', 'id'=>'img_page'
));?>
</div>
</div>
</div>
<?php if(count($this->view->partnerList)):?>
<div class="cooperation clearfix">
<div class="cooperation-slide-box">
<div class="slide-wrap clearfix">
<?php
$partnerGroups = array();
foreach($this->view->partnerList as $partner)
{
foreach($this->view->partnerTypes as $key => $type)
{
if($partner['type'] == $key)
{
$partnerGroups[$type][] = $partner;
}
}
}
$groupNum = 0;
$groupLen = 0;
$template = '';
$html = '';
foreach($partnerGroups as $type => $group)
{
foreach ($group as $key => $partner)
{
$pic = Lib_Images::getImageUrl($partner['pic'], 'source','fragmentimg');
$html.= <<<EOL
<li>
<a href="{$partner['url']}" title="{$partner['name']}" target="_blank">
<img src="{$pic}" alt="" style="width:70px;"/>
</a>
</li>
EOL;
$groupLen ++;
if($groupLen>= 6)
{
$templates[] ='<div class="{class}"><h2>'.$type.'</h2><ul class="clearfix">'.$html.'</ul></div>';
$html = '';
$groupLen = 0;
$groupNum = 0;
}
}
if(!empty($html))
{
$templates[] ='<div class="{class}"><h2>'.$type.'</h2><ul class="clearfix">'.$html.'</ul></div>';
$html = '';
}
$groupNum ++;
if($groupNum == 2 && !empty($html))
{
$templates[] ='<div class="{class}"><h2>'.$type.'</h2><ul class="clearfix">'.$html.'</ul></div>';
$html = '';
$groupNum = 0;
$groupLen = 0;
}
}
$pos = 0;
foreach($templates as $temp)
{
if($pos % 2 == 0)
{
$temp = str_replace('{class}','partner', $temp);
}
else
{
$temp = str_replace('{class}','media', $temp);
}
preg_match_all("/<li>/i", $temp, $liLen, PREG_SET_ORDER);
if(count($liLen) >= 6)
{
$temp = preg_replace('@<div class="(\w+)">(.+)<\/div>@isU', "\\2", $temp);
$template .='<div class="box clearfix">'.$temp.'</div>';
$pos = -1;
}
else
{
if($pos % 2 == 0)
{
$template .='<div class="box clearfix">';
}
$template .= $temp;
if(($pos+1) % 2 == 0)
{
$template .='</div>';
}
}
$pos++;
}
if($pos % 2 == 1)
{
$template .='</div>';
}
echo $template;
?>
</div>
</div>
<div class="cooperation-slide-control">
<a class="cooperation-slide-prev iconfont" href="javascript:void(0);">&#xe600;</a>
<a class="cooperation-slide-next iconfont" href="javascript:void(0);">&#xe602;</a>
</div>
</div>
<?php endif;?>
<div id="right_banner" style="display:none;" num="<?php echo count($this->view->rightBanners);?>">
<div class="fluid-item layout-item tiled">
<?php
$banners = $this->view->rightBanners;
$temp = array();
$len = count($banners);
if($len >=3)
{
$temp = array_slice($banners, 0, 1);
$pos = rand(1, $len - 1);
$banners = array_merge($temp, array_slice($banners, $pos, 1));
}
foreach($banners as $banner):
$res_size = json_decode($banner['res_size'], true);
if($res_size['height'] < 308 && $res_size['width']< 308)
{
$height = $res_size['height'];
}
else
{
$height = ceil($res_size['height'] * (308 / $res_size['width']));
}
$width = 308;
?>
<div class="image-box" style="padding-bottom: 30px;">
<a href="<?php echo $banner['url']?>" target="_blank" style="<?php echo sprintf("height:%spx;width:%spx;overflow:hidden;", $height, $width);?>">
<img disopen="1" src="<?php echo Lib_Images::getImageUrl($banner['res'], 'source','fragmentimg');?>" style="<?php echo sprintf("height:%spx;width:%spx;", $height, $width);?>"/>
</a>
</div>
<?php endforeach;?>
</div>
</div>
<?php $this->_endblock();?>
<?php $this->_block('js');?>
<script type="text/javascript">
seajs.use('yohood',function(yohood){
yohood.index();
})
</script>
<?php $this->_endblock();?>
... ...