<?php

/**
 * 前台 酒店点评 模块 Controller
 * ============================================================================
 * ZhunaCMS 住哪网酒店分销联盟程序php版　BY Tmac PHP MVC framework
 * $Author: zhaojianjun $  <zwttmac@qq.com>
 * $Id: comment.php 110 2012-01-11 03:48:47Z zhaojianjun $
 * http://union.zhuna.cn；
 */
class commentAction 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('question');
        $this->lable_model = Tmac::model('lable');
        $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()
    {
        $pid = empty($_GET['pid']) ? '0' : intval($_GET['pid']);  //pid
        $classid = empty($_GET['classid']) ? '0' : intval($_GET['classid']);  //classid
        //根据pid取city_ary
        $city_ary = array();
        if ($pid != 0) {
            $city_ary = $this->lable_model->getCity('c', $pid);
        } 
            	
        //title keywords description k_page(comment)
        $keywords_info = $this->hotel_left_model->getKeywordsInfo(3);
        $keywords_array = $keywords_info[1];
        $keywords_search = array('{doname}', '{cityname}');
        $keywords_replace = array("$keywords_info[0]", $this->cityinfo['cityname']);
        $keywords_array = str_replace($keywords_search, $keywords_replace, $keywords_array);
        $this->assign('keywords_array', $keywords_array);
        
        $this->assign('pid', $pid);
        $this->assign('classid', $classid);
        $this->assign('city_ary', $city_ary);         

        $this->V('comment');
    }

    public function ajaxGetComment()
    {
        $result = $this->M('comment')->comment_info($this->cityinfo['cityid']);
        $array = json_encode($result);
        echo $array;
    }

}