示例#1
0
 /**
  * @param ContainerInterface $container
  * @param array $modules
  * @return array
  * @throws \Exception
  */
 public function installModules(ContainerInterface $container, array $modules = [])
 {
     foreach ($this->vendor->getVendors() as $vendor) {
         $vendorPath = $this->applicationPath->getModulesDir() . $vendor . '/';
         $vendorModules = count($modules) > 0 ? $modules : Filesystem::scandir($vendorPath);
         foreach ($vendorModules as $module) {
             $module = strtolower($module);
             if (isset($this->results[$module])) {
                 continue;
             }
             $modulePath = $vendorPath . ucfirst($module) . '/';
             $moduleConfigPath = $modulePath . 'Resources/config/module.xml';
             if (is_dir($modulePath) && is_file($moduleConfigPath)) {
                 $dependencies = $this->getModuleDependencies($moduleConfigPath);
                 if (count($dependencies) > 0) {
                     $this->installModules($container, $dependencies);
                 }
                 if ($this->installHelper->installModule($module, $container) === false) {
                     throw new \Exception("Error while installing module {$module}.");
                 }
                 $this->results[$module] = true;
             }
         }
     }
     return $this->results;
 }
示例#2
0
 /**
  * @return array
  */
 protected function getAvailableDesigns()
 {
     $designs = [];
     $path = $this->appPath->getDesignRootPathInternal();
     $directories = Core\Filesystem::scandir($path);
     foreach ($directories as $directory) {
         $designInfo = $this->xml->parseXmlFile($path . $directory . '/info.xml', '/design');
         if (!empty($designInfo)) {
             $designs[] = array_merge($designInfo, ['selected' => $this->config->getSettings(Schema::MODULE_NAME)['design'] === $directory ? 1 : 0, 'dir' => $directory]);
         }
     }
     return $designs;
 }
示例#3
0
 /**
  * Cacht die Sprachfiles, um diese schneller verarbeiten zu können
  *
  * @param string $language
  *
  * @return array
  */
 public function setLanguageCache($language)
 {
     $data = [];
     foreach (Filesystem::scandir($this->appPath->getInstallerModulesDir()) as $module) {
         $path = $this->appPath->getInstallerModulesDir() . $module . '/Resources/i18n/' . $language . '.xml';
         if (is_file($path) === true) {
             $xml = simplexml_load_file($path);
             if (isset($data['info']['direction']) === false) {
                 $data['info']['direction'] = (string) $xml->info->direction;
             }
             // Über die einzelnen Sprachstrings iterieren
             foreach ($xml->keys->item as $item) {
                 $data['keys'][strtolower($module . (string) $item['key'])] = trim((string) $item);
             }
         }
     }
     return $data;
 }
示例#4
0
文件: Purge.php 项目: acp3/core
 /**
  * @param string $directory
  * @param string $cacheId
  */
 protected static function purgeCurrentDirectory($directory, $cacheId)
 {
     if (is_link($directory)) {
         static::purgeCurrentDirectory(readlink($directory), $cacheId);
     } elseif (is_dir($directory)) {
         foreach (Filesystem::scandir($directory) as $dirContent) {
             $path = "{$directory}/{$dirContent}";
             if (is_dir($path)) {
                 static::purgeCurrentDirectory($path, $cacheId);
                 if (empty($cacheId)) {
                     @rmdir($path);
                 }
             } elseif (empty($cacheId) || strpos($dirContent, $cacheId) !== false) {
                 @unlink($path);
             }
         }
     } elseif (is_file($directory)) {
         @unlink($directory);
     }
 }
示例#5
0
 /**
  * @param ContainerInterface $container
  * @param array $modules
  * @return array
  * @throws \Exception
  */
 public function updateModules(ContainerInterface $container, array $modules = [])
 {
     foreach ($this->vendor->getVendors() as $vendor) {
         $vendorPath = $this->applicationPath->getModulesDir() . $vendor . '/';
         $vendorModules = count($modules) > 0 ? $modules : Filesystem::scandir($vendorPath);
         foreach ($vendorModules as $module) {
             $module = strtolower($module);
             if (isset($this->results[$module])) {
                 continue;
             }
             $modulePath = $vendorPath . ucfirst($module) . '/';
             $moduleConfigPath = $modulePath . 'Resources/config/module.xml';
             if (is_dir($modulePath) && is_file($moduleConfigPath)) {
                 $dependencies = $this->getModuleDependencies($moduleConfigPath);
                 if (count($dependencies) > 0) {
                     $this->updateModules($container, $dependencies);
                 }
                 $this->results[$module] = $this->updateModule($container, $module);
             }
         }
     }
     return $this->results;
 }
示例#6
0
 /**
  * Generiert das Dropdown-Menü mit der zur Verfügung stehenden Installersprachen
  *
  * @param string $selectedLanguage
  *
  * @return array
  */
 private function languagesDropdown($selectedLanguage)
 {
     $languages = [];
     $path = $this->appPath->getInstallerModulesDir() . 'Install/Resources/i18n/';
     foreach (Filesystem::scandir($path) as $row) {
         $langInfo = simplexml_load_file($path . $row);
         if (!empty($langInfo)) {
             $languages[] = ['language' => substr($row, 0, -4), 'selected' => $selectedLanguage === substr($row, 0, -4) ? ' selected="selected"' : '', 'name' => $langInfo->info->name];
         }
     }
     return $languages;
 }
示例#7
0
 /**
  * @return array
  */
 private function fetchRequiredFilesAndDirectories()
 {
     $defaults = ['ACP3/config.yml', 'cache/', 'uploads/', 'uploads/assets/'];
     foreach (Filesystem::scandir($this->appPath->getModulesDir()) as $row) {
         $path = 'uploads/' . $row . '/';
         if (is_dir(ACP3_ROOT_DIR . $path) === true) {
             $defaults[] = $path;
         }
     }
     return $defaults;
 }
示例#8
0
文件: Modules.php 项目: acp3/core
 /**
  * Returns an alphabetically sorted array of all found ACP3 modules
  *
  * @return array
  */
 public function getAllModules()
 {
     if (empty($this->allModules)) {
         foreach ($this->vendors->getVendors() as $vendor) {
             foreach (Filesystem::scandir($this->appPath->getModulesDir() . $vendor . '/') as $module) {
                 $info = $this->getModuleInfo($module);
                 if (!empty($info)) {
                     $this->allModules[$info['name']] = $info;
                 }
             }
         }
         ksort($this->allModules);
     }
     return $this->allModules;
 }
示例#9
0
 /**
  * @param string $vendor
  *
  * @return array
  */
 protected function fetchVendorModules($vendor)
 {
     $infos = [];
     $modules = Filesystem::scandir($this->appPath->getModulesDir() . $vendor . '/');
     if (!empty($modules)) {
         foreach ($modules as $module) {
             $moduleInfo = $this->fetchModuleInfo($module);
             if (!empty($moduleInfo)) {
                 $infos[strtolower($module)] = $moduleInfo;
             }
         }
     }
     return $infos;
 }
示例#10
0
文件: Vendor.php 项目: acp3/core
 /**
  * Caches the various module vendors
  */
 protected function cacheVendors()
 {
     $this->vendors = array_merge(['ACP3'], Filesystem::scandir($this->appPath->getModulesDir(), ['ACP3', 'Custom']), ['Custom']);
 }
示例#11
0
 /**
  * @throws \Exception
  */
 public function installSampleData()
 {
     foreach ($this->vendor->getVendors() as $vendor) {
         foreach (Filesystem::scandir($this->appPath->getModulesDir() . $vendor . '/') as $module) {
             $module = strtolower($module);
             $sampleDataInstallResult = $this->installHelper->installSampleData($module, $this->container, $this->container->get('core.modules.schemaHelper'));
             if ($sampleDataInstallResult === false) {
                 throw new \Exception("Error while installing module sample data.");
             }
         }
     }
 }