• 研究ecmall一些流程、结构笔记 (转)


    index.php
    ECMall::startup() //ecmall.php

    object //所有类的基础类 ecmall.php
    BaseApp //控制器基础类 app.base.php
    ECBaseApp //ecapp.base.php
    FrontendApp //前台控制器基础类 frontend.base.php
    MallbaseApp //商城控制器基类 frontend.base.php
    default.app.php //以上的类是defaultApp类的父类

    根目录表示@(在这表示wwwroot/ecmall)
    @index.php(根目录下的index.php文件,即wwwroot/ecmall/index.php)


    @index.php(加载配置文件config.inc.php和核心文件ecmall.php)
    =>ECMall::startup();
    =>ecmall.php
    =>startup();
    =>require(ROOT_PATH.'/app'."/{$app}.app.php");(加载控制器,默认为default.app.php)
    =>do_action();(DefaultApp类的方法)
    =>default.app.php
    =>do_action();(do_action在,defaultApp父类MallbaseApp的父类FrontendApp的父类ECBaseApp中,
    其中类MallbaseApp和类FrontendApp在frontend.base.php文件中,ECBaseApp类在ecapp.base.php文件中)
    =>parent::do_action();(即类ECBaseApp的父类BaseApp的成员函数do_action()(不是静态成员,若为静态成员parent改为类名),
    其中BaseApp类在app.base.php文件中)
    =>_run_action();
    =>$this->$action();($action=$this->_curr_action,在这是等于index)





    deault.app.php(DefaultApp类)
    =>index();
    =>$this=>assign();
    =>app.base.php(BaseApp类)
    =>assign();
    =>_init_view();
    =>$this->_view=& v();
    =>ecmall.php(object类)
    =>& v();(加载了/eccore/view/template.php,ecsTemplate类)
    =>app.base.php(BaseApp类)
    =>$this->_view->assign();(此时的$this->_view为ecsTemplate类的一个实例)
    =>template.php(ecsTemplate类)
    =>assign();
    =>$this->_var[$key]=$val;


    > default.app.php(DefaultApp类)
    =>display()
    =>frontend.base.php
    =>display()


    seo(即title,description,keywords)
    $this->_config_seo(array('title'=>'...',...));//设置title标签的
    =>ecapp.base.php(ECBaseApp类)
    =>_config_seo();
    =>_assign_seo();
    =>_get_seo_code();//生成html代码,如$html.="<{$type}>{$info}</{$type}>";





    frontend.base.php(FrontendApp类,line 17-18)
    加载lang配置文件,
    Lang::load(lang_file('common));
    //加载了每个应用的配置
    Lang::load(lang_file(APP));
    ecmall.php()
    =>lang_file();ROOT_PATH . '/languages/' . LANG . '/' . $file . '.lang.php';(config.inc.php中'LANG'=>'sc-utf-8')
    ecapp.base.php(ECBaseApp类)
    =>加载了Conf配置,在line 114,Conf::load($setting->getAll());



    初始化方向
    ecmall.php(122,require($app_file,如default.app.php))
    =>default.app.php(DefaultApp类)
    =>frontend.base.php(类MallbaseApp和类FrontendApp)
    =>MallbaseApp
    =>FrontendApp
    Lang::load(lang_file('common'));
    Lang::load(lang_file(APP));
    =>ecapp.base.php(ECBaseApp类)
    =>ECBaseApp
    ->$setting=af();加载了/includes/arrayfile.base.php和/include/arrayfiles/$type(如,settings).arrayfile.php
    ->$setting->getAll();执行了settings.arrayfile.php中get_default()和arrayfile.base.php中的_loadfromfile();
    $this->_init_visitor();(Line116)(但执行了frontend.base.php中的FrontendApp类的成员函数_init_visitor(),跟
    frontend.base.php中的类UserVisitor和ecapp.base.php中的类BaseVisitor相关)
    =>app.base.php(BaseApp类)
    =>BaseApp
    $this->_init_session();//$GLOBALS['EC_ENV']
    =>ecmall.php(object类)


    ecapp.base.php(line 146)
    env('session',$this->_session);//实现$GLOBALS['EC_ENV']['session']=$this->_session;


    app.base.php()
    ->display
    ->_init_view();
    ->_config_view();//ecapp.base.php



    模板文件夹themes/mall/default
    控制器存放文件夹/app
    模板编译文件夹temp/compiled



    default.app.php(display())
    =>template.php()
    ->display();
    ->fetch();
    ->make_compiled();
    ->fetch_str();
    ->smarty_prefilter_preCompile(); //去除<!-- -->,提取{}里面的内容,把它发送到select();函数中去
    ->select(); //解析{}里面内容



    login.html
    有一表单action属性的值为空则当前action的值为当前窗口的url




    登陆验证码
    settings.arrayfile.php
    需'captcha_status'=>array('login'=>1),默认是空数组
    FrontendApp::login();
    if(Conf::get('captcha_status.login')){$this->assign('captcha',1);}
    login.html
    包含如下代码,即$captcha为真时,则显示验证码代码,为非真时则不执行验证码代码
    < !--{if $captcha}-->
    <tr><td>{$lang.captcha}:</td>
    < td><input type="text" name="captcha" class="text" id="captcha1" />
    < span><a href="javascript:change_captcha($('#captcha'));" class="renewedly">
    < img id="captcha" src="index.php?app=captcha&{$random_number}" /></a>
    < /span></td>
    < /tr>
    < !--{/if}-->







    模型
    ecmall.php
    & db();创建MySql数据库对象实例
    include_once(ROOT_PATH.'/eccore/model/mysql.php');
    return new cls_mysql();
    & m();获得一个模型
    ROOT_PATH.'/includes/models/'.$model_name.'.model.php';
    return new $model_name($params,db());

    global.lib.php
    & ms();会员系统连接接口
    include(ROOT_PATH.'/includes/passport.base.php')
    //config.inc.php,MEMBER_TYPE=>'default',default(使用内置的用户系统)
    include(ROOT_PATH.'/include/passports/'.MEMBER_TYPE.'.passport.php');
    return new ucfirst(MEMBER_TYPE).'Passport';

    联接
    自定模型属性$_relation=array();

    在某模块中查询数据,如$this->_user_mod->find(array(..,'join'=>'..,..',..));
    BaseModel::find();
    $this->_joinModel($tables,$join);
    $this->_getJoinString($_im);

    $_relation['dependent']='true'。如果该在member模型定义与store模型关系。则意思即,store属于(belong to)member。
    store模型对参考模型的依赖,删除时用到

    has_one,belongs_to 在自定义模型设置的模型关系。区别在BaseModel::_getJoinString();函数中,如果是HAS_ONE,
    则$refer_key=$this->$prikey;如果是BELONGS_TO,则$refer_key=$model->$prikey; $prikey是在自定义模型里设置的变量,$this和$model分别是这两个模型
    关系分别关联的模型的实例的引用

    reverse,是在type为belongs_to关系中,值是为一个自定模型的关系名称。如果在member.model.php有$_relation(..,'manage_store'=>array('model'=>'store','reverse'=>'be_manage',..),..);
    则M('store')的$_relation属性中就有be_manage关系。

    has_one
    本表参考键=外表外键
    belongs_to
    本表外键=外表参考键
    has_and_belongs_to_many
    本表主键=中间表外键

    中间表意思就是这个表是两个表之间的关系表,如会员表跟角色表的关系表就是中间表,这个表必须包含有这两个表的主键,如果会员表
    名为user而角色表名为role则中间表为user_role













    后台的登陆页,/ecmall/admin/index.php
    =>ECMall::startup();
    =>ecmall.php
    =>startup();
    =>require(dirname(__FILE__).'/app'."/{$app}.app.php");(加载控制器,默认为default.app.php)
    =>do_action();(do_action在,defaultApp父类MallbaseApp的父类FrontendApp的父类ECBaseApp中,
    其中类MallbaseApp和类FrontendApp在frontend.base.php文件中,ECBaseApp类在ecapp.base.php文件中)
    =>app.base.php
    =>do_action();ECBaseApp类父类BaseApp的方法)
    =>backend.base.php
    =>_run_action();
    =>$this->login();或parent::_run_action();(ecapp.base.php)

    ***********************************************************************************************************************

    模板
    显示挂件
    template::display_widgets();
    FrontendApp::display_widgets();
    include_once '/includes/widget.base.php';
    & widget(); //widget.base.php
    include_once('external/widgets/'.$name.'/main.widget.php'); //$name值如,notice
    return new $name.'Widget'();
    BaseWidget::BaseWidget();
    $this=id,widget_path,widget_root,_view,_view->lib_base,options;
    assign=options,widget_root,id,name
    $widget->display(); //frontendApp::display_widgets();$widget=new $name.'Widget'();
    BaseWidget::display();
    echo BaseWidget::get_contents();
    BaseWidget::get_contents();
    NoticeWidget::_get_data();
    assgin=widget_data,options,widget_root
    BaseWidget::_wrap_contents();


    ***********************************************************************************************************************
    eccore/ecmall.php
    class Object function _error($msg,$obj=''); //eccore/model/model.base.php中有实例

  • 相关阅读:
    HBase Coprocessor 剖析与编程实践
    图数据库实践系列 (一)Neo4J简介与安装
    BootStrap入门教程 (三)
    图数据库实践系列 (三)Neo4j Spatial的REST集成
    BootStrap入门教程 (二)
    R与GIS实践系列Shapefile导入与地图显示
    空间分析读书笔记
    BootStrap入门教程 (四)
    Java并发之线程池的使用浅析
    RSA详解
  • 原文地址:https://www.cnblogs.com/xihong2014/p/4298068.html
Copyright © 2020-2023  润新知