<?php
/**
 * Copyright (C) LJCMS All rights reserved.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2016.03.19
 */

class control extends indexbase {
    private $cid = 0;
    private $id = 0;
    private $treeid = 0;
    private $rootid = 0;
    private $catinfo = array();
    private $_tplname = NULL;
    private $_tplfile = NULL;

    private function _getDetailItems() {
        $path_info = $GLOBALS['path_info'];
        if (!empty($path_info) && isset($path_info['id'])) {
            $this->id = intval($path_info['id']);
        }
        else {
            $this->id = XRequest::getInt('id');
        }
        if ($this->id<1) {
            XHandle::halt("对不起，参数ID错误", "", 1);
        }
    }
    public function control_run() {

        $this->control_detail();
    }

    public function control_detail() {

        $this->_getDetailItems();
        $model = M("about", "im");
        list($data, $this->catinfo) = $model->getOneData($this->id);
        if (empty($data)) {
            XHandle::halt("对不起，信息不存在！", "", 1);
        }
        unset($model);
        if (!empty($data['tpldetail'])) {
            $this->_tplname = $data['tpldetail'];
        }
        else {
            if (!empty($this->catinfo['tpldetail'])) {
                $this->_tplname = $this->catinfo['tpldetail'];
            }
            else {
                $this->_tplname = $this->catinfo['mod_tpldetail'];
            }
        }

        $this->_tplfile = $this->getTPLFile($this->_tplname);

        $this->treeid = intval($this->catinfo['treeid']);
        $this->rootid = intval($this->catinfo['rootid']);
        $thepath = M("category", "im")->getCategoryUrl($data['catid'], 1);

        list($page_title, $page_description, $page_keyword) = XSeo::buildSeo("ch_about_detail", $data, $this->catinfo);
        $var_array = array(
            'about'=>$data,
            'thepath'=>$thepath,
            'page_title'=>$page_title,
            'page_keyword'=>$page_keyword,
            'page_description'=>$page_description,
            'id'=>$this->id,
            'treeid'=>$this->treeid,
            'rootid'=>$this->rootid,
        );
        $this->view($var_array, $this->_tplname);
    }
}
?>
