3 |
// $Id$ |
// $Id$ |
4 |
// ------------------------------------------------------------------------- |
// ------------------------------------------------------------------------- |
5 |
// $Log$ |
// $Log$ |
6 |
|
// Revision 1.4 2002/12/23 11:33:32 jonen |
7 |
|
// + minor changes |
8 |
|
// |
9 |
|
// Revision 1.3 2002/12/19 06:21:37 joko |
10 |
|
// + loadTemplate |
11 |
|
// + case 'template' for 'function loadComponent' |
12 |
|
// |
13 |
// Revision 1.2 2002/12/12 21:37:46 joko |
// Revision 1.2 2002/12/12 21:37:46 joko |
14 |
// + fixes: now returning success-/error-status |
// + fixes: now returning success-/error-status |
15 |
// |
// |
23 |
|
|
24 |
var $site; |
var $site; |
25 |
|
|
26 |
function includeFile($filename) { |
function includeFile($filename, $args = array()) { |
27 |
|
|
28 |
// TODO: try to remove these globals! |
// TODO: try to remove these globals! |
29 |
global $site; |
global $site; |
30 |
global $site_state; |
global $site_state; |
31 |
global $uservars; |
//global $uservars; |
32 |
global $request; |
global $request; |
33 |
global $http_referer; |
global $http_referer; |
34 |
|
|
35 |
|
global $page_state; |
36 |
|
|
37 |
$this->site->log( get_class($this) . "->includeFile( filename $filename )", LOG_DEBUG); |
$this->site->log( get_class($this) . "->includeFile( filename $filename )", LOG_DEBUG); |
38 |
$site = &$this->site; |
$site = &$this->site; |
39 |
if (include($filename)) { |
if (include($filename)) { |
40 |
return 1; |
return 1; |
41 |
} |
} |
42 |
|
|
43 |
} |
} |
44 |
|
|
45 |
function loadComponent($name, $type = "") { |
function loadComponent($name, $type = "", $arguments = array()) { |
46 |
$prefix = ""; |
$prefix = ""; |
47 |
$postfix = ""; |
$postfix = ""; |
48 |
$this->site->log( get_class($this) . "->loadComponent( name $name, type $type )", LOG_DEBUG); |
$this->site->log( get_class($this) . "->loadComponent( name $name, type $type )", LOG_DEBUG); |
49 |
|
|
50 |
|
// TODO: croak somewhere (STDOUT?, logger?) if unknown type gets used here |
51 |
switch ($type) { |
switch ($type) { |
52 |
|
|
53 |
case "handler": |
case "handler": |
54 |
$prefix = $this->site->config[path][base] . 'core/handler/'; |
$prefix = $this->site->config[path][base] . 'core/handler/'; |
55 |
//$postfix = ".handler.php"; |
//$postfix = ".handler.php"; |
56 |
$postfix = ".php"; |
$postfix = ".php"; |
57 |
|
$includefile = "$prefix$name$postfix"; |
58 |
|
return $this->includeFile($includefile); |
59 |
break; |
break; |
60 |
|
|
61 |
case "page": |
case "page": |
62 |
$prefix = $this->site->config[path][base] . 'core/pages/'; |
$prefix = $this->site->config[path][base] . 'core/pages/'; |
63 |
$postfix = ".page"; |
$postfix = ".page"; |
64 |
|
$includefile = "$prefix$name$postfix"; |
65 |
|
return $this->includeFile($includefile, $arguments ); |
66 |
|
break; |
67 |
|
|
68 |
|
case "template": |
69 |
|
// TODO: re-activate this (unset smarty's default directory or handle differently (generic)) |
70 |
|
//$prefix = $this->site->config[path][base] . 'core/templates/'; |
71 |
|
$prefix = ''; |
72 |
|
$postfix = ".html"; |
73 |
|
$includefile = "$prefix$name$postfix"; |
74 |
|
//return $this->includeFile($includefile); |
75 |
|
return $this->site->template->display($includefile, array( |
76 |
|
'cache_key' => $arguments[cache_key], |
77 |
|
'interpolate' => $arguments['vars'], |
78 |
|
'return' => $arguments['return'] |
79 |
|
)); |
80 |
break; |
break; |
81 |
} |
} |
|
$includefile = "$prefix$name$postfix"; |
|
|
return $this->includeFile($includefile); |
|
82 |
} |
} |
83 |
|
|
84 |
function loadHandler($name) { |
function loadHandler($name) { |
86 |
return $this->loadComponent($name, "handler"); |
return $this->loadComponent($name, "handler"); |
87 |
} |
} |
88 |
|
|
89 |
function loadPage($name) { |
function loadPage($name, $args = array()) { |
90 |
$this->site->log( get_class($this) . "->loadPage( name $name )", LOG_DEBUG); |
$this->site->log( get_class($this) . "->loadPage( name $name )", LOG_DEBUG); |
91 |
return $this->loadComponent($name, "page"); |
return $this->loadComponent($name, "page", $args); |
92 |
} |
} |
93 |
|
|
94 |
|
function loadTemplate($name, $template_variables = array(), $cache_key = "") { |
95 |
|
$this->site->log( get_class($this) . "->loadTemplate( name $name cache_key $cache_key )", LOG_DEBUG); |
96 |
|
return $this->loadComponent($name, "template", array( 'cache_key' => $cache_key, 'vars' => $template_variables) ); |
97 |
|
} |
98 |
|
|
99 |
function loadClass() { |
function loadClass() { |
100 |
} |
} |