private function setUpContainer() { $this->set('core.http.symfony_request', $this->symfonyRequest); $this->set('core.environment.application_path', $this->applicationPath); $this->setParameter('core.environment', $this->applicationMode); $this->addCompilerPass(new RegisterListenersPass('core.event_dispatcher', 'core.eventListener', 'core.eventSubscriber')); $this->addCompilerPass(new RegisterSmartyPluginsPass()); $this->addCompilerPass(new RegisterColumnRendererPass()); $this->addCompilerPass(new RegisterValidationRulesPass()); $this->addCompilerPass(new RegisterWysiwygEditorsCompilerPass()); $this->addCompilerPass(new RegisterColumnTypesCompilerPass()); $loader = new YamlFileLoader($this, new FileLocator(__DIR__)); $loader->load($this->applicationPath->getClassesDir() . 'config/services.yml'); $loader->load($this->applicationPath->getClassesDir() . 'View/Renderer/Smarty/config/services.yml'); // Try to get all available services /** @var Modules $modules */ $modules = $this->get('core.modules'); $availableModules = $this->allModules === true ? $modules->getAllModules() : $modules->getActiveModules(); $vendors = $this->get('core.modules.vendors')->getVendors(); foreach ($availableModules as $module) { foreach ($vendors as $vendor) { $modulePath = $this->applicationPath->getModulesDir() . $vendor . '/' . $module['dir']; $path = $modulePath . '/Resources/config/services.yml'; if (is_file($path)) { $loader->load($path); } $this->registerCompilerPass($vendor, $module['dir']); } } $this->compile(); }
/** * @param string $modulePath * @param string $designPath * @param string $dir * @param string $file * * @return string */ private function resolveAssetPath($modulePath, $designPath, $dir, $file) { if ($this->designAssetsPath === null) { $this->designAssetsPath = $this->appPath->getDesignPathInternal(); } $assetPath = ''; $designAssetPath = $this->designAssetsPath . $designPath . $dir . $file; // A theme has overridden a static asset of a module if (is_file($designAssetPath) === true) { $assetPath = $designAssetPath; } else { $designInfo = $this->xml->parseXmlFile($this->designAssetsPath . '/info.xml', '/design'); // Recursively iterate over the nested themes if (!empty($designInfo['parent'])) { $this->designAssetsPath = $this->appPath->getDesignRootPathInternal() . $designInfo['parent'] . '/'; $assetPath = $this->getStaticAssetPath($modulePath, $designPath, $dir, $file); $this->designAssetsPath = $this->appPath->getDesignPathInternal(); return $assetPath; } // No overrides have been found -> iterate over all possible module namespaces foreach (array_reverse($this->vendors->getVendors()) as $vendor) { $moduleAssetPath = $this->appPath->getModulesDir() . $vendor . '/' . $modulePath . $dir . $file; if (is_file($moduleAssetPath) === true) { $assetPath = $moduleAssetPath; break; } } } $systemAssetPath = $this->appPath->getModulesDir() . $modulePath . $dir . $file; $this->cachedPaths[$systemAssetPath] = $assetPath; $this->newAssetPathsAdded = true; return $assetPath; }
/** * Erstellt den Galerie-Cache anhand der angegebenen ID * * @param integer $galleryId * * @return boolean */ public function saveCache($galleryId) { $pictures = $this->pictureRepository->getPicturesByGalleryId($galleryId); $cPictures = count($pictures); $settings = $this->config->getSettings(Schema::MODULE_NAME); for ($i = 0; $i < $cPictures; ++$i) { $pictures[$i]['width'] = $settings['thumbwidth']; $pictures[$i]['height'] = $settings['thumbheight']; $picInfos = @getimagesize($this->appPath->getModulesDir() . 'gallery/' . $pictures[$i]['file']); if ($picInfos !== false) { if ($picInfos[0] > $settings['thumbwidth'] || $picInfos[1] > $settings['thumbheight']) { $newHeight = $settings['thumbheight']; $newWidth = intval($picInfos[0] * $newHeight / $picInfos[1]); } $pictures[$i]['width'] = isset($newWidth) ? $newWidth : $picInfos[0]; $pictures[$i]['height'] = isset($newHeight) ? $newHeight : $picInfos[1]; } } return $this->cache->save(self::CACHE_ID . $galleryId, $pictures); }
/** * @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; }
/** * Gibt ein Array mit den Abhängigkeiten zu anderen Modulen eines Moduls zurück * * @param string $moduleName * * @return array */ protected function getDependencies($moduleName) { if ((bool) preg_match('=/=', $moduleName) === false) { foreach ($this->vendors->getVendors() as $vendor) { $path = $this->appPath->getModulesDir() . $vendor . '/' . ucfirst($moduleName) . '/Resources/config/module.xml'; if (is_file($path) === true) { return $this->getModuleDependencies($path); } } } return []; }
/** * 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; }
/** * Sets the cache for all registered languages * * @return bool */ protected function saveLanguagePacksCache() { $languagePacks = []; foreach ($this->vendors->getVendors() as $vendors) { $languageFiles = glob($this->appPath->getModulesDir() . $vendors . '/*/Resources/i18n/*.xml'); if ($languageFiles !== false) { foreach ($languageFiles as $file) { $languagePack = $this->registerLanguagePack($file); if (!empty($languagePack)) { $languagePacks += $languagePack; } } } } return $this->cache->save('language_packs', $languagePacks); }
/** * @param string $moduleDirectory * * @return array */ protected function fetchModuleInfo($moduleDirectory) { $vendors = array_reverse($this->vendors->getVendors()); // Reverse the order of the array -> search module customizations first, then 3rd party modules, then core modules foreach ($vendors as $vendor) { $path = $this->appPath->getModulesDir() . $vendor . '/' . $moduleDirectory . '/Resources/config/module.xml'; if (is_file($path) === true) { $moduleInfo = $this->xml->parseXmlFile($path, 'info'); if (!empty($moduleInfo)) { $moduleName = strtolower($moduleDirectory); $moduleInfoDb = $this->systemModuleRepository->getInfoByModuleName($moduleName); return ['id' => !empty($moduleInfoDb) ? $moduleInfoDb['id'] : 0, 'dir' => $moduleDirectory, 'installed' => !empty($moduleInfoDb), 'active' => !empty($moduleInfoDb) && $moduleInfoDb['active'] == 1, 'schema_version' => !empty($moduleInfoDb) ? (int) $moduleInfoDb['version'] : 0, 'description' => $this->getModuleDescription($moduleInfo, $moduleName), 'author' => $moduleInfo['author'], 'version' => $moduleInfo['version'], 'name' => $this->getModuleName($moduleInfo, $moduleName), 'categories' => isset($moduleInfo['categories']), 'protected' => isset($moduleInfo['protected']), 'dependencies' => $this->getModuleDependencies($path)]; } } } return []; }
/** * Überprüft, ob das angegebene Sprachpaket existiert * * @param string $locale * * @return boolean */ public function languagePackExists($locale) { return !preg_match('=/=', $locale) && is_file($this->appPath->getModulesDir() . 'ACP3/System/Resources/i18n/' . $locale . '.xml') === true; }
/** * Caches the various module vendors */ protected function cacheVendors() { $this->vendors = array_merge(['ACP3'], Filesystem::scandir($this->appPath->getModulesDir(), ['ACP3', 'Custom']), ['Custom']); }