EPESI BIM • Business Information Manager • Cloud CRM/ERP http://epe.si/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.3 KiB

  1. <?php
  2. /**
  3. * Description of ModuleLoader
  4. *
  5. * @author Adam Bukowski <abukowski@telaxus.com>
  6. */
  7. class ModuleLoader {
  8. const all_modules = ':all:';
  9. private $lpa;
  10. private $lpa_count;
  11. private $lpa_index = 0;
  12. private $loaded_modules = array();
  13. private $initialized = false;
  14. private function init() {
  15. if (!$this->initialized) {
  16. $this->initialized = true;
  17. $this->lpa = ModuleManager::get_load_priority_array();
  18. $this->lpa_count = count($this->lpa);
  19. ModulesAutoloader::enable();
  20. }
  21. }
  22. function load($modules) {
  23. $this->init();
  24. if (!is_array($modules))
  25. $modules = array($modules);
  26. foreach ($modules as $m) {
  27. if (array_key_exists($m, ModuleManager::$modules))
  28. continue;
  29. while ($this->lpa_index < $this->lpa_count) {
  30. $row = $this->lpa[$this->lpa_index++];
  31. $module = $row['name'];
  32. $version = $row['version'];
  33. ModuleManager :: include_common($module, $version);
  34. ModuleManager :: register($module, $version, ModuleManager::$modules);
  35. if ($m != self::all_modules && $module == $m)
  36. break;
  37. }
  38. }
  39. }
  40. }
  41. ?>