/[cvs]/nfo/php/libs/org.netfrag.flib/Site/Loader.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.flib/Site/Loader.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Thu Dec 19 06:21:37 2002 UTC (21 years, 9 months ago) by joko
Branch: MAIN
Changes since 1.2: +31 -4 lines
+ loadTemplate
+ case 'template' for 'function loadComponent'

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

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed