method save documentation in bbn\Ide\Directories

Saves a file.

function($file, $code, array $cfg = NULL, bbn\User\Preferences $pref = NULL) { if ( ($file = bbn\Str::parsePath($file)) && ($real = $this->urlToReal($file)) && ($dir = $this->dir($this->dirFromUrl($file))) && \defined('BBN_USER_PATH') ){ $id_file = $this->realToId($real); $ext = bbn\Str::fileExt($real, 1); $id_user = false; if ( $session = bbn\User\Session::getInstance() ){ $id_user = $session->get('user', 'id'); } // We delete the file if code is empty and we aren't in a _ctrl file if ( empty($code) ){ $bits = explode('/', $file); if ( !empty($dir['tabs']) && !empty($bits) ){ $tab = $this->superiorSctrl(array_pop($bits))['tab']; if ( !empty($dir['tabs'][$tab]) && empty($dir['tabs'][$tab]['fixed']) ){ if ( @unlink($real) ){ // Remove permissions $this->deletePerm($real); if ( $id_file ){ // Remove file's options $this->options->remove($this->options->fromCode($id_file, $this->_files_pref())); // Remove ide backups bbn\File\Dir::delete(X::dirname(BBN_USER_PATH."ide/backup/$id_file")."/$ext[0]/", 1); } return [ 'deleted' => 1 ]; } } } } if ( is_file($real) && $id_file ){ $filename = empty($dir['tabs']) ? $ext[0].'.'.$ext[1] : $ext[0]; $backup = X::dirname(BBN_USER_PATH."ide/backup/".$id_file).'/'.$filename.'/'.date('Y-m-d His').'.'.$ext[1]; bbn\File\Dir::createPath(X::dirname($backup)); rename($real, $backup); } else if ( !is_dir(X::dirname($real)) ){ bbn\File\Dir::createPath(X::dirname($real)); } file_put_contents($real, $code); if ( $pref && $id_user ){ $this->setPreferences($id_user, $id_file, md5($code), $cfg, $pref); } return [ 'success' => 1, 'path' => $real ]; } return $this->error('Error: Save'); }

Saves a file. 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.