Example #1
0
 private function generate($sTable, $tField)
 {
     $tNewField = array('id');
     foreach ($tField as $sField) {
         if (trim($sField) == '') {
             continue;
         }
         $tNewField[] = trim($sField);
     }
     $sStructure = implode(';', $tNewField);
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/data/json');
     if (!$oDir->exist()) {
         $oDir->save();
     }
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/data/json/base');
     if (!$oDir->exist()) {
         $oDir->save();
     }
     $oDir = new _dir(_root::getConfigVar('path.generation') . _root::getParam('id') . '/data/json/base/' . $sTable . '');
     if (!$oDir->exist()) {
         $oDir->save();
     }
     $sPath = _root::getConfigVar('path.generation') . _root::getParam('id') . '/data/json/base/' . $sTable . '/';
     $oFile = new _file($sPath . 'structure.csv');
     $oFile->setContent($sStructure);
     $oFile->save();
     $sPath = _root::getConfigVar('path.generation') . _root::getParam('id') . '/data/json/base/' . $sTable . '/';
     $oFile = new _file($sPath . 'max.txt');
     $oFile->setContent(1);
     $oFile->save();
 }
Example #2
0
 private function generate($sTable, $tField)
 {
     $ret = "\n";
     $sXmlStructure = '<?xml version="1.0" encoding="UTF-8"?>' . $ret;
     $sXmlStructure .= '<structure>' . $ret;
     $sXmlStructure .= '<colonne primaire="true">id</colonne>' . $ret;
     foreach ($tField as $sField) {
         if (trim($sField) == '') {
             continue;
         }
         $sXmlStructure .= '<colonne>' . trim($sField) . '</colonne>' . $ret;
     }
     $sXmlStructure .= '</structure>' . $ret;
     $sXmlMax = '<?xml version="1.0" encoding="ISO-8859-1"?>' . $ret;
     $sXmlMax .= '<main>' . $ret;
     $sXmlMax .= '<max><![CDATA[1]]></max>' . $ret;
     $sXmlMax .= '</main>' . $ret;
     $sPath = _root::getConfigVar('path.generation') . _root::getParam('id') . '/data/xml/base/' . $sTable . '/';
     $oFile = new _file($sPath . 'structure.xml');
     $oFile->setContent($sXmlStructure);
     $oFile->save();
     $sPath = _root::getConfigVar('path.generation') . _root::getParam('id') . '/data/xml/base/' . $sTable . '/';
     $oFile = new _file($sPath . 'max.xml');
     $oFile->setContent($sXmlMax);
     $oFile->save();
 }
 protected function projectSaveFile($sContent, $sFilename)
 {
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/' . $sFilename);
     if ($oFile->exist()) {
         return false;
     }
     $oFile->setContent($sContent);
     $oFile->save();
     $oFile->chmod(0666);
 }
Example #4
0
 public function generate($sTable, $tField)
 {
     $ret = "\n";
     $sep = ';';
     $sFile = '1' . $ret;
     $sFile .= 'id' . $sep;
     foreach ($tField as $sField) {
         if (trim($sField) == '') {
             continue;
         }
         $sFile .= trim($sField) . $sep;
     }
     $sFile .= $ret;
     $sPath = _root::getConfigVar('path.generation') . _root::getParam('id') . '/data/csv/base/' . $sTable . '.csv';
     $oFile = new _file($sPath);
     $oFile->setContent($sFile);
     $oFile->save();
 }
Example #5
0
 public function __construct($sMicrotime)
 {
     $this->iStartMicrotime = self::microtime($sMicrotime);
     $iEndTime = self::microtime();
     self::$tTime[] = array('End', $iEndTime);
     $iDiff = $iEndTime - $this->iStartMicrotime;
     $this->add('Time', sprintf('%0.3f', $iDiff) . 's');
     $this->addComplexTimes('times', self::$tTime);
     $this->addComplex('$_GET', print_r($_GET, 1));
     if (isset($_POST)) {
         $this->addComplex('$_POST', print_r($_POST, 1));
     }
     if (isset($_SESSION)) {
         $this->addComplex('$_SESSION', print_r($_SESSION, 1));
     }
     if (isset($_SERVER)) {
         $this->addComplex('$_SERVER', print_r($_SERVER, 1));
     }
     $oRequest = _root::getRequest();
     $this->add('Module', $oRequest->getModule());
     $this->add('Action', $oRequest->getAction());
     $oFileLog = new _file(_root::getConfigVar('path.log', 'data/log/') . date('Y-m-d') . '_log.csv');
     if ($oFileLog->exist()) {
         $oFileLog->load();
         $sContentLog = $oFileLog->getContent();
         $this->addFileLog('File log', $sContentLog);
     }
     $sVarIniConfig = _root::getConfigVar('model.ini.var', 'db');
     $tClassSgbd = _root::getConfigVar($sVarIniConfig);
     $this->addComplexIni('Connexions', array($sVarIniConfig => $tClassSgbd));
     $tConfigSection = array('path', 'cache', 'language', 'auth', 'acl', 'navigation', 'urlrewriting', 'security', 'log', 'check', 'path', 'model');
     $tConfig = array();
     foreach ($tConfigSection as $sSection) {
         $tConfig[$sSection] = _root::getConfigVar($sSection);
     }
     $this->addComplexIni('Config', $tConfig);
     if (self::$tSpy) {
         $this->addComplexSpy('Spy variables', self::$tSpy);
     }
     $this->addAcl();
 }
Example #6
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);
 }
Example #7
0
 private function writefile($sMessage)
 {
     $sMessage = preg_replace('/\\s+/', ' ', $sMessage);
     $oFileLog = new _file(_root::getConfigVar('path.log', 'data/log/') . date('Y-m-d') . '_log.csv');
     if ($oFileLog->exist()) {
         $oFileLog->load();
     }
     $oFileLog->addContent(date('Y-m-d') . ';' . date('H:i:s') . ';' . $sMessage . "\n");
     try {
         $oFileLog->save();
     } catch (Exception $e) {
         throw new Exception('Probleme lors de l\'ecriture du log' . "\n" . 'note:verifier les droits du repertoire ' . _root::getConfigVar('path.log', 'data/log') . "\n" . 'Exception: ' . $e->getMessage());
     }
     $oFileLog->clean();
 }
Example #8
0
 private function stringReplaceIn($tMatch, $sFile)
 {
     $oFile = new _file($sFile);
     $sContent = $oFile->getContent();
     if ($tMatch and is_array($tMatch)) {
         foreach ($tMatch as $sPattern => $sReplace) {
             $sContent = preg_replace('/' . $sPattern . '/s', $sReplace, $sContent);
         }
     }
     return $sContent;
 }
Example #9
0
 /** 
  * supprime l'objet _view $sId en cache
  * @access public
  * @param string $sId
  */
 public function clearCache($sId)
 {
     $oFile = new _file(_root::getConfigVar('path.cache') . $sId . '.cache');
     $oFile->delete();
 }
Example #10
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);
 }
Example #11
0
 private function saveFullCode()
 {
     if (!_root::getRequest()->isPost()) {
         return null;
     }
     $sContent = $_POST['content'];
     $oFile = new _file(_root::getParam('file'));
     //backup
     $oBackupFile = new _file(_root::getParam('file') . '.bak');
     $oBackupFile->setContent($oFile->getContent());
     $oBackupFile->save();
     $tLine = $oFile->getTab();
     $oFile->setContent($sContent);
     $oFile->save();
     _root::redirect('code::editcode', array('project' => _root::getParam('project'), 'file' => _root::getParam('file')));
 }
Example #12
0
 private function removeRowFromIndex($sTable, $tProperty, $sIndex)
 {
     $sFileIndex = $this->getFileIndexFromTab($sIndex, $tProperty);
     if (!file_exists($this->_tConfig[$this->_sConfig . '.database'] . $sTable . '/index/' . $sIndex . '/' . $sFileIndex)) {
         return;
     }
     $tLine = file($this->_tConfig[$this->_sConfig . '.database'] . $sTable . '/index/' . $sIndex . '/' . $sFileIndex);
     $tContent = array();
     foreach ($tLine as $sLine) {
         $sLine = trim($sLine);
         if ($sLine == $tProperty['id'] . '.json') {
             continue;
         }
         $tContent[] = $sLine;
     }
     $oFile = new _file($this->_tConfig[$this->_sConfig . '.database'] . $sTable . '/index/' . $sIndex . '/' . $sFileIndex);
     $oFile->setContent(implode("\n", $tContent));
     $oFile->save();
 }
Example #13
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);
     }
 }
Example #14
0
 private function save($tProperty, $sFichier)
 {
     $oFile = new _file($sFichier);
     $sRet = "\n";
     $sXml = '<?xml version="1.0" encoding="ISO-8859-1"?>' . $sRet;
     $sXml .= '<main>' . $sRet;
     foreach ($tProperty as $sVar => $sVal) {
         $sXml .= '<' . $sVar . '><![CDATA[' . $sVal . ']]></' . $sVar . '>' . $sRet;
     }
     $sXml .= '</main>' . $sRet;
     $oFile->write($sXml);
 }
Example #15
0
 public function stringReplaceIn($tMatch, $sFile)
 {
     $oFile = new _file($sFile);
     $sContent = $oFile->getContent();
     foreach ($tMatch as $sPattern => $sReplace) {
         $sContent = preg_replace('/' . $sPattern . '/s', $sReplace, $sContent);
     }
     return $sContent;
 }
Example #16
0
    private function processSimple()
    {
        if (!_root::getRequest()->isPost()) {
            return array(null, null);
        }
        $ret = "\n";
        $t = "\t";
        $sModule = _root::getParam('module');
        $sView = _root::getParam('view');
        $tEnable = _root::getParam('tEnable');
        $tColumn = _root::getParam('tColumn');
        $tLabel = _root::getParam('tLabel');
        $tType = _root::getParam('tType');
        $sModel = _root::getParam('class');
        $sModel = str_replace('.php', '', $sModel);
        $sId = _root::getParam('sId');
        $sViewContent = '<?php ';
        $sViewContent .= $ret;
        $sViewContent .= '$oForm = new plugin_form($this->oData);' . $ret;
        $sViewContent .= '$oForm->setMessage($this->tMessage);' . $ret;
        $sViewContent .= '?>';
        $sViewContent .= $ret;
        $sViewContent .= '<form action="" method="POST" />' . $ret;
        $sViewContent .= '<table class="tb_edit">' . $ret;
        foreach ($tColumn as $i => $sColumn) {
            if (!in_array($sColumn, $tEnable)) {
                continue;
            }
            $tVar = array();
            if ($tType[$i] == 'text') {
                $sFormInput = '<?php echo $oForm->getInputText(\'' . $sColumn . '\');?>';
            } else {
                if ($tType[$i] == 'textarea') {
                    $sFormInput = '<?php echo $oForm->getInputTextarea(\'' . $sColumn . '\');?>';
                } else {
                    if (substr($tType[$i], 0, 6) == 'select') {
                        $tVar[] = $t . '$oView->tJoin' . $sColumn . '=' . substr($tType[$i], 7) . '::getInstance()->getSelect();';
                        $sFormInput = '<?php echo $oForm->getSelect(\'' . $sColumn . '\',$this->tJoin' . $sColumn . ');?>';
                    } else {
                        if ($tType[$i] == 'upload') {
                            $sFormInput = '<input type="file" name="<?php echo $' . $sColumn . ';?>"/>';
                        } else {
                            $sFormInput = 'getInputText(\'' . $sColumn . '\')';
                        }
                    }
                }
            }
            $sViewContent .= $t . '<tr>' . $ret;
            $sViewContent .= $t . $t . '<th>' . $tLabel[$i] . '</th>' . $ret;
            $sViewContent .= $t . $t . '<td>' . $sFormInput . '</td>' . $ret;
            $sViewContent .= $t . '</tr>' . $ret;
        }
        $sViewContent .= '</table>' . $ret;
        $sViewContent .= '<p> <input type="submit" value="Modifier" /> </p>' . $ret;
        $sViewContent .= '<?php echo $oForm->getToken(\'token\',$this->token)?>' . $ret;
        $sViewContent .= '</form>' . $ret;
        $oFile = new _file('data/genere/' . _root::getParam('id') . '/module/' . $sModule . '/view/' . $sView . '.php');
        if ($oFile->exist()) {
            return array('Vue deja existante', null);
        }
        $oFile->setContent($sViewContent);
        $oFile->save();
        $oFile->chmod(0666);
        $sModel = str_replace('.php', '', $sModel);
        $msg = 'Vue ' . $sView . '.php' . ' g&eacute;n&eacute;r&eacute; avec succ&egrave;s';
        $detail = '';
        $detail .= 'Cr&eacute;ation fichier module/' . $sModule . '/view/' . $sView . '.php ';
        $sCode = '<?php ' . "\n";
        $sCode .= 'public function _edit(){' . $ret;
        $sCode .= $t . '$tMessage=$this->processSave();' . $ret;
        $sCode .= $t . '//recupere l\'enregistrement' . "\n";
        $sCode .= $t . '$oData=' . $sModel . '::getInstance()->findById(_root::getParam(\'id\'));' . $ret . $ret;
        $sColumn = '';
        if ($tEnable) {
            foreach ($tEnable as $sEnable) {
                $sColumn .= ',' . "'" . $sEnable . "'";
            }
            $sColumn = substr($sColumn, 1);
        }
        $sCode .= $t . '//recupere la vue du module' . "\n";
        $sCode .= $t . '$oView=new _view(\'' . $sModule . '::' . $sView . '\');' . "\n";
        $sCode .= $t . '$oView->oData=$oData;' . $ret;
        $sCode .= $t . '$oView->tMessage=$tMessage;' . $ret;
        $sCode .= $ret;
        $sCode .= $t . '$oPluginXsrf=new plugin_xsrf();' . $ret;
        $sCode .= $t . '$oView->token=$oPluginXsrf->getToken();' . $ret;
        if ($tVar) {
            foreach ($tVar as $sVar) {
                $sCode .= $sVar . $ret;
            }
        }
        $sCode .= "\n";
        $sCode .= $t . '//assigner la vue retournee a votre layout' . "\n";
        $sCode .= $t . '$this->oLayout->add(\'main\',$oView);' . "\n";
        $sCode .= '}' . $ret;
        $sCode .= 'private function processSave(){' . $ret;
        //post
        $sCode .= $t . 'if(!_root::getRequest()->isPost()){' . $ret;
        $sCode .= $t . $t . 'return null;' . $ret;
        $sCode .= $t . '}' . $ret;
        $sCode .= $ret;
        $sCode .= $t . '$oPluginXsrf=new plugin_xsrf();' . $ret;
        $sCode .= $t . 'if(!$oPluginXsrf->checkToken( _root::getParam(\'token\') ) ){ //on verifie que le token est valide' . $ret;
        $sCode .= $t . $t . 'return array(\'token\'=>$oPluginXsrf->getMessage() );' . $ret;
        $sCode .= $t . '}' . $ret;
        $sCode .= $t . '$oData=' . $sModel . '::getInstance()->findById(_root::getParam(\'id\'));' . $ret . $ret;
        $sCode .= $t . '$tColumn=array(' . $sColumn . ');' . $ret;
        $sCode .= $t . 'foreach($tColumn as $sColumn){' . $ret;
        $sCode .= $t . $t . '$oData->$sColumn=_root::getParam($sColumn);' . $ret;
        $sCode .= $t . '}' . $ret;
        $sCode .= $t . 'if($oData->save() ){' . $ret;
        $sCode .= $t . $t . '//redirection vers la page d\'apres' . $ret;
        $sCode .= $t . '}else{' . $ret;
        $sCode .= $t . $t . '$tMessage=$oData->getListError();' . $ret;
        $sCode .= $t . '}' . $ret;
        $sCode .= '}' . $ret . $ret;
        $detail .= '<br/><br/>Pour l\'utiliser, indiquez dans votre module:<br />
		' . highlight_string($sCode, 1);
        return array($msg, $detail);
    }
Example #17
0
 private function updateLibPathInConf($sProject, $sLib)
 {
     //replace link library
     $oIniFile = new _file($sProject . '/conf/site.ini.php');
     $tIni = $oIniFile->getTab();
     $tNewIni = array();
     $bSection = 0;
     foreach ($tIni as $line) {
         if (preg_match('/\\[path\\]/', $line)) {
             $bSection = 1;
         } else {
             if ($bSection && substr($line, 0, 3) == 'lib') {
                 $line = 'lib=' . $sLib;
             }
         }
         $tNewIni[] = $line;
     }
     $oIniFile->setContent(implode($tNewIni, ""));
     $oIniFile->save();
 }
Example #18
0
    private function processComplexWithOrder()
    {
        if (!_root::getRequest()->isPost()) {
            return array(null, null);
        }
        if (_root::getParam('model') == '' or _root::getParam('method') == '') {
            return array(null, null);
        }
        if (!file_exists('data/genere/' . _root::getParam('id') . '/module/table')) {
            //copie module table + images
            $this->importModuleTable();
        }
        $sModule = _root::getParam('module');
        $sView = _root::getParam('view');
        $tableClass = _root::getParam('tableClass');
        $enableAlt = _root::getParam('enableAlt');
        $sModel = _root::getParam('model');
        $sMethod = _root::getParam('method');
        $arrayAlt = _root::getParam('arrayAlt');
        $tColumn = _root::getParam('tColumn');
        $tLabel = _root::getParam('tLabel');
        $tType = _root::getParam('tType');
        $tEnable = _root::getParam('tEnable');
        $tOrderEnable = _root::getParam('tOrderEnable');
        $defaultOrder = _root::getParam('tOrderDefault');
        foreach ($tColumn as $i => $sColumn) {
            if (!in_array($sColumn, $tEnable)) {
                unset($tColumn[$i]);
                unset($tLabel[$i]);
            }
        }
        $ret = "\n";
        $t = "\t";
        $sViewContent = '<?php ' . $ret;
        $sViewContent .= '$oTable = new module_table(\'complex1\');' . $ret;
        $sViewContent .= '$oTable->setClass(\'' . $tableClass . '\');' . $ret;
        if (!$enableAlt) {
            $sViewContent .= '/*';
        }
        $sViewContent .= '$oTable->setCycleClass( ' . var_export($arrayAlt, true) . ');' . $ret;
        if (!$enableAlt) {
            $sViewContent .= '*/';
        }
        //header
        $sViewContent .= $ret;
        foreach ($tLabel as $i => $sLabel) {
            if (in_array($tColumn[$i], $tOrderEnable)) {
                $sViewContent .= '$oTable->addHeaderWithOrder(\'' . $sLabel . '\',\'' . $tColumn[$i] . '\');' . $ret;
            } else {
                $sViewContent .= '$oTable->addHeader(\'' . $sLabel . '\');' . $ret;
            }
        }
        $sViewContent .= $ret;
        $sViewContent .= 'if($this->tData){' . $ret;
        $sViewContent .= $t . 'foreach($this->tData as $oData){' . $ret;
        $sViewContent .= $t . $t . '$oTable->addLine(array(' . $ret;
        foreach ($tColumn as $sColumn) {
            $sViewContent .= $t . $t . $t . '$oData->' . $sColumn . ',' . $ret;
        }
        $sViewContent .= $t . $t . '));' . $ret;
        $sViewContent .= $t . '}' . $ret;
        $sViewContent .= '}' . $ret;
        $sViewContent .= $ret;
        $sViewContent .= 'echo $oTable->build()->show();';
        $oFile = new _file('data/genere/' . _root::getParam('id') . '/module/' . $sModule . '/view/' . $sView . '.php');
        if ($oFile->exist()) {
            //return array('Vue deja existante',null);
        }
        $oFile->setContent($sViewContent);
        $oFile->save();
        $oFile->chmod(0666);
        $msg = 'Vue ' . $sView . '.php' . ' g&eacute;n&eacute;r&eacute; avec succ&egrave;s';
        $detail = '';
        $detail .= 'Cr&eacute;ation fichier module/' . $sModule . '/view/' . $sView . '.php ';
        $sCode = '<?php ' . "\n";
        $sCode .= '//recupere les enregistrements avec en parametre le champ de tri + le sens' . "\n";
        $sCode .= '$tData=new ' . $sModel . '::getInstance()->' . $sMethod . '(module_table::getParam(\'order\',\'' . $defaultOrder . '\'),module_table::getParam(\'side\',\'ASC\'));' . $ret;
        $sCode .= '//recupere la vue du module' . "\n";
        $sCode .= '$oView=new _view(\'' . $sModule . '::' . $sView . '\');' . "\n";
        $sCode .= '$oView->tData=$tData;' . $ret;
        $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 dans votre module:<br />
		' . highlight_string($sCode, 1);
        return array($msg, $detail);
    }
Example #19
0
 private function genModuleMenuMain($sModuleMenuName, $tMethod, $tLabel)
 {
     $sData = null;
     foreach ($tMethod as $i => $sLink) {
         $sData .= '\'' . $tLabel[$i] . '\' => \'' . $sLink . '\',' . "\n";
     }
     $oMainFile = new _file('data/sources/fichiers/module/menuBootstrap/main.php');
     $sContentMain = $oMainFile->getContent();
     $sContentMain = preg_replace('/\\/\\/TABLEAUICI/', $sData, $sContentMain);
     $sContentMain = preg_replace('/examplemenu/', $sModuleMenuName, $sContentMain);
     $oFileTpl = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleMenuName . '/main.php');
     $oFileTpl->setContent($sContentMain);
     $oFileTpl->save();
     $oFileTpl->chmod(0666);
     $oViewFile = new _file('data/sources/fichiers/module/menuBootstrap/view/index.php');
     $sContentView = $oViewFile->getContent();
     $oFileTpl2 = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleMenuName . '/view/index.php');
     $oFileTpl2->setContent($sContentView);
     $oFileTpl2->save();
     $oFileTpl2->chmod(0666);
     //update title
     $oTools = new module_builderTools();
     $oTools->updateFile(_root::getParam('id'), array('examplesite' => _root::getParam('id')), 'module/' . $sModuleMenuName . '/view/index.php');
 }
Example #20
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);
 }
Example #21
0
 /** 
  * lance le framework (dispatch...)
  * @access public	
  */
 public function run()
 {
     try {
         self::loadConf();
         self::loadAutoload();
         self::loadRequest();
         //parametrage du niveau d'erreur
         if (self::getConfigVar('site.mode') == 'dev') {
             error_reporting(E_ALL);
         } else {
             error_reporting(0);
         }
         self::getLog()->setInformation((int) self::getConfigVar('log.information'));
         self::getLog()->setWarning((int) self::getConfigVar('log.warning'));
         self::getLog()->setError((int) self::getConfigVar('log.error'));
         self::getLog()->setApplication((int) self::getConfigVar('log.application'));
         date_default_timezone_set(self::getConfigVar('site.timezone'));
         //auth
         if ((int) self::getConfigVar('auth.enabled') == 1) {
             self::getAuth()->enable();
         }
         //desactivation des magic quotes
         if (get_magic_quotes_gpc()) {
             $_POST = array_map('stripslashes_deep', $_POST);
             $_GET = array_map('stripslashes_deep', $_GET);
             $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
             $this->getRequest()->magic_quote();
         }
         if ((int) self::getConfigVar('urlrewriting.enabled') == 1) {
             self::getUrlRewriting()->parseUrl($_SERVER['REQUEST_URI']);
         }
         $sModuleToLoad = self::getRequest()->getModule();
         $sModuleActionToLoad = self::getRequest()->getAction();
         /*LOG*/
         self::getLog()->info('module a appeler [' . $sModuleToLoad . '::' . $sModuleActionToLoad . ']');
         //chargement module/action
         $sClassModule = 'module_' . $sModuleToLoad;
         $oModule = new $sClassModule();
         if (method_exists($oModule, '_' . $sModuleActionToLoad)) {
             /*LOG*/
             self::getLog()->info('appel module [' . $sModuleToLoad . '::before]');
             $oModule->before();
             //pre action
             if (method_exists($oModule, 'before_' . $sModuleActionToLoad)) {
                 /*LOG*/
                 self::getLog()->info('appel module [' . $sModuleToLoad . '::before_' . $sModuleActionToLoad . ']');
                 $sActionBefore = 'before_' . $sModuleActionToLoad;
                 $oModule->{$sActionBefore}();
             }
             //debut cache
             if ((int) self::getConfigVar('cache.enabled') == 1) {
                 $sNomPageCache = 'cache_' . str_replace('::', '_', implode('_', self::getRequest()->getParams())) . '.html';
                 $oFichierCache = new _file(self::getConfigVar('path.cache') . $sNomPageCache);
                 if ($oFichierCache->exist() and (int) self::getConfigVar('cache.lifetime') == 0 or $oFichierCache->exist() and time() - $oFichierCache->filemtime() < (int) self::getConfigVar('cache.lifetime')) {
                     /*LOG*/
                     self::getLog()->info('utilisation page en cache [' . $sNomPageCache . ']');
                     echo $oFichierCache->getContent();
                     return;
                 }
                 ob_start();
             }
             $sAction = '_' . $sModuleActionToLoad;
             /*LOG*/
             self::getLog()->info('appel module [' . $sModuleToLoad . '::' . $sAction . ']');
             $oModule->{$sAction}();
             //post action
             if (method_exists($oModule, 'after_' . $sModuleActionToLoad)) {
                 /*LOG*/
                 self::getLog()->info('appel module [' . $sModuleToLoad . '::after_' . $sModuleActionToLoad . ']');
                 $sActionAfter = 'after_' . $sModuleActionToLoad;
                 $oModule->{$sActionAfter}();
             }
             //post module
             /*LOG*/
             self::getLog()->info('appel module [' . $sModuleToLoad . '::after]');
             $oModule->after();
             //fin cache
             if ((int) self::getConfigVar('cache.enabled') == 1) {
                 $sSortie = ob_get_contents();
                 ob_end_clean();
                 $oFichierCache->write($sSortie . "\n<!--cache -->");
                 echo $sSortie;
             }
         } else {
             $tErreur = array('Erreur dans module/' . $sModuleToLoad . '/main.php', 'Pas de m&eacute;thode _' . $sModuleActionToLoad . '() dans le module "' . $sModuleToLoad . '" &agrave; charger', 'Note: vous pouvez modifier le couple module/action par defaut ', 'en modifiant la section [navigation] dans le fichier conf/site.ini.php');
             throw new Exception(implode("\n", $tErreur));
         }
     } catch (Exception $e) {
         self::erreurLog($e->getMessage() . "\n" . self::showException($e), $e);
     }
 }
Example #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);
     }
 }
Example #23
0
 /** 
  * retoune le flux rss
  * @access public
  * @return string le flux rss genere
  */
 public function getContent()
 {
     $head = '<?xml version="1.0" encoding="ISO-8859-1" ?>' . "\n";
     $head .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
     $foot = '</rss>';
     $atom = '<atom:link href="' . $this->sAdresseRss . '" rel="self" type="application/rss+xml" />';
     $sRss = $head . '<channel>' . $atom . $this->header . $this->news . '</channel>' . $foot;
     $oFile = new _file(_root::getConfigVar('path.data') . 'xml/' . $this->sName . '.rss');
     $oFile->setContent($sRss);
     $oFile->save();
     return $sRss;
 }
Example #24
0
 public function getTabFromTable($sTable)
 {
     $oFile = new _file($this->_tConfig[$this->_sConfig . '.database'] . $sTable . '.csv');
     $tFile = $oFile->getTab();
     return $tFile;
 }
Example #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;
 }