public function run($arguments = array()) { if (!empty($arguments)) { $new_theme = $arguments[0]; } if (!empty($new_theme)) { //CLONE DEFAULT THEME $theme_folder = path('bundle') . 'cms/views/theme/'; if (!file_exists($theme_folder . $new_theme)) { // COPY THEME File::cpdir($theme_folder . 'default', $theme_folder . $new_theme, false); echo PHP_EOL; echo 'Theme [' . $new_theme . '] created!' . PHP_EOL; } else { echo PHP_EOL; echo 'Theme [' . $new_theme . '] already exists!' . PHP_EOL; } } else { echo PHP_EOL; echo 'ERROR: no new theme name provided!' . PHP_EOL; } }
/** * It restores a backed up theme * Current theme if not specified * * @param array * @return string */ public function restore($arguments = array()) { $current_theme = Config::get('cms::settings.theme'); if (array_key_exists(0, $arguments)) { $theme = $arguments[0]; } else { $theme = $current_theme; } $backup_path = path('base') . '_backup/' . $theme; if (file_exists($backup_path)) { $theme_path = path('bundle') . 'cms/views/theme/' . $theme; //COPY FROM _BACKUP TO THEME File::cpdir($backup_path, $theme_path, false); $result = '[' . $theme . '] backup restored!' . PHP_EOL; } else { $result = '[' . $theme . '] backup folder doesn\'t exists!' . PHP_EOL; } echo PHP_EOL; echo $result; }
/** * Create tenant foler in /tenants directory based on the default. * * @param string $name * @return bool */ private static function create_tenant_folder($name) { if (file_exists(path('tenants') . $name)) { throw new Exception("ERROR! Could not create new tenant directory '{$name}'! Make sure this name is unique."); } return File::cpdir(path('tenants') . 'default', path('tenants') . $name); }
/** * Copy a directory of templates to a destination. * * <code> * $this->_dircopy[] = array( * 'type' => 'View', * 'name' => 'Descriptive identifier shown to terminal.', * 'source' => 'the/location/to/copy/from', * 'destination' => 'the/location/to/copy/to' * ); * </code> * * @return void */ private function _copy_dirs() { // loop through dirs to copy foreach ($this->_dircopy as $dir) { // if force is set we overwrite anyway if (!is_dir($dir['destination']) and Common::config('force') == false) { if (!Common::config('pretend')) { File::cpdir($dir['source'], $dir['destination']); } // log something pretty to the terminal Common::log("{c}({g}~{c}) {y}{$dir['type']}\t\t{w}{$dir['name']}"); } else { // we cant copy if its already there Common::error('The directory \'' . $dir['name'] . '\' already exists.'); } } }
public function theme($arguments = array()) { $current_theme = Config::get('cms::settings.theme'); if (array_key_exists(0, $arguments)) { $theme = $arguments[0]; } else { $theme = $current_theme; } //CHECK THEME FOLDER EXISTENCE $theme_settings = path('bundle') . 'cms/views/theme/' . $theme . '/theme' . EXT; if (file_exists($theme_settings)) { //SET NEW THEME NAME IN SETTINGS $theme_path = path('bundle') . 'cms/config/settings' . EXT; $theme_conf = File::get($theme_path); $theme_conf = str_replace("'theme' => '" . $current_theme . "',", "'theme' => '{$theme}',", $theme_conf); File::put($theme_path, $theme_conf); //COPY ASSETS $asset_path = path('bundle') . 'cms/views/theme/' . $theme . '/public'; if (file_exists($asset_path)) { //EMPTY BLADE COMPILED FILES $storage_path = path('storage') . 'views'; $files = glob($storage_path . '/*'); foreach ($files as $file) { if ($file != '.gitignore') { unlink($file); } } //EMPTY PUBLIC PATH $dirs = array('css', 'img', 'js'); $public_path = path('public'); foreach ($dirs as $dir) { $files = glob($public_path . $dir . '/*'); foreach ($files as $file) { if (is_dir($file)) { self::rrmdir($file); } else { if ($file != '.gitignore') { unlink($file); } } } } //COPY PUBLIC ASSETTS $asset_path = path('bundle') . 'cms/views/theme/' . $theme . '/public'; File::cpdir($asset_path, $public_path, false); echo 'Theme [' . $theme . '] ready!' . PHP_EOL; } else { echo 'Theme [' . $theme . '] doesn\'t exists!' . PHP_EOL; } } else { echo '[' . $theme . '] theme folder doesn\'t exists!' . PHP_EOL; } }