/[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.2 - (hide annotations)
Tue Feb 4 08:20:34 2003 UTC (21 years, 7 months ago) by joko
Branch: MAIN
Changes since 1.1: +15 -5 lines
+ should now be independent from former encapsulation inside the 'Site'-object

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

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