PHP Classes

PageLogic: A way to organize files in a web module

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 933 This week: 1All time: 3,836 This week: 560Up
Version License Categories
pagelogic 1.0GNU General Publi...Files and Folders
Description 

Author

I have written modules for webservers with so many php/html files that I lost track, so I come out with this simple module to simplify the logic among pages.

Imagine my module is a book, with many chapter inside.

-- The book is the main page, normally index.html or index.php.
-- The module comprises of many files, each file performs some functions.

Thus file is equivalent to a chapter.
-- Each file may contain several functions. This are the sections in the
chapter.

Imagine if I can say goto this book, this chapter and this section. I will need a content page to look up the pages. Thus the idea is formed.

The content pages is stored in an .ini format and read in using my INIPARSER class. It will be in the form:

[<LOGIC NAME>]
<action>=<php function name>
<action>=<php function name>, <file name>
<action>=<php function name>, <file name>, <file name 2> ...

If I hit the page with the action text embedded through
index.php?action="..."
or
<input type=hidden NAME="action" VALUE="...">

The index.php will just call up the function I want.

I hope that this will help to modularize your php codes as well.

Picture of Mark Quah
Name: Mark Quah <contact>
Classes: 7 packages by
Country: Singapore Singapore
Age: ???
All time rank: 2601 in Singapore Singapore
Week rank: 411 Down1 in Singapore Singapore Equal

Details

QUICK START ----------- Study the demo ONEFILE_SAMPLE.PHP to see how the logic is set up. Before you proceed to the more complicated multiple-file sample. You just need the file ONEFILE_SAMPLE.PHP and class_pagelogic.php to start. You also need the class_iniparser.php which is the base class of pagelogic. Get from here: http://www.phpclasses.org/browse.html/file/2889.html PAGELOGIC Framework ------------------- I have written modules for webservers with so many php/html files that I lost track, so I come out with this simple module to simplify the logic among pages. Imagine my module is a book, with many chapter inside this. -- The book is the main page, normally index.html or index.php. -- The module comprises of many files, each file performs some functions. Thus file is equivalent to a chapter. -- Each file may contain several functions. This are the sections in the chapter. Imagine if I can say goto this book, this chapter and this section. I will need a content page to look up the pages. Thus the idea is formed. The content pages is stored in an .ini format and read in using my INIPARSER class. It will be in the form: [<LOGIC NAME>] <action>=<php function name> <action>=<php function name>, <file name> <action>=<php function name>, <file name>, <file name 2> ... <action>=http://<web url> If I hit the page with the action text embedded through index.php?action="..." or <input type=hidden NAME="action" VALUE="..."> The index.php will just call up the function I want. Hope that this will help to modularize your php codes as well. Rgds, Mark FLOW CHART: MAIN PAGE --------------------- 1. ##### INITIALIZE Initialize form logic from sample_main.dat 2. ##### DATA PREPARATION Determine the action field, in this case I uses the the form variable: $HTTP_POST_VARS['form_action'] 3. ##### CALL OUT FORM LOGIC The action will be parsed in the FORMLOGIC, if a match is found, called up the respective function FLOW CHART: DISPLAY PAGE ------------------------ 1. ###### PREPARE DATA a. Get data to be displayed in the field b. The data fields are specified as {field_name} c. The action button called up a SUBMIT('ACTION'} button. The SUBMIT is an JS script that set the FORM field: form_action variable. Initialze by $sqlform->SetForm('FORM_NAME', $HTTP_SERVER_VARS['PHP_SELF'], 'form_action', 'POST'); the $sqlform->item['FORM_NAME']['JSSUBMIT'] will contain the function. Use {FORM_JSSUBMIT} to embed this into HTML template. Then use $sqlform->UpdateCat('HTML_TEMPLATE', 'FOMR_NAME') to replace the field in HTML_TEMPLATE. The other important component is the FORMSTART component, it gives: <FORM NAME='FORM_NAME' ACTION='filename' METHOD='POST' $extension> <INPUT TYPE=HIDDEN NAME='form_action'> which is the form that the action logics is transfered to. 2. ###### GET HTML TEMPLATE AND MERGE DATA FIELD a. Get HTML template from a file. b. Use the INIPARSER to replace {} fields in the template. 4. ###### DISPLAY HTML FLOW CHART: PROCESS PAGE ------------------------ 1. ###### PROCESS DATA a. Get data from the $HTTP_POST_VARS[] b. Process the data 2. ###### OUTCOME a. Detemine the outcome and generate approriate response. Type 1: Jump back direct: <script> alert('ERROR MESSAGES'); SUBMIT('') </script> Type 2: Display a page and wait there: echo "Error<BR>"; echo <A HREF=....></A>

  Files folder image Files  
File Role Description
Plain text file class_pagelogic.php Class Create interlinking web pages with index from an .ini file.
Accessible without login Plain text file ONEFILE_SAMPLE.PHP Example Display different html pages using one single file.
Accessible without login Plain text file README.TXT Doc. Explanation about PageLogic

 Version Control Unique User Downloads Download Rankings  
 0%
Total:933
This week:1
All time:3,836
This week:560Up