Xeel
April 29th, 2009, 12:20 PM
Hi :wave:
I'm pretty out of ideas in this matter. What I want is to somehow redirect from a controller php class to a php page without altering the url. I'm not a pro in php and maybe missing something. In Java it's done pretty easily using RequestDispatcher, but I know that in php the API is rather limited for this kind of functionality.
My controller model:
- each page contains an eXec parameter that carries a key for path forward so I know what class to execute and where to go go next;
- the controller contains an array with keys and class constructors, session validation, etc. and header() in the end;
- each class extends an interface to inherit the same function which is overloaded in each class where some data processing is made before loading next page;
Just to make myself clear, here are the files examples:
main controller:<?php
//MAIN CONTROLLER >>
require_once("classes/AppInterface.php");
require_once("classes/app_Null.php");
require_once("classes/app_Exit.php");
require_once("classes/app_Login.php");
//...
session_start();
$eXec = isset($_REQUEST["eXec"])?$_REQUEST["eXec"]:"app_logout";
if(isset($_SESSION["sid"]) && $_SESSION["sid"]==1){
$eXec = "app_logout";
}
$nextA = array(
"web_indexp" => new AppNull("login.php"),
"app_logout" => new AppExit("login.php"),
"app_ulogin" => new AppLogin("usher_search.php")
//...
);
$appc = isset($nextA[$eXec])?$nextA[$eXec]:$nextA["app_logout"];
$_SESSION["cPage"] = $appc->execF($_REQUEST);
header("Location: pagex.php");
?>
interface:<?php
interface AppInterface{
public function execF($req);
}
?>
a processing command class example:<?php
class AppNull implements AppInterface{
private $nextPage;
public function AppNull($eXec){
$this->nextPage = $eXec;
}
public function execF($req){
return $this->nextPage;
}
}
?>
pagex.php standart container:<?php
session_start();
include("includes/header.php");
include("includes/title.php");
include("pages/".$_SESSION["cPage"]);
include("includes/footer.php");
?>
What I hate is "mySite/pagex.php" part, I just want ti see "mySite"
I do not want to radically change the flow model so I have to find some solution that just slightly alters it.
Any ideas?
I'm pretty out of ideas in this matter. What I want is to somehow redirect from a controller php class to a php page without altering the url. I'm not a pro in php and maybe missing something. In Java it's done pretty easily using RequestDispatcher, but I know that in php the API is rather limited for this kind of functionality.
My controller model:
- each page contains an eXec parameter that carries a key for path forward so I know what class to execute and where to go go next;
- the controller contains an array with keys and class constructors, session validation, etc. and header() in the end;
- each class extends an interface to inherit the same function which is overloaded in each class where some data processing is made before loading next page;
Just to make myself clear, here are the files examples:
main controller:<?php
//MAIN CONTROLLER >>
require_once("classes/AppInterface.php");
require_once("classes/app_Null.php");
require_once("classes/app_Exit.php");
require_once("classes/app_Login.php");
//...
session_start();
$eXec = isset($_REQUEST["eXec"])?$_REQUEST["eXec"]:"app_logout";
if(isset($_SESSION["sid"]) && $_SESSION["sid"]==1){
$eXec = "app_logout";
}
$nextA = array(
"web_indexp" => new AppNull("login.php"),
"app_logout" => new AppExit("login.php"),
"app_ulogin" => new AppLogin("usher_search.php")
//...
);
$appc = isset($nextA[$eXec])?$nextA[$eXec]:$nextA["app_logout"];
$_SESSION["cPage"] = $appc->execF($_REQUEST);
header("Location: pagex.php");
?>
interface:<?php
interface AppInterface{
public function execF($req);
}
?>
a processing command class example:<?php
class AppNull implements AppInterface{
private $nextPage;
public function AppNull($eXec){
$this->nextPage = $eXec;
}
public function execF($req){
return $this->nextPage;
}
}
?>
pagex.php standart container:<?php
session_start();
include("includes/header.php");
include("includes/title.php");
include("pages/".$_SESSION["cPage"]);
include("includes/footer.php");
?>
What I hate is "mySite/pagex.php" part, I just want ti see "mySite"
I do not want to radically change the flow model so I have to find some solution that just slightly alters it.
Any ideas?