Changeset 8 for trunk/Application/Core.php
- Timestamp:
- Jun 1, 2023, 12:18:18 AM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r7 r8 4 4 if (file_exists($ConfigFileName)) include_once($ConfigFileName); 5 5 6 include_once(dirname(__FILE__).'/../Packages/Common/Common.php'); 6 include_once(dirname(__FILE__).'/../Packages/Common/PackageCommon.php'); 7 include_once(dirname(__FILE__).'/../Packages/FormManager/PackageFormManager.php'); 7 8 include_once(dirname(__FILE__).'/Version.php'); 8 include_once(dirname(__FILE__).'/View.php'); 9 include_once(dirname(__FILE__).'/BaseView.php'); 10 include_once(dirname(__FILE__).'/PageMissing.php'); 9 11 include_once(dirname(__FILE__).'/UpdateTrace.php'); 10 12 include_once(dirname(__FILE__).'/DefaultConfig.php'); 11 13 include_once(dirname(__FILE__).'/../Global.php'); 12 14 13 class Core extends Application15 class Core extends System 14 16 { 15 var $Pages;16 var $ShowPage;17 var $BaseURL;18 var $Config;19 var $HeadItems;20 var $Bars;21 /** @var FormManager */22 var $FormManager;17 public bool $ShowPage; 18 public string $BaseURL; 19 public array $Config; 20 public array $HeadItems; 21 public array $Bars; 22 public array $PathItems; 23 public FormManager $FormManager; 24 public BaseView $BaseView; 23 25 24 26 function __construct() … … 65 67 $this->RegisterPageBar('TopLeft'); 66 68 67 // Register and start existing modules 68 $this->Setup = new Setup($this); 69 $this->Setup->Start(); 70 if ($this->Setup->CheckState()) 69 $this->StartModules(); 70 } 71 72 function StartModules(): void 73 { 74 $ModuleSetup = $this->ModuleManager->LoadModule(dirname(__FILE__).'/../Packages/Common/Modules/ModuleSetup.php'); 75 $ModuleSetup->Install(); 76 $ModuleSetup->Start(); 77 $this->ModuleManager->LoadModules(); 78 $this->ModuleManager->LoadModule(dirname(__FILE__).'/../Packages/Common/Modules/ModuleAdmin.php'); 79 if (file_exists($this->ModuleManager->FileName)) $this->ModuleManager->LoadState(); 80 if (ModuleSetup::Cast($ModuleSetup)->CheckState()) 71 81 { 72 $this->ModuleManager->Start ();82 $this->ModuleManager->StartAll(array(ModuleCondition::Enabled)); 73 83 } 74 84 } 75 85 76 function Run() 86 function Run(): void 77 87 { 78 88 $this->RunCommon(); … … 98 108 echo($this->BaseView->GetOutput($Page)); 99 109 } 100 101 function RegisterPage($Path, $Handler) 102 { 103 if (is_array($Path)) 104 { 105 $Page = &$this->Pages; 106 $LastKey = array_pop($Path); 107 foreach ($Path as $PathItem) 108 { 109 $Page = &$Page[$PathItem]; 110 } 111 if (!is_array($Page)) $Page = array('' => $Page); 112 $Page[$LastKey] = $Handler; 113 } else $this->Pages[$Path] = $Handler; 114 } 115 116 function UnregisterPage($Path) 117 { 118 unset($this->Pages[$Path]); 119 } 120 110 121 111 function RegisterPageBar($Name) 122 112 { … … 148 138 } 149 139 150 function Link($Target) 140 function Link($Target): string 151 141 { 152 142 return $this->BaseURL.$Target; 153 143 } 154 }155 144 156 class PageMissing extends Page 157 { 158 function __construct($System) 145 static function Cast(System $System): Core 159 146 { 160 parent::__construct($System); 161 $this->ParentClass = ''; 162 $this->Title = T('Page not found'); 163 } 164 165 function Show() 166 { 167 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 168 return '<h3 align="center">'.T('Required page not found').'</h3>'; 147 if ($System instanceof Core) 148 { 149 return $System; 150 } 151 throw new Exception('Expected Core type but '.gettype($System)); 169 152 } 170 153 }
Note:
See TracChangeset
for help on using the changeset viewer.