Dotclear


Ignore:
Timestamp:
04/21/15 20:01:46 (10 years ago)
Author:
Dsls
Branch:
default
Message:

First step in modules dependencies management

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.modules.php

    r2954 r2997  
    2626     protected $errors = array(); 
    2727     protected $modules_names = array(); 
     28     protected $all_modules = array(); 
    2829     protected $disabled_mode = false; 
    2930     protected $disabled_meta = array(); 
     
    4950     { 
    5051          $this->core =& $core; 
     52     } 
     53 
     54 
     55     public function checkDependencies() { 
     56          $to_disable = array(); 
     57          foreach ($this->all_modules as $k => &$m) { 
     58               if (isset($m['requires'])) { 
     59                    foreach ($m['requires'] as &$dep) { 
     60                         $missing = array(); 
     61                         if (!is_array($dep)) { 
     62                              $dep = array($dep); 
     63                         } 
     64                         if (!isset($this->all_modules[$dep[0]])) { 
     65                              // module not present 
     66                              $missing[$dep[0]] = true; 
     67                         } elseif (count($dep)>1 && version_compare($m['version'],$dep[1],'<')) { 
     68                              // module present, but version missing 
     69                              $missing[$dep[0]] = $dep[1]; 
     70                         } 
     71                         if (count($missing)) { 
     72                              $m['errors']=$missing; 
     73                              $to_disable[]=$k; 
     74                         } else { 
     75                              $this->all_modules[$dep[0]]['disable_also'][]=$k; 
     76                              $m['require_enable'][]=$dep[0]; 
     77                              if (!$this->all_modules[$dep[0]]['enabled']) { 
     78                                   $to_disable[]=$k; 
     79                              } 
     80                         } 
     81                    } 
     82               } 
     83          } 
    5184     } 
    5285 
     
    100133                              $this->mroot = $full_entry; 
    101134                              require $full_entry.'/_define.php'; 
     135                              $this->all_modules[$entry] =& $this->modules[$entry]; 
    102136                              $this->id = null; 
    103137                              $this->mroot = null; 
     
    106140                         { 
    107141                              if (file_exists($full_entry.'/_define.php')) { 
     142                                   $this->id = $entry; 
     143                                   $this->mroot = $full_entry; 
    108144                                   $this->disabled_mode=true; 
    109145                                   require $full_entry.'/_define.php'; 
    110146                                   $this->disabled_mode=false; 
    111147                                   $this->disabled[$entry] =  $this->disabled_meta; 
     148                                   $this->all_modules[$entry] =& $this->disabled[$entry]; 
     149                                   $this->id = null; 
     150                                   $this->mroot = null; 
    112151                              } 
    113152                         } 
     
    116155               $d->close(); 
    117156          } 
    118  
     157          $this->checkDependencies(); 
    119158          # Sort plugins 
    120159          uasort($this->modules,array($this,'sortModules')); 
     
    190229                              'author' => $author, 
    191230                              'version' => $version, 
     231                              'enabled' => false, 
    192232                              'root_writable' => is_writable($this->mroot) 
    193233                         ) 
     
    214254                    'standalone_config' => false, 
    215255                    'type' => null, 
     256                    'enabled' => true, 
    216257                    'requires' => array() 
    217258               ), $properties 
Note: See TracChangeset for help on using the changeset viewer.

Sites map