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

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

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

revision 1.5 by jonen, Mon Dec 23 11:33:58 2002 UTC revision 1.6 by joko, Sun Feb 9 17:29:02 2003 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    -------------------------------------------------------------------------------  //    -------------------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.6  2003/02/09 17:29:02  joko
7    //    - refactored code to org.netfrag.glib/
8    //    + added startup code here (Site/Boot.php got purged)
9    //
10  //    Revision 1.5  2002/12/23 11:33:58  jonen  //    Revision 1.5  2002/12/23 11:33:58  jonen
11  //    + minor changes  //    + minor changes
12  //  //
# Line 32  Line 36 
36  //    -------------------------------------------------------------------------------  //    -------------------------------------------------------------------------------
37    
38    
39  require_once 'Site/Boot.php';  require_once 'Site/DebugBox.php';
40    require_once 'Site/ExtHttp.php';
41    require_once 'Site/Misc.php';
42    require_once 'Site/Template.php';
43    
44  class Site extends Site_Boot {  class Site extends Application_AbstractBase {
45  //class Site extends PEAR_Autoloader {  //class Site extends PEAR_Autoloader {
46    
47      //$this->_mkEmbeddedObjects( array( parent_name => get_class($this), run => 'start', class_names => $class_names, ref_names => $ref_names ) );
48    
49      var $children = array(
50        '_block1' => array(
51          'Site_DebugBox', 'Site_Handler', 'Site_Request', 'Site_Loader', 'Site_Http', 'Site_Template'
52        ),
53        '_block2' => array(
54          'User', 'Session',
55        ),
56        '_block3' => array(
57          'LocaleText' => array( ref_names => array('lt'), run => '_'),
58        ),
59      );
60    
61    // this collects all/some stuff (object variables and methods)    // this collects all/some stuff (object variables and methods)
62    // from other (helper)-objects and acts as a dispatcher to them...    // from other (helper)-objects and acts as a dispatcher to them...
63    // ...is this a bridge then?    // ...is this a bridge then?
# Line 47  class Site extends Site_Boot { Line 68  class Site extends Site_Boot {
68    // - implement autoloading mechanism via php's overload    // - implement autoloading mechanism via php's overload
69    
70    // essentials (more or less)    // essentials (more or less)
71      var $configuration;  // new - the configuration object (a Application::Config one....)
72    var $config;      // config  ...is very essential (especially preboot stuff)    var $config;      // config  ...is very essential (especially preboot stuff)
73    var $logger;     // logging? yea    var $logger;     // logging? yea
74    var $db;          // the database handle (actually a PEAR::DB)    var $db;          // the database handle (actually a PEAR::DB)
# Line 62  class Site extends Site_Boot { Line 84  class Site extends Site_Boot {
84    var $session;    var $session;
85    var $user;    var $user;
86    
87    function Site(&$config) {    function Site(&$configObject) {
88        //print "Site<br>";
89        //print Dumper($configObject);
90        parent::constructor();
91      // this will not work, logger is initialized two lines below      // this will not work, logger is initialized two lines below
92      $this->log( get_class($this) . "->Site( config $config )", LOG_DEBUG );      $this->log( get_class($this) . "->new", PEAR_LOG_DEBUG );
93      $this->config = $config;      $this->configuration = &$configObject;
94      $this->_init_logger();      $this->config = $this->configuration->get();
95      $this->_init_helpers();      //$this->_init_logger();
96      $this->_init_application();      $this->_init_session();
97      $this->_init_database();      $this->_init_database();
98      $this->_init_smarty();      $this->_init_smarty();
99      $this->_init_lt();      $this->_init_locales();
100      }
101    
102      // -------------------------------------------------------------------------
103      // Initializers for various things
104      //    called on object instantiation by constructor
105      //
106    
107      function _init_session() {
108        global $site_state;
109        session_register_safe('site_state');
110        if (!is_array($site_state)) { $site_state = array(); }
111      }
112      
113      function _init_smarty() {
114        $this->log( get_class($this) . "->_init_smarty()", PEAR_LOG_DEBUG );
115    
116        // smarty (template engine)
117          $smarty = new Smarty;
118          $smarty->template_dir = $this->config[path][templates];
119          $smarty->compile_dir = $this->config[path]["var"] . "smarty/templates_c/";
120          $smarty->config_dir = $this->config[path]["var"] . "smarty/configs/";
121          $smarty->cache_dir = $this->config[path]["var"] . "smarty/cache/";
122          $smarty->compile_check = true;
123    
124          // trace
125          //print Dumper($smarty);
126    
127          //$smarty->caching = false;
128          //$smarty->caching = true;
129          // TODO: inherit global debugging option(s) here?
130          //$smarty->debugging = true;
131          // we declare "volatile" as a special namespace/cache key which is clean on each script-startup/reuse
132          $smarty->clear_cache(null, "volatile");
133          //$site->smarty = &$smarty;
134          $this->smarty = &$smarty;
135          //$site->log( "init_site: smarty ready", PEAR_LOG_DEBUG);
136      }
137    
138      // LocaleText-class for language
139      function _init_locales() {
140         $this->log( get_class($this) . "->_init_lt: LocaleText starting", PEAR_LOG_DEBUG);
141        
142        $this->lt->start();
143    
144        // Set locale according to chosen language (needed for date/time functions)
145        // TODO: set this according to user's profile
146        // TODO: make an flib/Application/l10n/Locale.php from this (available by doing e.g. an '$locale_key = $app->l10n->getLocaleKey()')
147        // TODO: don't wire this to the locale-text setting
148        //             ---> actually wire the locale-text setting to $app->l10n->getLocaleKey()      (the other way round....)
149        $langkey = $this->localetext->getCurrentLanguage();
150        if($langkey == "de") {
151            setlocale (LC_ALL, 'de_DE');
152        }
153        elseif($langkey == "en") {
154            setlocale (LC_ALL, 'en_US');
155        }
156        elseif($langkey == "tr") {
157            setlocale (LC_ALL, 'tr_TR');
158        }
159    
160    }    }
161    
162      // -------------------------------------------------------------------------
163    // Dispatchers for all subobjects    // Dispatchers for all subobjects
164      // TODO:      // TODO:
165      //    - make this much more generic      //    - make this much more generic
# Line 150  class Site extends Site_Boot { Line 236  class Site extends Site_Boot {
236      return $site->user->isLoggedOn();      return $site->user->isLoggedOn();
237    }    }
238        
   function log($msg, $level) {  
     if ($this->logger) {  
       $this->logger->log($msg, $level);  
     } else {  
       // TODO: how are these type of errors handled?  
       //print "error-message: $msg<br>";  
     }  
   }  
     
239    function loadCmsPage($template, $data_merge = array()) {    function loadCmsPage($template, $data_merge = array()) {
240            
241  //print Dumper($this->getRequest());  //print Dumper($this->getRequest());

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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