First release of domframework
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1207 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
42
outputhtml.php
Normal file
42
outputhtml.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require_once ("output.php");
|
||||
class outputhtml extends output
|
||||
{
|
||||
/** Data is printed by viewClass->viewmethod, in the middle of $layout
|
||||
title is put in the title of the HTML page
|
||||
$replacement modify the result (it can do title too :
|
||||
array ("{title}"=>"title to display") */
|
||||
public function out ($data, $title = FALSE,
|
||||
$viewClass = FALSE, $viewMethod = FALSE,
|
||||
$layout = FALSE, $replacement = array())
|
||||
{
|
||||
@header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
@header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
|
||||
@header('Last-Modified: '.gmdate ('D, d M Y H:i:s').' GMT');
|
||||
@header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
@header('Pragma: no-cache');
|
||||
@header ("Content-Type: text/html");
|
||||
$resView = $data;
|
||||
if ($viewClass !== FALSE && $viewMethod !== FALSE)
|
||||
{
|
||||
require ("views/$viewClass.php");
|
||||
$reflection = new ReflectionMethod ($viewClass, $viewMethod);
|
||||
$resView = $reflection->invokeArgs (new $viewClass, array ($data));
|
||||
}
|
||||
|
||||
if ($layout !== FALSE)
|
||||
{
|
||||
$layoutPage = file_get_contents ("views/$layout.html");
|
||||
$resView = str_replace ("{content}", $resView, $layoutPage);
|
||||
}
|
||||
|
||||
// Do the title replacement in the replacement structure
|
||||
if (! isset ($replacement["{title}"]))
|
||||
$replacement["{title}"] = $title;
|
||||
|
||||
foreach ($replacement as $key=>$val)
|
||||
$resView = str_replace ($key, $val, $resView);
|
||||
|
||||
return $resView;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user