Changeset 10 for Common/AppModule.php


Ignore:
Timestamp:
Apr 7, 2020, 8:52:35 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/AppModule.php

    r8 r10  
    7777  function Install()
    7878  {
    79     if($this->Installed) return;
     79    if ($this->Installed) return;
    8080    $List = array();
    8181    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled));
     
    8989  function Uninstall()
    9090  {
    91     if(!$this->Installed) return;
     91    if (!$this->Installed) return;
    9292    $this->Stop();
    9393    $this->Installed = false;
     
    100100  function Upgrade()
    101101  {
    102     if(!$this->Installed) return;
    103     if($this->InstalledVersion == $this->Version) return;
     102    if (!$this->Installed) return;
     103    if ($this->InstalledVersion == $this->Version) return;
    104104    $List = array();
    105105    $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed));
     
    117117  function Start()
    118118  {
    119     if($this->Running) return;
    120     if(!$this->Installed) return;
     119    if ($this->Running) return;
     120    if (!$this->Installed) return;
    121121    $List = array();
    122122    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotRunning));
     
    128128  function Stop()
    129129  {
    130     if(!$this->Running) return;
     130    if (!$this->Running) return;
    131131    $this->Running = false;
    132132    $List = array();
     
    144144  function Enable()
    145145  {
    146     if($this->Enabled) return;
    147     if(!$this->Installed) return;
     146    if ($this->Enabled) return;
     147    if (!$this->Installed) return;
    148148    $List = array();
    149149    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotEnabled));
     
    154154  function Disable()
    155155  {
    156     if(!$this->Enabled) return;
     156    if (!$this->Enabled) return;
    157157    $this->Stop();
    158158    $this->Enabled = false;
     
    203203  function Perform($List, $Actions, $Conditions = array(ModuleCondition::All))
    204204  {
    205     foreach($List as $Index => $Module)
    206     {
    207       if(in_array(ModuleCondition::All, $Conditions) or
     205    foreach ($List as $Index => $Module)
     206    {
     207      if (in_array(ModuleCondition::All, $Conditions) or
    208208        ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    209209        (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
     
    213213        (!$Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)))
    214214      {
    215         foreach($Actions as $Action)
     215        foreach ($Actions as $Action)
    216216        {
    217           if($Action == ModuleAction::Start) $Module->Start();
    218           if($Action == ModuleAction::Stop) $Module->Stop();
    219           if($Action == ModuleAction::Install) $Module->Install();
    220           if($Action == ModuleAction::Uninstall) $Module->Uninstall();
    221           if($Action == ModuleAction::Enable) $Module->Enable();
    222           if($Action == ModuleAction::Disable) $Module->Disable();
    223           if($Action == ModuleAction::Upgrade) $Module->Upgrade();
     217          if ($Action == ModuleAction::Start) $Module->Start();
     218          if ($Action == ModuleAction::Stop) $Module->Stop();
     219          if ($Action == ModuleAction::Install) $Module->Install();
     220          if ($Action == ModuleAction::Uninstall) $Module->Uninstall();
     221          if ($Action == ModuleAction::Enable) $Module->Enable();
     222          if ($Action == ModuleAction::Disable) $Module->Disable();
     223          if ($Action == ModuleAction::Upgrade) $Module->Upgrade();
    224224        }
    225225      }
     
    229229  function EnumDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
    230230  {
    231     foreach($Module->Dependencies as $Dependency)
    232     {
    233       if(!array_key_exists($Dependency, $this->Modules))
     231    foreach ($Module->Dependencies as $Dependency)
     232    {
     233      if (!array_key_exists($Dependency, $this->Modules))
    234234        throw new Exception(sprintf(T('Module "%s" dependency "%s" not found'), $Module->Name, $Dependency));
    235235      $DepModule = $this->Modules[$Dependency];
    236       if(in_array(ModuleCondition::All, $Conditions) or
     236      if (in_array(ModuleCondition::All, $Conditions) or
    237237        ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    238238        (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
     
    250250  function EnumSuperiorDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
    251251  {
    252     foreach($this->Modules as $RefModule)
    253     {
    254       if(in_array($Module->Name, $RefModule->Dependencies) and
     252    foreach ($this->Modules as $RefModule)
     253    {
     254      if (in_array($Module->Name, $RefModule->Dependencies) and
    255255          (in_array(ModuleCondition::All, $Conditions) or
    256256          ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
     
    270270  {
    271271    $this->LoadModules();
    272     if(file_exists($this->FileName)) $this->LoadState();
     272    if (file_exists($this->FileName)) $this->LoadState();
    273273    $this->StartEnabled();
    274274  }
     
    315315  function ModulePresent($Name)
    316316  {
    317     return(array_key_exists($Name, $this->Modules));
     317    return array_key_exists($Name, $this->Modules);
    318318  }
    319319
    320320  function ModuleEnabled($Name)
    321321  {
    322     return(array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled);
     322    return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled;
    323323  }
    324324
    325325  function ModuleRunning($Name)
    326326  {
    327     return(array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running);
     327    return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running;
    328328  }
    329329
     
    331331  function SearchModuleById($Id)
    332332  {
    333     foreach($this->Modules as $Module)
     333    foreach ($this->Modules as $Module)
    334334    {
    335335      //DebugLog($Module->Name.' '.$Module->Id);
    336       if($Module->Id == $Id) return($Module->Name);
    337     }
    338     return('');
     336      if ($Module->Id == $Id) return $Module->Name;
     337    }
     338    return '';
    339339  }
    340340
     
    343343    $ConfigModules = array();
    344344    include($this->FileName);
    345     foreach($ConfigModules as $Mod)
    346     {
    347       if(array_key_exists($Mod['Name'], $this->Modules))
     345    foreach ($ConfigModules as $Mod)
     346    {
     347      if (array_key_exists($Mod['Name'], $this->Modules))
    348348      {
    349349        $this->Modules[$Mod['Name']] = $this->Modules[$Mod['Name']];
     
    358358  {
    359359    $Data = array();
    360     foreach($this->Modules as $Module)
     360    foreach ($this->Modules as $Module)
    361361    {
    362362      $Data[] = array('Name' => $Module->Name, 'Enabled' => $Module->Enabled,
     
    381381  {
    382382    $List = scandir($Directory);
    383     foreach($List as $Item)
    384     {
    385       if(is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))
     383    foreach ($List as $Item)
     384    {
     385      if (is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))
    386386      {
    387387        include_once($Directory.'/'.$Item.'/'.$Item.'.php');
     
    394394  function LoadModules()
    395395  {
    396     if(method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
     396    if (method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
    397397      $this->OnLoadModules();
    398398    else $this->LoadModulesFromDir($this->ModulesDir);
Note: See TracChangeset for help on using the changeset viewer.