<?php

/**
 * 前台 酒店预订帮助中心 模块 Model
 * ============================================================================
 * zhuna_php 住哪网酒店分销联盟程序php版　BY Tmac PHP MVC framework
 * $Author: zhangwentao $  <zwttmac@qq.com>
 * $Id: help.class.php 19 2011-11-22 11:00:06Z zhangwentao $
 * http://un.zhuna.cn；
 */
class help extends Model
{

    /**
     * 初始化变量　定义私有变量
     */
    public function _init()
    {
        //连接数据库
//        $this->connect();
    }

    /**
     * 取城市酒店点评 api help.asp
     * @return <array>
     */
    public function help_info()
    {        
        $hotel_left_model = Tmac::model('hotelLeft');
        $nofind_help = '';
        $cfg_webname = Tmac::config('configcache.config.cfg_webname', APP_NAME, '.inc.php');

        $xml_url = "http://union.zhuna.cn/api/utf-8/help.xml";
        $xml_root = VAR_ROOT . "xml/help/";
        $xml_name = "help.xml";
        $hotel_left_model->createXML($xml_url, $xml_root, $xml_name, 864000);
        $xmlstring = $xml_root . $xml_name;

        $content = '';
        $dom = new DomDocument;
        $dom_load = $dom->load($xmlstring);
        if ($dom_load) {
            $help = $dom->getElementsByTagName("Content");
            if ($help->length > 0) {
                $content = $help->item(0)->nodeValue;
            } else {
                $nofind_help = '暂无帮助信息!';
            }
        } else {
            $nofind_help = '暂无帮助信息!';
        }

        $content_search = array('{doname}', '{images}');
        $content_replace = array("$cfg_webname", BASE_V . $GLOBALS['TmacConfig']['Template']['template_dir'] . '/');
        $content = str_replace($content_search, $content_replace, $content);        
        $result['content'] = $content;
        $result['nofind_help'] = $nofind_help;
        return $result;
    }

}