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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

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