From 5eb278e8836d439a765fcbfd5647d6ae8488eabb Mon Sep 17 00:00:00 2001 From: TimFoerster Date: Thu, 4 May 2017 14:53:19 +0200 Subject: [PATCH 01/16] Filter layout by ignored file names The Layouts get filtered by the filesystem definition of ignored files. #814 --- modules/cms/classes/Page.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/cms/classes/Page.php b/modules/cms/classes/Page.php index b25c550f0..85ecef009 100644 --- a/modules/cms/classes/Page.php +++ b/modules/cms/classes/Page.php @@ -4,6 +4,7 @@ use Lang; use Cms\Classes\Theme; use Cms\Classes\Layout; use ApplicationException; +use October\Rain\Filesystem\Definitions as FileDefinitions; /** * The CMS page class. @@ -88,8 +89,24 @@ class Page extends CmsCompoundObject $layouts = Layout::listInTheme($theme, true); $result = []; $result[null] = Lang::get('cms::lang.page.no_layout'); + $ignoreNames = FileDefinitions::get('ignoreFiles'); + foreach ($layouts as $layout) { $baseName = $layout->getBaseFileName(); + + //Filter ignore files + $ignoreFile = false; + foreach ($ignoreNames as $ignoreName) { + if(strpos($baseName, $ignoreName) === 0) { + $ignoreFile = true; + break; + } + } + + if($ignoreFile) { + continue; + } + $result[$baseName] = strlen($layout->name) ? $layout->name : $baseName; } From 25daf546fa77cfd0316c4e33d17d58c50b8faf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Fo=CC=88rster?= Date: Fri, 5 May 2017 11:20:10 +0200 Subject: [PATCH 02/16] =?UTF-8?q?Allows=200=20and=20=E2=80=980=E2=80=99=20?= =?UTF-8?q?values=20as=20default=20values=20for=20theme=20settings=20-=20R?= =?UTF-8?q?efs=20#2388?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/cms/models/ThemeData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cms/models/ThemeData.php b/modules/cms/models/ThemeData.php index dde92f731..1dd99f8b5 100644 --- a/modules/cms/models/ThemeData.php +++ b/modules/cms/models/ThemeData.php @@ -154,7 +154,7 @@ class ThemeData extends Model $result = []; foreach ($this->getFormFields() as $attribute => $field) { - if (!$value = array_get($field, 'default')) { + if (($value = array_get($field, 'default')) === null) { continue; } From 85934654f1f6bf34ed044fc38bf83d6f159d5288 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Tue, 9 May 2017 01:17:06 -0600 Subject: [PATCH 03/16] Adding Lithuanian to the available languages Refs: #2648 --- modules/system/lang/en/lang.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/system/lang/en/lang.php b/modules/system/lang/en/lang.php index b227f541e..a2eaaf033 100644 --- a/modules/system/lang/en/lang.php +++ b/modules/system/lang/en/lang.php @@ -25,6 +25,7 @@ return [ 'id' => 'Bahasa Indonesia', 'it' => 'Italiano', 'ja' => '日本語', + 'lt' => 'Lietuvių', 'lv' => 'Latvijas', 'nb-no' => 'Norsk (Bokmål)', 'nl' => 'Nederlands', From 2a5f9e5ce2d48e7e6f5e6d587f57459975378ad5 Mon Sep 17 00:00:00 2001 From: Nauris Linde Date: Wed, 10 May 2017 04:01:04 +0300 Subject: [PATCH 04/16] Update Latvian locales translation (#2862) --- modules/system/lang/en/lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/system/lang/en/lang.php b/modules/system/lang/en/lang.php index a2eaaf033..d04cab1ad 100644 --- a/modules/system/lang/en/lang.php +++ b/modules/system/lang/en/lang.php @@ -26,7 +26,7 @@ return [ 'it' => 'Italiano', 'ja' => '日本語', 'lt' => 'Lietuvių', - 'lv' => 'Latvijas', + 'lv' => 'Latviešu', 'nb-no' => 'Norsk (Bokmål)', 'nl' => 'Nederlands', 'pl' => 'Polskie', From 95cd3f70773072732d202c0c69c25c241a7a9936 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Fri, 12 May 2017 11:22:13 -0600 Subject: [PATCH 05/16] Translate group name and description Refs: https://github.com/octobercms/october/issues/2772#issuecomment-301125572 --- modules/backend/formwidgets/repeater/partials/_repeater.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/backend/formwidgets/repeater/partials/_repeater.htm b/modules/backend/formwidgets/repeater/partials/_repeater.htm index 7c5d6611b..79cea1e78 100644 --- a/modules/backend/formwidgets/repeater/partials/_repeater.htm +++ b/modules/backend/formwidgets/repeater/partials/_repeater.htm @@ -53,8 +53,8 @@ data-request="getEventHandler('onAddItem') ?>" data-request-data="_repeater_group: ''"> - - + + @@ -67,4 +67,4 @@ - \ No newline at end of file + From fe3e44efeb495fb142b0c6b3d65996a41c0f3e5c Mon Sep 17 00:00:00 2001 From: CSNWEB Date: Sun, 14 May 2017 01:31:09 +0200 Subject: [PATCH 06/16] Add method to easily extend filter scopes (#2866) * Add method to easily extend filter scopes * Add non static method for filter scope extension --- modules/backend/behaviors/ListController.php | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index 91baff00c..6cbd5a924 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -240,6 +240,13 @@ class ListController extends ControllerBehavior $filterWidget->bindEvent('filter.update', function () use ($widget, $filterWidget) { return $widget->onRefresh(); }); + + /* + * Filter Widget with extensibility + */ + $filterWidget->bindEvent('filter.extendScopes', function () use ($filterWidget) { + $this->controller->filterExtendScopes($filterWidget); + }); /* * Extend the query of the list of options @@ -449,6 +456,15 @@ class ListController extends ControllerBehavior public function listExtendColumns($host) { } + + /** + * Called after the filter scopes are defined. + * @param \Backend\Widgets\Filter $host The hosting filter widget + * @return void + */ + public function filterExtendScopes($host) + { + } /** * Controller override: Extend supplied model @@ -543,4 +559,20 @@ class ListController extends ControllerBehavior call_user_func_array($callback, [$widget, $widget->model]); }); } + + /** + * Static helper for extending filter scopes. + * @param callable $callback + * @return void + */ + public static function extendFilterScopes($callback) + { + $calledClass = self::getCalledExtensionClass(); + Event::listen('backend.filter.extendScopes', function ($widget) use ($calledClass, $callback) { + if (!is_a($widget->getController(), $calledClass)) { + return; + } + call_user_func_array($callback, [$widget]); + }); + } } From 57aa723c23a9122bc5492b9d2693acb1c9597c5d Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sun, 14 May 2017 14:47:17 +1000 Subject: [PATCH 07/16] filterExtendScopes -> listFilterExtendScopes extendFilterScopes -> extendListFilterScopes Filter still belongs to the "List", this would help resolve conflicts if there were ever a FilterController that would carry rightful claim to "filterExtendScopes" --- modules/backend/behaviors/ListController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index 6cbd5a924..9882bb7ad 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -240,12 +240,12 @@ class ListController extends ControllerBehavior $filterWidget->bindEvent('filter.update', function () use ($widget, $filterWidget) { return $widget->onRefresh(); }); - + /* * Filter Widget with extensibility */ $filterWidget->bindEvent('filter.extendScopes', function () use ($filterWidget) { - $this->controller->filterExtendScopes($filterWidget); + $this->controller->listFilterExtendScopes($filterWidget); }); /* @@ -462,7 +462,7 @@ class ListController extends ControllerBehavior * @param \Backend\Widgets\Filter $host The hosting filter widget * @return void */ - public function filterExtendScopes($host) + public function listFilterExtendScopes($host) { } @@ -565,7 +565,7 @@ class ListController extends ControllerBehavior * @param callable $callback * @return void */ - public static function extendFilterScopes($callback) + public static function extendListFilterScopes($callback) { $calledClass = self::getCalledExtensionClass(); Event::listen('backend.filter.extendScopes', function ($widget) use ($calledClass, $callback) { From 84ee4f26799fe6524b2cebd687c8640db76199d4 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sun, 14 May 2017 19:32:57 -0600 Subject: [PATCH 08/16] Fix for #2765 Actual changes are in `MediaManager.prototype.deleteConfirmation`, apologies for the trailing whitespace removals, my editor auto does that and I didn't feel like removing it since there shouldn't really be trailing whitespace anyways. Fixes #2675 (and probably other potential oopsies) by skipping over the "return to parent" item in the deletion handling method. The "return to parent" item contains a reference to the folder above the current folder, which could potentially cause the entire media folder to be deleted; and would certainly remove a lot more than actually intended. --- .../mediamanager/assets/js/mediamanager.js | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/modules/cms/widgets/mediamanager/assets/js/mediamanager.js b/modules/cms/widgets/mediamanager/assets/js/mediamanager.js index 00de9d83c..5c19242de 100644 --- a/modules/cms/widgets/mediamanager/assets/js/mediamanager.js +++ b/modules/cms/widgets/mediamanager/assets/js/mediamanager.js @@ -199,7 +199,7 @@ } MediaManager.prototype.isSearchMode = function() { - return this.$el.find('[data-type="search-mode"]').val() == 'true' + return this.$el.find('[data-type="search-mode"]').val() == 'true' } MediaManager.prototype.initScroll = function() { @@ -264,7 +264,7 @@ if (this.isPreviewSidebarVisible()) { // Use the timeout to prevent too many AJAX requests // when the selection changes too quickly (with the keyboard arrows) - this.selectTimer = setTimeout(this.proxy(this.updateSidebarPreview), 100) + this.selectTimer = setTimeout(this.proxy(this.updateSidebarPreview), 100) } // Disable delete and move buttons @@ -407,7 +407,7 @@ this.resetSearch() this.gotoFolder($item.data('path'), true) } - } + } else if ($item.data('item-type') == 'file') { // Trigger the Insert popup command if a file item // was double clicked or Enter key was pressed. @@ -432,7 +432,7 @@ $sidebar.removeClass('hide') this.updateSidebarPreview() $button.removeClass('sidebar-hidden') - } + } else { $sidebar.addClass('hide') $button.addClass('sidebar-hidden') @@ -597,8 +597,8 @@ for (var i = (placeholders.length-1); i >= 0; i--) this.thumbnailQueue.push({ id: placeholders[i].getAttribute('id'), - width: placeholders[i].getAttribute('data-width'), - height: placeholders[i].getAttribute('data-height'), + width: placeholders[i].getAttribute('data-width'), + height: placeholders[i].getAttribute('data-height'), path: placeholders[i].getAttribute('data-path'), lastModified: placeholders[i].getAttribute('data-last-modified') }) @@ -919,6 +919,10 @@ paths = [] for (var i=0, len=items.length; i 2 || Math.abs(deltaY) > 2)) { - // Start processing the selection only if the mouse was moved by + // Start processing the selection only if the mouse was moved by // at least 2 pixels. this.createSelectionMarker() @@ -1209,20 +1213,20 @@ if (this.selectionStarted) { if (deltaX >= 0) { - this.selectionMarker.style.left = this.selectionStartPoint.x + 'px' - this.selectionMarker.style.width = deltaX + 'px' + this.selectionMarker.style.left = this.selectionStartPoint.x + 'px' + this.selectionMarker.style.width = deltaX + 'px' } else { - this.selectionMarker.style.left = relativePosition.x + 'px' - this.selectionMarker.style.width = Math.abs(deltaX) + 'px' + this.selectionMarker.style.left = relativePosition.x + 'px' + this.selectionMarker.style.width = Math.abs(deltaX) + 'px' } if (deltaY >= 0) { - this.selectionMarker.style.height = deltaY + 'px' + this.selectionMarker.style.height = deltaY + 'px' this.selectionMarker.style.top = this.selectionStartPoint.y + 'px' } else { - this.selectionMarker.style.top = relativePosition.y + 'px' + this.selectionMarker.style.top = relativePosition.y + 'px' this.selectionMarker.style.height = Math.abs(deltaY) + 'px' } } @@ -1285,7 +1289,7 @@ var old = $.fn.mediaManager $.fn.mediaManager = function (option) { - var args = Array.prototype.slice.call(arguments, 1), + var args = Array.prototype.slice.call(arguments, 1), result = undefined this.each(function () { @@ -1296,7 +1300,7 @@ if (typeof option == 'string') result = data[option].apply(data, args) if (typeof result != 'undefined') return false }) - + return result ? result : this } @@ -1317,4 +1321,4 @@ $('div[data-control=media-manager]').mediaManager() }) -}(window.jQuery); \ No newline at end of file +}(window.jQuery); From 0f04afbea47ccb5f8350802eaf19737991bc804f Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sun, 14 May 2017 19:34:50 -0600 Subject: [PATCH 09/16] Recompile mediamanager assets to include the fix --- .../mediamanager/assets/js/mediamanager-browser-min.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/cms/widgets/mediamanager/assets/js/mediamanager-browser-min.js b/modules/cms/widgets/mediamanager/assets/js/mediamanager-browser-min.js index 6dd38823d..993855a1b 100644 --- a/modules/cms/widgets/mediamanager/assets/js/mediamanager-browser-min.js +++ b/modules/cms/widgets/mediamanager/assets/js/mediamanager-browser-min.js @@ -343,7 +343,8 @@ $.oc.confirm(this.options.deleteConfirm,this.proxy(this.deleteConfirmation))} MediaManager.prototype.deleteConfirmation=function(confirmed){if(!confirmed) return var items=this.$el.get(0).querySelectorAll('[data-type="media-item"].selected'),paths=[] -for(var i=0,len=items.length;i Date: Sun, 14 May 2017 22:28:08 -0600 Subject: [PATCH 10/16] Remove reference to hardcoded media path Replaces the reference to a hardcoded `/media` path when generating a local temp file path to utilize the folder name as set in `cms.storage.media.folder`. --- modules/cms/widgets/MediaManager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/cms/widgets/MediaManager.php b/modules/cms/widgets/MediaManager.php index 2bbbdee07..629bdbaba 100644 --- a/modules/cms/widgets/MediaManager.php +++ b/modules/cms/widgets/MediaManager.php @@ -6,6 +6,7 @@ use Lang; use File; use Form; use Input; +use Config; use Request; use Response; use Exception; @@ -872,7 +873,7 @@ class MediaManager extends WidgetBase { $fileName = md5($fileName.uniqid().microtime()); - $path = temp_path() . '/media'; + $path = temp_path() . MediaLibrary::validatePath(Config::get('cms.storage.media.folder', 'media'), true); if (!File::isDirectory($path)) { File::makeDirectory($path, 0777, true, true); From 21d4f683c375280f520f41451acdecce910c8902 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sun, 14 May 2017 22:41:31 -0600 Subject: [PATCH 11/16] Support custom thumbnail directory This enables support for edge cases that require custom thumbnail directories (such as requiring authentication to view generated thumbnails). --- modules/cms/widgets/MediaManager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/cms/widgets/MediaManager.php b/modules/cms/widgets/MediaManager.php index 629bdbaba..5a3d71c7d 100644 --- a/modules/cms/widgets/MediaManager.php +++ b/modules/cms/widgets/MediaManager.php @@ -884,7 +884,8 @@ class MediaManager extends WidgetBase protected function getThumbnailDirectory() { - return '/public/'; + // NOTE: Custom routing for /storage/temp/$thumbnailDirectory must be setup to return the thumbnail if not using default 'public' directory + return MediaLibrary::validatePath(Config::get('cms.storage.media.thumbnailDirectory', 'public'), true) . '/'; } protected function getPlaceholderId($item) From a5b081b74b45f4dc2d638cfe7c6fa181f76a0377 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Mon, 15 May 2017 00:16:28 -0600 Subject: [PATCH 12/16] Make the MediaManager messages more generic --- modules/cms/lang/en/lang.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cms/lang/en/lang.php b/modules/cms/lang/en/lang.php index 7bab451cc..3ca8cc453 100644 --- a/modules/cms/lang/en/lang.php +++ b/modules/cms/lang/en/lang.php @@ -284,7 +284,7 @@ return [ 'size' => 'Size', 'title' => 'Title', 'last_modified' => 'Last modified', - 'public_url' => 'Public URL', + 'public_url' => 'Download URL', 'click_here' => 'Click here', 'thumbnail_error' => 'Error generating thumbnail.', 'return_to_parent' => 'Return to the parent folder', @@ -310,7 +310,7 @@ return [ 'move_destination' => 'Destination folder', 'please_select_move_dest' => 'Please select a destination folder.', 'move_dest_src_match' => 'Please select another destination folder.', - 'empty_library' => 'The Media Library is empty. Upload files or create folders to get started.', + 'empty_library' => 'It looks a bit empty here. Upload files or create folders to get started.', 'insert' => 'Insert', 'crop_and_insert' => 'Crop & Insert', 'select_single_image' => 'Please select a single image.', From 2a0a91486ce086e2427291c7dd579d0c71114544 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Tue, 16 May 2017 07:24:07 +1000 Subject: [PATCH 13/16] Logic error - fixes #2654 --- modules/cms/classes/ComponentBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cms/classes/ComponentBase.php b/modules/cms/classes/ComponentBase.php index 8ccdcd949..9546cd4c0 100644 --- a/modules/cms/classes/ComponentBase.php +++ b/modules/cms/classes/ComponentBase.php @@ -260,7 +260,7 @@ abstract class ComponentBase extends Extendable public function __call($method, $parameters) { try { - parent::__call($method, $parameters); + return parent::__call($method, $parameters); } catch (BadMethodCallException $ex) {} From d9cf7381dc64536a0a254aa6b4823874050456c4 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Tue, 16 May 2017 07:38:38 +1000 Subject: [PATCH 14/16] Implement helper method for checking ignored path Refs #2858 --- modules/cms/classes/Page.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/modules/cms/classes/Page.php b/modules/cms/classes/Page.php index 7225d6bcf..c9cb2d0ea 100644 --- a/modules/cms/classes/Page.php +++ b/modules/cms/classes/Page.php @@ -89,21 +89,11 @@ class Page extends CmsCompoundObject $layouts = Layout::listInTheme($theme, true); $result = []; $result[null] = Lang::get('cms::lang.page.no_layout'); - $ignoreNames = FileDefinitions::get('ignoreFiles'); foreach ($layouts as $layout) { $baseName = $layout->getBaseFileName(); - //Filter ignore files - $ignoreFile = false; - foreach ($ignoreNames as $ignoreName) { - if(strpos($baseName, $ignoreName) === 0) { - $ignoreFile = true; - break; - } - } - - if($ignoreFile) { + if (FileDefinitions::isPathIgnored($baseName)) { continue; } From 4d1bec860dad56a74539ab913c80b2c242c86dd1 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Tue, 16 May 2017 08:47:15 +1000 Subject: [PATCH 15/16] thumbnailDirectory -> thumbFolder --- modules/cms/widgets/MediaManager.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/cms/widgets/MediaManager.php b/modules/cms/widgets/MediaManager.php index 5a3d71c7d..5d863c14e 100644 --- a/modules/cms/widgets/MediaManager.php +++ b/modules/cms/widgets/MediaManager.php @@ -873,7 +873,9 @@ class MediaManager extends WidgetBase { $fileName = md5($fileName.uniqid().microtime()); - $path = temp_path() . MediaLibrary::validatePath(Config::get('cms.storage.media.folder', 'media'), true); + $mediaFolder = Config::get('cms.storage.media.folder', 'media'); + + $path = temp_path() . MediaLibrary::validatePath($mediaFolder, true); if (!File::isDirectory($path)) { File::makeDirectory($path, 0777, true, true); @@ -884,8 +886,11 @@ class MediaManager extends WidgetBase protected function getThumbnailDirectory() { - // NOTE: Custom routing for /storage/temp/$thumbnailDirectory must be setup to return the thumbnail if not using default 'public' directory - return MediaLibrary::validatePath(Config::get('cms.storage.media.thumbnailDirectory', 'public'), true) . '/'; + /* + * NOTE: Custom routing for /storage/temp/$thumbnailDirectory must be setup + * to return the thumbnail if not using default 'public' directory + */ + return MediaLibrary::validatePath(Config::get('cms.storage.media.thumbFolder', 'public'), true) . '/'; } protected function getPlaceholderId($item) From 25bcc3502064d06a854cb4bf829aa3b1a89e28c9 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 20 May 2017 09:03:58 +1000 Subject: [PATCH 16/16] Stream notes to console --- modules/system/classes/UpdateManager.php | 47 +++++++++++++++++++---- modules/system/classes/VersionManager.php | 34 ++++++++++++++-- modules/system/console/OctoberDown.php | 10 ++--- modules/system/console/OctoberInstall.php | 6 ++- modules/system/console/OctoberUp.php | 10 ++--- modules/system/console/OctoberUpdate.php | 4 +- modules/system/console/PluginInstall.php | 6 +-- modules/system/console/PluginRefresh.php | 19 ++++----- modules/system/console/PluginRemove.php | 6 +-- 9 files changed, 96 insertions(+), 46 deletions(-) diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 0f1120687..7435a74d1 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -31,11 +31,15 @@ class UpdateManager use \October\Rain\Support\Traits\Singleton; /** - * The notes for the current operation. - * @var array + * @var array The notes for the current operation. */ protected $notes = []; + /** + * @var \Illuminate\Console\OutputStyle + */ + protected $notesOutput; + /** * @var string Application base path. */ @@ -365,9 +369,11 @@ class UpdateManager $this->migrator->run(base_path() . '/modules/'.strtolower($module).'/database/migrations'); $this->note($module); + foreach ($this->migrator->getNotes() as $note) { $this->note(' - '.$note); } + return $this; } @@ -466,13 +472,17 @@ class UpdateManager return; } - $this->versionManager->resetNotes(); + $this->note($name); + + $this->versionManager->resetNotes()->setNotesOutput($this->notesOutput); + if ($this->versionManager->updatePlugin($plugin) !== false) { - $this->note($name); + foreach ($this->versionManager->getNotes() as $note) { - $this->note(' - '.$note); + $this->note($note); } } + return $this; } @@ -689,11 +699,17 @@ class UpdateManager /** * Raise a note event for the migrator. * @param string $message - * @return void + * @return self */ protected function note($message) { - $this->notes[] = $message; + if ($this->notesOutput !== null) { + $this->notesOutput->writeln($message); + } + else { + $this->notes[] = $message; + } + return $this; } @@ -708,11 +724,26 @@ class UpdateManager /** * Resets the notes store. - * @return array + * @return self */ public function resetNotes() { + $this->notesOutput = null; + $this->notes = []; + + return $this; + } + + /** + * Sets an output stream for writing notes. + * @param Illuminate\Console\Command $output + * @return self + */ + public function setNotesOutput($output) + { + $this->notesOutput = $output; + return $this; } diff --git a/modules/system/classes/VersionManager.php b/modules/system/classes/VersionManager.php index 05576e27e..be19b3a2f 100644 --- a/modules/system/classes/VersionManager.php +++ b/modules/system/classes/VersionManager.php @@ -36,6 +36,11 @@ class VersionManager */ protected $notes = []; + /** + * @var \Illuminate\Console\OutputStyle + */ + protected $notesOutput; + /** * Cache of plugin versions as files. */ @@ -85,7 +90,7 @@ class VersionManager // No updates needed if ($currentVersion == $databaseVersion) { - $this->note('Nothing to update.'); + $this->note('- Nothing to update.'); return; } @@ -150,7 +155,7 @@ class VersionManager $this->setDatabaseVersion($code, $version); - $this->note(sprintf('v%s: %s', $version, $comment)); + $this->note(sprintf('- v%s: %s', $version, $comment)); } /** @@ -471,7 +476,13 @@ class VersionManager */ protected function note($message) { - $this->notes[] = $message; + if ($this->notesOutput !== null) { + $this->notesOutput->writeln($message); + } + else { + $this->notes[] = $message; + } + return $this; } @@ -486,11 +497,26 @@ class VersionManager /** * Resets the notes store. - * @return array + * @return self */ public function resetNotes() { + $this->notesOutput = null; + $this->notes = []; + + return $this; + } + + /** + * Sets an output stream for writing notes. + * @param Illuminate\Console\Command $output + * @return self + */ + public function setNotesOutput($output) + { + $this->notesOutput = $output; + return $this; } } diff --git a/modules/system/console/OctoberDown.php b/modules/system/console/OctoberDown.php index acb7595cd..fbaf42997 100644 --- a/modules/system/console/OctoberDown.php +++ b/modules/system/console/OctoberDown.php @@ -15,7 +15,6 @@ use Symfony\Component\Console\Input\InputArgument; */ class OctoberDown extends Command { - use \Illuminate\Console\ConfirmableTrait; /** @@ -45,11 +44,10 @@ class OctoberDown extends Command return; } - $manager = UpdateManager::instance()->resetNotes()->uninstall(); - - foreach ($manager->getNotes() as $note) { - $this->output->writeln($note); - } + UpdateManager::instance() + ->setNotesOutput($this->output) + ->uninstall() + ; } /** diff --git a/modules/system/console/OctoberInstall.php b/modules/system/console/OctoberInstall.php index 31badc7fa..4554a3f60 100644 --- a/modules/system/console/OctoberInstall.php +++ b/modules/system/console/OctoberInstall.php @@ -291,7 +291,11 @@ class OctoberInstall extends Command try { Db::purge(); - UpdateManager::instance()->resetNotes()->update(); + + UpdateManager::instance() + ->setNotesOutput($this->output) + ->update() + ; } catch (Exception $ex) { $this->error($ex->getMessage()); diff --git a/modules/system/console/OctoberUp.php b/modules/system/console/OctoberUp.php index b5a02e17a..bce7b1506 100644 --- a/modules/system/console/OctoberUp.php +++ b/modules/system/console/OctoberUp.php @@ -15,7 +15,6 @@ use Symfony\Component\Console\Input\InputArgument; */ class OctoberUp extends Command { - /** * The console command name. */ @@ -39,13 +38,12 @@ class OctoberUp extends Command */ public function fire() { - $manager = UpdateManager::instance()->resetNotes()->update(); - $this->output->writeln('Migrating application and plugins...'); - foreach ($manager->getNotes() as $note) { - $this->output->writeln($note); - } + UpdateManager::instance() + ->setNotesOutput($this->output) + ->update() + ; } /** diff --git a/modules/system/console/OctoberUpdate.php b/modules/system/console/OctoberUpdate.php index 7a40e7214..b5186c5e7 100644 --- a/modules/system/console/OctoberUpdate.php +++ b/modules/system/console/OctoberUpdate.php @@ -44,7 +44,7 @@ class OctoberUpdate extends Command public function fire() { $this->output->writeln('Updating October...'); - $manager = UpdateManager::instance()->resetNotes(); + $manager = UpdateManager::instance()->setNotesOutput($this->output); $forceUpdate = $this->option('force'); /* @@ -66,7 +66,7 @@ class OctoberUpdate extends Command * Perform update */ $updateList = $manager->requestUpdateList($forceUpdate); - $updates = (int)array_get($updateList, 'update', 0); + $updates = (int) array_get($updateList, 'update', 0); if ($updates == 0) { $this->output->writeln('No new updates found'); diff --git a/modules/system/console/PluginInstall.php b/modules/system/console/PluginInstall.php index 546c1cab9..49e62f40d 100644 --- a/modules/system/console/PluginInstall.php +++ b/modules/system/console/PluginInstall.php @@ -45,7 +45,7 @@ class PluginInstall extends Command public function fire() { $pluginName = $this->argument('name'); - $manager = UpdateManager::instance()->resetNotes(); + $manager = UpdateManager::instance()->setNotesOutput($this->output); $pluginDetails = $manager->requestPluginDetails($pluginName); @@ -64,10 +64,6 @@ class PluginInstall extends Command $this->output->writeln(sprintf('Migrating plugin...', $code)); PluginManager::instance()->loadPlugins(); $manager->updatePlugin($code); - - foreach ($manager->getNotes() as $note) { - $this->output->writeln($note); - } } /** diff --git a/modules/system/console/PluginRefresh.php b/modules/system/console/PluginRefresh.php index 7358e1729..5888da71a 100644 --- a/modules/system/console/PluginRefresh.php +++ b/modules/system/console/PluginRefresh.php @@ -45,26 +45,27 @@ class PluginRefresh extends Command */ public function fire() { + /* + * Lookup plugin + */ $pluginName = $this->argument('name'); $pluginName = PluginManager::instance()->normalizeIdentifier($pluginName); if (!PluginManager::instance()->exists($pluginName)) { throw new \InvalidArgumentException(sprintf('Plugin "%s" not found.', $pluginName)); } - $manager = UpdateManager::instance()->resetNotes(); + $manager = UpdateManager::instance()->setNotesOutput($this->output); + /* + * Rollback plugin + */ $manager->rollbackPlugin($pluginName); - foreach ($manager->getNotes() as $note) { - $this->output->writeln($note); - } - $manager->resetNotes(); + /* + * Update plugin + */ $this->output->writeln('Reinstalling plugin...'); $manager->updatePlugin($pluginName); - - foreach ($manager->getNotes() as $note) { - $this->output->writeln($note); - } } /** diff --git a/modules/system/console/PluginRemove.php b/modules/system/console/PluginRemove.php index df2d743c4..e256f3938 100644 --- a/modules/system/console/PluginRemove.php +++ b/modules/system/console/PluginRemove.php @@ -63,13 +63,9 @@ class PluginRemove extends Command /* * Rollback plugin */ - $manager = UpdateManager::instance()->resetNotes(); + $manager = UpdateManager::instance()->setNotesOutput($this->output); $manager->rollbackPlugin($pluginName); - foreach ($manager->getNotes() as $note) { - $this->output->writeln($note); - } - /* * Delete from file system */