Exemple #1
0
 private function xmlindexselect()
 {
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $oTpl = $this->getView('indexselect');
     $oTpl->tConnexion = _root::getConfigVar('db');
     return $oTpl;
 }
Exemple #2
0
 private function xmlindexselect()
 {
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $oTpl = new _Tpl('moduleJsonIndex::indexselect');
     $oTpl->tConnexion = _root::getConfigVar('db');
     return $oTpl;
 }
Exemple #3
0
 public function _index()
 {
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $tConnexion = _root::getConfigVar('db');
     $tSqlite = array();
     foreach ($tConnexion as $sConfig => $val) {
         if (substr($val, 0, 6) == 'sqlite') {
             $tSqlite[substr($sConfig, 0, -4)] = $val;
         }
     }
     $msg = '';
     $detail = '';
     if (_root::getRequest()->isPost()) {
         $sDbFilename = _root::getParam('sDbFilename');
         $sTable = _root::getParam('sTable');
         $tField = _root::getParam('tField');
         $tType = _root::getParam('tType');
         $tSize = _root::getParam('tSize');
         try {
             $oDb = new PDO($sDbFilename);
         } catch (PDOException $exception) {
             die($exception->getMessage());
         }
         $oDb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $sSql = 'CREATE TABLE IF NOT EXISTS ' . $sTable . '(';
         $sSql .= 'id  INTEGER PRIMARY KEY AUTOINCREMENT';
         foreach ($tField as $i => $sField) {
             $sSql .= ',';
             $sSql .= $sField . ' ' . $tType[$i];
             if ($tType[$i] == 'VARCHAR') {
                 $sSql .= '(' . $tSize[$i] . ')';
             }
         }
         $sSql .= ')';
         try {
             $oDb->exec($sSql);
         } catch (PDOException $exception) {
             die($exception->getMessage());
         }
         $msg = 'Table ' . $sTable . ' (champs: ' . implode(',', $tField) . ') généré avec succès';
         $detail = 'Création du fichier sqlite ' . $sDbFilename;
     }
     $oTpl = new _Tpl('moduleSqlite::index');
     $oTpl->msg = $msg;
     $oTpl->detail = $detail;
     $oTpl->tSqlite = $tSqlite;
     return $oTpl;
 }
Exemple #4
0
 public function _index()
 {
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $tConnexion = _root::getConfigVar('db');
     $tSqlite = array();
     foreach ($tConnexion as $sConfig => $val) {
         if (substr($val, 0, 6) == 'sqlite') {
             $tSqlite[substr($sConfig, 0, -4)] = $val;
         }
     }
     $msg = '';
     $detail = '';
     if ($this->isPost()) {
         $sDbFilename = _root::getParam('sDbFilename');
         $sTable = _root::getParam('sTable');
         $tField = _root::getParam('tField');
         $tType = _root::getParam('tType');
         $tSize = _root::getParam('tSize');
         try {
             $oDb = new PDO($sDbFilename);
         } catch (PDOException $exception) {
             die($exception->getMessage());
         }
         $oDb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $sSql = 'CREATE TABLE IF NOT EXISTS ' . $sTable . '(';
         $sSql .= 'id  INTEGER PRIMARY KEY AUTOINCREMENT';
         foreach ($tField as $i => $sField) {
             $sSql .= ',';
             $sSql .= $sField . ' ' . $tType[$i];
             if ($tType[$i] == 'VARCHAR') {
                 $sSql .= '(' . $tSize[$i] . ')';
             }
         }
         $sSql .= ')';
         try {
             $oDb->exec($sSql);
         } catch (PDOException $exception) {
             die($exception->getMessage());
         }
         $msg = trR('baseTableGenereAvecSucces', array('#maTable#' => $sTable, '#listField#' => implode(',', $tField)));
         $detail = trR('creationFichier', array('#FICHIER#' => ' sqlite ' . $sDbFilename));
     }
     $oTpl = $this->getView('index');
     $oTpl->msg = $msg;
     $oTpl->detail = $detail;
     $oTpl->tSqlite = $tSqlite;
     return $oTpl;
 }
Exemple #5
0
 public function _simple()
 {
     $msg = '';
     $detail = '';
     list($msg, $detail) = $this->processSimple();
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/');
     $tFile = array();
     $tRowMethodes = array();
     $tModule = module_builder::getTools()->getListModule();
     foreach ($oDir->getListFile() as $oFile) {
         if (preg_match('/.sample.php/', $oFile->getName()) or !preg_match('/.php$/', $oFile->getName())) {
             continue;
         }
         $tFile[] = $oFile->getName();
         require_once $oFile->getAdresse();
         $sClassFoo = substr($oFile->getName(), 0, -4);
         $oModelFoo = new $sClassFoo();
         if (method_exists($oModelFoo, 'getSelect')) {
             $tRowMethodes[substr($oFile->getName(), 0, -4)] = substr($oFile->getName(), 0, -4) . '::getSelect()';
         }
     }
     $oTpl = new _Tpl('moduleViewForm::simple');
     if (_root::getParam('class') != '') {
         $sClass = substr(_root::getParam('class'), 0, -4);
         require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
         $tColumn = module_builder::getTools()->getListColumnFromClass($sClass);
         $oTpl->sClass = $sClass;
         $sId = null;
         $tId = module_builder::getTools()->getIdTabFromClass($sClass);
         foreach ($tColumn as $i => $sColumn) {
             if (in_array($sColumn, $tId)) {
                 unset($tColumn[$i]);
                 $sId = $sColumn;
             }
         }
         $oTpl->tColumn = $tColumn;
         $oTpl->sId = $sId;
         $oTpl->tRowMethodes = $tRowMethodes;
         $oModel = new $sClass();
     }
     $oTpl->msg = $msg;
     $oTpl->detail = $detail;
     $oTpl->tFile = $tFile;
     $oTpl->tModule = $tModule;
     return $oTpl;
 }
Exemple #6
0
    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');
        $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 .= '<br />' . trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule . '/view'));
                    $this->genModuleMenuMain($sModule, $tMethod, $tLabel);
                    $msg = trR('moduleGenereAvecSucces', array('#MODULE#' => $sModule));
                    $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/main.php'));
                    $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/index.php'));
                    $sCode = '<?php ' . "\n";
                    $sCode .= '//assignez le menu a l\'emplacement menu' . "\n";
                    $sCode .= '$this->oLayout->addModule(\'menu\',\'' . $sModule . '::index\');' . "\n";
                    $detail .= '<br/><br/>' . tr('pourLutiliserAjoutez') . '<br />
					' . highlight_string($sCode, 1);
                } else {
                    $detail .= '<br />' . 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;
    }
Exemple #7
0
 public function _index()
 {
     $msg = '';
     $detail = '';
     if (_root::getRequest()->isPost()) {
         $sTable = _root::getParam('sTable');
         $tField = explode("\n", _root::getParam('sField'));
         module_builder::getTools()->projetmkdir('data/json/base/' . $sTable);
         $this->generate($sTable, $tField);
         $msg = 'Base ' . $sTable . ' (champs: ' . implode(',', $tField) . ') g&eacute;n&eacute;r&eacute; avec succ&egrave;s';
         $detail = 'Cr&eacute;ation repertoire data/json/base/' . $sTable;
         $detail .= '<br />Cr&eacute;ation fichier data/json/base/' . $sTable . '/structure.csv';
         $detail .= '<br />Cr&eacute;ation fichier data/json/base/' . $sTable . '/max.txt';
     }
     $oTpl = new _Tpl('moduleJson::index');
     $oTpl->msg = $msg;
     $oTpl->detail = $detail;
     return $oTpl;
 }
Exemple #8
0
 private function genModuleMain($sModule, $tAction)
 {
     $sContent = module_builder::getTools()->stringReplaceIn(array('_examplemodule' => '_' . $sModule), 'data/sources/projet/module/example/main.php');
     preg_match_all('/#debutaction#(.*)?#finaction#/s', $sContent, $tMatch);
     $sMethodeSource = $tMatch[1][0];
     $sMethodes = '';
     foreach ($tAction as $sAction) {
         $sAction = trim($sAction);
         if ($sAction == '') {
             continue;
         }
         $sMethodes .= preg_replace('/examplemodule/', $sModule, preg_replace('/exampleaction/', $sAction, $sMethodeSource));
         $oFileTpl = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModule . '/view/' . $sAction . '.php');
         $oFileTpl->setContent('vue ' . $sModule . '::' . $sAction);
         $oFileTpl->save();
         $oFileTpl->chmod(0666);
     }
     $sContent = preg_replace('/\\/\\/ICI--/', $sMethodes, $sContent);
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModule . '/main.php');
     $oFile->setContent($sContent);
     $oFile->save();
     $oFile->chmod(0666);
 }
Exemple #9
0
    public function _index()
    {
        $detail = null;
        $tError = array();
        $tModuleAndMethod = array();
        $bExist = 0;
        if (_root::getRequest()->isPost()) {
            $sModule = _root::getParam('modulename');
            $tMethod = _root::getParam('tMethod');
            $tLabel = _root::getParam('tLabel');
            $ok = 1;
            //check formulaire
            foreach ($tMethod as $i => $sMethod) {
                if ($tLabel[$i] == '') {
                    $tError[$i] = 'Remplissez le libell&eacute; du lien';
                    $ok = 0;
                }
            }
            if ($ok) {
                if (module_builder::getTools()->projetmkdir('module/' . $sModule) == true) {
                    $detail = 'Cr&eacute;ation repertoire module/' . $sModule;
                    if (module_builder::getTools()->projetmkdir('module/' . $sModule . '/view') == true) {
                        $detail .= '<br />Cr&eacute;ation r&eacute;pertoire module/' . $sModule . '/view';
                        $this->genModuleMenuMain($sModule, $tMethod, $tLabel);
                        $msg = 'Module ' . $sModule . ' g&eacute;n&eacute;r&eacute; avec succ&egrave;s';
                        $detail .= '<br />Cr&eacute;ation fichier module/' . $sModule . '/main.php';
                        $detail .= '<br />Cr&eacute;ation fichier module/' . $sModule . '/view/index.php';
                        $sCode = '<?php ' . "\n";
                        $sCode .= '//assignez le menu a l\'emplacement menu' . "\n";
                        $sCode .= '$this->oLayout->addModule(\'menu\',\'' . $sModule . '::index\');' . "\n";
                        $detail .= '<br/><br/>Pour l\'utiliser, ajoutez dans votre methode before():<br />
						' . highlight_string($sCode, 1);
                    } else {
                        $detail .= '<br />Warning: repertoire d&eacute;j&agrave; existant module/' . $sModule . '/view';
                    }
                } else {
                    $detail = 'Warning: repertoire module/' . $sModule . ' d&eacute;j&agrave; existant: modifiez le nom du module menu';
                }
            }
        } else {
            $tModule = module_builder::getTools()->getListModule();
            $tModuleAndMethod = array();
            foreach ($tModule as $oModule) {
                $sModuleName = $oModule->getName();
                if (in_array($sModuleName, array('menu', 'builder', 'example', 'exampleembedded'))) {
                    continue;
                }
                include module_builder::getTools()->getRootWebsite() . 'module/' . $sModuleName . '/main.php';
                if (get_parent_class('module_' . $sModuleName) != 'abstract_module') {
                    continue;
                }
                $tMethods = get_class_methods('module_' . $sModuleName);
                foreach ($tMethods as $i => $sMethod) {
                    if ($sMethod[0] != '_' or substr($sMethod, 0, 2) == '__') {
                        unset($tMethods[$i]);
                    }
                }
                if (empty($tMethods)) {
                    continue;
                }
                $tModuleAndMethod[$sModuleName] = $tMethods;
            }
            $oDir = new _dir(module_builder::getTools()->getRootWebsite() . 'module/menu');
            $bExist = $oDir->exist();
        }
        $oView = new _view('moduleMenuBootstrap::index');
        $oView->tModuleAndMethod = $tModuleAndMethod;
        $oView->detail = $detail;
        $oView->bExist = $bExist;
        $oView->tError = $tError;
        return $oView;
    }
Exemple #10
0
    public function _index()
    {
        module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
        $msg = '';
        $detail = '';
        $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/');
        $tFile = array();
        $tRowMethodes = array();
        foreach ($oDir->getListFile() as $oFile) {
            if (preg_match('/.sample.php/', $oFile->getName()) or !preg_match('/.php$/', $oFile->getName())) {
                continue;
            }
            $tFile[] = $oFile->getName();
            require_once $oFile->getAdresse();
            $sClassFoo = substr($oFile->getName(), 0, -4);
            $oModelFoo = new $sClassFoo();
            if (method_exists($oModelFoo, 'getSelect')) {
                $tRowMethodes[substr($oFile->getName(), 0, -4)] = substr($oFile->getName(), 0, -4) . '::getSelect()';
            }
        }
        $oTpl = $this->getView('index');
        if (_root::getParam('class') != '') {
            $sClass = substr(_root::getParam('class'), 0, -4);
            require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
            $tColumn = module_builder::getTools()->getListColumnFromClass($sClass);
            $oTpl->sClass = $sClass;
            $tId = module_builder::getTools()->getIdTabFromClass($sClass);
            foreach ($tColumn as $i => $sColumn) {
                if (in_array($sColumn, $tId)) {
                    unset($tColumn[$i]);
                }
            }
            $oTpl->tColumn = $tColumn;
            $oTpl->tRowMethodes = $tRowMethodes;
            $oModel = new $sClass();
            $oTpl->sModuleToCreate = $oModel->getTable();
            $oTpl->sgbd = _root::getConfigVar('db.' . $oModel->getConfig() . '.sgbd');
        }
        if ($this->isPost()) {
            $sModuleToCreate = _root::getParam('moduleToCreate');
            $sClass = _root::getParam('sClass');
            $tColumn = _root::getParam('tColumn');
            $tLabel = _root::getParam('tLabel');
            $tType = _root::getParam('tType');
            $tEnable = _root::getParam('tEnable');
            foreach ($tColumn as $i => $sColumn) {
                if (!in_array($sColumn, $tEnable)) {
                    unset($tColumn[$i]);
                }
            }
            require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
            $oModel = new $sClass();
            $sModule = $sModuleToCreate;
            $this->projectMkdir('module/' . $sModule);
            $this->projectMkdir('module/' . $sModule . '/view');
            $tCrud = _root::getParam('crud', null);
            $bWithPagination = _root::getParam('withPagination');
            $this->genModelMain($sModuleToCreate, $oModel->getTable(), $sClass, $tColumn, $tCrud, $bWithPagination);
            $this->genModelTpl($sModuleToCreate, $sClass, $tColumn, $oModel->getTable(), $tCrud, $tLabel);
            $msg = trR('moduleGenereAvecSucces', array('#MODULE#' => $sModule));
            $detail = trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule));
            $detail .= '<br />' . trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule . '/view'));
            $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/main.php'));
            $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/list.php'));
            if (in_array('crudEdit', $tCrud)) {
                $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/edit.php'));
            }
            if (in_array('crudNew', $tCrud)) {
                $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/new.php'));
            }
            if (in_array('crudShow', $tCrud)) {
                $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/show.php'));
            }
            if (in_array('crudDelete', $tCrud)) {
                $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/delete.php'));
            }
            $sCode = '<?php ' . "\n";
            $sCode .= '//instancier le module' . "\n";
            $sCode .= '$oModule' . ucfirst(strtolower($sModule)) . '=new module_' . $sModule . ";\n\n";
            $sCode .= '//si vous souhaitez indiquer au module integrable des informations sur le module parent' . "\n";
            $sCode .= '//$oModuleExamplemodule->setRootLink(\'module::action\',array(\'parametre\'=>_root::getParam(\'parametre\')));' . "\n\n";
            $sCode .= '//recupere la vue du module' . "\n";
            $sCode .= '$oView=$oModule' . ucfirst(strtolower($sModule)) . '->_index();' . "\n";
            $sCode .= "\n";
            $sCode .= '//assigner la vue retournee a votre layout' . "\n";
            $sCode .= '$this->oLayout->add(\'main\',$oView);' . "\n";
            $detail .= '<br/><br/>' . tr('pourLutiliser') . '<br />
			' . highlight_string($sCode, 1);
        }
        $oTpl->msg = $msg;
        $oTpl->detail = $detail;
        $oTpl->tFile = $tFile;
        return $oTpl;
    }
Exemple #11
0
 public function getListModule()
 {
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/');
     $tDir = $oDir->getListDir();
     $tNewDir = array();
     foreach ($tDir as $oModule) {
         $sModuleName = $oModule->getName();
         if (in_array($sModuleName, array('menu', 'builder', 'example', 'exampleembedded'))) {
             continue;
         }
         if (!file_exists(module_builder::getTools()->getRootWebsite() . 'module/' . $sModuleName . '/main.php')) {
             continue;
         }
         $tNewDir[] = $oModule;
     }
     return $tNewDir;
 }
Exemple #12
0
 public function getListIni()
 {
     $tLinkModule = array();
     $tLocalIni = array();
     $sPathModule = module_builder::getTools()->getRootWebsite() . 'module';
     $tModulesAll = scandir($sPathModule);
     foreach ($tModulesAll as $sModule) {
         if (file_exists($sPathModule . '/' . $sModule . '/info.ini')) {
             $tIni = parse_ini_file($sPathModule . '/' . $sModule . '/info.ini');
             $tLocalIni[$tIni['id']] = $tIni['version'];
         }
     }
     return $tLocalIni;
 }
Exemple #13
0
 private function generate()
 {
     if (!_root::getRequest()->isPost() or _root::getParam('formu') != 'generate') {
         return null;
     }
     $oPluginValid = new plugin_valid(_root::getRequest()->getParams());
     $oPluginValid->isNotEmpty('modulename', 'Le champ doit &ecirc;tre rempli');
     $oPluginValid->isNotEmpty('classmodel', 'Le champ doit &ecirc;tre rempli');
     $oPluginValid->isNotEmpty('redirect', 'Le champ doit &ecirc;tre rempli');
     if (!$oPluginValid->isValid()) {
         return $oPluginValid->getListError();
     }
     $sModuleName = _root::getParam('modulename');
     $sClassModuleName = 'module_' . $sModuleName;
     $sRedirectModuleAction = _root::getParam('redirect');
     $sModelName = _root::getParam('classmodel');
     $sViewName = $sModuleName . '::login';
     $sContent = module_builder::getTools()->stringReplaceIn(array('module_exampleauth' => $sClassModuleName, 'privatemodule_action' => $sRedirectModuleAction, 'model_example' => $sModelName, 'auth_login' => $sViewName), 'data/sources/fichiers/module/auth/main.php');
     module_builder::getTools()->projetmkdir('module/' . $sModuleName);
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleName . '/main.php');
     $oFile->setContent($sContent);
     $oFile->save();
     $oFile->chmod(0666);
     module_builder::getTools()->projetmkdir('module/' . $sModuleName . '/view');
     $oFile = new _file('data/sources/fichiers/module/auth/view/login.php');
     $sContent = $oFile->getContent();
     $oNewViewFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleName . '/view/login.php');
     $oNewViewFile->setContent($sContent);
     $oNewViewFile->save();
     return array('success' => 1);
 }
Exemple #14
0
 public function _index()
 {
     $bGuriddoExist = false;
     $bGuriddoPublicExist = false;
     $bModelCountExist = false;
     $bModelPaginationExist = false;
     $bModelFilterCountExist = false;
     $bModelFilterPaginationExist = false;
     //check guriddo
     if (file_exists(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/guriddo')) {
         $bGuriddoExist = true;
     }
     //check guriddo public
     if (file_exists(_root::getConfigVar('path.generation') . _root::getParam('id') . '/public/guriddo')) {
         $bGuriddoPublicExist = true;
     }
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $msg = '';
     $detail = '';
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/');
     $tFile = array();
     $tRowMethodes = array();
     foreach ($oDir->getListFile() as $oFile) {
         if (preg_match('/.sample.php/', $oFile->getName()) or !preg_match('/.php$/', $oFile->getName())) {
             continue;
         }
         $tFile[] = $oFile->getName();
         require_once $oFile->getAdresse();
         $sClassFoo = substr($oFile->getName(), 0, -4);
         $oModelFoo = new $sClassFoo();
         if (method_exists($oModelFoo, 'getSelect')) {
             $tRowMethodes[substr($oFile->getName(), 0, -4)] = substr($oFile->getName(), 0, -4) . '::getSelect()';
         }
     }
     $oTpl = $this->getView('index');
     $oTpl->bGuriddo = $bGuriddoExist;
     $oTpl->bGuriddoPublicExist = $bGuriddoPublicExist;
     $oTpl->pathGenerated = _root::getConfigVar('path.generation') . _root::getParam('id');
     $oTpl->pathModule = _root::getConfigVar('path.generation') . _root::getParam('id') . '/module';
     $oTpl->pathPublic = _root::getConfigVar('path.generation') . _root::getParam('id') . '/public/';
     if (_root::getParam('class') != '') {
         $sClass = substr(_root::getParam('class'), 0, -4);
         require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
         $oTpl->class = $sClass;
         $oModel = new $sClass();
         if (method_exists($oModel, 'findTotal')) {
             $bModelCountExist = true;
         }
         if (method_exists($oModel, 'findListLimitOrderBy')) {
             $bModelPaginationExist = true;
         }
         if (method_exists($oModel, 'findTotalFiltered')) {
             $bModelFilterCountExist = true;
         }
         if (method_exists($oModel, 'findListFilteredAndLimitOrderBy')) {
             $bModelFilterPaginationExist = true;
         }
         $tColumn = module_builder::getTools()->getListColumnFromClass($sClass);
         $oTpl->sClass = $sClass;
         $oTpl->tSortColumn = $tColumn;
         $tId = module_builder::getTools()->getIdTabFromClass($sClass);
         foreach ($tColumn as $i => $sColumn) {
             if (in_array($sColumn, $tId)) {
                 unset($tColumn[$i]);
             }
         }
         $oTpl->tColumn = $tColumn;
         $oTpl->tRowMethodes = $tRowMethodes;
         $oTpl->sModuleToCreate = $oModel->getTable();
     }
     if ($this->isPost()) {
         $sModuleToCreate = _root::getParam('moduleToCreate');
         $sClass = _root::getParam('sClass');
         $tColumn = _root::getParam('tColumn');
         $tLabel = _root::getParam('tLabel');
         $tType = _root::getParam('tType');
         $tEnable = _root::getParam('tEnable');
         $sDefaultField = _root::getParam('defaultSort');
         $tTableOption = array();
         $tTableOption['width'] = _root::getParam('tableWidth');
         $tTableOption['height'] = _root::getParam('tableHeight');
         $tTableOption['limit'] = _root::getParam('tableLimit');
         foreach ($tColumn as $i => $sColumn) {
             if (!in_array($sColumn, $tEnable)) {
                 unset($tColumn[$i]);
             }
         }
         require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
         $oModel = new $sClass();
         $sModule = $sModuleToCreate;
         $tCrud = _root::getParam('crud', null);
         $bWithPagination = _root::getParam('withPagination');
         $this->genModelMain($sModuleToCreate, $oModel->getTable(), $sClass, $tColumn, $tLabel, $sDefaultField, $tTableOption, $tCrud, $bWithPagination);
         $this->genModelTpl($sModuleToCreate, $sClass, $tColumn, $oModel->getTable(), $tCrud, $tLabel);
         $msg = trR('moduleGenereAvecSucces', array('#MODULE#' => $sModule));
         $detail = trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule));
         $detail .= '<br />' . trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule . '/view'));
         $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/main.php'));
         $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/list.php'));
         $detail .= '<br/><br/>' . tr('accessibleVia') . '<a href="' . _root::getConfigVar('path.generation') . _root::getParam('id') . '/public/index.php?:nav=' . $sModule . '::index">index.php?:nav=' . $sModule . '::index</a>';
     }
     $oTpl->bModelFilterCountExist = $bModelFilterCountExist;
     $oTpl->bModelFilterPaginationExist = $bModelFilterPaginationExist;
     $oTpl->bModelCountExist = $bModelCountExist;
     $oTpl->bModelPaginationExist = $bModelPaginationExist;
     $oTpl->msg = $msg;
     $oTpl->detail = $detail;
     $oTpl->tFile = $tFile;
     return $oTpl;
 }
Exemple #15
0
 private function processIndex()
 {
     if (!_root::getRequest()->isPost() or _root::getParam('actioncode') != 'generate') {
         return null;
     }
     $tField = $this->tField;
     $oValid = new plugin_valid(_root::getRequest()->getParams());
     foreach ($tField as $sField) {
         $oValid->isLongerOrEqualThan($sField, 2, 'obligatoire');
     }
     if (!$oValid->isValid()) {
         return $oValid->getListError();
     }
     //ok
     $sClassModelRightsManager = 'model_' . _root::getParam('modelToGenerate');
     $sClassRowRightsManager = 'row_' . _root::getParam('modelToGenerate');
     $sModuleRightsManager = _root::getParam('moduleToGenerate');
     //permissions
     $classModelPermission = _root::getParam('classModelPermission');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelPermission . '.php';
     $oPermission = new $classModelPermission();
     //actions
     $classModelAction = _root::getParam('classModelAction');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelAction . '.php';
     $oAction = new $classModelAction();
     //items
     $classModelItem = _root::getParam('classModelItem');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelItem . '.php';
     $oItem = new $classModelItem();
     //groups
     $classModelGroup = _root::getParam('classModelGroup');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelGroup . '.php';
     $oGroup = new $classModelGroup();
     //users
     $classModelUser = _root::getParam('classModelUser');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelUser . '.php';
     $oUser = new $classModelUser();
     $exampleConfig = $oPermission->getConfig();
     $exampleTable = $oPermission->getTable();
     $exampleRequeteFindListByGroup = null;
     $exampleUserGroups_id = _root::getParam('classModelUser_groups_id');
     $exampleAction_name = _root::getParam('classModelAction_name');
     $exampleItem_name = _root::getParam('classModelItem_name');
     //exampleGroups_id
     //exampleAction_name
     //exampleItem_name
     $sPermissionTable = $oPermission->getTable();
     $sPermissionActionId = _root::getParam('classModelPermission_actions_id');
     $sPermissionItemId = _root::getParam('classModelPermission_items_id');
     $sPermissionGroupId = _root::getParam('classModelPermission_groups_id');
     $sPermissionId = _root::getParam('classModelPermission_id');
     $sActionTable = $oAction->getTable();
     $sActionId = _root::getParam('classModelAction_id');
     $sActionName = _root::getParam('classModelAction_name');
     $sItemTable = $oItem->getTable();
     $sItemId = _root::getParam('classModelItem_id');
     $sItemName = _root::getParam('classModelItem_name');
     $sGroupTable = $oGroup->getTable();
     $sGroupId = _root::getParam('classModelGroup_id');
     $sGroupName = _root::getParam('classModelGroup_name');
     $sUserTable = $oUser->getTable();
     $sUserId = _root::getParam('classModelUser_id');
     $sUserGroupId = _root::getParam('classModelUser_groups_id');
     $sUserLogin = _root::getParam('classModelUser_login');
     $r = "\n";
     $t = "\t";
     //requete findByGroupId
     $sRequest = $r;
     $sRequest .= $t . $t . 'SELECT ' . $r;
     $sRequest .= $t . $t . $t . '' . $sActionTable . '.' . $sActionName . ' as actionName';
     $sRequest .= ' , ' . $sItemTable . '.' . $sItemName . ' as itemName' . $r;
     $sRequest .= $t . $t . 'FROM ' . $sPermissionTable . '' . $r;
     $sRequest .= $t . $t . $t . 'INNER JOIN ' . $sActionTable . '' . $r;
     $sRequest .= $t . $t . $t . $t . 'ON ' . $sActionTable . '.' . $sActionId . '=' . $sPermissionTable . '.' . $sPermissionActionId . $r;
     $sRequest .= $t . $t . $t . 'INNER JOIN ' . $sItemTable . '' . $r;
     $sRequest .= $t . $t . $t . $t . ' ON ' . $sItemTable . '.' . $sItemId . '=' . $sPermissionTable . '.' . $sPermissionItemId . $r;
     $sRequest .= $t . $t . 'WHERE ' . $sPermissionTable . '.' . $sPermissionGroupId . '=?';
     $exampleRequeteFindListByGroup = $sRequest;
     //requete findAll
     $sRequest = $r;
     $sRequest .= $t . $t . 'SELECT ' . $r;
     $sRequest .= $t . $t . $t . '' . $sActionTable . '.' . $sActionName . ' as actionName';
     $sRequest .= ' , ' . $sItemTable . '.' . $sItemName . ' as itemName' . $r;
     $sRequest .= ' , ' . $sGroupTable . '.' . $sGroupName . ' as groupName' . $r;
     $sRequest .= ' , ' . $sPermissionTable . '.' . $sPermissionId . $r;
     $sRequest .= $t . $t . 'FROM ' . $sPermissionTable . '' . $r;
     $sRequest .= $t . $t . $t . 'INNER JOIN ' . $sActionTable . '' . $r;
     $sRequest .= $t . $t . $t . $t . 'ON ' . $sActionTable . '.' . $sActionId . '=' . $sPermissionTable . '.' . $sPermissionActionId . $r;
     $sRequest .= $t . $t . $t . 'INNER JOIN ' . $sItemTable . '' . $r;
     $sRequest .= $t . $t . $t . $t . ' ON ' . $sItemTable . '.' . $sItemId . '=' . $sPermissionTable . '.' . $sPermissionItemId . $r;
     $sRequest .= $t . $t . $t . 'INNER JOIN ' . $sGroupTable . '' . $r;
     $sRequest .= $t . $t . $t . $t . ' ON ' . $sGroupTable . '.' . $sGroupId . '=' . $sPermissionTable . '.' . $sPermissionGroupId . $r;
     $exampleRequeteFindAll = $sRequest;
     //---model
     $sContentModel = module_builder::getTools()->stringReplaceIn(array('exampleTable' => $exampleTable, 'exampleConfig' => $exampleConfig, 'exampleRequeteFindListByGroup' => $exampleRequeteFindListByGroup, 'exampleRequeteFindAll' => $exampleRequeteFindAll, 'examplePermission_id' => $sPermissionId, 'exampleUserGroups_id' => $sUserGroupId, 'exampleAction_name' => $sActionName, 'exampleItem_name' => $sItemName, 'exampleGroupTable' => $sGroupTable, 'exampleGroup_id' => $sGroupId, 'exampleGroup_name' => $sGroupName, 'exampleActionTable' => $sActionTable, 'exampleAction_id' => $sActionId, 'exampleAction_name' => $sActionName, 'exampleItemTable' => $sItemTable, 'exampleItem_id' => $sItemId, 'exampleItem_name' => $sItemName, 'exampleUserTable' => $sUserTable, 'exampleUser_id' => $sUserId, 'exampleUser_login' => $sUserLogin, 'exampleUser_groupsId' => $sUserGroupId), 'data/sources/fichiers/model/model_rightsManager.php');
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClassModelRightsManager . '.php');
     if ($oFile->exist()) {
         return array('error' => 'Fichier model/' . $sClassModelRightsManager . '.php exite deja');
     }
     $oFile->setContent($sContentModel);
     $oFile->save();
     $oFile->chmod(0666);
     $tReplace = array('examplemodule' => $sModuleRightsManager, 'model_examplemodel' => $sClassModelRightsManager, 'row_examplemodel' => $sClassRowRightsManager, 'examplePermissionId' => $sPermissionId, 'exampleGroupId' => $sPermissionGroupId, 'exampleActionId' => $sPermissionActionId, 'exampleItemId' => $sPermissionItemId, 'exampleUserTable' => $sUserTable, 'exampleUser_id' => $sUserId, 'exampleUser_login' => $sUserLogin, 'exampleUser_groupsId' => $sUserGroupId, 'exampleUserTable' => $sUserTable, 'exampleUser_id' => $sUserId, 'exampleUser_login' => $sUserLogin, 'exampleUser_groupsId' => $sUserGroupId);
     //-module
     //---main
     module_builder::getTools()->projetmkdir('module/' . $sModuleRightsManager);
     module_builder::getTools()->projetmkdir('module/' . $sModuleRightsManager . '/view');
     $sContentModel = module_builder::getTools()->stringReplaceIn($tReplace, 'data/sources/fichiers/module/rightsManager/main.php');
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleRightsManager . '/main.php');
     if ($oFile->exist()) {
         return array('error' => 'Fichier module/' . $sModuleRightsManager . '/view/main.php exite deja');
     }
     $oFile->setContent($sContentModel);
     $oFile->save();
     $oFile->chmod(0666);
     //--view index
     $sContentModel = module_builder::getTools()->stringReplaceIn($tReplace, 'data/sources/fichiers/module/rightsManager/view/index.php');
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleRightsManager . '/view/index.php');
     if ($oFile->exist()) {
         return array('error' => 'Fichier module/' . $sModuleRightsManager . '/view/index.php exite deja');
     }
     $oFile->setContent($sContentModel);
     $oFile->save();
     $oFile->chmod(0666);
     //--view new
     $sContentModel = module_builder::getTools()->stringReplaceIn($tReplace, 'data/sources/fichiers/module/rightsManager/view/new.php');
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleRightsManager . '/view/new.php');
     if ($oFile->exist()) {
         return array('error' => 'Fichier module/' . $sModuleRightsManager . '/view/new.php exite deja');
     }
     $oFile->setContent($sContentModel);
     $oFile->save();
     $oFile->chmod(0666);
     //--view edit
     $sContentModel = module_builder::getTools()->stringReplaceIn($tReplace, 'data/sources/fichiers/module/rightsManager/view/edit.php');
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleRightsManager . '/view/edit.php');
     if ($oFile->exist()) {
         return array('error' => 'Fichier module/' . $sModuleRightsManager . '/view/edit.php exite deja');
     }
     $oFile->setContent($sContentModel);
     $oFile->save();
     $oFile->chmod(0666);
     //--view delete
     $sContentModel = module_builder::getTools()->stringReplaceIn($tReplace, 'data/sources/fichiers/module/rightsManager/view/delete.php');
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleRightsManager . '/view/delete.php');
     if ($oFile->exist()) {
         return array('error' => 'Fichier module/' . $sModuleRightsManager . '/view/delete.php exite deja');
     }
     $oFile->setContent($sContentModel);
     $oFile->save();
     $oFile->chmod(0666);
     //--view editUser
     $sContentModel = module_builder::getTools()->stringReplaceIn($tReplace, 'data/sources/fichiers/module/rightsManager/view/userEdit.php');
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleRightsManager . '/view/userEdit.php');
     if ($oFile->exist()) {
         return array('error' => 'Fichier module/' . $sModuleRightsManager . '/view/userEdit.php exite deja');
     }
     $oFile->setContent($sContentModel);
     $oFile->save();
     $oFile->chmod(0666);
     //-----------
     $sMsg = null;
     $sDetail = null;
     $sMsg = 'Model ' . $sClassModelRightsManager . ' et Module ' . $sModuleRightsManager . ' g&eacute;n&eacute;r&eacute;s avec succ&egrave;s';
     $sDetail .= 'Cr&eacute;ation fichier model/' . $sClassModelRightsManager . '.php <br/><br/>';
     $sDetail .= 'Cr&eacute;ation du repertoire module/' . $sModuleRightsManager . '/ <br/>';
     $sDetail .= 'Cr&eacute;ation du repertoire module/' . $sModuleRightsManager . '/view/ <br/>';
     $sDetail .= 'Cr&eacute;ation fichier module/' . $sModuleRightsManager . '/main.php <br/>';
     $sDetail .= 'Cr&eacute;ation fichier module/' . $sModuleRightsManager . '/view/index.php <br/>';
     $sDetail .= 'Cr&eacute;ation fichier module/' . $sModuleRightsManager . '/view/new.php <br/>';
     $sDetail .= 'Cr&eacute;ation fichier module/' . $sModuleRightsManager . '/view/edit.php <br/>';
     $sDetail .= 'Cr&eacute;ation fichier module/' . $sModuleRightsManager . '/view/delete.php <br/>';
     $sDetail .= '<br/><br/>Pour y acc&eacute;der <a href="' . _root::getConfigVar('path.generation') . _root::getParam('id') . '/public/index.php?:nav=' . $sModuleRightsManager . '::index">cliquer ici (index.php?:nav=' . $sModuleRightsManager . '::index)</a>';
     $sModuleAuth = 'auth';
     $tConfig = module_builder::getTools()->rootAddConf('conf/site.ini.php');
     if (isset($tConfig['auth']) and isset($tConfig['auth']['module'])) {
         $sModuleAuthAndAction = $tConfig['auth']['module'];
         if (preg_match('/:/', $sModuleAuthAndAction)) {
             list($sModuleAuth, $foo) = explode(':', $sModuleAuthAndAction);
         }
     }
     $r = "\n";
     $t = "\t";
     $sCode = null;
     $sCode = '<?php ' . "\n";
     $sCode .= 'private function checkLoginPass(){' . $r;
     $sCode .= $t . '(...)' . $r;
     $sCode .= $t . '$oUser=_root::getAuth()->getAccount();' . $r;
     $sCode .= $t . $sClassModelRightsManager . '::getInstance()->loadForUser($oUser);' . $r;
     $sCode .= $r;
     $sCode .= $t . '_root::redirect(\'privatemodule_action\');' . $r;
     $sCode .= '}' . $r;
     $sCodeHighli = highlight_string($sCode, 1);
     return array('msg' => $sMsg, 'detail' => $sDetail, 'code' => $sCodeHighli, 'auth' => $sModuleAuth);
 }
Exemple #16
0
 private function generate($sTable, $sConfig, $sId, $tSelect = null)
 {
     $sFileModel = 'model_example.sample.php';
     if (_root::getConfigVar('db.' . _root::getParam('sConfig') . '.sgbd') == 'mongodb') {
         $sFileModel = 'model_exampleMongodb.php';
     }
     /*SOURCE*/
     $oSourceModel = $this->getObjectSource($sFileModel);
     $r = "\n";
     $t = "\t";
     $sTable = trim($sTable);
     /*SOURCE*/
     $oSourceModel->setPattern('#maTable#', $sTable);
     /*SOURCE*/
     $oSourceModel->setPattern('#maTable_id#', $sId);
     /*SOURCE*/
     $oSourceModel->setPattern('#maConfig#', $sConfig);
     $sContentGetSelect = null;
     if (is_array($tSelect)) {
         $sContentGetSelect = $oSourceModel->getSnippet('methodGetSelect', array('#key#' => $tSelect['key'], '#val#' => $tSelect['val']));
     }
     /*SOURCE*/
     $oSourceModel->setPattern('#modelMethods#', $sContentGetSelect);
     $srowCallSave = 'parent::save();';
     $smodelSaveDuplicateKey = null;
     if (_root::getParam('mysqlOnDuplicateKey') == 1) {
         $soData = '$o' . ucfirst($sTable);
         $tColumn = module_builder::getTools()->getListColumnFromConfigAndTable($sConfig, $sTable);
         foreach ($tColumn as $sColumn) {
             if ($sColumn == $sId) {
                 continue;
             }
             $tFieldSql[] = $sColumn;
             $tSqlInsert[] = '?';
             $tSqlUpdate[] = $sColumn . '=?';
             $tParam[] = $soData . '->' . $sColumn;
         }
         foreach ($tColumn as $sColumn) {
             if ($sColumn == $sId) {
                 continue;
             }
             $tParam[] = $soData . '->' . $sColumn;
         }
         $smodelSaveDuplicateKey = $oSourceModel->getSnippet('methodSave', array('#oData#' => $soData, '#implodetFieldSql#' => implode(',', $tFieldSql), '#implodetSqlInsert#' => implode(',', $tSqlInsert), '#implodetSqlUpdate#' => implode(',', $tSqlUpdate), '#implodetParam#' => implode(',', $tParam)));
         $srowCallSave = 'model_' . $sTable . '::getInstance()->save($this);';
     }
     /*SOURCE*/
     $oSourceModel->setPattern('#modelSaveDuplicateKey#', $smodelSaveDuplicateKey);
     /*SOURCE*/
     $oSourceModel->setPattern('#rowCallSave#', $srowCallSave);
     $sRules = null;
     if (_root::getParam('tRuleColumn' . $sTable)) {
         $tRuleColumn = _root::getParam('tRuleColumn' . $sTable);
         $tRuleName = _root::getParam('tRuleName' . $sTable);
         $tRuleParam = _root::getParam('tRuleParam' . $sTable);
         $tRuleMsg = _root::getParam('tRuleMsg' . $sTable);
         if ($tRuleColumn) {
             $sRules = $r;
             foreach ($tRuleColumn as $key => $sRuleColumn) {
                 if ($sRuleColumn == '') {
                     continue;
                 }
                 $sRuleName = $tRuleName[$key];
                 $sRuleParam = $tRuleParam[$key];
                 $sRuleMsg = $tRuleMsg[$key];
                 $sRules .= $t . $t;
                 //$oPluginValid->isEqual('champ','valeurB','Le champ n\est pas &eacute;gal &agrave; '.$valeurB);
                 $sRules .= '$oPluginValid->' . $sRuleName . '(' . "'{$sRuleColumn}'";
                 if (!in_array($sRuleName, array('isEmpty', 'isNotEmpty', 'isEmailValid'))) {
                     $sRules .= ",'{$sRuleParam}'";
                 }
                 $sRules .= ",'{$sRuleMsg}'";
                 $sRules .= ');' . $r;
             }
         }
     }
     /*SOURCE*/
     $oSourceModel->setPattern('#rowMethodGetCheckContraints#', $sRules);
     /*SOURCE*/
     $oSourceModel->save();
     return true;
 }
Exemple #17
0
 private function analyze($oTpl)
 {
     $error = null;
     $msg = null;
     $detail = null;
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/');
     $tFile = array();
     $tRowMethodes = array();
     foreach ($oDir->getListFile() as $oFile) {
         if (preg_match('/.sample.php/', $oFile->getName()) or !preg_match('/.php$/', $oFile->getName())) {
             continue;
         }
         $tFile[] = $oFile->getName();
         require_once $oFile->getAdresse();
         $sClassFoo = substr($oFile->getName(), 0, -4);
         $oModelFoo = new $sClassFoo();
         if (method_exists($oModelFoo, 'getSelect')) {
             $tRowMethodes[substr($oFile->getName(), 0, -4)] = substr($oFile->getName(), 0, -4) . '::getSelect()';
         }
     }
     if (_root::getParam('model') != '') {
         $sClass = substr(_root::getParam('model'), 0, -4);
         require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
         $tBlackListMethod = get_class_methods('abstract_model');
         $tBlackListMethod[] = 'getInstance';
         $tMethod = array();
         $tMethod0 = get_class_methods($sClass);
         foreach ($tMethod0 as $sMethod) {
             if (!in_array($sMethod, $tBlackListMethod)) {
                 $tMethod[] = $sMethod;
             }
         }
         $oTpl->tMethod = $tMethod;
     }
     if (_root::getParam('model') != '' and _root::getParam('method') != '') {
         $tModule = module_builder::getTools()->getListModule();
         $sClass = substr(_root::getParam('model'), 0, -4);
         require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
         $sMethod = _root::getParam('method');
         module_builder::getTools()->loadConfig($sClass);
         $oModel = new $sClass();
         $tData = array();
         try {
             $tData = $oModel->{$sMethod}();
             if (!$tData) {
                 $error = 'Votre methode ' . $sMethod . ' ne retourne pas d\'enregistrement.<br />';
                 $error .= 'Ce generateur necessite d\'avoir des donnees pour construire le tableau';
             }
         } catch (Exception $e) {
             $error = 'La methode ' . $sMethod . ' n\'est pas compatible avec ce generateur';
         }
         $tColumn = array();
         if ($tData) {
             foreach ($tData as $oRow) {
                 if (is_subclass_of($oRow, 'abstract_row')) {
                     $tColumn0 = $oRow->getTab();
                 } else {
                     $tColumn0 = get_object_vars($oRow);
                 }
                 $tColumn = array_keys($tColumn0);
                 break;
             }
         } else {
         }
         $oTpl->sClass = $sClass;
         $oTpl->tModule = $tModule;
         $tId = module_builder::getTools()->getIdTabFromClass($sClass);
         foreach ($tColumn as $i => $sColumn) {
             if (in_array($sColumn, $tId)) {
                 unset($tColumn[$i]);
             }
         }
         $oTpl->tColumn = $tColumn;
         $oTpl->tRowMethodes = $tRowMethodes;
         $oModel = new $sClass();
         $oTpl->sModuleToCreate = $oModel->getTable();
     }
     $oTpl->msg = $msg;
     $oTpl->detail = $detail;
     $oTpl->tFile = $tFile;
     $oTpl->error = $error;
     return $oTpl;
 }
Exemple #18
0
 public function _index()
 {
     $tMessage = $this->process();
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/');
     $tFile = array();
     $tRowMethodes = array();
     foreach ($oDir->getListFile() as $oFile) {
         if (preg_match('/.sample.php/', $oFile->getName()) or !preg_match('/.php$/', $oFile->getName())) {
             continue;
         }
         $tFile[] = $oFile->getName();
         require_once $oFile->getAdresse();
         $sClassFoo = substr($oFile->getName(), 0, -4);
         $oModelFoo = new $sClassFoo();
         if (method_exists($oModelFoo, 'getListAccount') and method_exists($oModelFoo, 'hashPassword')) {
             $tRowMethodes[substr($oFile->getName(), 0, -4)] = substr($oFile->getName(), 0, -4) . '::getInstance()->getListAccount() et hashPassword()';
         }
     }
     if (_root::getParam('model') == null) {
         $tRowMethodes = array();
     }
     $tModule = module_builder::getTools()->getListModule();
     $tModuleAndMethod = array();
     foreach ($tModule as $oModule) {
         $sModuleName = $oModule->getName();
         if (in_array($sModuleName, array('menu', 'builder', 'example', 'exampleembedded'))) {
             continue;
         }
         include module_builder::getTools()->getRootWebsite() . 'module/' . $sModuleName . '/main.php';
         if (get_parent_class('module_' . $sModuleName) != 'abstract_module') {
             continue;
         }
         $tMethods = get_class_methods('module_' . $sModuleName);
         foreach ($tMethods as $i => $sMethod) {
             if ($sMethod[0] != '_' or substr($sMethod, 0, 2) == '__') {
                 unset($tMethods[$i]);
             }
         }
         if (empty($tMethods)) {
             continue;
         }
         $tModuleAndMethod[$sModuleName] = $tMethods;
     }
     $tColumnAccount = null;
     $sClassAccount = _root::getParam('model');
     if ($sClassAccount) {
         $sClassAccount = substr($sClassAccount, 0, -4);
         $tColumnAccount = module_builder::getTools()->getListColumnFromClass($sClassAccount);
     }
     $oTpl = $this->getView('index');
     $oTpl->tRowMethodes = $tRowMethodes;
     $oTpl->tModuleAndMethod = $tModuleAndMethod;
     $oTpl->tFile = $tFile;
     $oTpl->tColumnAccount = $tColumnAccount;
     $oTpl->tError = $this->tError;
     $oTpl->msg = $this->msg;
     $oTpl->detail = $this->detail;
     $oTpl->tMessage = $tMessage;
     return $oTpl;
 }
Exemple #19
0
 public function before()
 {
     self::$oTools = new module_builderTools();
     $this->oLayout = new _layout('template1');
     $this->oLayout->addModule('menu', 'menu::index');
 }
Exemple #20
0
 private function process()
 {
     if (_root::getRequest()->isPost() == false or _root::getParam('actioncode') != 'generate') {
         return null;
     }
     $tField = $this->tField;
     $oValid = new plugin_valid(_root::getRequest()->getParams());
     foreach ($tField as $sField) {
         $oValid->isLongerOrEqualThan($sField, 2, 'obligatoire');
     }
     if (!$oValid->isValid()) {
         return $oValid->getListError();
     }
     //ok
     $sClassModelRightsManager = 'model_' . _root::getParam('modelToGenerate');
     $sClassRowRightsManager = 'row_' . _root::getParam('modelToGenerate');
     $sObjectRightManger = 'o' . ucfirst(_root::getParam('modelToGenerate'));
     $sModuleRightsManager = _root::getParam('moduleToGenerate');
     //permissions
     $classModelPermission = _root::getParam('classModelPermission');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelPermission . '.php';
     $oPermission = new $classModelPermission();
     //actions
     $classModelAction = _root::getParam('classModelAction');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelAction . '.php';
     $oAction = new $classModelAction();
     //items
     $classModelItem = _root::getParam('classModelItem');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelItem . '.php';
     $oItem = new $classModelItem();
     //groups
     $classModelGroup = _root::getParam('classModelGroup');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelGroup . '.php';
     $oGroup = new $classModelGroup();
     //groupsUser
     $classModelGroupUser = _root::getParam('classModelGroupUser');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelGroupUser . '.php';
     $oGroupUser = new $classModelGroupUser();
     //users
     $classModelUser = _root::getParam('classModelUser');
     include_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $classModelUser . '.php';
     $oUser = new $classModelUser();
     $exampleConfig = $oPermission->getConfig();
     $exampleTable = $oPermission->getTable();
     $exampleUserGroups_id = _root::getParam('classModelUser_groups_id');
     $exampleAction_name = _root::getParam('classModelAction_name');
     $exampleItem_name = _root::getParam('classModelItem_name');
     //exampleGroups_id
     //exampleAction_name
     //exampleItem_name
     $sPermissionTable = $oPermission->getTable();
     $sPermissionActionId = _root::getParam('classModelPermission_actions_id');
     $sPermissionItemId = _root::getParam('classModelPermission_items_id');
     $sPermissionGroupId = _root::getParam('classModelPermission_groups_id');
     $sPermissionId = _root::getParam('classModelPermission_id');
     $sActionTable = $oAction->getTable();
     $sActionId = _root::getParam('classModelAction_id');
     $sActionName = _root::getParam('classModelAction_name');
     $sItemTable = $oItem->getTable();
     $sItemId = _root::getParam('classModelItem_id');
     $sItemName = _root::getParam('classModelItem_name');
     $sGroupTable = $oGroup->getTable();
     $sGroupId = _root::getParam('classModelGroup_id');
     $sGroupName = _root::getParam('classModelGroup_name');
     $sGroupUserTable = $oGroupUser->getTable();
     $sGroupUserUserId = _root::getParam('classModelGroupUser_users_id');
     $sGroupUserGroupId = _root::getParam('classModelGroupUser_groups_id');
     $sUserTable = $oUser->getTable();
     $sUserId = _root::getParam('classModelUser_id');
     $sUserGroupId = _root::getParam('classModelUser_groups_id');
     $sUserLogin = _root::getParam('classModelUser_login');
     $r = "\n";
     $t = "\t";
     //requete requeteFindListByUser
     /*SOURCE*/
     $oSourceModel = $this->getObjectSource('model_rightsManagerMulti.php');
     $exampleRequeteFindListByUser = $oSourceModel->getSnippet('requeteFindListByUser', array('#sActionTable#' => $sActionTable, '#sActionId#' => $sActionId, '#sActionName#' => $sActionName, '#sItemTable#' => $sItemTable, '#sItemId#' => $sItemId, '#sItemName#' => $sItemName, '#sGroupUserTable#' => $sGroupUserTable, '#sGroupUserGroupId#' => $sGroupUserGroupId, '#sGroupUserUserId#' => $sGroupUserUserId, '#sPermissionTable#' => $sPermissionTable, '#sPermissionItemId#' => $sPermissionItemId, '#sPermissionActionId#' => $sPermissionActionId, '#sPermissionGroupId#' => $sPermissionGroupId));
     //requete findAll
     $exampleRequeteFindAll = $oSourceModel->getSnippet('exampleRequeteFindAll', array('#sActionTable#' => $sActionTable, '#sActionId#' => $sActionId, '#sActionName#' => $sActionName, '#sItemTable#' => $sItemTable, '#sItemId#' => $sItemId, '#sItemName#' => $sItemName, '#sGroupTable#' => $sGroupTable, '#sGroupId#' => $sGroupId, '#sGroupName#' => $sGroupName, '#sPermissionId#' => $sPermissionId, '#sPermissionTable#' => $sPermissionTable, '#sPermissionItemId#' => $sPermissionItemId, '#sPermissionActionId#' => $sPermissionActionId, '#sPermissionGroupId#' => $sPermissionGroupId));
     /*SOURCE*/
     $oSourceModel->setPattern('#model_examplemodel#', $sClassModelRightsManager);
     /*SOURCE*/
     $oSourceModel->setPattern('#row_examplemodel#', $sClassRowRightsManager);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleTable#', $exampleTable);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleConfig#', $exampleConfig);
     /*SOURCE*/
     $oSourceModel->setPattern('#requeteFindListByUser#', $exampleRequeteFindListByUser);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleRequeteFindAll#', $exampleRequeteFindAll);
     /*SOURCE*/
     $oSourceModel->setPattern('#examplePermission_id#', $sPermissionId);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleUserGroups_id#', $sUserGroupId);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleAction_name#', $sActionName);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleItem_name#', $sItemName);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleGroupTable#', $sGroupTable);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleGroup_id#', $sGroupId);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleGroup_name#', $sGroupName);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleActionTable#', $sActionTable);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleAction_id#', $sActionId);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleAction_name#', $sActionName);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleItemTable#', $sItemTable);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleItem_id#', $sItemId);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleItem_name#', $sItemName);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleUserTable#', $sUserTable);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleUser_id#', $sUserId);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleUser_login#', $sUserLogin);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleUser_groupsId#', $sUserGroupId);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleGroupUserTable#', $sGroupUserTable);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleGroupUserGroupId#', $sGroupUserGroupId);
     /*SOURCE*/
     $oSourceModel->setPattern('#exampleGroupUserUserId#', $sGroupUserUserId);
     /*SOURCE*/
     $oSourceModel->setPattern('#sClassModelRightsManager#', $sClassModelRightsManager);
     /*SOURCE*/
     $bSave = $oSourceModel->save();
     if ($bSave == false) {
         return array('error' => trR('fichierExisteDeja', array('#FICHIER#' => 'model/' . $sClassModelRightsManager . '.php')));
     }
     //--module main
     /*SOURCE*/
     $oSourceMain = $this->getObjectSource('example/main.php');
     /*SOURCE*/
     $oSourceMain->setPattern('#MODULE#', $sModuleRightsManager);
     $tReplace = array('#examplemodule#' => $sModuleRightsManager, '#model_examplemodel#' => $sClassModelRightsManager, '#row_examplemodel#' => $sClassRowRightsManager, '#oExamplemodel#' => $sObjectRightManger, '#examplePermissionId#' => $sPermissionId, '#exampleGroupId#' => $sPermissionGroupId, '#exampleActionId#' => $sPermissionActionId, '#exampleItemId#' => $sPermissionItemId, '#exampleUserTable#' => $sUserTable, '#exampleUser_id#' => $sUserId, '#exampleUser_login#' => $sUserLogin, '#exampleUser_groupsId#' => $sUserGroupId, '#exampleUserTable#' => $sUserTable, '#exampleUser_id#' => $sUserId, '#exampleUser_login#' => $sUserLogin, '#exampleUser_groupsId#' => $sUserGroupId);
     /*SOURCE*/
     $oSourceMain->setListPattern($tReplace);
     /*SOURCE*/
     $bSave = $oSourceMain->save();
     if ($bSave == false) {
         return array('error' => trR('fichierExisteDeja', array('#FICHIER#' => 'module/' . $sModuleRightsManager . '/main.php')));
     }
     $tView = array('index', 'new', 'edit', 'delete', 'userEdit');
     foreach ($tView as $sView) {
         //--view
         /*SOURCE*/
         $oSourceView = $this->getObjectSource('example/view/' . $sView . '.php');
         /*SOURCE*/
         $oSourceView->setPattern('#MODULE#', $sModuleRightsManager);
         /*SOURCE*/
         $oSourceView->setListPattern($tReplace);
         /*SOURCE*/
         $bSave = $oSourceView->save();
         if ($bSave == false) {
             return array('error' => trR('fichierExisteDeja', array('#FICHIER#' => 'module/' . $sModuleRightsManager . '/view/' . $sView . '.php')));
         }
     }
     //-----------
     $sMsg = null;
     $sDetail = null;
     $sMsg = 'Model ' . $sClassModelRightsManager . ' et Module ' . $sModuleRightsManager . ' g&eacute;n&eacute;r&eacute;s avec succ&egrave;s';
     $sDetail .= trR('CreationDuFichierVAR', array('#FICHIER#' => 'model/' . $sClassModelRightsManager . '.php')) . ' <br/><br/>';
     $sDetail .= trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModuleRightsManager . '/')) . '<br/>';
     $sDetail .= trR('creationRepertoire', array('#REPERTOIRE#' => 'Cr&eacute;ation du repertoire module/' . $sModuleRightsManager . '/view/')) . ' <br/>';
     $sDetail .= trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModuleRightsManager . '/main.php')) . ' <br/>';
     $sDetail .= trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModuleRightsManager . '/view/index.php')) . ' <br/>';
     $sDetail .= trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModuleRightsManager . '/view/new.php')) . ' <br/>';
     $sDetail .= trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModuleRightsManager . '/view/edit.php')) . ' <br/>';
     $sDetail .= trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModuleRightsManager . '/view/delete.php')) . ' <br/>';
     $sDetail .= '<br/><br/>' . tr('accessibleVia') . ' <a href="' . _root::getConfigVar('path.generation') . _root::getParam('id') . '/public/index.php?:nav=' . $sModuleRightsManager . '::index">index.php?:nav=' . $sModuleRightsManager . '::index</a>';
     $sModuleAuth = 'auth';
     $tConfig = module_builder::getTools()->rootAddConf('conf/site.ini.php');
     if (isset($tConfig['auth']) and isset($tConfig['auth']['module'])) {
         $sModuleAuthAndAction = $tConfig['auth']['module'];
         if (preg_match('/:/', $sModuleAuthAndAction)) {
             list($sModuleAuth, $foo) = explode(':', $sModuleAuthAndAction);
         }
     }
     $r = "\n";
     $t = "\t";
     $sCode = null;
     $sCode = '<?php ' . "\n";
     $sCode .= 'private function checkLoginPass(){' . $r;
     $sCode .= $t . '(...)' . $r;
     $sCode .= $t . '$oUser=_root::getAuth()->getAccount();' . $r;
     $sCode .= $t . $sClassModelRightsManager . '::getInstance()->loadForUser($oUser);' . $r;
     $sCode .= $r;
     $sCode .= $t . '_root::redirect(\'privatemodule_action\');' . $r;
     $sCode .= '}' . $r;
     $sCodeHighli = highlight_string($sCode, 1);
     return array('msg' => $sMsg, 'detail' => $sDetail, 'code' => $sCodeHighli, 'auth' => $sModuleAuth);
 }
 protected function getObjectSource($sSource)
 {
     return module_builder::getTools()->getSource(_root::getConfigVar('path.module') . $this->sModuleView, _root::getConfigVar('path.generation') . _root::getParam('id'), $sSource);
 }
Exemple #22
0
 private function genModelTpl($sModule, $sClass, $tColumn, $sTableName, $tCrud, $tLabel)
 {
     //$tColumn=_root::getParam('tColumn');
     $tType = _root::getParam('tType');
     $tCrud[] = 'list';
     $tTpl = array('list', 'show', 'edit', 'new', 'delete');
     $tTplCrud = array('show' => 'crudShow', 'new' => 'crudNew', 'delete' => 'crudDelete', 'edit' => 'crudEdit', 'list' => 'list');
     foreach ($tTpl as $sTpl) {
         //print $sTpl;
         if (!in_array($tTplCrud[$sTpl], $tCrud)) {
             //print "skip $sTpl ";
             continue;
         }
         $oFile = new _file('data/sources/fichiers/module/crudBootstrap/view/' . $sTpl . '.php');
         $sContent = $oFile->getContent();
         $oVar = simplexml_load_file('data/sources/fichiers/module/crudBootstrap/view/' . $sTpl . '.php.xml');
         $sLigne = (string) $oVar->lignetd;
         $sInputText = (string) $oVar->input;
         $sInputTextarea = (string) $oVar->textarea;
         $sInputSelect = (string) $oVar->select;
         $sInputUpload = (string) $oVar->upload;
         $sLinks = '';
         $sLinkNew = '';
         if ($sTpl == 'list') {
             //TH
             $sLigneTH = (string) $oVar->ligneth;
             //liens
             $tLink['crudNew'] = (string) $oVar->linkNew;
             $tLink['crudEdit'] = (string) $oVar->linkEdit;
             $tLink['crudShow'] = (string) $oVar->linkShow;
             $tLink['crudDelete'] = (string) $oVar->linkDelete;
             $iMaxCrud = count($tCrud);
             $iMaxCrud -= 2;
             foreach ($tCrud as $i => $sAction) {
                 if (in_array($sAction, array('crudNew', 'list'))) {
                     continue;
                 }
                 if (!isset($tLink[$sAction])) {
                     continue;
                 }
                 $sLinks .= $tLink[$sAction];
                 if ($i < $iMaxCrud) {
                     //$sLinks .= '| ';
                 }
             }
             if (in_array('crudNew', $tCrud)) {
                 $sLinkNew = $tLink['crudNew'];
             }
         }
         $sTable = '';
         $sTableTh = '';
         $sEnctype = '';
         foreach ($tColumn as $i => $sColumn) {
             $sLabel = $tLabel[$i];
             $sType = $tType[$i];
             if ($sType == 'text' or $sType == 'date') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputText);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
             } elseif ($sType == 'textarea') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputTextarea);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
             } elseif (substr($sType, 0, 7) == 'select;') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputSelect);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
                 $sInput = preg_replace('/examplemodel/', substr($sType, 7), $sInput);
             } elseif ($sType == 'upload') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputUpload);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
                 $sEnctype = ' enctype="multipart/form-data"';
                 //changement du enctype du formulaire
             }
             $sTable .= preg_replace('/examplecolumn/', $sLabel, preg_replace('/exampletd/', $sInput, $sLigne));
             $sTableTh .= preg_replace('/exampleth/', $sLabel, $sLigneTH);
         }
         $tReplace = array('<\\?php \\/\\/linknew\\?>' => $sLinkNew, '<\\?php \\/\\/links\\?>' => $sLinks, 'oExamplemodel' => 'o' . ucfirst($sTableName), 'tExamplemodel' => 't' . ucfirst($sTableName), 'examplemodule' => $sModule, '<\\?php \\/\\/enctype\\?>' => $sEnctype, '<\\?php \\/\\/ici\\?>' => $sTable, '<\\?php \\/\\/icith\\?>' => $sTableTh, '<\\?php \\/\\/colspan\\?>' => count($tColumn) + 1);
         $sContent = module_builder::getTools()->stringReplaceIn($tReplace, 'data/sources/fichiers/module/crudBootstrap/view/' . $sTpl . '.php');
         $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModule . '/view/' . $sTpl . '.php');
         $oFile->setContent($sContent);
         $oFile->save();
         $oFile->chmod(0666);
     }
 }
Exemple #23
0
 public function _index()
 {
     module_builder::getTools()->rootAddConf('conf/connexion.ini.php');
     $msg = '';
     $detail = '';
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/');
     $tFile = array();
     $tRowMethodes = array();
     foreach ($oDir->getListFile() as $oFile) {
         if (preg_match('/.sample.php/', $oFile->getName()) or !preg_match('/.php$/', $oFile->getName())) {
             continue;
         }
         $tFile[] = $oFile->getName();
         require_once $oFile->getAdresse();
         $sClassFoo = substr($oFile->getName(), 0, -4);
         $oModelFoo = new $sClassFoo();
         if (method_exists($oModelFoo, 'getSelect')) {
             $tRowMethodes[substr($oFile->getName(), 0, -4)] = substr($oFile->getName(), 0, -4) . '::getSelect()';
         }
     }
     $oTpl = $this->getView('index');
     if (_root::getParam('class') != '') {
         $sClass = substr(_root::getParam('class'), 0, -4);
         require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
         $tColumn = module_builder::getTools()->getListColumnFromClass($sClass);
         $oTpl->sClass = $sClass;
         $tId = module_builder::getTools()->getIdTabFromClass($sClass);
         foreach ($tColumn as $i => $sColumn) {
             if (in_array($sColumn, $tId)) {
                 unset($tColumn[$i]);
             }
         }
         $oTpl->tColumn = $tColumn;
         $oTpl->tRowMethodes = $tRowMethodes;
         $oModel = new $sClass();
         $oTpl->sModuleToCreate = $oModel->getTable();
         $oTpl->sgbd = _root::getConfigVar('db.' . $oModel->getConfig() . '.sgbd');
     }
     if ($this->isPost()) {
         $sModuleToCreate = _root::getParam('moduleToCreate');
         $sClass = _root::getParam('sClass');
         $tColumn = _root::getParam('tColumn');
         $tLabel = _root::getParam('tLabel');
         $tType = _root::getParam('tType');
         $tEnable = _root::getParam('tEnable');
         foreach ($tColumn as $i => $sColumn) {
             if (!in_array($sColumn, $tEnable)) {
                 unset($tColumn[$i]);
             }
         }
         require_once _root::getConfigVar('path.generation') . _root::getParam('id') . '/model/' . $sClass . '.php';
         $oModel = new $sClass();
         $sModule = $sModuleToCreate;
         $this->projectMkdir('module/' . $sModule);
         $this->projectMkdir('module/' . $sModule . '/view');
         $tCrud = array('crudShow');
         $bWithPagination = _root::getParam('withPagination');
         $this->genModelMain($sModuleToCreate, $oModel->getTable(), $sClass, $tColumn, $tCrud, $bWithPagination);
         $this->genModelTpl($sModuleToCreate, $sClass, $tColumn, $oModel->getTable(), $tCrud, $tLabel);
         $msg = trR('moduleGenereAvecSucces', array('#MODULE#' => $sModule));
         $detail = trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule));
         $detail .= '<br />' . trR('creationRepertoire', array('#REPERTOIRE#' => 'module/' . $sModule . '/view'));
         $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/main.php'));
         $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/list.php'));
         if (in_array('crudShow', $tCrud)) {
             $detail .= '<br />' . trR('CreationDuFichierVAR', array('#FICHIER#' => 'module/' . $sModule . '/view/show.php'));
         }
         $detail .= '<br/><br/>' . tr('accessibleVia') . '<a href="' . _root::getConfigVar('path.generation') . _root::getParam('id') . '/public/index.php?:nav=' . $sModule . '::index">index.php?:nav=' . $sModule . '::index</a>';
     }
     $oTpl->msg = $msg;
     $oTpl->detail = $detail;
     $oTpl->tFile = $tFile;
     return $oTpl;
 }
Exemple #24
0
 public function genModelTplCrudembeddedReadonly($sModule, $sClass, $tColumn, $sTableName)
 {
     //$tColumn=_root::getParam('tColumn');
     $tType = _root::getParam('tType');
     $tTpl = array('list', 'show');
     foreach ($tTpl as $sTpl) {
         $oFile = new _file('data/sources/fichiers/module/crudembeddedreadonly/view/' . $sTpl . '.php');
         $sContent = $oFile->getContent();
         preg_match_all('/#lignetd(.*)?#fin_lignetd/s', $sContent, $tMatch);
         $sLigne = $tMatch[1][0];
         preg_match_all('/#input(.*)?#fin_input/s', $sContent, $tMatch);
         $sInputText = $tMatch[1][0];
         preg_match_all('/#textarea(.*)?#fin_textarea/s', $sContent, $tMatch);
         $sInputTextarea = $tMatch[1][0];
         preg_match_all('/#select(.*)?#fin_select/s', $sContent, $tMatch);
         $sInputSelect = $tMatch[1][0];
         preg_match_all('/#upload(.*)?#fin_upload/s', $sContent, $tMatch);
         $sInputUpload = $tMatch[1][0];
         if ($sTpl == 'list') {
             //TH
             preg_match_all('/#ligneth(.*)?#fin_ligneth/s', $sContent, $tMatch);
             $sLigneTH = $tMatch[1][0];
         }
         $sTable = '';
         $sTableTh = '';
         $sEnctype = '';
         foreach ($tColumn as $i => $sColumn) {
             $sType = $tType[$i];
             if ($sType == 'text' or $sType == 'date') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputText);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
             } elseif ($sType == 'textarea') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputTextarea);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
             } elseif (substr($sType, 0, 7) == 'select;') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputSelect);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
                 $sInput = preg_replace('/examplemodel/', substr($sType, 7), $sInput);
             } elseif ($sType == 'upload') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputUpload);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
                 $sEnctype = ' enctype="multipart/form-data"';
                 //changement du enctype du formulaire
             }
             $sTable .= preg_replace('/examplecolumn/', $sColumn, preg_replace('/exampletd/', $sInput, $sLigne));
             $sTableTh .= preg_replace('/exampleth/', $sColumn, $sLigneTH);
         }
         $sContent = module_builder::getTools()->stringReplaceIn(array('oExamplemodel' => 'o' . ucfirst($sTableName), 'tExamplemodel' => 't' . ucfirst($sTableName), 'examplemodule' => $sModule, '<\\?php \\/\\/enctype\\?>' => $sEnctype, '<\\?php \\/\\/ici\\?>' => $sTable, '<\\?php \\/\\/icith\\?>' => $sTableTh, '<\\?php\\/\\*variables(.*)variables\\*\\/\\?>' => ''), 'data/sources/fichiers/module/crudembeddedreadonly/view/' . $sTpl . '.php');
         $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModule . '/view/' . $sTpl . '.php');
         $oFile->setContent($sContent);
         $oFile->save();
         $oFile->chmod(0777);
     }
 }
Exemple #25
0
 private function genModelAndRowByTableConfigAndId($sTable, $sConfig, $sId, $tSelect = null)
 {
     $r = "\n";
     $t = "\t";
     $sTable = trim($sTable);
     $sContentGetSelect = null;
     if (is_array($tSelect)) {
         $sContentGetSelect = module_builder::getTools()->stringReplaceIn(array('exampleselectkey' => $tSelect['key'], 'exampleselectval' => $tSelect['val']), 'data/sources/fichiers/model/getSelect.php');
     }
     $sSave = 'parent::save();';
     $sSaveDuplicateKey = null;
     if (_root::getParam('mysqlOnDuplicateKey') == 1) {
         $soData = '$o' . ucfirst($sTable);
         $tColumn = module_builder::getTools()->getListColumnFromConfigAndTable($sConfig, $sTable);
         foreach ($tColumn as $sColumn) {
             if ($sColumn == $sId) {
                 continue;
             }
             $tFieldSql[] = $sColumn;
             $tSqlInsert[] = '?';
             $tSqlUpdate[] = $sColumn . '=?';
             $tParam[] = $soData . '->' . $sColumn;
         }
         foreach ($tColumn as $sColumn) {
             if ($sColumn == $sId) {
                 continue;
             }
             $tParam[] = $soData . '->' . $sColumn;
         }
         //$tParam[]=$soData.'->'.$sId;
         $sSqlUpdateId = $sId;
         $sSaveDuplicateKey .= 'public function save(' . $soData . '){' . "\n";
         $sSaveDuplicateKey .= "\t" . "\t" . '$this->execute(\'INSERT INTO \'.$this->sTable.\' (' . implode(',', $tFieldSql) . ') VALUES (' . implode(',', $tSqlInsert) . ') ON DUPLICATE KEY UPDATE ' . implode(',', $tSqlUpdate) . '  \',array(' . implode(',', $tParam) . '));' . "\n";
         $sSaveDuplicateKey .= "\t" . '}' . "\n";
         $sSave = 'model_' . $sTable . '::getInstance()->save($this);';
     }
     $sRules = null;
     if (_root::getParam('tRuleColumn' . $sTable)) {
         $tRuleColumn = _root::getParam('tRuleColumn' . $sTable);
         $tRuleName = _root::getParam('tRuleName' . $sTable);
         $tRuleParam = _root::getParam('tRuleParam' . $sTable);
         $tRuleMsg = _root::getParam('tRuleMsg' . $sTable);
         if ($tRuleColumn) {
             $sRules = $r;
             foreach ($tRuleColumn as $key => $sRuleColumn) {
                 if ($sRuleColumn == '') {
                     continue;
                 }
                 $sRuleName = $tRuleName[$key];
                 $sRuleParam = $tRuleParam[$key];
                 $sRuleMsg = $tRuleMsg[$key];
                 $sRules .= $t . $t;
                 //$oPluginValid->isEqual('champ','valeurB','Le champ n\est pas &eacute;gal &agrave; '.$valeurB);
                 $sRules .= '$oPluginValid->' . $sRuleName . '(' . "'{$sRuleColumn}'";
                 if (!in_array($sRuleName, array('isEmpty', 'isNotEmpty', 'isEmailValid'))) {
                     $sRules .= ",'{$sRuleParam}'";
                 }
                 $sRules .= ",'{$sRuleMsg}'";
                 $sRules .= ');' . $r;
             }
         }
     }
     $sFileModel = 'data/sources/projet/model/model_example.sample.php';
     if (_root::getConfigVar('db.' . _root::getParam('sConfig') . '.sgbd') == 'mongodb') {
         $sFileModel = 'data/sources/fichiers/model/model_exampleMongodb.php';
     }
     $sContent = module_builder::getTools()->stringReplaceIn(array('exampletb' => $sTable, 'exampleid' => $sId, 'exampleconfig' => $sConfig, '\\/\\/ICI' => $sContentGetSelect, '\\/\\/sSaveDuplicateKey' => $sSaveDuplicateKey, '\\/\\/save' => $sSave, '\\/\\/checkContraint' => $sRules), $sFileModel);
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/model_' . $sTable . '.php');
     if ($oFile->exist()) {
         return false;
     }
     $oFile->setContent($sContent);
     $oFile->save();
     $oFile->chmod(0666);
     return true;
 }