/[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.9 by jonen, Thu Aug 11 14:07:45 2005 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    -------------------------------------------------------------------------------  //    -------------------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.9  2005/08/11 14:07:45  jonen
7    //    + added workaround for locale_number problem relating to generate Postscript files
8    //
9    //    Revision 1.8  2005/01/21 16:51:57  jonen
10    //    + changed lang-key for turkish
11    //
12    //    Revision 1.7  2004/11/15 17:24:50  jonen
13    //    + updated 'setlocale' for FreeBSD
14    //
15    //    Revision 1.6  2003/02/09 17:29:02  joko
16    //    - refactored code to org.netfrag.glib/
17    //    + added startup code here (Site/Boot.php got purged)
18    //
19  //    Revision 1.5  2002/12/23 11:33:58  jonen  //    Revision 1.5  2002/12/23 11:33:58  jonen
20  //    + minor changes  //    + minor changes
21  //  //
# Line 32  Line 45 
45  //    -------------------------------------------------------------------------------  //    -------------------------------------------------------------------------------
46    
47    
48  require_once 'Site/Boot.php';  require_once 'Site/DebugBox.php';
49    require_once 'Site/ExtHttp.php';
50    require_once 'Site/Misc.php';
51    require_once 'Site/Template.php';
52    
53  class Site extends Site_Boot {  class Site extends Application_AbstractBase {
54  //class Site extends PEAR_Autoloader {  //class Site extends PEAR_Autoloader {
55    
56      //$this->_mkEmbeddedObjects( array( parent_name => get_class($this), run => 'start', class_names => $class_names, ref_names => $ref_names ) );
57    
58      var $children = array(
59        '_block1' => array(
60          'Site_DebugBox', 'Site_Handler', 'Site_Request', 'Site_Loader', 'Site_Http', 'Site_Template'
61        ),
62        '_block2' => array(
63          'User', 'Session',
64        ),
65        '_block3' => array(
66          'LocaleText' => array( ref_names => array('lt'), run => '_'),
67        ),
68      );
69    
70    // this collects all/some stuff (object variables and methods)    // this collects all/some stuff (object variables and methods)
71    // from other (helper)-objects and acts as a dispatcher to them...    // from other (helper)-objects and acts as a dispatcher to them...
72    // ...is this a bridge then?    // ...is this a bridge then?
# Line 47  class Site extends Site_Boot { Line 77  class Site extends Site_Boot {
77    // - implement autoloading mechanism via php's overload    // - implement autoloading mechanism via php's overload
78    
79    // essentials (more or less)    // essentials (more or less)
80      var $configuration;  // new - the configuration object (a Application::Config one....)
81    var $config;      // config  ...is very essential (especially preboot stuff)    var $config;      // config  ...is very essential (especially preboot stuff)
82    var $logger;     // logging? yea    var $logger;     // logging? yea
83    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 93  class Site extends Site_Boot {
93    var $session;    var $session;
94    var $user;    var $user;
95    
96    function Site(&$config) {    function Site(&$configObject) {
97        //print "Site<br>";
98        //print Dumper($configObject);
99        parent::constructor();
100      // this will not work, logger is initialized two lines below      // this will not work, logger is initialized two lines below
101      $this->log( get_class($this) . "->Site( config $config )", LOG_DEBUG );      $this->log( get_class($this) . "->new", PEAR_LOG_DEBUG );
102      $this->config = $config;      $this->configuration = &$configObject;
103      $this->_init_logger();      $this->config = $this->configuration->get();
104      $this->_init_helpers();      //$this->_init_logger();
105      $this->_init_application();      $this->_init_session();
106      $this->_init_database();      $this->_init_database();
107      $this->_init_smarty();      $this->_init_smarty();
108      $this->_init_lt();      $this->_init_locales();
109      }
110    
111      // -------------------------------------------------------------------------
112      // Initializers for various things
113      //    called on object instantiation by constructor
114      //
115    
116      function _init_session() {
117        global $site_state;
118        session_register_safe('site_state');
119        if (!is_array($site_state)) { $site_state = array(); }
120      }
121      
122      function _init_smarty() {
123        $this->log( get_class($this) . "->_init_smarty()", PEAR_LOG_DEBUG );
124    
125        // smarty (template engine)
126          $smarty = new Smarty;
127          $smarty->template_dir = $this->config[path][templates];
128          $smarty->compile_dir = $this->config[path]["var"] . "smarty/templates_c/";
129          $smarty->config_dir = $this->config[path]["var"] . "smarty/configs/";
130          $smarty->cache_dir = $this->config[path]["var"] . "smarty/cache/";
131          $smarty->compile_check = true;
132    
133          // trace
134          //print Dumper($smarty);
135    
136          //$smarty->caching = false;
137          //$smarty->caching = true;
138          // TODO: inherit global debugging option(s) here?
139          //$smarty->debugging = true;
140          // we declare "volatile" as a special namespace/cache key which is clean on each script-startup/reuse
141          $smarty->clear_cache(null, "volatile");
142          //$site->smarty = &$smarty;
143          $this->smarty = &$smarty;
144          //$site->log( "init_site: smarty ready", PEAR_LOG_DEBUG);
145      }
146    
147      // LocaleText-class for language
148      function _init_locales() {
149         $this->log( get_class($this) . "->_init_lt: LocaleText starting", PEAR_LOG_DEBUG);
150        
151        $this->lt->start();
152    
153        // Set locale according to chosen language (needed for date/time functions)
154        // TODO: set this according to user's profile
155        // TODO: make an flib/Application/l10n/Locale.php from this (available by doing e.g. an '$locale_key = $app->l10n->getLocaleKey()')
156        // TODO: don't wire this to the locale-text setting
157        //             ---> actually wire the locale-text setting to $app->l10n->getLocaleKey()      (the other way round....)
158        $langkey = $this->localetext->getCurrentLanguage();
159    
160        $ident = $_GET[x];
161        // fallback to post
162        if (!$ident) { $ident = $_POST[x]; }
163    
164        if($langkey == "de") {
165          if(($ident == '/terminal/deposit/' || $ident == '/terminal/ss_success/') && $this->session->get('validTerminal')) {
166            if(!setlocale (LC_ALL, 'en_US')) {
167              // needed at e.g. FreeBSD
168              setlocale (LC_ALL, 'en_US.ISO_8859-1');
169            }
170          } else {
171            if(!setlocale (LC_ALL, 'de_DE')) {
172              // needed at e.g. FreeBSD
173              setlocale (LC_ALL, 'de_DE.ISO_8859-1');
174            }
175          }
176        }
177        elseif($langkey == "en") {
178            if(!setlocale (LC_ALL, 'en_US')) {
179              // needed at e.g. FreeBSD
180              setlocale (LC_ALL, 'en_US.ISO_8859-1');
181            }
182        }
183        elseif($langkey == "tr") {
184          if(($ident == '/terminal/deposit/' || $ident == '/terminal/ss_success/') && $this->session->get('validTerminal')) {
185          //if($_POST[xsend] && $this->session->get('validTerminal')) {
186            if(!setlocale (LC_ALL, 'en_US')) {
187              // needed at e.g. FreeBSD
188              setlocale (LC_ALL, 'en_US.ISO_8859-1');
189            }
190          } else {
191            if(!setlocale (LC_ALL, 'tr_TR')) {
192              // needed at e.g. FreeBSD
193              setlocale (LC_ALL, 'tr_TR.ISO_8859-1');
194            }
195          }
196        }
197    
198    }    }
199    
200      // -------------------------------------------------------------------------
201    // Dispatchers for all subobjects    // Dispatchers for all subobjects
202      // TODO:      // TODO:
203      //    - make this much more generic      //    - make this much more generic
# Line 150  class Site extends Site_Boot { Line 274  class Site extends Site_Boot {
274      return $site->user->isLoggedOn();      return $site->user->isLoggedOn();
275    }    }
276        
   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>";  
     }  
   }  
     
277    function loadCmsPage($template, $data_merge = array()) {    function loadCmsPage($template, $data_merge = array()) {
278            
279  //print Dumper($this->getRequest());  //print Dumper($this->getRequest());

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

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