route : route allow now to get the information from a return in the function of map and display it with the provided output type (json, html, xml, text).
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2374 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
83
route.php
83
route.php
@@ -32,6 +32,24 @@ class route
|
||||
just display a "Unauthorized" message */
|
||||
public $authenticationURL = null;
|
||||
|
||||
|
||||
/// RENDERER PART ///
|
||||
/** Output type to no previous catched renderer (allow : json, xml, txt html)
|
||||
*/
|
||||
public $output = "html";
|
||||
/** Title by default : space to be compatible with HTML5 */
|
||||
public $title = " ";
|
||||
/** Filename of class containing the presentation layer */
|
||||
public $viewClass = FALSE;
|
||||
/** Method apply to class object to display the $result */
|
||||
public $viewMethod = FALSE;
|
||||
/** Filename in views containing the HTML layout. Without .html at the end */
|
||||
public $layout = FALSE;
|
||||
/** Array to search/replace */
|
||||
public $replacement = array();
|
||||
/** Array to variable definition */
|
||||
public $variable = array ();
|
||||
|
||||
/** Return the baseURL of the site
|
||||
Always finish with a slash
|
||||
@param string|null $module The module name (if thereis one) */
|
||||
@@ -380,12 +398,28 @@ class route
|
||||
echo "==> FOUND EQUAL !\n";
|
||||
try
|
||||
{
|
||||
$function ();
|
||||
$data = $function ();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->error ($e);
|
||||
}
|
||||
require ("domframework/renderer.php");
|
||||
$renderer = new renderer ();
|
||||
$renderer->result = $data;
|
||||
$renderer->output = $this->output;
|
||||
$renderer->title = $this->title;
|
||||
$renderer->viewClass = $this->viewClass;
|
||||
$renderer->viewMethod = $this->viewMethod;
|
||||
$renderer->layout = $this->layout;
|
||||
$renderer->replacement = $this->replacement;
|
||||
$renderer->variable = $this->variable;
|
||||
$renderer->run ();
|
||||
exit;
|
||||
$class = "output".$this->output;
|
||||
require_once ("$class.php");
|
||||
$output = new $class ();
|
||||
$output->out ($data);
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -418,12 +452,28 @@ class route
|
||||
|
||||
try
|
||||
{
|
||||
call_user_func_array ($function, $params);
|
||||
$data = call_user_func_array ($function, $params);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->error ($e);
|
||||
}
|
||||
require ("domframework/renderer.php");
|
||||
$renderer = new renderer ();
|
||||
$renderer->result = $data;
|
||||
$renderer->output = $this->output;
|
||||
$renderer->title = $this->title;
|
||||
$renderer->viewClass = $this->viewClass;
|
||||
$renderer->viewMethod = $this->viewMethod;
|
||||
$renderer->layout = $this->layout;
|
||||
$renderer->replacement = $this->replacement;
|
||||
$renderer->variable = $this->variable;
|
||||
$renderer->run ();
|
||||
exit;
|
||||
$class = "output".$this->output;
|
||||
require_once ("$class.php");
|
||||
$output = new $class ();
|
||||
$output->out ($data);
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -470,17 +520,24 @@ class route
|
||||
$http = new http ();
|
||||
@header ($_SERVER["SERVER_PROTOCOL"]." $getCode ".
|
||||
$http->codetext ($getCode));
|
||||
echo "<html>\n";
|
||||
echo " <head>\n";
|
||||
echo " <title>".$http->codetext ($getCode)."</title>\n";
|
||||
echo " <meta charset='utf-8'>\n";
|
||||
echo " <meta name='ROBOTS' content='NOINDEX, NOFOLLOW'>\n";
|
||||
echo " </head>\n";
|
||||
echo" <body>\n";
|
||||
echo "<h1>".$http->codetext ($getCode)."</h1>";
|
||||
echo $message;
|
||||
echo" </body>\n";
|
||||
echo "</html>\n";
|
||||
// TODO : If the output is HTML, add the header line :
|
||||
// echo " <meta name='ROBOTS' content='NOINDEX, NOFOLLOW'>\n";
|
||||
require ("domframework/renderer.php");
|
||||
$renderer = new renderer ();
|
||||
$renderer->result = $message;
|
||||
$renderer->output = $this->output;
|
||||
$renderer->title = $http->codetext ($getCode);
|
||||
$renderer->viewClass = $this->viewClass;
|
||||
$renderer->viewMethod = $this->viewMethod;
|
||||
$renderer->layout = $this->layout;
|
||||
$renderer->replacement = $this->replacement;
|
||||
$renderer->variable = $this->variable;
|
||||
$renderer->run ();
|
||||
exit;
|
||||
$class = "output".$this->output;
|
||||
require_once ("$class.php");
|
||||
$output = new $class ();
|
||||
$output->out ($message, $http->codetext ($getCode));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user