forked from mayflower/PHProjekt
/
index.php
132 lines (105 loc) · 4.23 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* Bootstrap file.
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* @category Htdocs
* @package Htdocs
* @copyright Copyright (c) 2008 Mayflower GmbH (http://www.mayflower.de)
* @version $Id$
* @license LGPL 2.1 (See LICENSE file)
* @author David Soria Parra <david.soria_parra@mayflower.de>
* @since File available since Release 6.0
*/
define('PHPR_CONFIG_SECTION', 'production');
define('PHPR_ROOT_PATH', realpath(dirname(__FILE__) . '/../'));
define('PHPR_CORE_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application');
define('PHPR_LIBRARY_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'library');
define('PHPR_CONFIG_FILE', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'configuration.ini');
define('PHPR_TEMP_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'tmp/');
set_include_path('.' . PATH_SEPARATOR
. PHPR_LIBRARY_PATH . PATH_SEPARATOR
. PHPR_CORE_PATH . PATH_SEPARATOR
. get_include_path());
require_once 'Zend/Loader.php';
require_once 'Phprojekt/Loader.php';
Zend_Loader::registerAutoload('Phprojekt_Loader');
/* Start zend session to handle all session stuff */
Zend_Session::start();
/* Read the config file, but only the production setting */
try {
$config = new Zend_Config_Ini(PHPR_CONFIG_FILE, PHPR_CONFIG_SECTION, true);
Zend_Registry::set('config', $config);
} catch (Zend_Config_Exception $error) {
$error->getMessage();
echo 'You need the file configuration.ini to continue';
die();
}
if (substr($config->webpath, -1) != '/') {
$config->webpath.= '/';
}
define('PHPR_ROOT_WEB_PATH', $config->webpath . 'index.php/');
/* Make the connection to the DB*/
// require_once 'Zend/Db.php';
$db = Zend_Db::factory($config->database->type, array(
'host' => $config->database->host,
'username' => $config->database->username,
'password' => $config->database->password,
'dbname' => $config->database->name,
));
Zend_Registry::set('db', $db);
/**
* Initialize Debug Log
*
* use $log->priority($txt);
* Where priority can be emerg,alert,crit,err,warn,notice,info,debug
*/
Zend_Loader::loadClass('Phprojekt_Log', PHPR_LIBRARY_PATH);
$log = new Phprojekt_Log($config);
Zend_Registry::set('log', $log);
$view = new Zend_View();
$view->addScriptPath(PHPR_CORE_PATH . '/Default/Views/dojo/');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
$viewRenderer->setViewBasePathSpec(':moduleDir/Views');
$viewRenderer->setViewScriptPathSpec(':action.:suffix');
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
/* Languages Set */
Zend_Loader::loadClass('Phprojekt_Language', PHPR_LIBRARY_PATH);
$translate = new Phprojekt_Language(Phprojekt_User_User::getSetting("language", $config->language));
/* Front controller stuff */
$front = Zend_Controller_Front::getInstance();
$front->setDispatcher(new Phprojekt_Dispatcher());
$plugin = new Zend_Controller_Plugin_ErrorHandler();
$plugin->setErrorHandlerModule('Default');
$plugin->setErrorHandlerController('Error');
$plugin->setErrorHandlerAction('error');
$front->registerPlugin($plugin);
$front->setDefaultModule('Default');
foreach (scandir(PHPR_CORE_PATH) as $module) {
$dir = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $module;
if (is_dir(!$dir)) {
continue;
}
if (is_dir($dir . DIRECTORY_SEPARATOR . 'Controllers')) {
$front->addModuleDirectory($dir);
}
$helperPath = $dir . DIRECTORY_SEPARATOR . 'Helpers';
if (is_dir($helperPath)) {
$view->addHelperPath($helperPath, $module . '_' . 'Helpers');
Zend_Controller_Action_HelperBroker::addPath($helperPath);
}
}
Zend_Registry::set('view', $view);
Zend_Registry::set('translate', $translate);
$front->setModuleControllerDirectoryName('Controllers');
$front->addModuleDirectory(PHPR_CORE_PATH);
$front->setParam('useDefaultControllerAlways', true);
$front->dispatch();