index.php 9.45 KB
<?php $this->_extends('layout/default_layout');?>
<?php $this->_block('main');?>
 <div class="slide-main clearfix">
     <div class="left-overlay"></div>
     <div class="slide-box-warp">
         <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'],'1180x0500','fragmentimg');?>" alt=""/>
             </a>
             </div>
          <?php endforeach;?>
         </div>
         </div>
         <?php if(count($this->view->banners)>1){?>
         <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>
         <?php }?>
         <div class="slide-control">
             <a class="slide-prev iconfont-new" href="javascript:void(0);">&#xe614;</a>
             <a class="slide-next iconfont-new" href="javascript:void(0);">&#xe622;</a>
         </div>
     </div>
     <div class="right-overlay"></div>
 </div>
 <div class="content-wrap clearfix">
     <div class="fluid-list">
         <div id="index_content" 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' => 'NEXT >','next_class' => 'next','prev_label' => 'PREV <','prev_class' => 'prev','current_class' => 'current',
               		'page_class'=>'pagination-inner', 'id'=>'img_page'
      			));?>
         </div>
     </div>
 </div>
 <?php if(count($this->view->partnerList)):?>
<!-- 合作商等信息滑动条 start -->
<div class="cooperation clearfix">
    <div class="cooperation-slide-warp">
        <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)
                    {
                        // echo $key;
                        // echo $type;
                        // echo $partner['type'];
                        if($partner['type'] == $key)
                        {
                            $partnerGroups[$type][] = $partner;
                            // echo $partner;
                        }
                    }
                }
                $groupNum = 0;
                $groupLen = 0;
                $template = '';
                $html = '';
                foreach($partnerGroups as $type => $group)
                {
                    foreach ($group as $key => $partner)
                    {
                        // echo $partner['name'];
                        $pic = Lib_Images::getImageUrl($partner['pic'], 'source','fragmentimg');
                        $html.= <<<EOL
                        <li>
                      <a href="{$partner['url']}" title="{$partner['name']}" target="_blank">
                        <img src="{$pic}" alt=""/>
                     </a>
                   </li>
EOL;
                        $groupLen ++;
                        if($groupLen>=16)
                        {
                            $templates[] ='<div class="box big-size clearfix"><h2>'.$type.'</h2><hr><ul class="clearfix">'.$html.'</ul></div>';
                            $html = '';
                            $groupLen = 0;
                            $groupNum = 0;
                        }
                    }
                    if(!empty($html))
                    {
                        $templates[] ='<div class="box clearfix"><h2>'.$type.'</h2><hr><ul class="clearfix">'.$html.'</ul></div>';
                        $html = '';
                    }
                    $groupNum ++;
                    if($groupNum == 2 && !empty($html))
                    {
                        $templates[] ='<div class="box clearfix"><h2>'.$type.'</h2><hr><ul class="clearfix">'.$html.'</ul></div>';
                        $html = '';
                        $groupNum = 0;
                        $groupLen = 0;
                    }
                }

                foreach ($templates as $temp) {
                    preg_match_all("/<li>/i", $temp, $liLen, PREG_SET_ORDER);
                    if(count($liLen) >= 8)
                    {
                        $temp = preg_replace('@<div class="(.*)">(.+)<\/div>@isU', "\\2", $temp);
                        $template .='<div class="box big-size clearfix">'.$temp.'</div>';
                    }
                    else
                    {
                        $temp = preg_replace('@<div class="(.*)">(.+)<\/div>@isU', "\\2", $temp);
                        $template .='<div class="box big-size clearfix">'.$temp.'</div>';
                    }

                }

                // $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);
                //     // echo '111';
                //     // echo $temp;
                //     // echo '2222';
                //     if(count($liLen) > 8)
                //     {
                //         $temp = preg_replace('@<div class="(\w+)">(.+)<\/div>@isU', "\\2", $temp);
                //         // echo '111';
                //         // echo $temp;
                //         // echo '222';
                //         $template .='<div class="box big-size 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>
</div>
<?php endif;?>
<!-- 合作商等信息滑动条 end -->

  <div id="right_banner" class="right-banner-warp" num="<?php echo count($this->view->rightBanners);?>">
          <div class="right-banner fluid-item layout-item tiled">
         <?php
            $banners = $this->view->rightBanners;
            $temp = array();
            $len =  count($banners);
            if($len >3 && is_numeric($len)&(!($len&1)))
            {
             //随机选择出两个元素
             $temp=array_rand($banners,2);
             foreach($temp as $val){
                 $mergebanners[]=$banners[$val];
             }
                $banners=array();
                $banners=$mergebanners;
            }
            if($len >=3 && is_numeric($len)&($len&1)){
             $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">
               <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();?>