/[cvs]/nfo/php/libs/org.netfrag.glib/Application/Core.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/Application/Core.php

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

revision 1.2 by joko, Mon Feb 3 14:42:28 2003 UTC revision 1.5 by joko, Wed Mar 5 23:16:47 2003 UTC
# Line 1  Line 1 
1  <?  <?
2    /**
3     * This file contains the Application::Core module.
4     *
5     * @author Andreas Motl <andreas.motl@ilo.de>
6     * @package org.netfrag.glib
7     * @name Application::Core
8     *
9     */
10    
11    
12  // ---------------------------------------------------------------------------  // ---------------------------------------------------------------------------
13  //  $Id$  //  $Id$
14  // ---------------------------------------------------------------------------  // ---------------------------------------------------------------------------
15  //  $Log$  //  $Log$
16    //  Revision 1.5  2003/03/05 23:16:47  joko
17    //  updated docu - phpDocumentor is very strict about its 'blocks'...
18    //
19    //  Revision 1.4  2003/03/03 21:11:01  joko
20    //  mungled the namespaces
21    //
22    //  Revision 1.3  2003/02/09 17:05:15  joko
23    //  + minor update related to new log level constants
24    //  + restructured get-/setter methods
25    //
26  //  Revision 1.2  2003/02/03 14:42:28  joko  //  Revision 1.2  2003/02/03 14:42:28  joko
27  //  + logging (LOG_DEBUG)  //  + added logging
28  //  + methods for accessing configuration variables  //  + methods for accessing configuration variables
29  //  //
30  //  Revision 1.1  2003/02/03 05:00:01  joko  //  Revision 1.1  2003/02/03 05:00:01  joko
# Line 13  Line 33 
33  // ---------------------------------------------------------------------------  // ---------------------------------------------------------------------------
34    
35    
36  /*  $appConfig = mkObject('Application::Config', $init);
37    
38    ------------------------------------------------------------  $app = mkObject('Application::Core', $appConfig);
39      How to use this?  $app->run();
   ------------------------------------------------------------  
   
     require_once("../etc/defaults.php");  
     require_once("../etc/includes.php");  
       
     $init =  
       array(  
         'machine' => 'grasshopper',  
         'appname' => 'pub',  
         'resources' => array(  
           'machines' => '../etc/machines.php',  
         ),  
         'run' => array(  
           'boot' => array(  
             'scripts' => array( '../core/boot/boot.php' ),  
             //'objects' => array(),  
             'methods' => array( 'e_init', 'e_start', 'e_shutdown' ),  
           ),  
         ),  
       );  
       
     $appConfig = mkObject('Application::Config', $init);  
       
     $app = mkObject('Application::Core', $appConfig);  
     $app->run();  
40    
   ------------------------------------------------------------  
41    
42  */  loadModule('Class::Logger');
43    
44    
45  class Application_Core extends DesignPattern_Logger {  /**
46     * This is the Application::Core module.
47     *
48     * How to use this?
49     *
50     * <code>
51     * require_once("../etc/defaults.php");
52     * require_once("../etc/includes.php");
53     *
54     * $init =
55     *   array(
56     *     'machine' => 'grasshopper',
57     *     'appname' => 'pub',
58     *     'resources' => array(
59     *       'machines' => '../etc/machines.php',
60     *     ),
61     *     'run' => array(
62     *       'boot' => array(
63     *         'scripts' => array( '../core/boot/boot.php' ),
64     *         //'objects' => array(),
65     *         'methods' => array( 'e_init', 'e_start', 'e_shutdown' ),
66     *       ),
67     *     ),
68     *   );
69     * </code>
70     *
71     *
72     * @author Andreas Motl <andreas.motl@ilo.de>
73     * @package org.netfrag.glib
74     * @subpackage Application
75     * @name Application::AbstractBase
76     *
77     */
78    class Application_Core extends Class_Logger {
79        
80    var $_config;    var $_config;
81        
# Line 61  class Application_Core extends DesignPat Line 88  class Application_Core extends DesignPat
88    
89      parent::constructor();      parent::constructor();
90    
91      $this->log(get_class($this) . "->run: begin", LOG_INFO);      $this->log("-----------------------------------------------------------------", PEAR_LOG_INFO);
92        $this->log(get_class($this) . "->run: begin", PEAR_LOG_INFO);
93            
94      $cfg = $this->getConfig();      $cfg = $this->getConfig();
95    
# Line 84  class Application_Core extends DesignPat Line 112  class Application_Core extends DesignPat
112        // run procedural functions        // run procedural functions
113        if (is_array($container[methods])) {        if (is_array($container[methods])) {
114          foreach ($container[methods] as $method) {          foreach ($container[methods] as $method) {
115            $this->log(get_class($this) . "->run: calling function in global namespace: '$method'", LOG_DEBUG);            $this->log(get_class($this) . "->run: calling function in global namespace: '$method'", PEAR_LOG_DEBUG);
116            call_user_func($method);            call_user_func($method);
117          }          }
118        }        }
119    
120      }      }
121            
122      $this->log(get_class($this) . "->run: end", LOG_INFO);      $this->log(get_class($this) . "->run: end", PEAR_LOG_INFO);
123    
124    }    }
125        
126    function getConfig($var = null) {    function getConfig($var = null) {
127      return $this->_config->getPart($var);      return $this->_config->get($var);
128    }    }
129        
130    function _require_once_isolated($file) {    function _require_once_isolated($file) {
131      $this->log(get_class($this) . "->_require_once_isolated: $file", LOG_DEBUG);      $this->log(get_class($this) . "->_require_once_isolated: $file", PEAR_LOG_DEBUG);
132      if (require_once($file)) {      if (require_once($file)) {
133        return 1;        return 1;
134      }      }
# Line 108  class Application_Core extends DesignPat Line 136  class Application_Core extends DesignPat
136        
137    function setConfigVar($var, $val) {    function setConfigVar($var, $val) {
138      //print "$var=$val<br>";      //print "$var=$val<br>";
139      $this->_config->setVar($var, $val);      $this->_config->set_absolute($var, $val);
140    }    }
141    
142    function getConfigVar($var) {    function getConfigVar($var) {
143      return $this->_config->getVar($var);      return $this->_config->get_absolute($var);
144    }    }
145    
146  }  }

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

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