<?php

/**
 * 前台 连锁酒店 模块 Controller
 * ============================================================================
 * ZhunaCMS 住哪网酒店分销联盟程序php版　BY Tmac PHP MVC framework
 * $Author: zhangwentao $  <zwttmac@qq.com>
 * $Id: liansuohotel.php 19 2011-11-22 11:00:06Z zhangwentao $
 * http://union.zhuna.cn；
 */
class liansuohotelAction extends Action
{

    private $tmp_model;
    private $common_model;
    private $hotel_left_model;
    private $cityinfo;

    public function _init()
    {
        $this->assign('action', $_GET['TMAC_ACTION']);
        $this->tmp_model = Tmac::model('liansuohotel');
        $this->common_model = Tmac::model('common');
        $this->hotel_left_model = Tmac::model('hotelLeft');
        //搜索块默认值
        $Searchinfo = $this->hotel_left_model->setLeftSearch();
        //设置SearchCookies$Searchinfo
        $sk_array = $this->hotel_left_model->getSearchCookies($Searchinfo);
        //取cityinfo
        $this->cityinfo = $this->hotel_left_model->getCityinfo();

        //footer里的相关设置
        $config_footer = $this->common_model->footer();
        $this->assign($config_footer);
        $this->assign('sk_array', $sk_array);
        $this->assign('cityinfo', $this->cityinfo);
    }

    public function index()
    {
        $cityid = !empty($_GET['cityid']) ? (int) $_GET['cityid'] : 0;
        $chain_id = !empty($_GET['chain_id']) ? (int) $_GET['chain_id'] : 0;

        if ($cityid == 0 && $chain_id == 0) {
            $cityid = $this->cityinfo['cityid'];
        }
        $chain_info = array();
        $chain_info['chain_name'] = '';
        $citypic = '';
        if ($cityid <> 0) {
            $nav_son = "<a href='" . PHP_SELF . "?m=liansuohotel&cityid={$this->cityinfo['cityid']}'>{$this->cityinfo['cityname']}连锁酒店</a>";
            //取当前城市图片picture
            $globals_model = $this->M('common');
            $cityinfo = $globals_model->getCityinfo($cityid, 'other');
            $citypic = $cityinfo['citypic'];
        }
        if ($chain_id <> 0) {
            $chain_info = $this->tmp_model->getChainInfo($chain_id);
            $nav_son = "<a href='" . PHP_SELF . "?m=liansuohotel&chain_id={$chain_info['chain_id']}'>{$chain_info['chain_name']}连锁酒店</a>";
        }

        $roll = false;
        if ($cityid <> 0 && $chain_id <> 0) {
            $roll = true;
            $nav_son = "<a href='" . PHP_SELF . "?m=liansuohotel&chain_id={$chain_info['chain_id']}'>{$chain_info['chain_name']}连锁酒店</a> &gt; <a href='" . PHP_SELF . "?m=liansuohotel&cityid={$this->cityinfo['cityid']}'>{$this->cityinfo['cityname']}连锁酒店</a>";
            $nav_son .= " &gt; {$this->cityinfo['cityname']}{$chain_info['chain_name']}连锁酒店";
        }

        //title keywords description k_page(liansuohotel)
        $keywords_info = $this->hotel_left_model->getKeywordsInfo(18);
        $keywords_array = $keywords_info[1];
        $keywords_search = array('{doname}', '{cityname}', '{liansuoname}');
        $keywords_replace = array("$keywords_info[0]", $this->cityinfo['cityname'], $chain_info['chain_name']);
        $keywords_array = str_replace($keywords_search, $keywords_replace, $keywords_array);
        $this->assign('keywords_array', $keywords_array);
        
        $this->assign('cityid', $cityid);
        $this->assign('chain_id', $chain_id);
        $this->assign('nav_son', $nav_son);
        $this->assign('roll', $roll);
        $this->assign('chain_info', $chain_info);
        $this->assign('citypic', $citypic);
        $this->V('liansuohotel');
    }

}