Page Class is parent class of every SartajPHP Application. This gives event oriented structure to develop an application. There are different type of events which is occurred on different time.
New Event of page class is occurred when a new request is received by an application. It is start of request to that application. If application has new event handler then the application process that code only. You can check the new event of application and change the output to browser.
if(SphpBase::page()->isnew){
echo "this is simple module type new event handler";
}
if(SphpBase::page()->issubmit){
echo "this is simple module type submit event handler";
}
if(SphpBase::page()->isinsert){
echo "this is simple module type insert event handler";
}
if(SphpBase::page()->isupdate){
echo "this is simple module type update event handler";
}
if(SphpBase::page()->isdelete){
echo "this is simple module type delete event handler";
}
if(SphpBase::page()->isview){
echo "this is simple module type view event handler";
}
if(SphpBase::page()->isevent){
echo "this is simple module type user event handler for " . SphpBase::page()->getEvent() ;
}
class index extends \Sphp\tools\BasicApp{
private $temp1 = null;
// Application life cycle events with in sequence
public function onstart(){
echo "app start";
}
public function ontempinit($temp){
echo " when temp file initialize";
}
public function ontempprocess($temp){
echo "tempfile process";
}
public function onready(){
echo "temp file processed with all components";
}
public function page_new(){
echo "you open in browser " . getThisURL();
}
public function page_submit(){
echo "you submit form to " . getThisURL() ;
}
public function onrun($temp){
echo "app run";
}
public function onrender($temp){
echo "app ready to render";
}
// Application Database handling events
public function page_insert(){
echo "you open in browser " . getThisURL() . " and form submit to " . getThisURL() . " url";
}
public function page_update(){
echo "you open in browser " . getEventURL("view",1) . " and edited form submit to " . getThisURL() . " url";
}
public function page_delete(){
echo "you open in browser " . getEventURL("delete",1) . " to delete record in table where id=1 " ;
//$this->dbEngine->executeQueryQuick("SELECT FROM tbl1 WHERE id=1");
}
public function page_view(){
// fill all components of form automatically from database and send to browser
$this->page->viewData($this->temp1->getComponent('form2'));
$this->setTempFile($this->temp1);
}
// Application life custom events
// $evtp == event parameter, myevent1 == any event name you want to handle
public function page_event_myevent1($evtp){
//open url = getEventURL("myevent1")
}
public function page_event_myevent2($evtp){
//open url = getEventURL("myevent2")
}
}