/** * Pubishes the theme to the site * * @param {Site} $site */ public static function publishTheme($theme, $site) { // publish theme files $src = app()->basePath() . '/public/themes/' . $theme; $dest = app()->basePath() . '/public/sites/' . $site->id; // copy the directory Utilities::copyDirectory($src, $dest); // copy the private files $src = app()->basePath() . '/public/themes/' . $theme . '/private'; $dest = app()->basePath() . '/resources/sites/' . $site->id; // copy the directory Utilities::copyDirectory($src, $dest); /* echo('remove settings and plugins'); // remove settings and plugins if(file_exists($dest.'/private/plugins.js')) { unlink($dest.'/private/plugins.js'); } if(file_exists($dest.'/private/settings.json')) { unlink($dest.'/private/settings.json'); } // remove the directory if(file_exists($dest.'/private')) { rmdir($dest.'/private'); }*/ }
/** * Copies a directory * * @param {string} $src the source * @param {string} $dst the destination * @return void */ public static function copyDirectory($src, $dst) { $dir = opendir($src); if (!file_exists($dst)) { mkdir($dst, 0777, true); } while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir($src . '/' . $file)) { if ($file !== 'private' && $file !== 'dist') { Utilities::copyDirectory($src . '/' . $file, $dst . '/' . $file); } } else { copy($src . '/' . $file, $dst . '/' . $file); } } } closedir($dir); }