Changeset 587
- Timestamp:
- Oct 31, 2013, 10:13:01 PM (11 years ago)
- Location:
- trunk/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/AppModule.php
r586 r587 6 6 const Normal = 1; 7 7 const Application = 2; 8 } 9 10 class ModuleAction 11 { 12 const Start = 0; 13 const Stop = 1; 14 const Install = 2; 15 const Uninstall = 3; 16 const Upgrade = 4; 17 const Enable = 5; 18 const Disable = 6; 19 } 20 21 class ModuleCondition 22 { 23 const All = 0; 24 const Enabled = 1; 25 const NotEnabled = 2; 26 const Installed = 3; 27 const NotInstalled = 4; 28 const Running = 5; 29 const NotRunning = 6; 8 30 } 9 31 … … 53 75 { 54 76 if($this->Running) return; 77 $List = array(); 78 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotRunning)); 79 $this->Manager->Perform($List, array(ModuleAction::Start), array(ModuleCondition::NotRunning)); 55 80 $this->DoStart(); 56 81 $this->Running = true; … … 60 85 { 61 86 if(!$this->Running) return; 62 $this->Running = false; 87 $this->Running = false; 88 $List = array(); 89 $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Running)); 90 $this->Manager->Perform($List, array(ModuleAction::Stop), array(ModuleCondition::Running)); 63 91 $this->DoStop(); 64 92 } … … 100 128 } 101 129 130 function Perform($List, $Actions, $Conditions = array(ModuleCondition::All)) 131 { 132 foreach($List as $Index => $Module) 133 { 134 if(in_array(ModuleCondition::All, $Conditions) or 135 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or 136 (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or 137 ($Module->Installed and in_array(ModuleCondition::Installed, $Conditions)) or 138 (!$Module->Installed and in_array(ModuleCondition::NotInstalled, $Conditions))) 139 { 140 foreach($Actions as $Action) 141 { 142 if($Action == ModuleAction::Start) $Module->Start(); 143 if($Action == ModuleAction::Stop) $Module->Stop(); 144 if($Action == ModuleAction::Install) $Module->Install(); 145 if($Action == ModuleAction::Uninstall) $Module->Uninstall(); 146 } 147 } 148 } 149 } 150 151 function EnumDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All)) 152 { 153 foreach($Module->Dependencies as $Dependency) 154 { 155 $DepModule = $this->Modules[$Dependency]; 156 if(in_array(ModuleCondition::All, $Conditions) or 157 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or 158 (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or 159 ($Module->Installed and in_array(ModuleCondition::Installed, $Conditions)) or 160 (!$Module->Installed and in_array(ModuleCondition::NotInstalled, $Conditions))) 161 { 162 array_push($List, $DepModule); 163 $this->EnumDependenciesCascade($DepModule, $List, $Conditions); 164 } 165 } 166 } 167 168 function EnumSuperiorDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All)) 169 { 170 foreach($this->Modules as $RefModule) 171 { 172 $DepModule = $this->Modules[$Dependency]; 173 if(in_array($Module->Name, $RefModule->Dependencies) and 174 (in_array(ModuleCondition::All, $Conditions) or 175 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or 176 (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or 177 ($Module->Installed and in_array(ModuleCondition::Installed, $Conditions)) or 178 (!$Module->Installed and in_array(ModuleCondition::NotInstalled, $Conditions)))) 179 { 180 array_push($List, $DepModule); 181 $this->EnumSuperiorDependenciesCascade($DepModule, $List, $Conditions); 182 } 183 } 184 } 185 102 186 function StartAll() 103 187 { 104 188 foreach($this->Modules as $Index => $Module) 105 189 { 106 //DebugLog('Init module '.$Module->Name); 107 if($this->Modules[$Index]->Running == false) 108 $this->Modules[$Index]->Start(); 190 $this->Modules[$Index]->Start(); 109 191 } 110 192 } … … 114 196 foreach($this->Modules as $Index => $Module) 115 197 { 116 //DebugLog('Init module '.$Module->Name); 117 if($this->Modules[$Index]->Running == true) 118 $this->Modules[$Index]->Stop(); 198 $this->Modules[$Index]->Stop(); 119 199 } 120 200 } -
trunk/Common/Version.php
r585 r587 1 1 <?php 2 2 3 $Revision = 5 85; // Subversion revision3 $Revision = 575; // Subversion revision 4 4 $DatabaseRevision = 584; // SQL structure revision 5 5 $ReleaseTime = '2013-10-31';
Note:
See TracChangeset
for help on using the changeset viewer.