public function _createContent(&$toReturn) { $moduleName = CopixZone::getParam('moduleName'); $infos = CopixModule::getInformations($moduleName); $tpl = new CopixTpl(); if (in_array($moduleName, CopixModule::getList())) { $arModule = CopixModule::getDependenciesForDelete($moduleName); $template = 'detailmoduledelete.tpl'; $record = _dao('Copix:copixmodule')->get($moduleName); $tpl->assign('version', $record->version_cpm); } else { $arDependencies = CopixModule::getDependenciesForInstall($moduleName); $arModule = array(); $arExtension = array(); $install = true; foreach ($arDependencies as $key => $dependency) { if ($dependency->kind === 'module') { if (CopixModule::testDependency($dependency)) { $dependency->exists = true; $dependency->isInabled = CopixModule::isEnabled($dependency->name); $arModule[] = $dependency; } else { $dependency->exists = false; $install = false; $arModule[] = $dependency; } } else { if (CopixModule::testDependency($dependency)) { $dependency->exists = true; $arExtension[] = $dependency; } else { $dependency->exists = false; $install = false; $arExtension[] = $dependency; } } } $tpl->assign('arExtension', $arExtension); $tpl->assign('install', $install); $template = 'detailmoduleinstall.tpl'; } $tpl->assign('path', CopixModule::getPath($moduleName)); $tpl->assign('arModule', $arModule); $tpl->assign('info', $infos); $tpl->assign('moduleName', $moduleName); $toReturn = $tpl->fetch($template); return true; }
public function _createContent(&$toReturn) { if (CopixZone::getParam('arModule') !== null && is_array(CopixZone::getParam('arModule'))) { $arModule = CopixZone::getParam('arModule'); } else { $arModule = array(CopixZone::getParam('moduleName')); } $arModuleToInstall = array(); $arOrder = array(); foreach ($arModule as $moduleName) { $arDependency = CopixModule::getDependenciesForInstall($moduleName); foreach ($arDependency as $key => $dependency) { if ($dependency->kind === 'module') { //Gestion des modules en double avec les dependences if (!in_array($dependency->name, $arModuleToInstall)) { $arModuleToInstall[] = $dependency->name; $arOrder[] = $dependency->level; } else { //Gestion du niveau d'install des dependences $key = array_search($dependency->name, $arModuleToInstall); if ($arOrder[$key] < $dependency->level) { $arOrder[$key] = $dependency->level; } } } } } array_multisort($arOrder, SORT_ASC, $arModuleToInstall, SORT_DESC); $arModuleInfos = array(); $tpl = new CopixTpl(); $tpl->assign('arModuleToInstall', $arModuleToInstall); $tpl->assign('arModuleInfos', $arModuleInfos); CopixSession::set('arModuleToInstall', $arModuleToInstall, 'copix'); CopixSession::set('arInstalledModule', array(), 'copix'); $tpl->assign('id', uniqid()); $tpl->assign('url', CopixZone::getParam('url_return', _url('admin|install|manageModules'))); $tpl->assign('messageConfirm', CopixZone::getParam('messageConfirm', true)); $toReturn = $tpl->fetch('admin|install.script.tpl'); return true; }
/** * Liste des dependance a installer si on install le module * * @param string $pModuleName Nom du module * @param mixed $arDependencies tableau de dépendances permettant de concatener les sous dépendance * @return mixed Tableau des dépendances */ public static function getDependenciesForInstall($moduleName, $arDependencies = array(), $pLevel = 0, $pGetAll = false) { $toCheck = self::getInformations($moduleName); $moduleDependency = new stdClass(); $moduleDependency->level = $pLevel; $moduleDependency->name = $moduleName; $moduleDependency->kind = 'module'; $arDependencies['module_' . $moduleName] = $moduleDependency; foreach ($toCheck->dependencies as $dependency) { if (!isset($arDependencies[$dependency->kind . '_' . $dependency->name])) { $dependency->level = $pLevel + 1; $arDependencies[$dependency->kind . '_' . $dependency->name] = $dependency; if ($dependency->kind === 'module') { if (!in_array($dependency->name, self::getList(true))) { if (in_array($dependency->name, self::getList(false))) { $arDependencies = array_merge($arDependencies, CopixModule::getDependenciesForInstall($dependency->name, $arDependencies, $pLevel + 1, $pGetAll)); } } else { if (!$pGetAll) { unset($arDependencies[$dependency->kind . '_' . $dependency->name]); } } } } } return $arDependencies; }