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