2 require_once('plugins/plugin.charsetheader.php');
3 require_once('plugins/plugin.forceauth.php');
4 require_once('plugins/plugin.loginlogout.php');
5 require_once('plugins/plugin.buildmenu.php');
6 require_once('config/Config.php');
7 require_once('log/Log.php');
8 require_once('l10n/L10n.php');
9 require_once('i18n/I18n.php');
11 class Bootstrap
extends Zend_Application_Bootstrap_Bootstrap
{
12 protected function _initAutoload() {
13 $autoloader = new Zend_Application_Module_Autoloader(array(
14 'namespace' => 'Default_',
15 'basePath' => dirname(__FILE__
)
20 protected function _initPlugins() {
21 $this->bootstrap('session');
23 $fc = Zend_Controller_Front
::getInstance();
25 $charset_header = new CharsetHeader();
26 $fc->registerPlugin($charset_header);
28 $force_auth = new ForceAuth();
29 $fc->registerPlugin($force_auth);
31 $buildmenu = new BuildMenu();
32 $fc->registerPlugin($buildmenu);
34 $loginlogout = new LoginLogout();
35 $fc->registerPlugin($loginlogout);
38 protected function _initDoctype() {
39 $this->bootstrap('view');
40 $this->bootstrap('log');
41 $this->bootstrap('I18n');
42 $this->bootstrap('session');
44 $view = $this->getResource('view');
45 Zend_Registry
::set('view', $view);
46 $view->doctype('XHTML1_STRICT');
47 $view->addHelperPath(APPLICATION_PATH
. '/views/helpers/');
48 $view->headTitle
= I18n
::_('CAcert Test Manager');
52 * @todo expireSessionCookie()
53 * @todo rememberMe(xx)
55 * @see Zend_Registry::get('session');
56 * @return Zend_Session_Namespace
58 protected function _initSession() {
59 $options = $this->getOption('ca_mgr');
61 $db = Zend_Db
::factory($options['db']['session']['pdo'], $options['db']['session']);
64 * automatically clean up expired session entries from session cache
65 * use the modified and lifetime stamps to calculate expire time
67 if ($options['db']['session']['autocleanup'] == '1') {
68 $stmt = $db->query('delete from front_session where (modified + lifetime * 2) < unix_timestamp()');
72 //you can either set the Zend_Db_Table default adapter
73 //or you can pass the db connection straight to the save handler $config
74 // @see lifetimeColumn / lifetime / overrideLifetime, lifetime defaults to php.ini: session.gc_maxlifetime
75 Zend_Db_Table_Abstract
::setDefaultAdapter($db);
77 'name' => 'front_session',
79 'modifiedColumn' => 'modified',
80 'dataColumn' => 'data',
81 'lifetimeColumn' => 'lifetime'
84 //create your Zend_Session_SaveHandler_DbTable and
85 //set the save handler for Zend_Session
86 Zend_Session
::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
88 // Zend_Session::rememberMe(7200);
91 Zend_Session
::start();
93 $session = new Zend_Session_Namespace();
94 if (!isset($session->started
))
95 $session->started
= time();
96 if (!isset($session->authdata
))
97 $session->authdata
= array('authed' => false
);
99 Zend_Registry
::set('session', $session);
104 * get the basic system config from database, store the config object in the bootstrap registry
105 * @see Zend_Registry::get('config');
108 protected function _initConfig() {
109 $options = $this->getOption('ca_mgr');
110 $db = Zend_Db
::factory($options['db']['config']['pdo'], $options['db']['config']);
111 $config = Config
::getInstance(SYSTEM_CONFIG
, $db);
113 Zend_Registry
::set('config', $config);
114 Zend_Registry
::set('config_dbc', $db);
120 * make singleton system logger
121 * @see Zend_Registry::get('log');
124 public function _initLog() {
125 $this->bootstrap('Config');
127 $op = $this->getOption('log');
128 $log = Log
::getInstance(SYSTEM_LOG
, $op['application']);
130 Zend_Registry
::set('log', $log);
135 * make singleton I18n (internationalization) object (translation)
137 public function _initI18n() {
138 $this->bootstrap('Config');
139 // need existing L10n object for initialization
140 $this->bootstrap('L10n');
142 $I18n = I18n
::getInstance(L10n
::getInstance()->getLanguage());
146 * make singleton L10n (localization) object (set locale, convert date and
149 public function _initL10n() {
150 $this->bootstrap('Config');
152 $L10n = L10n
::getInstance();