/[cvs]/nfo/php/libs/org.netfrag.glib/Application/ComponentLoader.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.glib/Application/ComponentLoader.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Mon Mar 3 21:11:39 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
refactored from flib/Site/Loader

1 <?
2 // -------------------------------------------------------------------------
3 // $Id: Loader.php,v 1.3 2003/02/09 17:10:34 joko Exp $
4 // -------------------------------------------------------------------------
5 // $Log: Loader.php,v $
6 // Revision 1.3 2003/02/09 17:10:34 joko
7 // + minor update related to new log level constants
8 //
9 // Revision 1.2 2003/02/04 08:20:34 joko
10 // + should now be independent from former encapsulation inside the 'Site'-object
11 //
12 // Revision 1.1 2003/02/03 14:44:35 joko
13 // + initial commit
14 // + refactored from flib/Site/Loader.php
15 // + now inherits from DesignPattern::Logger
16 //
17 // Revision 1.4 2002/12/23 11:33:32 jonen
18 // + minor changes
19 //
20 // Revision 1.3 2002/12/19 06:21:37 joko
21 // + loadTemplate
22 // + case 'template' for 'function loadComponent'
23 //
24 // Revision 1.2 2002/12/12 21:37:46 joko
25 // + fixes: now returning success-/error-status
26 //
27 // Revision 1.1 2002/11/12 05:42:31 joko
28 // + initial checkin
29 //
30 // -------------------------------------------------------------------------
31
32
33 loadModule('Class::Logger');
34
35 class Application_ComponentLoader extends Class_Logger {
36
37 var $parent;
38
39 function includeFile($filename, $args = array()) {
40 $this->log( get_class($this) . "->includeFile( filename $filename )", PEAR_LOG_DEBUG);
41 // TODO: capture errors (e.g. via an eval) here?
42 //global $site;
43 //print "parent: " . $this->parent . "<br>";
44 if (include($filename)) {
45 return 1;
46 }
47 }
48
49 function loadComponent($name, $type = "", $arguments = array()) {
50 $prefix = "";
51 $postfix = "";
52 $this->log( get_class($this) . "->loadComponent( name $name, type $type )", PEAR_LOG_DEBUG);
53
54 $parent = $this->parent;
55
56 // TODO: croak somewhere (STDOUT?, logger?) if unknown type gets used here
57 switch ($type) {
58
59 case "handler":
60 $prefix = $this->$parent->config[path][handler];
61 //$postfix = ".handler.php";
62 $postfix = ".php";
63 $includefile = "$prefix$name$postfix";
64 return $this->includeFile($includefile);
65 break;
66
67 case "page":
68 $prefix = $this->$parent->config[path][pages];
69 $postfix = ".page";
70 $includefile = "$prefix$name$postfix";
71 return $this->includeFile($includefile, $arguments );
72 break;
73
74 case "template":
75 // TODO: re-activate this (unset smarty's default directory or handle differently (generic))
76 //$prefix = $this->$parent->config[path][base] . 'core/templates/';
77 $prefix = '';
78 $postfix = ".html";
79 $includefile = "$prefix$name$postfix";
80 //return $this->includeFile($includefile);
81 return $this->$parent->template->display($includefile, array(
82 'cache_key' => $arguments[cache_key],
83 'interpolate' => $arguments['vars'],
84 'return' => $arguments['return']
85 ));
86 break;
87 }
88 }
89
90 function loadHandler($name) {
91 $this->log( get_class($this) . "->loadHandler( name $name )", PEAR_LOG_DEBUG);
92 return $this->loadComponent($name, "handler");
93 }
94
95 function loadPage($name, $args = array()) {
96 $this->log( get_class($this) . "->loadPage( name $name )", PEAR_LOG_DEBUG);
97 return $this->loadComponent($name, "page", $args);
98 }
99
100 function loadTemplate($name, $template_variables = array(), $cache_key = "") {
101 $this->log( get_class($this) . "->loadTemplate( name $name cache_key $cache_key )", PEAR_LOG_DEBUG);
102 return $this->loadComponent($name, "template", array( 'cache_key' => $cache_key, 'vars' => $template_variables) );
103 }
104
105 function loadClass() {
106 }
107
108 function loadBusinessClass() {
109 }
110
111
112
113 }
114 ?>

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