<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * 自动加载
 */
if(!defined('GROWTH_DIR')) {
    throw new Exception("没有定义常量：GROWTH_DIR");
}

class Growth {
    public function __construct(){

    }
    
    public static function getDir() {
        return GROWTH_DIR;
    }
    
    public static function getCoreLibDir() {
        return GROWTH_DIR.'../../../core/lib/';
    }
}

class ClassAutoloader {
        public function __construct() {
            spl_autoload_register(array($this, 'loader'));
        }
        private function loader($className) {
            $core_lib_dir = Growth::getCoreLibDir();
            $web_model_dir = GROWTH_DIR.'../../model/';
            $moduleName = strtolower(substr(get_class($this), 0, '-15'));
            $libGrowth = $core_lib_dir."/$moduleName/".$className.'.php';
            $modelGrowth = $web_model_dir."/$moduleName/".$className.'.php';
            if(file_exists($libGrowth)) {
               $this->loadFile($libGrowth);
            } else if (file_exists ($modelGrowth)) {
                $this->loadFile($modelGrowth);
            }
            
        }
        private function loadFile($filename) {
            include_once $filename;
        }
    }

class GrowthClassAutoloader extends ClassAutoloader {
    }
new GrowthClassAutoloader();
//
class BlockClassAutoloader extends ClassAutoloader {
    }
new BlockClassAutoloader();

class StreetClassAutoloader extends ClassAutoloader {
    }
new StreetClassAutoloader();
include_once Growth::getCoreLibDir().'/SqlCombinHelper.php';
include_once Growth::getCoreLibDir().'/CommonBase.php';
include_once Growth::getCoreLibDir().'/broker/BrokerGroup.php';
include_once Growth::getCoreLibDir().'/OperateRecord.php';
$operateRecord = new OperateRecord($db_sys, $conf_cityflag);
include_once Growth::getCoreLibDir().'/broker/BrokerGroup.php';
//include_once CORE_LIB.'/block/BlockLevelHeatSetting.php';
include_once Growth::getCoreLibDir().'/MCache.php';
$MCache = new MCache($conf_city,true);//第二个参数表示是否开启缓存
//include_once Growth::getCoreLibDir().'/growth/Container.php';
$container = Container::getInstance();
$container->set('db', $db);
$container->set('dbback', $dbback);
$container->set('mc', $MCache);

?>
