<?php
class IndexAction extends HomeBaseAction {
    public function index(){
        header("Content-Type:text/html; charset=utf-8");
        $welcome = THEME_PATH.'Channel/welcome.html';
        if( !file_exists($welcome) ){ //是否存在引导页
        	   switch (LANG_SET){
		        	case 'en': $ChannelID = 2; break;
		        	case 'cn': $ChannelID = 1; break;
		        	default: $ChannelID = 1;
		        }
		        $SitePath = $this->_getSitePath($ChannelID); //获取当前路径信息
		        $this->assign('SitePath', $SitePath);
		                
		        $this->assign('ChannelID', $ChannelID);
		        
		        $m = D('Admin/Channel');
		        $data = $m->find($ChannelID);
		        
		        //频道优化设置, 会覆盖网站设置
		        $s = YdCache::readSeo();
		        $Title = empty($data['Title']) ? $s['TITLE'] : $data['Title'];
		        $Keywords = empty($data['Keywords']) ? $s['KEYWORDS'] : $data['Keywords'];
		        $Description = empty($data['Description']) ? $s['DESCRIPTION'] : $data['Description'];		        
		        $this->assign('Title', $Title);
		        $this->assign('Keywords', $Keywords);
		        $this->assign('Description', $Description);
		        //===========================================================
		        
		        
		        $this->assign('ChannelName', $data['ChannelName']);
		        $this->assign('ChannelSName', $data['ChannelSName']);
		        $ChannelContent= ParseTag( $data['ChannelContent'] );
		        tag('channel_content', $ChannelContent);
		        $this->assign('ChannelContent', $ChannelContent);
		        $this->assign('ChannelSContent', $data['ChannelSContent']);
		        $IndexTemplate = $data['IndexTemplate'];
		        
		        $this->assign('ChannelModelID', $data['ChannelModelID']);
		        $this->assign('ChannelTarget', $data['ChannelTarget']);
		        $this->assign('LinkUrl', $data['LinkUrl']);
		        $this->assign('HasPicture', $data['HasPicture']);
		        $this->assign('ChannelPicture', $data['ChannelPicture']);
		        
		        $this->assign('PageSize', $data['PageSize']);
		        $this->assign('IndexTemplate', $data['IndexTemplate']);
		        $this->assign('ReadTemplate', $data['ReadTemplate']);
		        $this->assign('Parent', $data['Parent']);
		        $this->assign('HasParent', ($data['Parent'] > 0 ) ? 1 : 0 );       //是否有子频道
		        $this->assign('HasChild', $data['HasChild'] );         //是否有子频道
		        
		        $this->assign('ChannelIcon', $data['ChannelIcon']);
		        $this->assign('ChannelStyle', $data['ChannelStyle']);
		        
		        $this->assign('f1', $data['f1']);
		        $this->assign('f2', $data['f2']);
		        $this->assign('f3', $data['f3']);
		        $this->assign('TopChannelID',  $ChannelID);   //顶层频道ID
		        $this->assign('TopHasChild', 0);   //顶层频道ID     
		        
		        $IndexTemplate = str_ireplace('.html', '', trim($IndexTemplate) );
		        $IndexTemplate = "Channel:$IndexTemplate";
		        unset($m, $data);
		        $this->display($IndexTemplate);
        }else{
        	$this->display('Channel:welcome');
        }

    }
}
?>