/[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.2 by joko, Thu Dec 12 21:37:46 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  //    Revision 1.2  2002/12/12 21:37:46  joko
11  //    + fixes: now returning success-/error-status  //    + fixes: now returning success-/error-status
12  //  //
# Line 33  class Site_Loader { Line 37  class Site_Loader {
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";          $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";  
     return $this->includeFile($includefile);  
77    }    }
78        
79    function loadHandler($name) {    function loadHandler($name) {
# Line 62  class Site_Loader { Line 86  class Site_Loader {
86      return $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.2  
changed lines
  Added in v.1.3

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