getModulesOnFilesystem() public static method

Get the modules that are available on the filesystem
public static getModulesOnFilesystem ( boolean $includeCore = true ) : array
$includeCore boolean Should core be included as a module?
return array
Example #1
0
 /**
  * Set the module
  *
  * We can't rely on the parent setModule function, because config could be
  * called before any authentication is required.
  *
  * @param string $module The module to load.
  * @throws BackendException If module is not allowed
  */
 public function setModule($module)
 {
     // does this module exist?
     $modules = BackendModel::getModulesOnFilesystem();
     if (!in_array($module, $modules)) {
         // set correct headers
         header('HTTP/1.1 403 Forbidden');
         // throw exception
         throw new BackendException('Module not allowed.');
     }
     // set property
     $this->module = $module;
 }
Example #2
0
 /**
  * Get all the modules that can be installed
  *
  * @return array The modules
  */
 protected function getInstallableModules()
 {
     $modules = array_unique(array_merge(ForkInstaller::getRequiredModules(), BackendModel::getModulesOnFilesystem(false)));
     $this->removeHiddenModules($modules);
     return array_combine($modules, $modules);
 }
Example #3
0
 /**
  * Set the module
  *
  * We can't rely on the parent setModule function, because a cronjob requires no login
  *
  * @param string $module The module to load.
  */
 public function setModule($module)
 {
     // does this module exist?
     $modules = BackendModel::getModulesOnFilesystem();
     if (!in_array($module, $modules)) {
         // set correct headers
         \SpoonHTTP::setHeadersByCode(403);
         // throw exception
         throw new Exception('Module not allowed.');
     }
     // set property
     $this->module = $module;
 }
Example #4
0
 /**
  * Get modules based on the directory listing in the backend application.
  *
  * If a module contains a info.xml it will be parsed.
  *
  * @return array
  */
 public static function getModules()
 {
     $installedModules = (array) BackendModel::getContainer()->getParameter('installed_modules');
     $modules = BackendModel::getModulesOnFilesystem(false);
     $manageableModules = array();
     // get more information for each module
     foreach ($modules as $moduleName) {
         if (in_array($moduleName, self::$ignoredModules)) {
             continue;
         }
         $module = array();
         $module['id'] = 'module_' . $moduleName;
         $module['raw_name'] = $moduleName;
         $module['name'] = \SpoonFilter::ucfirst(BL::getLabel(\SpoonFilter::toCamelCase($moduleName)));
         $module['description'] = '';
         $module['version'] = '';
         $module['installed'] = false;
         $module['cronjobs_active'] = true;
         if (in_array($moduleName, $installedModules)) {
             $module['installed'] = true;
         }
         try {
             $infoXml = @new \SimpleXMLElement(BACKEND_MODULES_PATH . '/' . $module['raw_name'] . '/info.xml', LIBXML_NOCDATA, true);
             $info = self::processModuleXml($infoXml);
             // set fields if they were found in the XML
             if (isset($info['description'])) {
                 $module['description'] = BackendDataGridFunctions::truncate($info['description'], 80);
             }
             if (isset($info['version'])) {
                 $module['version'] = $info['version'];
             }
             // check if cronjobs are set
             if (isset($info['cronjobs'])) {
                 foreach ($info['cronjobs'] as $cronjob) {
                     if (!$cronjob['active']) {
                         $module['cronjobs_active'] = false;
                         break;
                     }
                 }
             }
         } catch (\Exception $e) {
             // don't act upon error, we simply won't possess some info
         }
         $manageableModules[] = $module;
     }
     return $manageableModules;
 }