Пример #1
0
 function __construct()
 {
     parent::__construct();
     $arr = getModelFilterByNodeSetting();
     if (is_array($arr)) {
         $this->_filter = $arr;
     }
 }
Пример #2
0
/**
 +----------------------------------------------------------
* D函数用于实例化Model 格式 项目://分组/模块
+----------------------------------------------------------
* @param string name Model资源地址
 +----------------------------------------------------------
* @return Model
 +----------------------------------------------------------
*/
function D($name = '')
{
    if (empty($name)) {
        return new Model();
    }
    //新存储一个模型名称
    $modelname = $name;
    static $_model = array();
    if (strpos($name, '://')) {
        // 指定项目
        $name = str_replace('://', '/Model/', $name);
    } else {
        $name = C('DEFAULT_APP') . '/Model/' . $name;
    }
    if (isset($_model[$name])) {
        $model = $_model[$name];
        $arr = getModelFilterByNodeSetting($modelname);
        if (is_array($arr) && count($arr)) {
            $model->setProperty('_filter', $arr);
        }
        return $model;
    }
    import($name . 'Model');
    $class = basename($name . 'Model');
    if (class_exists($class)) {
        $model = new $class();
    } else {
        $model = new Model(basename($name));
    }
    $arr = getModelFilterByNodeSetting($modelname);
    if (is_array($arr) && count($arr)) {
        $model->setProperty('_filter', $arr);
    }
    $_model[$name] = $model;
    return $model;
}