ECMall requests and system redirects. Ecmall is a framework system based on the mvc mode, which is a bit like thinkphp. Starting from the ecmall entry point, the ecmall entry file uploadindex. php, admin. php: index. php starts the ecmall front-end. starting ecmall is a mvc-based framework system, which is a bit like thinkphp. Starting from the ecmall entry, the ecmall entry file upload/index. php and admin. php:
Index. php starts the ecmall front-end, and then enters the ecmall framework core file ecmall. php. ecmall. php is equivalent to a scheduling center. it receives different control commands (apps) and command-related operations (funciton), and then allocates them for processing. The scheduling center then uploads these commands and functions to the specific controller corresponding to the foreground control center. After the "controller" receives the command, it implements the execution control and sends the processed result to the view template file (the template naming rule is appname.fucname.html ).
When the controller receives the command execution, it can call the model acquisition method of the scheduling Center & m () to instantiate a model and perform the data curd operation.
Index. php:
Include (ROOT_PATH. '/eccore/ecmall. php ');/* start ECMall */ECMall: startup (array ('default _ app' => 'default', 'default _ AC' => 'index ', 'app _ root' => ROOT_PATH. '/app', // The basic class required for loading the system 'external _ Libs' => array (ROOT_PATH. '/regiondes/global. lib. php', ROOT_PATH. '/regiondes/libraries/time. lib. php', ROOT_PATH. '/shortdes/ecapp. base. php', ROOT_PATH. '/uplodes/plugin. base. php', ROOT_PATH. '/app/frontend. base. php ',),));
Ecmall. php:
Class ECMall {/* start */function startup ($ config = array () {/* load the initialization file */require (ROOT_PATH. '/eccore/controller/app. base. php '); // basic controller class require (ROOT_PATH. '/eccore/model. base. php '); // model base class if (! Emptyempty ($ config ['external _ Libs']) {foreach ($ config ['external _ Libs'] as $ lib) {require ($ lib );}} /* data filtering */if (! Get_magic_quotes_gpc () {$ _ GET = addslashes_deep ($ _ GET); $ _ POST = addslashes_deep ($ _ POST); $ _ COOKIE = addslashes_deep ($ _ COOKIE );} /* request forwarding */$ default_app = $ config ['default _ app']? $ Config ['default _ app']: 'default'; $ default_act = $ config ['default _ AC']? $ Config ['default _ act ']: 'index'; $ app = isset ($ _ REQUEST ['app'])? Trim ($ _ REQUEST ['app']): $ default_app; $ act = isset ($ _ REQUEST ['AC'])? Trim ($ _ REQUEST ['AC']): $ default_act; $ app_file = $ config ['app _ root']. "/{$ app }. app. php "; if (! Is_file ($ app_file) {exit ('missing controller');} require ($ app_file); define ('app', $ APP); define ('AC ', $ act); $ app_class_name = ucfirst ($ app ). 'app';/* instantiate the controller */$ App = new $ app_class_name (); c ($ app); $ app-> do_action ($ act ); // forward the file to the corresponding Action $ app-> destruct () ;}// determine whether to load the corresponding controller file based on the parameters following the app, the class file is in the app folder, and the corresponding name is the same as the parameter. the parameter after act is the action corresponding to the operation method in the controller to process the request // and there is a judgment in the action: if (! IS_POST) {display of the page content before the request} else {form processing after the request and page jump after the processing is complete }. Which includes processing data in json format. // Here, we need to propose: $ this-> assign ('order', $ order_info) in the controller ); // pass the value of the required parameter to the template page $ this-> display('buyer_order.confirm.html '); // the page to jump to $ this-> json_result ($ new_data, 'confirm _ order_successed '); // use json to pass parameters, and then use javascript to process request redirects on the page
Because of this mechanism, you can add apps, modules, and plug-ins to ECMALL. How can I add my own APP to ECMALL? For example, the access address is http://xxx.com/index.php? App = hello
- Create an application file named hello. app. php in the app directory of ecmall.
- Create the corresponding language file hello. lang. php in the sc-utf8 directory of ages and return the array (if not set up, an error will occur)
- The class in hello. app. php is HelloApp and inherits the FrontendApp
- This is a front-end program. a hello.index.html template file is created under the themes/mall/defaultfolder of ecmall.
- Override the default index method and use the template to output the result:
$h = "Hello"; $this->assign("h",$h); $this->display('hello.index.html');
- Write other methods such as the access address is http://xxx.com/index.php? App = hello & act = test
This URL accesses the test method in the app class named hello, actually http://xxx.com/index.php? App = hello the index method is accessed by default.
// 1. create a test. app. php file under upload/app /.
'; $ Uc_words = ucwords ($ str ).'
'; $ Model = & m ('Goods'); $ res = $ Model-> get (27); print_r ($ res ); $ this-> assign ('SS', $ uc_first); $ this-> assign ('SS', $ uc_words); $ this-> display('test.index.html ') ;}}?> // 2. create a test. lang. php under upload/languages/sc-utf-8/
// 3. create a test.index.html file in upload/themes/mall/default /.
Admin. php this is to start the ecmall background. After it is started, enter the core file ecmall. php of the ecmall framework. The subsequent operations are similar to those at the front-end. The difference is that the scheduling center sends commands to the "back-end" control center. However, the model called by the controller is the same model Center.
Bytes. Starting from the ecmall entry, start the ecmall entry file upload/index. php and admin. php: index. php to start the ecmall front-end and start...