Exemplo n.º 1
0
 /**
  * This method is charged to build the Modules object in order to add them to the context of the application.
  * @return an array of Modules objects.
  */
 public static function buildInstalledModules()
 {
     $modules = array();
     $path = parent::getRelativePathToApps();
     //Check if there was errors previously:
     //Concerning the path to the ApplicationsCommonInterface:
     if (empty($path) || is_null($path)) {
         self::setError('An error occured while reading the ApplicationsCommonInterface, please check the correct location of this file.');
         return false;
     }
     //Concerning the ApplicationsCommonInterface class file itself:
     if (!file_exists($path . 'ApplicationsCommonInterface.class.php')) {
         //If so, an error already occured previously, so just return false:
         return false;
     }
     //If everything went fine so far, instanciate the ApplicationsCommonInterface:
     $interface = new ApplicationsCommonInterface($path);
     //Check if the init of the dependencies table went fine:
     if (is_null($table = parent::getDependenciesTable())) {
         return false;
     }
     //For each module in the dependencies table,
     foreach ($table as $module_name => $dependencies_list) {
         //Check if the module has unsatisfied dependencies:
         if (!Module::hasUnsatisfiedDependencies(self::getDependenciesTable(), $module_name)) {
             //print($module_name.'<br>');
             //If not, it's ok to build it:
             //Check whether it's compulsory:
             if ($interface->getModuleProperty($module_name, 'compulsory') == 'yes') {
                 if (($menu_entry = $interface->getModuleProperty($module_name, 'module_menu_name')) != 'null') {
                     $modules[] = new Module($module_name, true, $menu_entry);
                 } else {
                     $modules[] = new Module($module_name, true, null);
                 }
             } else {
                 if (($menu_entry = $interface->getModuleProperty($module_name, 'module_menu_name')) != 'null') {
                     $modules[] = new Module($module_name, false, $menu_entry);
                 } else {
                     $modules[] = new Module($module_name, false, null);
                 }
             }
         }
     }
     return $modules;
 }
Exemplo n.º 2
0
 /**
  * An alias to ApplicationsCommonInterface->getModuleProperty() method.
  * Its hide the instanciation, the property name and the path to the template.
  * @param string $module_name
  */
 public static function isCompulsoryByName($module_name)
 {
     $interface = new ApplicationsCommonInterface(ProjectConfiguration::guessRootDir() . '/apps/');
     if ($interface->getModuleProperty($module_name, 'compulsory') == 'yes') {
         return true;
     } else {
         return false;
     }
 }