File:
0.00.3a/core/FreeDESK.php (
View as Code)
1: 2: /* -------------------------------------------------------------
3: This file is part of FreeDESK
4:
5: FreeDESK is (C) Copyright 2012 David Cutting
6:
7: FreeDESK is free software: you can redistribute it and/or modify
8: it under the terms of the GNU General Public License as published by
9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
11:
12: FreeDESK is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with FreeDESK. If not, see www.gnu.org/licenses
19:
20: For more information see www.purplepixie.org/freedesk/
21: -------------------------------------------------------------- */
22:
23: /**
24: * Main FreeDESK class contains all sub-classes
25: **/
26: class FreeDESK
27: {
28: /**
29: * Major and Minor Version
30: **/
31: private $majorVersion = "0.00";
32: /**
33: * Patch Level
34: **/
35: private $patchVersion = 3;
36: /**
37: * Release level flag (a b or blank)
38: **/
39: private $releaseFlag = "a";
40: /**
41: * Get the full compound version
42: * @return string Compound version
43: **/
44: function Version()
45: {
46: return $this->majorVersion.".".$this->patchVersion;
47: }
48: /**
49: * Get the full compound version with release level flag
50: * @return string Full compound version with release flag
51: **/
52: function FullVersion()
53: {
54: return $this->Version().$this->releaseFlag;
55: }
56:
57:
58: /**
59: * Base Directory
60: **/
61: var $BaseDir = "";
62:
63: // Component Class Instances
64:
65: /**
66: * Configuration Class
67: **/
68: var $Configuration = null;
69:
70: /**
71: * Basic Configuration
72: **/
73: var $BaseConfig = null;
74:
75: /**
76: * Logging engine
77: **/
78: var $LoggingEngine = null;
79:
80: /**
81: * Plugin Manager
82: **/
83: var $PluginManager = null;
84:
85: /**
86: * Database
87: **/
88: var $Database = null;
89:
90: /**
91: * Entity Manager
92: **/
93: var $EntityManager = null;
94:
95: /**
96: * Data Dictionary
97: **/
98: var $DataDictionary = null;
99:
100: /**
101: * Context Manager
102: **/
103: var $ContextManager = null;
104:
105: /**
106: * Permission Manager
107: **/
108: var $PermissionManager = null;
109:
110: /**
111: * Request Manager
112: **/
113: var $RequestManager = null;
114:
115: /**
116: * Include System
117: **/
118: var $Include = null;
119:
120: /**
121: * Skin
122: **/
123: var $Skin = null;
124:
125: /**
126: * Language
127: **/
128: var $Lang = null;
129:
130: /**
131: * Email System
132: **/
133: var $Email = null;
134:
135: // Methods and Processes in Main FreeDESK class
136:
137: /**
138: * Constructor for FreeDESK
139: * @param string $baseDir Base directory of the system (file root, can be relative)
140: **/
141: function FreeDESK($baseDir)
142: {
143: $this->BaseDir = $baseDir;
144: // First include and instantiate the include system for all further includes
145: require($baseDir."core/IncludeManager.php");
146: //or die("Cannot open core/IncludeManager.php - fatal error");
147: $this->Include = new IncludeManager($this, $baseDir);
148:
149: // Error Containers
150: $this->Include->IncludeFile("core/Error.php");
151:
152: // Now the basic configuration
153: $this->BaseConfig = $this->Include->IncludeInstance("config/Config.php","FreeDESK_Configuration",false);
154:
155: // Permission Manager
156: $this->PermissionManager = $this->Include->IncludeInstance("core/PermissionManager.php", "PermissionManager");
157:
158: // Plugin Manager
159: $this->PluginManager = $this->Include->IncludeInstance("core/PluginManager.php","PluginManager");
160: // And the PIM Base
161: $this->Include->IncludeFile("core/FreeDESK_PIM.php");
162:
163: // Register Ourselves
164: $core = new Plugin();
165: $core->name="FreeDESK Core";
166: $core->version=$this->Version();
167: $core->type="Core";
168: $this->PluginManager->Register($core);
169:
170: // XML Creator
171: $this->Include->IncludeExec("core/XML.php","xmlCreate");
172:
173: // Database Engine
174: // First include the base class
175: $this->Include->IncludeFile("core/database/DatabaseBase.php");
176: // Now the concrete class
177: $this->Database = $this->Include->IncludeInstance("core/database/".$this->BaseConfig->db_System.".php",
178: $this->BaseConfig->db_System);
179:
180: // Configuration Manager
181: $this->Configuration = $this->Include->IncludeInstance("core/Configuration.php","Configuration");
182:
183: // Logging Engine
184: $this->LoggingEngine = $this->Include->IncludeInstance("core/LoggingEngine.php", "LoggingEngine");
185:
186: // Data Dictionary
187: $this->DataDictionary = $this->Include->IncludeInstance("core/DataDictionary.php", "DataDictionary");
188: $this->Include->IncludeExec("config/DD.php","FreeDESK_DD"); // Core DD
189:
190: // Context Manager
191: $this->ContextManager = $this->Include->IncludeInstance("core/ContextManager.php", "ContextManager");
192:
193: // Authentication Methods
194: // The core files
195: $this->Include->IncludeFile("core/auth/AuthMethodBase.php");
196: $this->Include->IncludeFile("core/auth/AuthenticationFactory.php");
197: // Inbuilt Methods
198: $this->Include->IncludeExec("core/auth/AuthMethodStandard.php","AuthMethodStandard");
199:
200: // Entity Classes
201: $this->Include->IncludeFile("core/entity/EntityBase.php");
202: $this->Include->IncludeFile("core/entity/EntityList.php");
203: $this->Include->IncludeExec("core/entity/Entity.php","Entity");
204: $this->Include->IncludeExec("core/entity/EntityFactory.php", "EntityFactory");
205: $this->EntityManager = $this->Include->IncludeInstance("core/entity/EntityManager.php", "EntityManager");
206:
207: // Request Classes
208: $this->Include->IncludeFile("core/request/RequestBase.php");
209: $this->Include->IncludeFile("core/request/Request.php");
210: $this->Include->IncludeExec("core/request/RequestFactory.php", "RequestFactory");
211: $this->RequestManager = $this->Include->IncludeInstance("core/request/RequestManager.php", "RequestManager");
212:
213: // Skin
214: $this->Skin = $this->Include->IncludeInstance("core/Skin.php","Skin");
215:
216: // Language
217: $this->Lang = $this->Include->IncludeInstance("core/Language.php", "Language");
218:
219: // Email
220: $this->Email = $this->Include->IncludeInstance("core/Email.php", "Email");
221:
222: // Browser Detection
223: $this->Include->IncludeFile("core/BrowserDetect.php");
224:
225: }
226:
227: /**
228: * Start the FreeDESK system, will connect to the database and load configuration
229: * @return bool True on successful start otherwise false on failure
230: **/
231: function Start()
232: {
233: // Connect to the database
234: if (!$this->Database->Connect($this->BaseConfig->db_Server, $this->BaseConfig->db_Username,
235: $this->BaseConfig->db_Password, $this->BaseConfig->db_Database, $this->BaseConfig->db_Prefix))
236: return false;
237: // Load system configuration
238: $this->Configuration->Load();
239: // Logging Engine
240: $this->LoggingEngine->Start();
241: $this->LoggingEngine->Log("FreeDESK Startup ".$this->FullVersion(),"Core","Start",10);
242:
243: // Register System Pages
244: $this->PluginManager->RegisterPage("debug","pages/debug.php",false);
245: $this->PluginManager->RegisterPage("sysadmin","pages/sysadmin.php",true);
246:
247: // Load the PIMs
248: $this->PluginManager->LoadPIMS();
249:
250: return true;
251: }
252:
253: /**
254: * Stop the FreeDESK system - disconnect from the database
255: **/
256: function Stop()
257: {
258: $this->Database->Disconnect();
259: }
260:
261: }
262: ?>
263: