public function _editcode() { $this->saveCode(); $oModuleDir = new _dir('data/genere/' . _root::getParam('project') . '/module'); $tModule = array(); foreach ($oModuleDir->getListDir() as $oDir) { $tModule[] = $oDir->getName(); } $oModelDir = new _dir('data/genere/' . _root::getParam('project') . '/model'); $tModel = array(); foreach ($oModelDir->getListFile() as $oFile) { $tModel[] = substr($oFile->getName(), 0, -4); } $this->oLayout = new _layout('templateCodeFrame'); $oFile = new _file(_root::getParam('file')); if (!$oFile->exist()) { $oView = new _view('code::nocode'); } else { $oView = new _view('code::code'); } $oView->oFile = $oFile; $oView->tModule = $tModule; $oView->tModel = $tModel; $this->oLayout->add('main', $oView); }
/** * @access public static * @return object sgbd */ public function getSgbd() { $bFirst = false; if ($this->_sClassSgbd == null) { $sVarIniConfig = _root::getConfigVar('model.ini.var', 'db'); $tClassSgbd = _root::getConfigVar($sVarIniConfig); if (!$tClassSgbd) { $sMsg = 'Il vous manque un fichier de configuration'; $sMsg .= ' ou le bloc de configuration [' . $sVarIniConfig . '] concernant la connexion' . "\n"; $sMsg .= ' Exemple: [' . $sVarIniConfig . '] mysql.dsn="mysql:dbname=blog;host=localhost" mysql.sgbd=pdo_mysql mysql.hostname=localhost mysql.database=blog mysql.username=root mysql.password=pass '; throw new Exception($sMsg); } $this->_sClassSgbd = 'sgbd_' . $tClassSgbd[$this->sConfig . '.sgbd']; $bFirst = true; if (substr($this->_sClassSgbd, 0, 8) == 'sgbd_pdo') { $sClassPath = _root::getConfigVar('path.lib') . 'sgbd/pdo/' . $this->_sClassSgbd . '.php'; } elseif (substr($this->_sClassSgbd, 0, 5) == 'sgbd_') { $sClassPath = _root::getConfigVar('path.lib') . 'sgbd/' . $this->_sClassSgbd . '.php'; } if (!file_exists($sClassPath)) { $oDirPdo = new _dir(_root::getConfigVar('path.lib') . 'sgbd/pdo/'); $tListPdo = $oDirPdo->getListFile(); $tPlus = array('Liste driver pdo:'); foreach ($tListPdo as $oFile) { $tPlus[] = '-' . $oFile->getName(); } $sListePdo = implode("\n", $tPlus); $oDir = new _dir(_root::getConfigVar('path.lib') . 'sgbd/'); $tList = $oDir->getListFile(); $tPlus = array('Liste driver autre:'); foreach ($tList as $oFile) { $tPlus[] = '-' . $oFile->getName(); } $sListeAutre = implode("\n", $tPlus); throw new Exception('Pas de driver ' . $this->_sClassSgbd . ' (' . $sClassPath . ')' . "\n" . $sListePdo . "\n" . $sListeAutre); } } $this->_oSgbd = call_user_func(array($this->_sClassSgbd, 'getInstance'), $this->sConfig); if ($bFirst) { $this->_oSgbd->setConfig($tClassSgbd); } return $this->_oSgbd; }
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; }
public function _index() { $this->init(); $tMessage = $this->process(); module_builder::getTools()->rootAddConf('conf/connexion.ini.php'); $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/model/'); $tFile = array(null); $tColumn = array(); $tRowMethodes = array(); foreach ($oDir->getListFile() as $oFile) { if (preg_match('/.sample.php/', $oFile->getName()) or !preg_match('/.php$/', $oFile->getName())) { continue; } require_once $oFile->getAdresse(); $sClass = substr($oFile->getName(), 0, -4); $oModelFoo = new $sClass(); $tFile[$sClass] = $oFile->getName(); $tColumnFoo = module_builder::getTools()->getListColumnFromClass($sClass); $tColumnClass = array(null); foreach ($tColumnFoo as $sField) { $tColumnClass[$sField] = $sField; } $tColumn[$sClass] = $tColumnClass; } //formu $oForm = new stdclass(); foreach ($this->tField as $sField) { $oForm->{$sField} = null; } $oForm->moduleToGenerate = 'rightsManagerMulti'; $oForm->modelToGenerate = 'rightsManagerMulti'; $oTpl = $this->getView('index'); $oTpl->tModel = $tFile; $oTpl->tColumn = $tColumn; $oTpl->oForm = $oForm; $oTpl->tMessage = $tMessage; $oTpl->msg = $this->msg; $oTpl->detail = $this->detail; $oTpl->tError = $this->tError; return $oTpl; }
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 = new _Tpl('moduleCrudEmbeddedReadonly::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(); } if (_root::getRequest()->isPost()) { $sModuleToCreate = _root::getParam('moduleToCreate'); $sClass = _root::getParam('sClass'); $tColumn = _root::getParam('tColumn'); $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; module_builder::getTools()->projetmkdir('module/' . $sModule); module_builder::getTools()->projetmkdir('module/' . $sModule . '/view'); $this->genModelMainCrudembeddedReadonly($sModuleToCreate, $oModel->getTable(), $sClass, $tColumn); $this->genModelTplCrudembeddedReadonly($sModuleToCreate, $sClass, $tColumn, $oModel->getTable()); $msg = 'Module ' . $sModule . ' généré avec succès'; $detail = 'Création repertoire module/' . $sModule; $detail .= '<br />Création repertoire module/' . $sModule . '/view'; $detail .= '<br />Création fichier module/' . $sModule . '/main.php'; $detail .= '<br />Création fichier module/' . $sModule . '/view/list.php'; $detail .= '<br />Création fichier module/' . $sModule . '/view/edit.php'; $detail .= '<br />Création fichier module/' . $sModule . '/view/new.php'; $detail .= '<br />Création fichier module/' . $sModule . '/view/show.php'; $detail .= '<br />Création 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/>Pour l\'utiliser, indiquez:<br /> ' . highlight_string($sCode, 1); } $oTpl->msg = $msg; $oTpl->detail = $detail; $oTpl->tFile = $tFile; return $oTpl; }
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 = new _Tpl('moduleCrudBootstrap::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(); } if (_root::getRequest()->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; module_builder::getTools()->projetmkdir('module/' . $sModule); module_builder::getTools()->projetmkdir('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 = 'Module ' . $sModule . ' généré avec succès'; $detail = 'Création repertoire module/' . $sModule; $detail .= '<br />Création repertoire module/' . $sModule . '/view'; $detail .= '<br />Création fichier module/' . $sModule . '/main.php'; $detail .= '<br />Création fichier module/' . $sModule . '/view/list.php'; if (in_array('crudEdit', $tCrud)) { $detail .= '<br />Création fichier module/' . $sModule . '/view/edit.php'; } if (in_array('crudNew', $tCrud)) { $detail .= '<br />Création fichier module/' . $sModule . '/view/new.php'; } if (in_array('crudShow', $tCrud)) { $detail .= '<br />Création fichier module/' . $sModule . '/view/show.php'; } if (in_array('crudDelete', $tCrud)) { $detail .= '<br />Création fichier module/' . $sModule . '/view/delete.php'; } $detail .= '<br/><br/>Pour y accéder <a href="' . _root::getConfigVar('path.generation') . _root::getParam('id') . '/public/index.php?:nav=' . $sModule . '::index">cliquer ici (index.php?:nav=' . $sModule . '::index)</a>'; } $oTpl->msg = $msg; $oTpl->detail = $detail; $oTpl->tFile = $tFile; return $oTpl; }
public function generateIndexForTable($sTable, $sIndex) { $tFields = $this->getFieldsFromIndex($sIndex); $oDir = new _dir($this->_tConfig[$this->_sConfig . '.database'] . $sTable); $tFile = $oDir->getListFile(); $tIndexContent = array(); foreach ($tFile as $oFile) { if ($oFile->getName() == 'structure.xml') { continue; } if ($oFile->getName() == 'max.xml') { continue; } $tRow = (array) simplexml_load_file($oFile->getAdresse(), null, LIBXML_NOCDATA); $sKey = ''; foreach ($tFields as $sField) { $sKey .= $tRow[$sField]; $sKey .= '####'; } $tIndexContent[$sKey][] = $tRow['id'] . '.xml'; } $oDir = new _dir($this->_tConfig[$this->_sConfig . '.database'] . $sTable . '/index/' . $sIndex); foreach ($oDir->getListFile() as $oFile) { $oFile->delete(); } foreach ($tIndexContent as $sKey => $tFile) { $oFile = new _file($this->_tConfig[$this->_sConfig . '.database'] . $sTable . '/index/' . $sIndex . '/' . $sKey . '.csv'); $oFile->setContent(implode($tFile, "\n")); $oFile->save(); } }
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; }
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 = new _Tpl('moduleCrudGuriddo::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 (_root::getRequest()->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; module_builder::getTools()->projetmkdir('module/' . $sModule); module_builder::getTools()->projetmkdir('module/' . $sModule . '/view'); $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 = 'Module ' . $sModule . ' généré avec succès'; $detail = 'Création repertoire module/' . $sModule; $detail .= '<br />Création repertoire module/' . $sModule . '/view'; $detail .= '<br />Création fichier module/' . $sModule . '/main.php'; $detail .= '<br />Création fichier module/' . $sModule . '/view/list.php'; $detail .= '<br/><br/>Pour y accéder <a href="' . _root::getConfigVar('path.generation') . _root::getParam('id') . '/public/index.php?:nav=' . $sModule . '::index">cliquer ici (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; }
public function _index() { $tMessage = $this->generate(); module_builder::getTools()->rootAddConf('conf/connexion.ini.php'); $msg = null; $detail = null; if (isset($tMessage['success']) and $tMessage['success'] == 1) { $sModuleName = _root::getParam('modulename'); $msg = 'Création du module ' . $sModuleName; $detail = ' Création du repertoire module/' . $sModuleName . '<br/> Création du fichier module/' . $sModuleName . '/main.php<br/> Création du repertoire module/' . $sModuleName . '/view<br/> Création du fichier module/' . $sModuleName . '/view/login.php<br/> <br/> Editez votre fichier <a target="_blank" href="' . _root::getLink('code::index', array('project' => _root::getParam('id'), 'file' => 'conf/site.ini.php')) . '">conf/site.ini.php</a> et indiquez <br/> <div style="padding:8px;border:2px dotted gray"> [auth]<br/> enabled=1<br/> et<br/> module=' . $sModuleName . '::login </div> '; } $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()'; } } $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 = new _Tpl('moduleAuth::index'); $oTpl->tRowMethodes = $tRowMethodes; $oTpl->tModuleAndMethod = $tModuleAndMethod; $oTpl->tMessage = $tMessage; $oTpl->msg = $msg; $oTpl->detail = $detail; $oTpl->tFile = $tFile; $oTpl->tColumnAccount = $tColumnAccount; return $oTpl; }
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; }
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; }
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; }
private function loadAutoload() { if ((int) self::getConfigVar('cache.autoload.enabled') == 1) { $sCacheFilename = self::getConfigVar('path.cache') . 'autoload.php'; if (file_exists($sCacheFilename)) { include $sCacheFilename; } else { //on creer un tableau associatif de tous les path des classes $tDir = array('lib' => self::getConfigVar('path.lib'), 'abstract' => self::getConfigVar('path.lib') . 'abstract/', 'sgbd' => self::getConfigVar('path.lib') . 'sgbd/', 'sgbd_pdo' => self::getConfigVar('path.lib') . 'sgbd/pdo/', 'sgbd_syntax' => self::getConfigVar('path.lib') . 'sgbd/syntax/', 'plugin' => self::getConfigVar('path.plugin'), 'model' => self::getConfigVar('path.model'), 'module' => self::getConfigVar('path.module')); $tAutoload = array(); foreach ($tDir as $sType => $sDir) { if (in_array($sType, array('lib', 'abstract', 'sgbd', 'sgbd_pdo', 'sgbd_syntax', 'plugin', 'model'))) { $oDir = new _dir($sDir); $tFile = $oDir->getListFile(); foreach ($tFile as $oFile) { $sFilename = $oFile->getName(); $tFilename = preg_split('/_/', $sFilename); if ($sType == 'lib') { $tAutoload['_' . substr($tFilename[1], 0, -4)] = $sDir . $sFilename; } else { $tAutoload[substr($sFilename, 0, -4)] = $sDir . $sFilename; } } } else { if ($sType == 'module') { $oDir = new _dir($sDir); $tModuleDir = $oDir->getListDir(); foreach ($tModuleDir as $oModuleDir) { $sModuleDirname = $oModuleDir->getName(); $tAutoload['module_' . $sModuleDirname] = $sDir . $sModuleDirname . '/main.php'; } } } } $sCodeCache = '<?php _root::$tAutoload=' . var_export($tAutoload, true) . ';'; file_put_contents($sCacheFilename, $sCodeCache); self::$tAutoload = $tAutoload; } } }