shopex 程序执行流程:
$this->system->loadModel('goods/productCat'); ----> E:\web\nikeshoes\core\kernel.php 里面的函数

index.php 入口文件
--> shopCore.php
->$GLOBALS['system'] = &$this; 获取当前对象
->require('core\include_v5\defined.php');
->require 引入 core\include_v5\setmgr.php // 和 sdb_settings表 相关的操作。
->$this->__setting = new setmgr;
->$this->system =&$GLOBALS['system'];
->set_timezone($tz) 设置中国时区的时间。
-> $system=&$GLOBALS['system']; 引用赋值

构造函数运行完, 调用shopCore.php 的run
-->$this->run( ); //函数最后获取完整的 $output 网页代码并输出。
-> $request = $this->parseRequest( ); 返回域名 和 域名后面的字符串 //保存 域名和 get 请求过来的信息、
-> 进入函数 $page =& $this->_frontend( $request ); ----- shopCore类 函数 //引入php 文件。 调用控制器方法。
-> 引入 core/func_ext.php
-> 引入 core\include_v5\shopPage.php 和 pageFactory.php
-> 调用 kernel 的 callAction() 函数
-> 根据参数载入不同的控制器文件; 控制器目录: E:\web\nikeshoes\core\shop\controller\
-> 通过参数调用指定的 函数。

//E:\web\nikeshoes\core\shop\controller\

进入控制器操作
1、将需要输出的数据保存在 $this->pagedata 数组里。
2、$this->getGlobal($this->seoTag,$this->pagedata); 将数据 传递给父类 shopPage.php
3、进入shopPage.php 的output 函数里面。
//E:\web\nikeshoes\core\include_v5\shopPage.php
--> $theme 包含模板相关的信息。 $theme = $oTemplate->applyTheme( constant( "TPL_ID" ) );
--> $this->runtime['theme_dir'] //themes/Mbaobao 模板文件夹名称
//$this->__tmpl ---> user:Mbaobao/gallery.html
--> $output = $this->fetch( $this->__tmpl, false );//$output 输出网页源码
--> 调用父类 fetch() 函数 // E:\web\nikeshoes\core\include_v5\pageFactory.php
--> 调用 pageFactory.php 的 _fetch_compile 返回 $output 生成的网页字符串。
--> $file_contents = file_get_contents( $file ); // 读取 $file 文件内容
--> $this->_compile_obj //初始化对象: E:\web\nikeshoes\core\model_v5\system\mdl.tramsy.php
--> $output 将模板文件的 smarty 语法转换为 php 语法。
// 调用插件 tpl_function_widgets(array('id' => "max-topnav"), $this);
--> 引入: CORE_DIR.'/include_v5/smartyplugins/function.widgets.php';
--> 运行php字符串里的php代码 : eval( " ?>".$output );

-- 模板文件一般需要注意的 smarty 三种语法
<{require file="block/header.html"}> -----> 读取模板文件的smarty 生成php ,运行, 调用插件 , 读取数据库,生成html 字符串。
<{widgets id="max-topnav"}> -----> 调用插件 , 读取数据库,生成字符串。
<{main}> -----> 进入core 的shop文件夹。 找到相应的控制器方法和html页面。执行生成。
这三类 语法。调用不同的php函数
<{require file="block/header.html"}> 调用函数:
$this->_fetch_compile_include($this->_get_resource('user:'.$this->theme.'/'."block/header.html")?('user:'.$this->theme.'/'."block/header.html"):('shop:'."block/header.html"), array());

<{widgets id="max-topnav"}> 调用函数:
echo tpl_function_widgets(array('id' => "max-topnav"), $this);

<{main}> 调用函数:
$this->_fetch_compile_include($this->template_exists('user:'.$this->theme.'/view/'.$this->_vars['_MAIN_'])?'user:'.$this->theme.'/view/'.$this->_vars['_MAIN_']:'shop:'.$this->_vars['_MAIN_'], array());

 

插件调用:

 

E:\web\nikeshoes\core\include_v5\smartyplugins\function.widgets.php
执行 tpl_function_widgets 函数
--> E:\web\nikeshoes\core\model_v5\content\mdl.widgets.php
--> 执行load函数
//读取插件的widgets.php文件 并加入 $setting["type"] = $widgets['widgets_type'] ;
--> $env = $this->getWidgetsInfo( $widgets['widgets_type'] );
--> $this->system 是 core\kernel.php
--> $this 是当前类。 436
--> 调用函数 fetch(); 函数 引入 widget_".$widgets['widgets_type'].".php"; 文件。
--> 调用与php文件 同名函数。 $this->smarty->pagedata['data'] 获取返回值。

widgets_974
goods/default.html


widgets 调用:
require(CORE_DIR.'/include_v5/smartyplugins/block.capture.php');
require(CORE_DIR.'/include_v5/smartyplugins/function.link.php');
require(CORE_DIR.'/include_v5/smartyplugins/modifier.storager.php');
require(CORE_DIR.'/include_v5/smartyplugins/modifier.escape.php');
require(CORE_DIR.'/include_v5/smartyplugins/modifier.cut.php');
require(CORE_DIR.'/include_v5/smartyplugins/modifier.styleset.php');
require(CORE_DIR.'/include_v5/smartyplugins/function.goodsmenu.php');
$CURRENCY = &$this->system->loadModel("system/cur");

 

$this->_vars['data'] 保存php模板返回的数据
echo $this->_vars['data']['goods_num'];
相关函数:
tpl_block_capture

 

模板里的 smarty 函数 : <{link .... }> 调用
E:\web\nikeshoes\core\include_v5\smartyplugins\function.link.php (1 hit)
tpl_function_link(

 

 

 插件流程

E:\web\nikeshoes\core\model_v5\system\mdl.tramsy.php 进入函数。
--> public function &_compile_file( &$file_contents ) 将插件里的html 文件里的所有smarty 代码获取。并循环生成数据,
--> $argments = $this->_parse( $v, $bundle_var_only );smarty 变量转成 php 变量。
--> $_result = $this->_parse_function( $func, $argments, $bundle_var_only ); smarty 函数转成php 函数
--> 进入 _parse_function 函数
--> 进入 _compile_custom_function 函数
//E:\web\nikeshoes\core\include_v5\template\compile.compile_custom_function.php
--> 进入 compile_compile_custom_function() 函数
-->_plugin_exists 进入函数 mdl.tramsy.php ; 返回 php函数代码

 

E:\web\nikeshoes\core\include_v5\template\compile.plugin_path.php 改一下配置