-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtemplating.php
More file actions
executable file
·77 lines (66 loc) · 2.38 KB
/
templating.php
File metadata and controls
executable file
·77 lines (66 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
// Code to initialize Mustache and associated helper functions
require_once(ROOT.'Controllers/suggestions.php');
require_once('Vendor/Mustache/Autoloader.php');
Mustache_Autoloader::register();
$options = array('extension' => '.htm');
$template = new Mustache_Engine(array(
'loader' => new Mustache_Loader_FilesystemLoader(ROOT.'/Templates', $options),
));
function RenderError($description, $addtl = null) {
$controller = GetController("error");
$_SYSTEM = array("SUGGESTR_ERROR"=>$description);
if($GLOBALS['CONFIG']['development']) $_SYSTEM["SUGGESTR_EXTENDED_ERROR"] = $addtl;
$controller->process($_GET,$_POST,$_FILES,$_SYSTEM);
echo "Error:".$controller->render(); // this might be cauing ajax errors.
die();
}
function Render($templ, $objects, $useMain=true) {
global $template;
$objects["BaseURL"] = $GLOBALS['CONFIG']['app-path'];
$inner = $template->render($templ, $objects);
$objects["BaseContent"] = $inner;
if($useMain){
// This is the place to make other ajax calls that don't use main and need to be loaded in..
// Tasks
// $tasksController = GetController('tasks');
// $tasksController->process($_GET,$_POST);
// $objects["Tasks"] = Render($tasksController->pageTemplate,$tasksController->pageData,false);
return $template->render('base', $objects);
}else
return $inner;
}
/*
function RenderEmail($templ, $objects, $useMain=true) {
global $template;
$inner = $template->render('Email/'.$templ, $objects);
$objects["BaseContent"] = $inner;
if($useMain) return $template->render('Email/base', $objects);
else return $inner;
}
*/
// Function to load in Page Controllers.
// DO NOT TRUST THIS WITH EXTERNAL DATA!!!
// Note your class must be named in the following format:
// $name = "index" means a class name of IndexController
// took away / from file thing
// require_once('config.php');
function GetController($name) {
if (file_exists('Controllers/'.$name.'.php')) {//must change.
require_once('Controllers/'.$name.'.php');
$className = ucwords($name)."Controller";
return new $className;
}else{
die();
}
}
class PageController {
public $pageTemplate = "";
public $pageData = array();
public function process($get, $post) {
}
public function render($displayBase=true){
// Could add to pageData here...
echo Render($this->pageTemplate,$this->pageData,$displayBase);
}
}