From the closed university, it is time to re-exposure to the time of changing society, can't help but shed tears, while standing in place in this world. From my brother, I heard the concept of Mode2 and MVC. When I started watching MVC's articles, I still have a long-lost enthusiasm, huh, huh. After understanding the feasibility of the MVC model, I intend to apply MVC to their own graduation design (web trading platform), which is a good practical opportunity. There are many PHPs on the Internet to implement the MVC articles, but there are many implementation frames, but they can understand the MVC's connotation (in fact, it is lazy to see the headache "English document: P), so I plan to write an MVC framework, temporary Call him pitt, below is Pitt framework outline: FrontController - -> ActionManager1 -> [ActionNode -> ActionNode] -> PageMaker | -> ActionManager2 -> ......... -> ActionManager3 -> ......... FrontController implements FrontControlr in Mode2 to call different behaviors according to user requests, and a behavior and multiple ActionNode components ActionManager implementationManager implements Controler control, management, calling an actionNode chain and PagemakeractionNode chain implements a local location, such as database operation, sort, calculation, etc. PageMaker implements the View according to the .tpl file generated HTML, sending it to the client ActionNode is the minimum unit of logic, such as landing this behavior, just starting my Login request requires Name and Password, for this, I need to create an actionNode, named checknamepassnode, and override the _execute method, implement the correctness check of Name and Password, and later, I can use two middle methods due to the verification code. Implement the verification code detection function 1, derive the checknamepassnode class, rewritten _execute method.
Class AdvCheckNamePassNode Extends ChecknamePassNode {..... Function_execute ($ Parameter) {if (...) // Here you check the accuracy of the verification code {Parent :: _ Execute ($ parameter); // Call superclass _execute Method, complete the correctness detection of the original // Name and Password} else {... // verification code error}}} 2, create a new actionNode, named CheckNumbernode Class CheckNumbernode Extends ActionNode {... function _execute $ parameter) {... // completes the check code of the verification code}} then add this ActionNode in the ActionManager configuration file, and deployed before checknamepassnode, I will write a few class code I have written out, due to There is no truly definition of these classes, so the code may change frontControl.php at any time.
phpRequire "request // get.php"; Class FrontController {var $ _key = "do"; var $ AMF; var $ ActionMApping; var $ action;
Function setkey ($ k) {$ this -> _ key = $ k;} function setamf ($ f) {$ this-> amf = $ f;
Function Getamf ($ f) {Return $ this-> AMF;}
Function getKey () {RETURN $ this -> _ key;} function setActionmapping () {$ AMF = $ this-> amf; if (file_exists ($ av)) {Require $ AMF; return true;} else returnaf;} GetActionMapping () {Return $ this-> anctionMApping;
Function LaunchactionManager ($ AM) {if (! Empty ($ AM)) {$ CLSFL = $ AM. ". PHP"; if (File_exists ($ CLSFL)) {Require $ CLSFL; $ ACTMNG = New $ AM; $ ACTMNG init ($ this); $ actmng.start (); return true;}}}} function getActionManagernameFromkey ($ k) {if (! Empty ($ k)) {if (Array_Key_Exists ($ K, $ this-> actionMapping) {RETURN $ this-> actionmapping [$ k];} else return false;} function getRequestActionName ($ SK = $ this -> _ key; if (array_key_exists ($ SK) , Get :: getget ()) {return get :: getValue ($ this -> _ key);}} function getRequestData ()} function getRequestData () {return $ _POST;} function _init () {} function _EXECUTE ) {/ * Todo here * /}}
?>
Get.php // encapsulated $ _GET class get {function getValue ($ key) {return $ _GET [$ key];} function getGet () {return $ _get;} function keyexist ($ key) {if (array_key_exist ($ KEY, $ _ get)) Return True; Return False;}}?>
Post.php // Package $ _POST Class Post {Function getValue ($ key) {return}} function getpost () {returnction getpost () {RETURN $ _POST;} Function Keyexist ($ key) {ix (array_key_exist ($ KEY, $ _ POST)) RETURN TRUE; RETURN FALSE;}}?>
Request.php // Package $ _GET and $ _POST Collection Class Request {Var $ Request; function request () {$ this-> request = $ _ post $ _ get;} Function getValue ($ key) {Return $ THIS -> Request [$ Key];} Function Keyexist ($ key) {if (Array_Key_Exist ($ KEY, $ THIS-> Request) RETURN TRUE; RETURN FALSE;}}?>
Parameter.php // Implement the parameter class, is the event delivery between ActionNode Class Parameter {var $ Para; Function AddParameter ($ KEY, $ VALUE) {$ this-> para [$ key] = $ value;} function RemoveParameter ($ this-> Isexists ($ key)) {$ keys = array_keys ($ this-> para); $ index = array_search ($ key, $ key); array_splice ($ this-> para , $ index, 1);}} Function ISPAREXISTS ($ key) {if (Array_Key_Exists ($ Key, $ THIS-> Para)) Return True; Return False;} Function getpara () {Return $ this-> para;} Function makeparameter ($ a) {$}}?> The above classes I think the problem is not big. In fact, I am more blurred, huh, huh, I will write it on February 20, 2005. Day 2:08:50