/[cvs]/nfo/php/libs/org.netfrag.glib/DesignPattern/Loader.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.glib/DesignPattern/Loader.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Mon Mar 3 21:56:34 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +4 -1 lines
FILE REMOVED
refactored to Application::ComponentLoader

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

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