From 5d832a2f7b5b19fc68bd1a5890e378715a66debd Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 25 Jul 2014 17:21:06 +1000 Subject: [PATCH 1/5] Fixes #461 --- modules/cms/classes/Theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cms/classes/Theme.php b/modules/cms/classes/Theme.php index ca7b92715..440c98bdf 100644 --- a/modules/cms/classes/Theme.php +++ b/modules/cms/classes/Theme.php @@ -145,7 +145,7 @@ class Theme { $editTheme = Config::get('cms.editTheme'); if (!$editTheme) - $editTheme = Config::get('cms.activeTheme'); + $editTheme = static::getActiveTheme()->getDirName(); $apiResult = Event::fire('cms.editTheme', [], true); if ($apiResult !== null) From a475773c7c7d463881182d51db1e1b166d24f301 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 25 Jul 2014 17:24:43 +1000 Subject: [PATCH 2/5] Add info flash message --- modules/backend/assets/css/october.css | 3 +++ modules/backend/assets/less/controls/flashmessage.less | 1 + modules/backend/assets/less/core/variables.less | 1 + 3 files changed, 5 insertions(+) diff --git a/modules/backend/assets/css/october.css b/modules/backend/assets/css/october.css index d2e4438c2..25bb5b602 100644 --- a/modules/backend/assets/css/october.css +++ b/modules/backend/assets/css/october.css @@ -11039,6 +11039,9 @@ body.dropdown-open .dropdown-overlay { .flash-message.warning { background: #f0ad4e; } +.flash-message.info { + background: #5fb6f5; +} .flash-message button { float: none; position: absolute; diff --git a/modules/backend/assets/less/controls/flashmessage.less b/modules/backend/assets/less/controls/flashmessage.less index 916c7ff05..ba0333a27 100644 --- a/modules/backend/assets/less/controls/flashmessage.less +++ b/modules/backend/assets/less/controls/flashmessage.less @@ -32,6 +32,7 @@ &.success { background: @color-flash-success-bg; } &.error { background: @color-flash-error-bg; } &.warning { background: @color-flash-warning-bg; } + &.info { background: @color-flash-info-bg; } button { float: none; diff --git a/modules/backend/assets/less/core/variables.less b/modules/backend/assets/less/core/variables.less index 99e18463c..9479fd5ad 100644 --- a/modules/backend/assets/less/core/variables.less +++ b/modules/backend/assets/less/core/variables.less @@ -148,6 +148,7 @@ @color-flash-success-bg: #8da85e; @color-flash-error-bg: #cc3300; @color-flash-warning-bg: #f0ad4e; +@color-flash-info-bg: #5fb6f5; @color-flash-text: #ffffff; @color-filter-text: #666666; From 49d40e77ad6bbd8e715fc1629f04fccc54c146de Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 25 Jul 2014 17:49:32 +1000 Subject: [PATCH 3/5] Add deselect function to API --- modules/backend/widgets/grid/assets/js/datagrid.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/backend/widgets/grid/assets/js/datagrid.js b/modules/backend/widgets/grid/assets/js/datagrid.js index bf1728ee4..6a12550bd 100644 --- a/modules/backend/widgets/grid/assets/js/datagrid.js +++ b/modules/backend/widgets/grid/assets/js/datagrid.js @@ -232,6 +232,11 @@ } }) } + + DataGrid.prototype.deselect = function() { + this.gridInstance.deselectCell() + } + DataGrid.prototype.setData = function(data) { this.gridInstance.loadData(data) } From 3ac3a7318f4ce398886dad635ae1b6a623b01e25 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 25 Jul 2014 17:41:37 +1000 Subject: [PATCH 4/5] Fixes bug preventing plugins from being installed --- modules/system/controllers/Updates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php index 15039312b..366e6b86d 100644 --- a/modules/system/controllers/Updates.php +++ b/modules/system/controllers/Updates.php @@ -413,7 +413,7 @@ class Updates extends Controller /* * Update steps */ - $updateSteps = $this->buildUpdateSteps(null, $plugins); + $updateSteps = $this->buildUpdateSteps(null, $plugins, []); /* * Finish up From 19a3fe2b43d02c83ce9a469851642f6888226168 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 25 Jul 2014 17:51:36 +1000 Subject: [PATCH 5/5] Added a new console command `october:util` for performing utility and maintenance tasks. --- CHANGELOG.md | 8 +- modules/system/ServiceProvider.php | 1 + modules/system/console/OctoberDown.php | 25 +++-- modules/system/console/OctoberUtil.php | 119 ++++++++++++++++++++++++ modules/system/console/PluginRemove.php | 54 +++++++---- 5 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 modules/system/console/OctoberUtil.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f463a17f..eef7fe2dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ +* **Build 129** (2014-07-25) + - Fixes a bug where the active theme is not editable in the back-end. + - Added a new console command `october:util` for performing utility and maintenance tasks. + - Added new utility command for deleting thumbs in the uploads directory `october:util purge thumbs`. + - Improved console command confirmation dialogs. + * **Build 125** (2014-07-24) - - Theme support added. + - Added support for Themes. - Added new Theme picker to the backend via Settings > Front-end theme - New shorthand method for `$this->getClassExtension('Backend.Behaviors.FormController')` becomes `$this->asExtension('FormController')`. - Buttons inside a popup support new `data-popup-load-indicator` attribute. diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index 05438b4b9..b74d2e4ee 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -248,6 +248,7 @@ class ServiceProvider extends ModuleServiceProvider $this->registerConsoleCommand('october.up', 'System\Console\OctoberUp'); $this->registerConsoleCommand('october.down', 'System\Console\OctoberDown'); $this->registerConsoleCommand('october.update', 'System\Console\OctoberUpdate'); + $this->registerConsoleCommand('october.util', 'System\Console\OctoberUtil'); $this->registerConsoleCommand('plugin.install', 'System\Console\PluginInstall'); $this->registerConsoleCommand('plugin.remove', 'System\Console\PluginRemove'); $this->registerConsoleCommand('plugin.refresh', 'System\Console\PluginRefresh'); diff --git a/modules/system/console/OctoberDown.php b/modules/system/console/OctoberDown.php index ade4c4252..0c0185975 100644 --- a/modules/system/console/OctoberDown.php +++ b/modules/system/console/OctoberDown.php @@ -8,6 +8,8 @@ use Symfony\Component\Console\Input\InputArgument; class OctoberDown extends Command { + use \Illuminate\Console\ConfirmableTrait; + /** * The console command name. */ @@ -31,13 +33,13 @@ class OctoberDown extends Command */ public function fire() { - if ($this->confirm('Destroy all database tables? [yes|no]')) { + if (!$this->confirmToProceed('This will DESTROY all database tables.')) + return; - $manager = UpdateManager::instance()->resetNotes()->uninstall(); + $manager = UpdateManager::instance()->resetNotes()->uninstall(); - foreach ($manager->getNotes() as $note) - $this->output->writeln($note); - } + foreach ($manager->getNotes() as $note) + $this->output->writeln($note); } /** @@ -53,7 +55,18 @@ class OctoberDown extends Command */ protected function getOptions() { - return []; + return [ + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run.'], + ]; + } + + /** + * Get the default confirmation callback. + * @return \Closure + */ + protected function getDefaultConfirmCallback() + { + return function() { return true; }; } } \ No newline at end of file diff --git a/modules/system/console/OctoberUtil.php b/modules/system/console/OctoberUtil.php new file mode 100644 index 000000000..4a09bb911 --- /dev/null +++ b/modules/system/console/OctoberUtil.php @@ -0,0 +1,119 @@ +argument('name')); + $method = 'util'.studly_case($command); + + if (!method_exists($this, $method)) { + $this->error(sprintf('Utility command "%s" does not exist!', $command)); + return; + } + + $this->$method(); + } + + /** + * Get the console command arguments. + * @return array + */ + protected function getArguments() + { + return [ + ['name', InputArgument::IS_ARRAY, 'A utility command to perform.'], + ]; + } + + /** + * Get the console command options. + */ + protected function getOptions() + { + return [ + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ]; + } + + // + // Utilties + // + + protected function utilPurgeThumbs() + { + if (!$uploadsDir = Config::get('cms.uploadsDir')) + return $this->error('No uploads directory defined in config (cms.uploadsDir)'); + + if (!$this->confirmToProceed('This will PERMANENTLY DELETE all thumbs in the uploads directory.')) + return; + + $uploadsDir = base_path() . $uploadsDir; + $totalCount = 0; + + /* + * Recursive function to scan the directory for files beginning + * with "thumb_" and repeat itself on directories. + */ + $purgeFunc = function($targetDir) use (&$purgeFunc, &$totalCount) { + if ($files = File::glob($targetDir.'/thumb_*')) { + foreach ($files as $file) { + $this->info('Purged: '. basename($file)); + $totalCount++; + @unlink($file); + } + } + + if ($dirs = File::directories($targetDir)) { + foreach ($dirs as $dir) { + $purgeFunc($dir); + } + } + }; + + $purgeFunc($uploadsDir); + + if ($totalCount > 0) + $this->comment(sprintf('Successfully deleted %s thumbs', $totalCount)); + else + $this->comment('No thumbs found to delete'); + } + +} \ No newline at end of file diff --git a/modules/system/console/PluginRemove.php b/modules/system/console/PluginRemove.php index c51e60ab1..cae780827 100644 --- a/modules/system/console/PluginRemove.php +++ b/modules/system/console/PluginRemove.php @@ -10,6 +10,8 @@ use Symfony\Component\Console\Input\InputArgument; class PluginRemove extends Command { + use \Illuminate\Console\ConfirmableTrait; + /** * The console command name. * @var string @@ -37,26 +39,31 @@ class PluginRemove extends Command */ public function fire() { - if ($this->confirm('Are you sure you want to uninstall this plugin? [yes|no]')) { - $pluginName = $this->argument('name'); - $pluginName = PluginManager::instance()->normalizeIdentifier($pluginName); + $pluginManager = PluginManager::instance(); + $pluginName = $this->argument('name'); + $pluginName = $pluginManager->normalizeIdentifier($pluginName); - /* - * Rollback plugin - */ - $manager = UpdateManager::instance()->resetNotes(); - $manager->rollbackPlugin($pluginName); + if (!$pluginManager->hasPlugin($pluginName)) + return $this->error(sprintf('Unable to find a registered plugin called "%s"', $pluginName)); - foreach ($manager->getNotes() as $note) - $this->output->writeln($note); + if (!$this->confirmToProceed(sprintf('This will DELETE "%s" from the filesystem and database.', $pluginName))) + return; - /* - * Delete from file system - */ - if ($pluginPath = PluginManager::instance()->getPluginPath($pluginName)) { - File::deleteDirectory($pluginPath); - $this->output->writeln(sprintf('Deleted: %s', $pluginName)); - } + /* + * Rollback plugin + */ + $manager = UpdateManager::instance()->resetNotes(); + $manager->rollbackPlugin($pluginName); + + foreach ($manager->getNotes() as $note) + $this->output->writeln($note); + + /* + * Delete from file system + */ + if ($pluginPath = $pluginManager->getPluginPath($pluginName)) { + File::deleteDirectory($pluginPath); + $this->output->writeln(sprintf('Deleted: %s', $pluginName)); } } @@ -77,7 +84,18 @@ class PluginRemove extends Command */ protected function getOptions() { - return []; + return [ + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run.'], + ]; + } + + /** + * Get the default confirmation callback. + * @return \Closure + */ + protected function getDefaultConfirmCallback() + { + return function() { return true; }; } } \ No newline at end of file