<?php

/**
 * 前台 酒店祥细信息
 * ============================================================================
 * ZhunaCMS 住哪网酒店分销联盟程序php版　BY Tmac PHP MVC framework
 * $Author: zhaojianjun $  <zwttmac@qq.com>
 * $Id: hotelinfo.php 78 2011-12-12 10:35:03Z zhaojianjun $
 * http://union.zhuna.cn；
 */
class hotelinfoAction extends Action
{

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

    public function _init()
    {
        $this->assign('action', $_GET['TMAC_ACTION']);
        $this->assign('method',$_GET['TMAC_CONTROLLER']);
        $this->tmp_model = Tmac::model('hotelinfo');
        $this->common_model = Tmac::model('common');
        $this->hotel_left_model = Tmac::model('hotelLeft');
        //搜索块默认值
        $sk_array = $Searchinfo = $this->hotel_left_model->setLeftSearch();
        //设置SearchCookies$Searchinfo
        $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()
    {
        $hotel_id = intval($this->getParam('hotel_id'));
        //取该酒店信息
        $info = $this->tmp_model->getHotelInfo($hotel_id);
        //处理 content
        $content = str_replace($info['HotelName'], "<a href='" . PHP_SELF . "?m=hotelmap&hotel_id={$info['hotel_id']}'>{$info['HotelName']}</a>", $info['Content']);

        $this->tmp_model->cookiehotel($info['hotel_id'],$info['HotelName']);
        
        //title keywords description k_page(hotelinfo)
        $keywords_info = $this->hotel_left_model->getKeywordsInfo(12);
        $keywords_array = $keywords_info[1];
        $keywords_search = array('{doname}', '{cityname}', '{hotelnames}');
        $keywords_replace = array("$keywords_info[0]", $this->cityinfo['cityname'], $info['HotelName']);
        $keywords_array = str_replace($keywords_search, $keywords_replace, $keywords_array);
        $this->assign('keywords_array', $keywords_array);

        $this->assign('info', $info);
        $this->assign('content', $content);
        $this->V('hotelinfo');
    }

    /**
     * ajax取问答无分页带条数
     */
    public function getQuestionLimit()
    {
        $hotel_id = (int) $this->getParam('hotel_id', 0);
        $limit = (int) $this->getParam('limit', 4);
        $result = $this->tmp_model->qa_list($hotel_id, $limit);
        $array = json_encode($result);
        echo $array;
    }

    /**
     * ajax取评论无分页带条数
     */
    public function getCommentLimit()
    {
        $hotel_id = (int) $this->getParam('hotel_id', 0);
        $limit = (int) $this->getParam('limit', 4);
        $result = $this->tmp_model->comment_list($hotel_id, $limit);
        $array = json_encode($result);
        echo $array;
    }

}