|
442
|
1 |
<?php |
|
|
2 |
|
|
541
|
3 |
require_once realpath(dirname(__FILE__).'/../config.php'); |
|
442
|
4 |
|
|
541
|
5 |
function renderLayoutWithContentFile($contentFile, $variables = array(), $css = array()) |
|
|
6 |
{ |
|
|
7 |
$contentFileFullPath = TEMPLATES_PATH.'/'.$contentFile; |
|
|
8 |
|
|
|
9 |
// making sure passed in variables are in scope of the template |
|
|
10 |
// each key in the $variables array will become a variable |
|
|
11 |
if (count($variables) > 0) { |
|
|
12 |
foreach ($variables as $key => $value) { |
|
|
13 |
if (strlen($key) > 0) { |
|
|
14 |
${$key} = $value; |
|
442
|
15 |
} |
|
|
16 |
} |
|
541
|
17 |
} |
|
442
|
18 |
|
|
541
|
19 |
require_once TEMPLATES_PATH.'/header.php'; |
|
|
20 |
|
|
|
21 |
echo "<div id=\"container\">\n" |
|
|
22 |
."\t<div id=\"content\">\n"; |
|
442
|
23 |
|
|
541
|
24 |
if (file_exists($contentFileFullPath)) { |
|
|
25 |
require_once $contentFileFullPath; |
|
|
26 |
} else { |
|
|
27 |
/* |
|
|
28 |
If the file isn't found the error can be handled in lots of ways. |
|
|
29 |
In this case we will just include an error template. |
|
|
30 |
*/ |
|
|
31 |
require_once TEMPLATES_PATH.'/error.php'; |
|
|
32 |
} |
|
442
|
33 |
|
|
541
|
34 |
// close content div |
|
|
35 |
echo "\t</div>\n"; |
|
442
|
36 |
|
|
541
|
37 |
// close container div |
|
|
38 |
echo "</div>\n"; |
|
442
|
39 |
|
|
541
|
40 |
require_once TEMPLATES_PATH.'/footer.php'; |
|
|
41 |
} |