1: | <?php |
2: | /** |
3: | * page class |
4: | * |
5: | * This class is parent class of all page application. You can Develop SartajPHP Application with extend |
6: | * of this class or simple use SphpBase::page() function to implement page object in any php module. |
7: | * |
8: | * @author Sartaj Singh |
9: | * @copyright 2007 |
10: | * @version 4.4.4 |
11: | */ |
12: | namespace Sphp\kit{ |
13: | class Page { |
14: | public $authentication = false; |
15: | public $issubmit = false; |
16: | public $isview = false; |
17: | public $isnew = false; |
18: | public $isdelete = false; |
19: | public $isinsert = false; |
20: | public $isupdate = false; |
21: | public $isaction = false; |
22: | public $isevent = false; |
23: | public $act = ""; |
24: | public $sact = ""; |
25: | public $evtp = ""; |
26: | public $txtid = ""; |
27: | public $apppath = ""; |
28: | public $appfilepath = ""; |
29: | public $appobj = null; |
30: | public $tblName = ""; |
31: | public $auth = ""; |
32: | public $masterfilepath = ""; |
33: | public $isSesSecure = false; |
34: | /** |
35: | * Advance No Use |
36: | * @depends start |
37: | */ |
38: | /** Advance |
39: | * Overload, Event Handler For App Type development |
40: | */ |
41: | public function page_init() {} |
42: | /** Advance |
43: | * Overload, Event Handler For App Type development |
44: | */ |
45: | public function page_load() {} |
46: | /** Advance |
47: | * Controller Event handler like (url=index-page-contacts.html) |
48: | * this function gives $event = page and $evtp = contacts |
49: | * @param string $event |
50: | * @param string $evtp |
51: | */ |
52: | public function page_event($event, $evtp) {} |
53: | /** Advance |
54: | * Custom action designer. Default value delete or view or evt. |
55: | * like for events value = evt |
56: | * @param string $act |
57: | * @param string $event |
58: | * @param string $evtp |
59: | */ |
60: | public function page_action($act, $event, $evtp) {} |
61: | /** Special Event |
62: | * Delete Event Handler, occur when browser get (url=index-delete.html) |
63: | * where index is controller of application and application path is in reg.php file |
64: | */ |
65: | public function page_delete() {} |
66: | /** Special Event |
67: | * View Event Handler, occur when browser get (url=index-view-19.html) |
68: | * where index is controller of application and application path is in reg.php file |
69: | * view = event name |
70: | * 19 = recid of database table or any other value. |
71: | */ |
72: | public function page_view() {} |
73: | /** Special Event |
74: | * Submit Event Handler, occur when browser post form (url=index.html) |
75: | * where index is controller of application and application path is in reg.php file |
76: | */ |
77: | public function page_submit() {} |
78: | /** Special Event |
79: | * Insert Event Handler, occur when browser post form (url=index.html) as new form |
80: | * where index is controller of application and application path is in reg.php file |
81: | */ |
82: | public function page_insert() {} |
83: | /** Special Event |
84: | * Update Event Handler, occur when browser post form (url=index.html) as filled form |
85: | * from database with view_data function |
86: | * where index is controller of application and application path is in reg.php file |
87: | */ |
88: | public function page_update() {} |
89: | /** Special Event |
90: | * New Event Handler, occur when browser get (url=index.html) first time |
91: | * where index is controller of application and application path is in reg.php file |
92: | */ |
93: | public function page_new() {} |
94: | /** Advance |
95: | * Overload, Event Handler For App Type development |
96: | */ |
97: | public function page_unload() {} |
98: | /** |
99: | * Get Controller Event name of current request |
100: | * @return string |
101: | */ |
102: | public function getEvent() {} |
103: | /** |
104: | * Get Controller Event parameter of current request |
105: | * @return string |
106: | */ |
107: | public function getEventParameter() {} |
108: | /** Advance |
109: | * Overload, Event Handler For App Type development |
110: | */ |
111: | public function readyPage() {} |
112: | /** Advance |
113: | * Overload, Event Handler For App Type development |
114: | */ |
115: | public function init() {} |
116: | /** Advance |
117: | * Overload, Event Handler For App Type development |
118: | */ |
119: | /** |
120: | * Set which user can access this application. Default user is GUEST. |
121: | * You can set session variable in login app |
122: | * SphpBase::sphp_request()->session('logType','ADMIN'); |
123: | * If user is not login with specific type then application exit and |
124: | * redirect according to the getWelcome function in comp.php |
125: | * @param string $auth <p> |
126: | * comma separated list of string. Example:- Authenticate("GUEST,ADMIN") or Authenticate("ADNIN") |
127: | * </p> |
128: | * @return boolean true if user type match with session variable logType, never return false |
129: | */ |
130: | public function Authenticate($auth="") {} |
131: | /** Advance |
132: | * Authorise base on server variables, in session less environment |
133: | * @param string $auth |
134: | * @depends Authenticate |
135: | */ |
136: | public function AuthenticateSVAR($auth="") {} |
137: | /** |
138: | * Check if user type in session logType = unauthorise |
139: | * @param string $param <p> |
140: | * comma separated list of string. Example:- checkUnAuth("GUEST,ADMIN") or checkUnAuth("ADNIN") |
141: | * </p> |
142: | * @return boolean true if user type match with session variable logType |
143: | */ |
144: | public function checkUnAuth($param) {} |
145: | /** |
146: | * Check if user type in session logType = authorise |
147: | * @param string $param <p> |
148: | * comma separated list of string. Example:- checkAuth("GUEST,ADMIN") or checkAuth("ADNIN") |
149: | * </p> |
150: | * @return boolean true if user type match with session variable logType |
151: | */ |
152: | public function checkAuth($param) {} |
153: | /** |
154: | * Read logType session variable as User Type of login user which is set in login app |
155: | * @return string |
156: | */ |
157: | public function getAuthenticateType() {} |
158: | /** Application exit if URL isn't session secure |
159: | *@return Application exit if URL isn't session secure |
160: | */ |
161: | public function sesSecure() {} |
162: | /** |
163: | * Forward request to url |
164: | * @param string $loc <p> |
165: | * pass url address |
166: | * </p> |
167: | */ |
168: | public function forward($loc) {} |
169: | /** |
170: | * Set default Database Engine for execute query and managing connections |
171: | * Default is MySQL |
172: | * @param \MySQL $objdbengine |
173: | */ |
174: | public function setDBEngine($objdbengine) {} |
175: | /** |
176: | * This Function delete the record of database table with generate and execute delete query. |
177: | * DELETE FROM $tblName WHERE id='$evtp' |
178: | * $tblName = default table of application |
179: | * $evtp = getEventParameter() |
180: | * @param string $recid If empty then use event parameter as record id.<br> |
181: | * |
182: | */ |
183: | public function deleteRec($recid="") {} |
184: | /** |
185: | * When Components use Database Binding. Then This Function insert the values to database table from a |
186: | * component value. This insert a new record in table.<br> |
187: | * $extra = array() |
188: | * $extra['table']['datecreate'] = date('Y-m-d) |
189: | * OR |
190: | * $extra[]['datecreate'] = date('Y-m-d) |
191: | * insertData($extra) |
192: | * @param array $extra extra fields to insert with query. |
193: | */ |
194: | public function insertData($extra = array()) {} |
195: | /** |
196: | * When Components use Database Binding. Then This Function Fill the values from database table to a |
197: | * control value.<br> |
198: | * changeable $sql = "SELECT $fldList FROM $tbln $where"<br> |
199: | * $tbln = use defualt tblName of application or controls dtable attribute |
200: | * SphpBase::page()->viewData(,,"WHERE id='1'");<br> |
201: | * SphpBase::page()->viewData('','aname,pass,lst',"WHERE lastname='devel'");<br> |
202: | * @param type $form <p> Form control |
203: | * Read value from database and fill all controls of TempFile object which is bind with field of table. |
204: | * </p> |
205: | * @param string $recID <p> |
206: | * Every table should have unique,auto increment and primary filed and default it has name id. |
207: | * id = record id in table, pass this record id to $recID or if it is empty then it uses SphpBase::page()->getEventParameter() |
208: | * </p> |
209: | * @param string $fldList <p> |
210: | * pass comma separated list of table fields or otherwise it is * |
211: | * </p> |
212: | * @param string $where WHERE Logic in SQL |
213: | * |
214: | */ |
215: | public function viewData($form , $recID = "", $fldList = "", $where = "") {} |
216: | /** |
217: | * When Components use Database Binding. Then This Function Update the values to database<br> table from a |
218: | * control value. This update old record in table.<br> |
219: | * $extra = array() |
220: | * $extra['table']['dateupdate'] = date('Y-m-d) |
221: | * OR |
222: | * $extra[]['dateupdate'] = date('Y-m-d) |
223: | * updateData($extra) |
224: | * @param array $extra extra fields to insert with query. |
225: | * @param string $recID <p> |
226: | * Every table should have unique,auto increment and primary filed and default it has name id. |
227: | * id = record id in table, pass this record id to $recID or if it is empty then it uses SphpBase::page()->getEventParameter() |
228: | * </p> |
229: | * @param string $where WHERE Logic in SQL |
230: | */ |
231: | public function updateData($extra = array(), $recID = '', $where = '') {} |
232: | } |
233: | class DbEngine{ |
234: | /** |
235: | * Fix Bad Format in Query call clearQuery |
236: | * @param string $string |
237: | * @depends clearQuery |
238: | * @return string |
239: | */ |
240: | public function cleanQuery($string) {} |
241: | /** |
242: | * Fix Bad Format in Query |
243: | * @param string $string |
244: | * @return string |
245: | */ |
246: | public function clearQuery($string) {} |
247: | /** |
248: | * Import table data as PHP Code. Override this function when you need to |
249: | * create of database adapter. Default work with MySQL |
250: | * @param string $tablenl <p> |
251: | * Comma Separated string as table names or table name |
252: | * </p> |
253: | * @param string $where <p> |
254: | * where logic for query |
255: | * </p> |
256: | * @return string |
257: | */ |
258: | public function getTableSQL($tablenl, $where = "") {} |
259: | /** |
260: | * List Fields in a Table. Override this function when you need to |
261: | * create of database adapter. Default work with MySQL |
262: | * @param string $tablename <p> |
263: | * pass table name in database |
264: | * </p> |
265: | * @return array |
266: | */ |
267: | public function getTableColumns($tablename) {} |
268: | /** |
269: | * List Tables in Database. execute SHOW TABLES query. Override this function when you need to |
270: | * create of database adapter. Default work with MySQL |
271: | * @return array |
272: | */ |
273: | public function getDbTables() {} |
274: | /** |
275: | * Generate a Table CREATE query. Override this function when you need to |
276: | * create of database adapter. Default work with MySQL |
277: | * @param string $table <p> table name |
278: | * </p> |
279: | * @return string |
280: | */ |
281: | public function getCreateTableSQL($table) {} |
282: | /** |
283: | * Serialize to a filepath |
284: | * @param array|object $data |
285: | * @param string $filename filepath |
286: | * @return boolean on error return false |
287: | */ |
288: | public function saveToCache($data, $filename) {} |
289: | /** |
290: | * Unserialize from file if exist. |
291: | * @param string $filename filepath |
292: | * @return array|object on error return empty array |
293: | */ |
294: | public function getFromCache($filename) {} |
295: | } |
296: | } |
297: |