. */ class model_mkfbuilderprojet extends abstract_model { private $sSource = 'data/sources/projet/'; private $sSourceEmpty = 'data/sources/projet_vide/'; private $sSourceScBootstrap = 'data/sources/projet_vide_sc_bootstrap/'; private $sGenere = null; public function __construct() { $this->sGenere = _root::getConfigVar('path.generation'); } public static function getInstance() { return self::_getInstance(__CLASS__); } public function create($sProjet) { self::copyFromTo($this->sSource, $this->sGenere . $sProjet); } public function createEmpty($sProjet) { self::copyFromTo($this->sSourceEmpty, $this->sGenere . $sProjet); } public function createScWithBootstrap($sProjet) { self::copyFromTo($this->sSourceScBootstrap, $this->sGenere . $sProjet); } public function findAll() { $oDir = new _dir($this->sGenere); $tProjet = array(); foreach ($oDir->getListDir() as $oDir) { $tProjet[] = $oDir->getName(); } return $tProjet; } public function copyFromTo($sFrom, $sTo) { if (preg_match('/test$/', $sFrom) or preg_match('/script/', $sFrom)) { return; } if (is_dir($sFrom)) { $oDir = new _dir($sFrom); try { mkdir($sTo); } catch (Exception $e) { throw new Exception( 'Erreur creation repertoire ' . $sTo . ' Verifier les droits du repertoire ' . $this->sGenere . ' du mkf4builder On doit pouvoir ecrire dedans (generation de projet) ' ); } chmod($sTo, 0777); foreach ($oDir->getList() as $oFile) { if (preg_match('/example/', $oFile->getAdresse())) { continue; } self::copyFromTo($oFile->getAdresse(), $sTo . '/' . $oFile->getName()); } } else { copy($sFrom, $sTo); chmod($sTo, 0666); } } } ?>