routeSQL : Allow the result to be displayed in HTML by the renderer

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2035 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-03-20 14:33:34 +00:00
parent 7b1c81d917
commit 672111b07e

View File

@@ -60,6 +60,12 @@ class routeSQL
The array must be of the form array ("linkname"=>,"icon"=>)
icon is optional and the linkname is used if it is not provided */
public $internalLinks = array ();
/** The renderer class to use for HTML pages */
public $rendererHTMLclass = false;
/** The renderer method to use for HTML pages */
public $rendererHTMLmethod = false;
/** The layout HTML to use for HTML pages */
public $rendererHTMLlayout = false;
/** The model file containing the database description */
private $model_file = "";
@@ -553,7 +559,7 @@ class routeSQL
$content .= " </div>\n";
$content .= " </div>\n"; // End of bottomBar
$content .= "</div>\n";
echo $content;
$this->rendererhtml ($content);
});
$route->get ($this->url_prefix."/{id}/delete/{token}",
@@ -726,7 +732,7 @@ echo $content;
unset ($field);
$f->fields ($fields);
$content .= $f->printHTML ("post", $values, $errors);
echo $content;
$this->rendererhtml ($content);
});
$route->post ($this->url_prefix."/add", function ($chain) use ($route)
@@ -919,7 +925,7 @@ echo $content;
}
$f->fields ($fields);
$content .= $f->printHTML ("post", $values, $errors);
echo $content;
$this->rendererhtml ($content);
});
$route->post ($this->url_prefix."/{id}", function ($id, $chain) use ($route)
@@ -1075,4 +1081,33 @@ echo $content;
return $datas[0];
return FALSE;
}
/** Display the data in HTML with the view class/method if they are defined */
private function rendererhtml ($data)
{
require_once ("domframework/outputhtml.php");
$route = new route ();
$html = new outputhtml ();
$replacement = array ("{baseurl}"=>$route->baseURL ());
if ($this->rendererHTMLlayout === false)
{
$this->rendererHTMLlayout = "<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
</head>
<body>
{content}
</body>
</html>";
}
// TODO : Test the $this->rendererHTMLclass, $this->rendererHTMLmethod !
echo $html->out ($data, FALSE,
$this->rendererHTMLclass, $this->rendererHTMLmethod,
$this->rendererHTMLlayout, $replacement);
}
}