method save documentation in bbn\Ide\Actions

function($data) { (strpos($data['file'], '../') === false) ){ $args = explode('/', $data['file']); // The root directory $dir = array_shift($args); // The rest of the path $path = implode('/', $args); // Gives the config array of each directory, indexed on the dir's name $directories = new Directories($this->db); $cfg = $directories->dirs(); if ( isset($cfg[$dir]) ){ $dirs =& $cfg[$dir]; // Change the path for the MVC if ( $this->isMvc($dirs) ){ // type of file part of the MVC foreach ( $dirs['files'] as $f ){ if ( $f['url'] === end($args) ){ if ( $f['url'] === '_ctrl' ){ $arg = \array_slice($args, 0 , \count($args)-2); $new_path = \count($arg) > 0 ? implode("/", $arg).'/_ctrl.'.$f['ext'] : '_ctrl.'.$f['ext']; } // If MVC file is not controller and no content, we delete the file else if ( empty($data['code']) && ($f['url'] !== 'php') ){ $new_path = $f['fpath'].substr(implode("/", $args), 0 , -3).$f['ext']; unlink($new_path); return ['path' => $new_path]; } else{ $arg = \array_slice($args, 0 , \count($args)-1); $new_path = substr(implode("/", $arg), 0 , -3).$f['ext']; } $new_path = $f['fpath'].$new_path; break; } } } else { foreach ( $dirs['files'] as $f ){ if ( $f['ext'] === bbn\Str::fileExt($path) ){ $new_path = $f['fpath'].$path; break; } } } if ( is_file($new_path) ){ $backup = BBN_DATA_PATH.'users/'.$_SESSION[BBN_APP_NAME]['user']['id'].'/ide/backup/'.date('Y-m-d His').' - Save/'.$dir.'/'.$path; //die(bbn\X::dump($f, $new_path, $backup, $dir )); bbn\File\Dir::createPath(X::dirname($backup)); rename($new_path, $backup); } else if ( !is_dir(X::dirname($new_path)) ){ bbn\File\Dir::createPath(X::dirname($new_path)); } file_put_contents($new_path, $data['code']); return ['path' => $new_path]; } } return $this->error('Error: Save'); }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.