Mercurial > SimpleWebPresenter
changeset 1:d91abe5f6214
Support for evaluated configuration files.
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Tue, 10 May 2011 14:45:45 +0200 |
| parents | d2da64705bce |
| children | 6d420f2a1d91 |
| files | index.php |
| diffstat | 1 files changed, 27 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/index.php Tue May 10 14:01:34 2011 +0200 +++ b/index.php Tue May 10 14:45:45 2011 +0200 @@ -43,15 +43,23 @@ } } -$body=loadFile("${lang}/${name}.html"); -if(floatval($body)<0) { +$title="Dummy title"; +$header="header.html"; +$footer="footer.html"; +$body="body.html"; + +$config=loadFile("${lang}/${name}.cfg"); + +eval($config); +$body_content=loadFile("${lang}/${body}"); +if(floatval($body_content)<0) { header('HTTP/1.0 404 Not Found'); - $body='<div id="page"><h1>Resource not found</h1></div>'; + $body_content='<div id="page"><h1>Resource not found</h1></div>'; } if (!file_exists($lang)) { $lang=no; header('HTTP/1.0 404 Not Found'); - $body='<div id="page"><h1>Language is not available</h1></div>'; + $body_content='<div id="page"><h1>Language is not available</h1></div>'; } print '<?xml version="1.0" encoding="UTF-8"?>'; @@ -60,28 +68,33 @@ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> - <title>BFG Consult</title> - <link type="text/css" href="/css/reset.css" rel="stylesheet" media="screen" /> - <link type="text/css" href="/css/bfggroup.css" rel="stylesheet" media="screen" /> + <title> +<?php +print "$title"; +?> + </title> +<?php +print "$css"; +?> </head> <body> <div id="container"> <?php -$header=loadFile("${lang}/header.html"); -$footer=loadFile("${lang}/footer.html"); +$header_content=loadFile("${lang}/${header}"); +$footer_content=loadFile("${lang}/${footer}"); $pattern = "/<li id=\"${name}\"\s?([^>]*)>/is"; $replacement = "<li id=\"${name}\" class=\"active\" $1>"; -$header= preg_replace($pattern, $replacement, $header); +$header_content= preg_replace($pattern, $replacement, $header_content); $pattern = '/<li id="([^"]+)"\s?([^>]*)>(.*?)<\/li>/is'; $replacement = "<li id=\"\$1\" \$2><a href=\"?name=$1&lang=${lang}\">\$3</a></li>"; -$header=preg_replace($pattern, $replacement, $header); +$header_content=preg_replace($pattern, $replacement, $header_content); -print $header; -print $body; -print $footer; +print $header_content; +print $body_content; +print $footer_content; ?>
