1: <?php
2: /**
3: * page class
4: *
5: * This class is parent class of all page Gate. You can Develop SartajPHP Gate 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: */
11: namespace Sphp\kit{
12: class Page {
13: public $authentication = false;
14: public $issubmit = false;
15: public $isview = false;
16: public $isnew = false;
17: public $isdelete = false;
18: public $isinsert = false;
19: public $isupdate = false;
20: public $isaction = false;
21: public $isevent = false;
22: public $act = "";
23: public $sact = "";
24: public $evtp = "";
25: public $txtid = "";
26: public $gate_dir_path = "";
27: public $gate_file_path = "";
28: public $current_gate_obj = null;
29: public $tblName = "";
30: public $auth = "";
31: public $masterfilepath = "";
32: /** Gate use Session Security */
33: public $isSesSecure = false;
34: /**
35: * Advance No Use
36: * @depends start
37: */
38: /** Advance
39: * Overload, Event Handler For Gate Type development
40: */
41: public function page_init() {}
42: /** Advance
43: * Overload, Event Handler For Gate Type development
44: */
45: public function page_load() {}
46: /** Advance
47: * Gate 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 Gate of Gate and Gate 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 Gate of Gate and Gate 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 Gate of Gate and Gate 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 Gate of Gate and Gate 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 Gate of Gate and Gate 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 Gate of Gate and Gate path is in reg.php file
92: */
93: public function page_new() {}
94: /** Advance
95: * Overload, Event Handler For Gate Type development
96: */
97: public function page_unload() {}
98: /**
99: * Get Gate Event name of current request
100: * @return string
101: */
102: public function getEvent() {}
103: /**
104: * Get Gate Event parameter of current request
105: * @return string
106: */
107: public function getEventParameter() {}
108: /** Advance
109: * Overload, Event Handler For Gate Type development
110: */
111: public function readyPage() {}
112: /** Advance
113: * Overload, Event Handler For Gate Type development
114: */
115: public function init() {}
116: /** Advance
117: * Overload, Event Handler For Gate Type development
118: */
119: /**
120: * Set which user Permission can access this Gate. Default Permission is ALL.
121: * You can set session variable in login Gate
122: * SphpBase::sphp_request()->session('lstpermis','profile-view,prfile-delete');
123: * If user is not login with specific permission then Gate exit and
124: * redirect according to the getWelcome function in comp.php
125: * @param string $perm Default=null mean, permission to everyone<p>
126: * @param string $gate optional Default is current Gate, permission like index-view where index is Gate.
127: * permission to allow Gate Processing. Example:- AuthenticatePerm("view")
128: * </p>
129: * @return boolean true if permission match with session variable lstpermis, never return false
130: */
131: public function getAuthenticatePerm($perm=null,$gate=null) {}
132: /**
133: * Check Permission is given to authorised user or not given.
134: * @param string $perm permission to check
135: * @param string $gate optional Default is current Gate, permission like index-view where index is Gate.
136: * @return bool return true if permission found
137: */
138: public function hasPermission($perm,$gate=null) {}
139: /**
140: * Set which user can access this Gate. Default user is GUEST.
141: * You can set session variable in login Gate
142: * SphpBase::sphp_request()->session('logType','ADMIN');
143: * If user is not login with specific type then Gate exit and
144: * redirect according to the getWelcome function in comp.php
145: * @param string $auth <p>
146: * comma separated list of string. Example:- Authenticate("GUEST,ADMIN") or Authenticate("ADNIN")
147: * </p>
148: * @return boolean true if user type match with session variable logType, never return false
149: */
150: public function Authenticate($auth="") {}
151: /** Advance
152: * Authorise base on server variables, in session less environment
153: * @param string $auth
154: * @depends Authenticate
155: */
156: public function AuthenticateSVAR($auth="") {}
157: /**
158: * Check if user type in session logType = unauthorised
159: * @param string $param <p>
160: * comma separated list of string. Example:- checkUnAuth("GUEST,ADMIN") or checkUnAuth("ADNIN")
161: * </p>
162: * @return boolean true if user type match with session variable logType
163: */
164: public function checkUnAuth($param) {}
165: /**
166: * Check if user type in session logType = authorised
167: * @param string $param <p>
168: * comma separated list of string. Example:- checkAuth("GUEST,ADMIN") or checkAuth("ADNIN")
169: * </p>
170: * @return boolean true if user type match with session variable logType
171: */
172: public function checkAuth($param) {}
173: /**
174: * Read logType session variable as User Type of login user which is set in login Gate
175: * @return string
176: */
177: public function getAuthenticateType() {}
178: /** Gate exit if URL isn't session secure
179: *@return Gate exit if URL isn't session secure
180: */
181: public function sesSecure() {}
182: /**
183: * Forward request to url
184: * @param string $loc <p>
185: * pass url address
186: * </p>
187: */
188: public function forward($loc) {}
189: /**
190: * Return True if page_insert event triggered
191: * @return bool
192: */
193: public function isInsertMode(){}
194: /**
195: * Return True if page_update event triggered
196: * @return bool
197: */
198: public function isUpdateMode(){}
199: /**
200: * Return True if page_view event triggered
201: * @return bool
202: */
203: public function isViewMode(){}
204: /**
205: * Return True if page_delete event triggered
206: * @return bool
207: */
208: public function isDeleteMode(){}
209: /**
210: * Return True if page_submit event triggered
211: * @return bool
212: */
213: public function isSubmitMode(){}
214: /**
215: * Return True if page_new event triggered
216: * @return bool
217: */
218: public function isNewMode(){}
219: /**
220: * User Event is a type of PageEvent as a custom Event build from url which
221: * doesn't match with any inbuilt Event.
222: * Return True if page_event_* User event triggered
223: * @return bool
224: */
225: public function isUserEventMode(){}
226: /**
227: * Set default Database Engine for execute query and managing connections
228: * Default is MySQL
229: * @param \MySQL $objdbengine
230: */
231: public function setDBEngine($objdbengine) {}
232: /**
233: * This Function delete the record of database table with generate and execute delete query.
234: * DELETE FROM $tblName WHERE id='$evtp'
235: * $tblName = default table of Gate
236: * $evtp = \SphpBase::page()->getEventParameter()
237: * @param string $recid If empty then use event parameter as record id.<br>
238: *
239: */
240: public function deleteRec($recid="") {}
241: /**
242: * When Components use Database Binding. Then This Function insert the values to database table from a
243: * component value. This insert a new record in table.<br>
244: * $extra = array()
245: * $extra['table']['datecreate'] = date('Y-m-d)
246: * OR
247: * $extra[]['datecreate'] = date('Y-m-d)
248: * insertData($extra)
249: * @param array $extra extra fields to insert with query.
250: */
251: public function insertData($form1,$extra = array()) {}
252: /**
253: * When Components use Database Binding. Then This Function Fill the values from database table to a
254: * Component value.<br>
255: * changeable $sql = "SELECT $fldList FROM $tbln $where"<br>
256: * $tbln = use default tblName of Gate or Components dtable attribute
257: * SphpBase::page()->viewData(,,"WHERE id='1'");<br>
258: * SphpBase::page()->viewData('','aname,pass,lst',"WHERE lastname='devel'");<br>
259: * @param type $form <p> Form Component
260: * Read value from database and fill all Children Components of Form object which is bind with field of table.
261: * </p>
262: * @param string $recID <p>
263: * Every table should have unique,auto increment and primary filed and default it has name id.
264: * id = record id in table, pass this record id to $recID or if it is empty then it uses SphpBase::page()->getEventParameter()
265: * </p>
266: * @param string $fldList <p>
267: * pass comma separated list of table fields or otherwise it is *
268: * </p>
269: * @param string $where WHERE Logic in SQL
270: *
271: */
272: public function viewData($form , $recID = "", $fldList = "", $where = "") {}
273: /**
274: * When Components use Database Binding. Then This Function Update the values to database table from a
275: * Component value. This update old record in table. This will only update Children of Form Component only.
276: * It will not update all bound components to Database. So Form Component is required to pass.
277: * $extra = array()
278: * $extra['table']['dateupdate'] = date('Y-m-d)
279: * OR
280: * $extra[]['dateupdate'] = date('Y-m-d)
281: * updateData($extra)
282: * @param \Sphp\tools\Component $form1 Form Component or container uses for getAllChildren.
283: * @param array $extra is extra fields to insert with query.
284: * @param string $recID Optional if empty then use $form1->getRecID()
285: * Every table should have unique,auto increment and primary filed and SartajPHP use default name "id".
286: * id = record id in table, pass this record id to $recID or if it is empty then it uses
287: * Form Component recID = $form1->getRecID()
288: *
289: * @param string $where WHERE Logic in SQL You can over write WHERE id=1 login to use other
290: * field to update record.
291: */
292: public function updateData($form1,$extra = array(), $recID = '', $where = '') {}
293: }
294: class DbEngine{
295: /**
296: * Fix Bad Format in Query call clearQuery
297: * @param string $string
298: * @depends clearQuery
299: * @return string
300: */
301: public function cleanQuery($string) {}
302: /**
303: * Fix Bad Format in Query
304: * @param string $string
305: * @return string
306: */
307: public function clearQuery($string) {}
308: public function fetchQuery($sql = "", $ttl = 0, $filename = "", $key = "id", $issave = false) {}
309: public function insertCache($filename, $key, $data = array(), $tbls = "", $sql = "") {}
310: public function clearCache($filename) {}
311: public function updateCache($filename, $keymap, $data = array(), $where = "", $tbls = "", $sql = "") {}
312: public function deleteCache($filename, $keymap, $where = "", $tbls = "", $sql = "") {}
313: public function updateCacheSQL($filename, $key, $sql, $priority = 1) {}
314: public function executeUpdateCacheSQL($filename) {}
315: /**
316: * Import table data as PHP Code. Override this function when you need to
317: * create of database adapter. Default work with MySQL
318: * @param string $tablenl <p>
319: * Comma Separated string as table names or table name
320: * </p>
321: * @param string $where <p>
322: * where logic for query
323: * </p>
324: * @return string
325: */
326: public function getTableSQL($tablenl, $where = "") {}
327: /**
328: * List Fields in a Table. Override this function when you need to
329: * create of database adapter. Default work with MySQL
330: * @param string $tablename <p>
331: * pass table name in database
332: * </p>
333: * @return array
334: */
335: public function getTableColumns($tablename) {}
336: /**
337: * List Tables in Database. execute SHOW TABLES query. Override this function when you need to
338: * create of database adapter. Default work with MySQL
339: * @return array
340: */
341: public function getDbTables() {}
342: /**
343: * Generate a Table CREATE query. Override this function when you need to
344: * create of database adapter. Default work with MySQL
345: * @param string $table <p> table name
346: * </p>
347: * @return string
348: */
349: public function getCreateTableSQL($table) {}
350: /**
351: * Check if result has rows of data
352: * @param Result Object From Database $param
353: * @return boolean true if rows exist
354: */
355: public function is_rows($result) {}
356: }
357: }
358: