Beispiel #1
0
 /**
  * constructeur
  * @access public
  * @param array tableau a verifier ($_POST,tableau de la row...)
  */
 public function __construct($tPost)
 {
     $this->tPost = $tPost;
     $sClass = _root::getConfigVar('check.class', 'plugin_check');
     $this->oCheck = new $sClass();
     $this->bCheck = true;
 }
Beispiel #2
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();
 }
Beispiel #3
0
 public function regenerateIndexXml($sConfig, $sTable, $sIndex)
 {
     //$sConfig='xml';
     if (_root::getConfigVar('db.' . $sConfig . '.sgbd') == 'xml') {
         if (!file_exists(_root::getConfigVar('db.' . $sConfig . '.database'))) {
             $sBuilderDbPath = _root::getConfigVar('path.data') . 'genere/' . _root::getParam('id') . '/public/' . _root::getConfigVar('db.' . $sConfig . '.database');
             if (file_exists($sBuilderDbPath)) {
                 _root::setConfigVar('db.' . $sConfig . '.database', $sBuilderDbPath);
             } else {
                 throw new Exception('Base inexistante ' . _root::getConfigVar('db.' . $sConfig . '.database') . ' ni ' . $sBuilderDbPath);
             }
         }
     } else {
         if (_root::getConfigVar('db.' . $sConfig . '.sgbd') == 'csv') {
             if (!file_exists(_root::getConfigVar('db.' . $sConfig . '.database'))) {
                 $sBuilderDbPath = _root::getConfigVar('path.data') . 'genere/' . _root::getParam('id') . '/public/' . _root::getConfigVar('db.' . $sConfig . '.database');
                 if (file_exists($sBuilderDbPath)) {
                     _root::setConfigVar('db.' . $sConfig . '.database', $sBuilderDbPath);
                 } else {
                     throw new Exception('Base inexistante ' . _root::getConfigVar('db.' . $sConfig . '.database') . ' ni ' . $sBuilderDbPath);
                 }
             }
         }
     }
     $oModelFactory = new model_mkfbuilderfactory();
     $oModelFactory->setConfig($sConfig);
     return $oModelFactory->getSgbd()->generateIndexForTable($sTable, $sIndex);
 }
Beispiel #4
0
 public function _new()
 {
     if (_root::getRequest()->isPost()) {
         $sProject = _root::getParam('projet');
         if (isset($_POST['opt']) and $_POST['opt'] == 'withexamples') {
             model_mkfbuilderprojet::getInstance()->create(_root::getParam('projet'));
             self::getTools()->updateLayoutTitle(_root::getParam('projet'));
         } else {
             if (isset($_POST['opt']) and $_POST['opt'] == 'withBootstrap') {
                 model_mkfbuilderprojet::getInstance()->createEmpty($sProject);
                 //copy bootstrap
                 model_mkfbuilderprojet::getInstance()->copyFromTo('data/sources/fichiers/layout/bootstrap.php', 'data/genere/' . $sProject . '/layout/bootstrap.php');
                 //update title
                 self::getTools()->updateFile(_root::getParam('projet'), array('examplesite' => $sProject), 'layout/bootstrap.php');
                 //update layout
                 self::getTools()->updateFile(_root::getParam('projet'), array('template1' => 'bootstrap'), 'module/default/main.php');
             } else {
                 model_mkfbuilderprojet::getInstance()->createEmpty(_root::getParam('projet'));
                 self::getTools()->updateLayoutTitle(_root::getParam('projet'));
             }
         }
         _root::redirect('builder::list');
     }
     $oTpl = new _tpl('builder::new');
     $oTpl->iswritable = is_writable(_root::getConfigVar('path.generation'));
     $this->oLayout->add('main', $oTpl);
 }
Beispiel #5
0
 /** 
  * constructeur
  * @access public
  * @param string $sToken
  */
 public function __construct()
 {
     $this->sSalt = 'fdsfA34T679hjfdsAfef';
     $this->iLifetime = _root::getConfigVar('security.xsrf.timeout.lifetime');
     $this->bUseSession = _root::getConfigVar('security.xsrf.session.enabled', 0);
     $this->sSessionVar = 'xsrfTokenArray';
 }
Beispiel #6
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();
 }
Beispiel #7
0
 /** 
  * retourne le code html d'une image
  * @access public
  * @param string $sSrc path de l'image, par defaut utilisera le path.img configure dans conf/site.php
  * @param string $sAlt texte alternatif
  * @param array $tOption tableau contenant autant d'options a ajouter 
  * 						array('style'=>'border:1px')  >> <img style="border:1px"...
  * @return string retourne le code html de l'image
  */
 public function getImg($sSrc, $sAlt = null, $tOption = null)
 {
     if ($sAlt == null) {
         $sAlt = $sSrc;
     }
     $sOptions = $this->getOptionFromTab($tOption);
     return '<img src="' . _root::getConfigVar('path.img') . $sSrc . '" title="' . $sAlt . '" ' . $sOptions . '/>';
 }
Beispiel #8
0
 private function load($sId)
 {
     if ($this->_toFile and isset($this->_toFile[$sId])) {
         return;
     }
     $oFile = new _file(_root::getConfigVar('path.cache') . $sId . '.cachevar');
     $this->_toFile[$sId] = $oFile;
 }
Beispiel #9
0
 /** 
  * charge le fichier de langue situe dans la section [path], valeur de i18n
  * @access public static
  * @param string $sLang (doit etre present dans le fichier de config [language] allow separer par des virgules
  */
 public static function load($sLang)
 {
     $tAllowed = preg_split('/,/', _root::getConfigVar('language.allow'));
     if (!in_array($sLang, $tAllowed) and $sLang != _root::getConfigVar('language.default')) {
         throw new Exception('Lang not allowed, list allow:' . _root::getConfigVar('language.allow'));
     }
     include_once _root::getConfigVar('path.i18n') . $sLang . '.php';
     self::$tLangue = _root::getConfigVar('tLangue');
 }
Beispiel #10
0
    /**
     * @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;
    }
Beispiel #11
0
 /**
  * @access public
  */
 public function _connect()
 {
     //on regenere un nouvel id de session
     session_regenerate_id(true);
     $this->_bConnected = true;
     $_SESSION['ip'] = sha1($_SERVER['REMOTE_ADDR']);
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
         $_SESSION['userAgent'] = sha1($_SERVER['HTTP_USER_AGENT']);
     } else {
         $_SESSION['userAgent'] = sha1('noUserAgent');
     }
     if ((int) _root::getConfigVar('auth.session.timeout.enabled') == 1) {
         $_SESSION['timeout'] = time() + (int) _root::getConfigVar('auth.session.timeout.lifetime');
     }
 }
Beispiel #12
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;
 }
Beispiel #13
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&eacute;n&eacute;r&eacute; avec succ&egrave;s';
         $detail = 'Cr&eacute;ation du fichier sqlite ' . $sDbFilename;
     }
     $oTpl = new _Tpl('moduleSqlite::index');
     $oTpl->msg = $msg;
     $oTpl->detail = $detail;
     $oTpl->tSqlite = $tSqlite;
     return $oTpl;
 }
Beispiel #14
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;
 }
Beispiel #15
0
 public function _project()
 {
     $bBootstrap = 0;
     if (file_exists('data/genere/' . _root::getParam('id') . '/layout/bootstrap.php')) {
         $bBootstrap = 1;
     }
     if ($bBootstrap) {
         $tType = array('all', 'bootstrap');
     } else {
         $tType = array('all', 'normal');
     }
     $sLang = _root::getConfigVar('language.default');
     $tLinkModule = array();
     foreach ($tType as $sType) {
         $sPathModule = _root::getConfigVar('path.module') . '/mods/' . $sType;
         $tModulesAll = scandir($sPathModule);
         foreach ($tModulesAll as $sModule) {
             if (file_exists($sPathModule . '/' . $sModule . '/info.ini')) {
                 $tIni = parse_ini_file($sPathModule . '/' . $sModule . '/info.ini');
                 $priority = 999;
                 if (isset($tIni['priority'])) {
                     $priority = $tIni['priority'];
                 }
                 $sPriority = sprintf('%03d', $priority);
                 $tLinkModule[$tIni['category']][$tIni['title.' . $sLang] . ' <sup>version ' . $tIni['version'] . '</sup>'] = $sPriority . 'mods_' . $sType . '_' . $sModule . '::index';
             }
         }
     }
     //$tModules=scandir(_root::getConfigVar('path.module')).'/mods/normal';
     $tTitle = array('market', 'coucheModel', 'modules', 'modulesEmbedded', 'views', 'databasesEmbedded', 'unitTest');
     $tLink = array();
     foreach ($tTitle as $sTitle) {
         if (isset($tLinkModule[$sTitle])) {
             $tLinkModuleCat = $tLinkModule[$sTitle];
             asort($tLinkModuleCat);
             $tLink[tr('menu_' . $sTitle)] = 'title';
             foreach ($tLinkModuleCat as $sLabel => $sLink) {
                 $tLink[$sLabel] = substr($sLink, 3);
             }
         }
     }
     $oTpl = $this->getView('project');
     $oTpl->tLink = $tLink;
     return $oTpl;
 }
Beispiel #16
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();
 }
Beispiel #17
0
 public static function autoload($sClass)
 {
     $tab = preg_split('/_/', $sClass);
     if ($sClass[0] == '_') {
         include _root::getConfigVar('path.lib') . 'class' . $sClass . '.php';
     } else {
         if (in_array($tab[0], array('plugin', 'model', 'abstract'))) {
             include _root::getConfigVar('path.' . $tab[0]) . $sClass . '.php';
         } else {
             if ($tab[0] == 'module') {
                 if (count($tab) == 2 or _root::getConfigVar('module.folder.organized', 0) == 0) {
                     include _root::getConfigVar('path.module') . substr($sClass, 7) . '/main.php';
                 } else {
                     unset($tab[0]);
                     include _root::getConfigVar('path.module') . implode('/', $tab) . '/main.php';
                 }
             } else {
                 if ($tab[0] == 'row') {
                     include _root::getConfigVar('path.model') . 'model_' . substr($sClass, 4) . '.php';
                 } else {
                     if ($tab[0] == 'sgbd' and in_array($tab[1], array('syntax', 'pdo'))) {
                         include _root::getConfigVar('path.lib') . 'sgbd/' . $tab[1] . '/' . $sClass . '.php';
                     } else {
                         if ($tab[0] == 'sgbd') {
                             include _root::getConfigVar('path.lib') . 'sgbd/' . $sClass . '.php';
                             //definissez ici votre regle de chargement
                             //ici, si la classe debute par my_, on la cherche dans ../myClass
                         } else {
                             if (substr($sClass, 0, 3) == 'my_') {
                                 //on inclut la classe en tronquant my_
                                 //exple: my_metier => ../myClass/metier.php
                                 include '../myClasses/' . substr($sClass, 3) . '.php';
                             } else {
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #18
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);
 }
Beispiel #19
0
 public function processSave()
 {
     if (!_root::getRequest()->isPost() or _root::getParam('formmodule') != self::$sModuleName) {
         //si ce n'est pas une requete POST on ne soumet pas
         return null;
     }
     $oPluginXsrf = new plugin_xsrf();
     if (!$oPluginXsrf->checkToken(_root::getParam('token'))) {
         //on verifie que le token est valide
         return array('token' => $oPluginXsrf->getMessage());
     }
     $iId = module_posts::getParam('id', null);
     if ($iId == null) {
         $oPosts = new row_posts();
     } else {
         $oPosts = model_posts::getInstance()->findById(module_posts::getParam('id', null));
     }
     $tId = model_posts::getInstance()->getIdTab();
     $tColumn = model_posts::getInstance()->getListColumn();
     foreach ($tColumn as $sColumn) {
         $oPluginUpload = new plugin_upload($sColumn);
         if ($oPluginUpload->isValid()) {
             $sNewFileName = _root::getConfigVar('path.upload') . $sColumn . '_' . date('Ymdhis');
             $oPluginUpload->saveAs($sNewFileName);
             $oPosts->{$sColumn} = $oPluginUpload->getPath();
             continue;
         } else {
             if (_root::getParam($sColumn, null) === null) {
                 continue;
             } else {
                 if (in_array($sColumn, $tId)) {
                     continue;
                 }
             }
         }
         $oPosts->{$sColumn} = _root::getParam($sColumn, null);
     }
     if ($oPosts->save()) {
         //une fois enregistre on redirige (vers la page liste)
         $this->redirect('list');
     } else {
         return $oPosts->getListError();
     }
 }
Beispiel #20
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);
     }
 }
Beispiel #21
0
        echo _root::getLink('builder::edit', array('id' => $sProjet));
        ?>
#createon"><?php 
        echo tr('menuNavProject_link_edit');
        ?>
</a>
								
								<a href="<?php 
        echo _root::getLink('code::index', array('project' => $sProjet));
        ?>
"><?php 
        echo tr('menuNavProject_link_explore');
        ?>
</a>
								
								
								<a target="_blank" href="<?php 
        echo _root::getConfigVar('path.generation');
        echo $sProjet;
        ?>
"><?php 
        echo tr('menuNavProject_link_gotoSite');
        ?>
</a>					
								</li>
	<?php 
    }
}
?>
</ul>
Beispiel #22
0
 /** 
  * initialise module/action a partir d'une chaine module::action
  * @access public
  * @param string $sChaine
  */
 public function loadModuleAndAction($sChaine)
 {
     $this->_tVar[_root::getConfigVar('navigation.var')] = $sChaine;
     $this->_bHasNavigation = true;
     $sModule = '';
     $sAction = '';
     if (preg_match('/::/', $sChaine)) {
         list($sModule, $sAction) = preg_split('/::/', $sChaine);
     } else {
         $sModule = $sChaine;
     }
     if ($sAction == '') {
         $sAction = 'index';
     }
     if ($sModule == '') {
         $sModule = 'index';
     }
     $this->setModule($sModule);
     $this->setAction($sAction);
 }
Beispiel #23
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);
     }
 }
Beispiel #24
0
 public function getListIni()
 {
     $tType = array('all', 'normal', 'bootstrap', 'builder');
     $tLinkModule = array();
     $tLocalIni = array();
     foreach ($tType as $sType) {
         $sPathModule = _root::getConfigVar('path.module') . '/mods/' . $sType;
         $tModulesAll = scandir($sPathModule);
         foreach ($tModulesAll as $sModule) {
             if (file_exists($sPathModule . '/' . $sModule . '/info.ini')) {
                 $tIni = parse_ini_file($sPathModule . '/' . $sModule . '/info.ini');
                 $tLocalIni['mods_' . $sType . '_' . $sModule] = $tIni['version'];
             }
         }
     }
     return $tLocalIni;
 }
Beispiel #25
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);
 }
Beispiel #26
0
 /**
  * @access public
  * @return bool retourne true/false selon qu'on est autorise ou non a faire $action sur $ressource
  * @param string $action action qu'on autorise sur $ressource
  * @param string $ressource ressource l'action est autorise sur $ressource	
  */
 public function can($action, $ressource)
 {
     $ok = true;
     if (!isset($this->tabAllowDeny[$ressource])) {
         $ok = false;
     }
     if (!isset($this->tabAllowDeny[$ressource][$action])) {
         $ok = false;
     }
     if (_root::getConfigVar('site.mode') == 'dev') {
         $tAskCan = _root::getConfigVar('tAskCan');
         $tAskCan[] = array($action, $ressource, $ok);
         _root::setConfigVar('tAskCan', $tAskCan);
     }
     if ($ok) {
         $sOk = 'oui';
     } else {
         $sOk = 'non';
     }
     _root::getLog()->info('ACL can "' . $action . '" on "' . $ressource . '" ? : ' . $sOk);
     return $ok;
 }
Beispiel #27
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;
 }
Beispiel #28
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();
 }
Beispiel #29
0
					<p>Model <?php 
                    echo $this->class;
                    ?>
 4/4: <span style="color:green">ok</span></p>
					

					<a id="editcrud" name="editcrud"></a>
					<div class="table">
						<?php 
                    if ($this->tColumn) {
                    }
                    ?>
						<form action="" method="POST">

						<?php 
                    if (!_root::getParam('moduleToCreate') and file_exists(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $this->sModuleToCreate)) {
                        ?>
							<p class="error"><?php 
                        echo sprintf(tr('leModuleExisteDeja'), $this->sModuleToCreate);
                        ?>
</p>
						<?php 
                    }
                    ?>

						<table>
							<tr>
								<th><?php 
                    echo tr('nomDuModuleAcreer');
                    ?>
</th>
Beispiel #30
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');
 }