process();
$tModule = module_builder::getTools()->getListModuleAndSousModule();
$tModuleAndMethod = array();
foreach ($tModule as $sModuleName) {
$sClassName = str_replace('/', '_', $sModuleName);
//$sModuleName = $oModule->getName();
if (in_array($sModuleName, array('menu', 'builder', 'example', 'exampleembedded'))) {
continue;
}
$sMainFilename=module_builder::getTools()->getRootWebsite() . 'module/' . $sModuleName . '/main.php';
if(true===file_exists($sMainFilename) ){
include $sMainFilename;
}else{
continue;
}
if (get_parent_class('module_' . $sClassName) != 'abstract_module') {
//continue;
}
$tMethods = get_class_methods('module_' . $sClassName);
foreach ($tMethods as $i => $sMethod) {
if ($sMethod[0] != '_' or substr($sMethod, 0, 2) == '__') {
unset($tMethods[$i]);
}
}
if (empty($tMethods)) {
continue;
}
$tModuleAndMethod[$sClassName] = $tMethods;
}
$oDir = new _dir(module_builder::getTools()->getRootWebsite() . 'module/menu');
$bExist = $oDir->exist();
$oTpl = $this->getView('index');
//$oTpl->var=$var;
$oTpl->msg = $this->msg;
$oTpl->detail = $this->detail;
$oTpl->tError = $this->tError;
$oTpl->bExist = $bExist;
$oTpl->tModuleAndMethod = $tModuleAndMethod;
return $oTpl;
}
private function process() {
if (_root::getRequest()->isPost() == false) {
return null;
}
$tError = null;
$msg = null;
$detail = null;
$sModule = _root::getParam('modulename');
$tMethod = _root::getParam('tMethod');
$tLabel = _root::getParam('tLabel');
$sTitle = _root::getParam('titreApplication');
$ok = 1;
//check formulaire
foreach ($tMethod as $i => $sMethod) {
if ($tLabel[$i] == '') {
$tError[$i] = tr('remplissezLeLibelle');
$ok = 0;
}
}
if ($ok) {
if (module_builder::getTools()->projetmkdir('module/' . $sModule) == true) {
$detail = trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule));
if (module_builder::getTools()->projetmkdir('module/' . $sModule . '/view') == true) {
$detail .= '
' . trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule . '/view'));
$this->genModuleMenuMain($sModule, $tMethod, $tLabel, $sTitle);
$msg = trR('moduleGenereAvecSucces', array('#MODULE#' => $sModule));
$detail .= '
' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/main.php'));
$detail .= '
' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/index.php'));
$sCode = 'oLayout->addModule(\'menu\',\'' . $sModule . '::index\');' . "\n";
$detail .= '
' . tr('pourLutiliserAjoutez') . '
' . highlight_string($sCode, 1);
} else {
$detail .= '
' . trR('repertoireDejaExistant', array('#REPERTOIRE#' => 'module/' . $sModule . '/view'));
}
} else {
$detail = trR('repertoireDejaExistant', array('#REPERTOIRE#' => 'module/' . $sModule . '/view'));
}
}
$this->tError = $tError;
$this->detail = $detail;
$this->msg = $msg;
}
private function genModuleMenuMain($sModuleMenuName, $tMethod, $tLabel, $sTitle) {
$sData = null;
foreach ($tMethod as $i => $sLink) {
$sData .= '\'' . $tLabel[$i] . '\' => \'' . $sLink . '\',' . "\n";
}
$this->projectMkdir('module/' . $sModuleMenuName);
/* SOURCE */$oSourceMain = $this->getObjectSource('example/main.php');
/* SOURCE */$oSourceMain->setPattern('#MODULE#', $sModuleMenuName);
/* SOURCE */$oSourceMain->setPattern('#TABLEAUICI#', $sData);
/* SOURCE */$oSourceMain->setPattern('#examplesite#', $sTitle);
/* SOURCE */$oSourceMain->save();
$this->projectMkdir('module/' . $sModuleMenuName . '/view');
/* SOURCE */$oSourceViewIndex = $this->getObjectSource('example/view/index.php');
/* SOURCE */$oSourceViewIndex->setPattern('#examplesite#', $sTitle);
/* SOURCE */$oSourceViewIndex->setPattern('#MODULE#', $sModuleMenuName);
/* SOURCE */$oSourceViewIndex->save();
}
}