Viewing File core/FreeDESK.php of 0.00.0a
|
1: <?php 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 = 0; 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: // Methods and Processes in Main FreeDESK class 131: 132: /** 133: * Constructor for FreeDESK 134: * @param string $baseDir Base directory of the system (file root, can be relative) 135: **/ 136: function FreeDESK($baseDir) 137: { 138: $this->BaseDir = $baseDir; 139: // First include and instantiate the include system for all further includes 140: require($baseDir."core/IncludeManager.php"); 141: //or die("Cannot open core/IncludeManager.php - fatal error"); 142: $this->Include = new IncludeManager($this, $baseDir); 143: 144: // Error Containers 145: $this->Include->IncludeFile("core/Error.php"); 146: 147: // Now the basic configuration 148: $this->BaseConfig = $this->Include->IncludeInstance("config/Config.php","FreeDESK_Configuration",false); 149: 150: // Permission Manager 151: $this->PermissionManager = $this->Include->IncludeInstance("core/PermissionManager.php", "PermissionManager"); 152: 153: // Plugin Manager 154: $this->PluginManager = $this->Include->IncludeInstance("core/PluginManager.php","PluginManager"); 155: // And the PIM Base 156: $this->Include->IncludeFile("core/FreeDESK_PIM.php"); 157: 158: // Register Ourselves 159: $core = new Plugin(); 160: $core->name="FreeDESK Core"; 161: $core->version=$this->Version(); 162: $core->type="Core"; 163: $this->PluginManager->Register($core); 164: 165: // XML Creator 166: $this->Include->IncludeExec("core/XML.php","xmlCreate"); 167: 168: // Database Engine 169: // First include the base class 170: $this->Include->IncludeFile("core/database/DatabaseBase.php"); 171: // Now the concrete class 172: $this->Database = $this->Include->IncludeInstance("core/database/".$this->BaseConfig->db_System.".php", 173: $this->BaseConfig->db_System); 174: 175: // Configuration Manager 176: $this->Configuration = $this->Include->IncludeInstance("core/Configuration.php","Configuration"); 177: 178: // Logging Engine 179: $this->LoggingEngine = $this->Include->IncludeInstance("core/LoggingEngine.php", "LoggingEngine"); 180: 181: // Data Dictionary 182: $this->DataDictionary = $this->Include->IncludeInstance("core/DataDictionary.php", "DataDictionary"); 183: $this->Include->IncludeExec("config/DD.php","FreeDESK_DD"); // Core DD 184: 185: // Context Manager 186: $this->ContextManager = $this->Include->IncludeInstance("core/ContextManager.php", "ContextManager"); 187: 188: // Authentication Methods 189: // The core files 190: $this->Include->IncludeFile("core/auth/AuthMethodBase.php"); 191: $this->Include->IncludeFile("core/auth/AuthenticationFactory.php"); 192: // Inbuilt Methods 193: $this->Include->IncludeExec("core/auth/AuthMethodStandard.php","AuthMethodStandard"); 194: 195: // Entity Classes 196: $this->Include->IncludeFile("core/entity/EntityBase.php"); 197: $this->Include->IncludeFile("core/entity/EntityList.php"); 198: $this->Include->IncludeExec("core/entity/Entity.php","Entity"); 199: $this->Include->IncludeExec("core/entity/EntityFactory.php", "EntityFactory"); 200: $this->EntityManager = $this->Include->IncludeInstance("core/entity/EntityManager.php", "EntityManager"); 201: 202: // Request Classes 203: $this->Include->IncludeFile("core/request/RequestBase.php"); 204: $this->Include->IncludeFile("core/request/Request.php"); 205: $this->Include->IncludeExec("core/request/RequestFactory.php", "RequestFactory"); 206: $this->RequestManager = $this->Include->IncludeInstance("core/request/RequestManager.php", "RequestManager"); 207: 208: // Skin 209: $this->Skin = $this->Include->IncludeInstance("core/Skin.php","Skin"); 210: 211: // Language 212: $this->Lang = $this->Include->IncludeInstance("core/Language.php", "Language"); 213: 214: } 215: 216: /** 217: * Start the FreeDESK system, will connect to the database and load configuration 218: * @return bool True on successful start otherwise false on failure 219: **/ 220: function Start() 221: { 222: // Connect to the database 223: if (!$this->Database->Connect($this->BaseConfig->db_Server, $this->BaseConfig->db_Username, 224: $this->BaseConfig->db_Password, $this->BaseConfig->db_Database, $this->BaseConfig->db_Prefix)) 225: return false; 226: // Load system configuration 227: $this->Configuration->Load(); 228: // Logging Engine 229: $this->LoggingEngine->Start(); 230: $this->LoggingEngine->Log("FreeDESK Startup ".$this->FullVersion(),"Core","Start",10); 231: 232: // Register System Pages 233: $this->PluginManager->RegisterPage("debug","pages/debug.php",false); 234: $this->PluginManager->RegisterPage("sysadmin","pages/sysadmin.php",true); 235: 236: // Load the PIMs 237: $this->PluginManager->LoadPIMS(); 238: 239: return true; 240: } 241: 242: /** 243: * Stop the FreeDESK system - disconnect from the database 244: **/ 245: function Stop() 246: { 247: $this->Database->Disconnect(); 248: } 249: 250: } 251: ?> 252: