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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Mon Feb 3 14:44:35 2003 UTC (21 years, 8 months ago) by joko
Branch: MAIN
+ initial commit
+ refactored from flib/Site/Loader.php
+ now inherits from DesignPattern::Logger

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

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