From e640b0d4316933c05acb6fb7e097d4e1006eaa3e Mon Sep 17 00:00:00 2001 From: Nikolay Lanets Date: Thu, 3 Sep 2015 13:42:28 +0300 Subject: [PATCH 1/5] Update savefile.class.php --- core/components/console/processors/savefile.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/components/console/processors/savefile.class.php b/core/components/console/processors/savefile.class.php index 9e354cf..caeff63 100644 --- a/core/components/console/processors/savefile.class.php +++ b/core/components/console/processors/savefile.class.php @@ -1,6 +1,9 @@ getProperty('code','')); $fileName = basename(trim($this->getProperty('name',''))); @@ -12,4 +15,4 @@ public function process() { } } -return 'ConsoleSaveFileProcessor'; \ No newline at end of file +return 'ConsoleSaveFileProcessor'; From a3038f54634d178045cb8ef4b3f2a3b75c555bad Mon Sep 17 00:00:00 2001 From: sergant210 Date: Thu, 3 Sep 2015 13:48:43 +0300 Subject: [PATCH 2/5] Edit savefile processor --- core/components/console/processors/savefile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/components/console/processors/savefile.class.php b/core/components/console/processors/savefile.class.php index caeff63..70d3356 100644 --- a/core/components/console/processors/savefile.class.php +++ b/core/components/console/processors/savefile.class.php @@ -9,7 +9,7 @@ public function process() { $fileName = basename(trim($this->getProperty('name',''))); $path = $this->modx->getOption('console_core_path', NULL, $this->modx->getOption('core_path') . 'components/console/').'files/'; if (!is_dir($path) && !mkdir($path,0755)) $this->failure($this->modx->lexicon('console_err_path_nf')); - if (!empty($code)) file_put_contents($path.$fileName.'.php', $code ); + if (!empty($code) && $fileName) file_put_contents($path.$fileName.'.php', $code ); return $this->success(); } From c58536c5386f4ae414de43ab261a1e5cee6cc157 Mon Sep 17 00:00:00 2001 From: sergant210 Date: Thu, 3 Sep 2015 14:36:10 +0300 Subject: [PATCH 3/5] Edit savefile processor --- .../console/lexicon/en/default.inc.php | 1 + .../console/lexicon/ru/default.inc.php | 1 + .../console/processors/savefile.class.php | 18 +++++++++++++++--- .../console/js/widgets/console.panel.js | 3 +++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/core/components/console/lexicon/en/default.inc.php b/core/components/console/lexicon/en/default.inc.php index 166c61a..fe88bf4 100644 --- a/core/components/console/lexicon/en/default.inc.php +++ b/core/components/console/lexicon/en/default.inc.php @@ -26,6 +26,7 @@ $_lang['console_err_file_nf'] = 'The file does not exist!'; $_lang['console_err_files_nf'] = 'Did not find any files!'; $_lang['console_err_file_ns'] = 'File is not specified!'; +$_lang['console_err_file_nsp'] = 'Specify the file name!'; $_lang['console_err_snippet_ns'] = 'No snippet specified!'; $_lang['console_err_snippet_nf'] = 'Snippet not found!'; $_lang['console_err_snippet_ae'] = 'Snippet already exists!'; \ No newline at end of file diff --git a/core/components/console/lexicon/ru/default.inc.php b/core/components/console/lexicon/ru/default.inc.php index ccb9399..f7bf5f1 100644 --- a/core/components/console/lexicon/ru/default.inc.php +++ b/core/components/console/lexicon/ru/default.inc.php @@ -26,6 +26,7 @@ $_lang['console_err_file_nf'] = 'Файл не найден!'; $_lang['console_err_files_nf'] = 'Файлы не найдены!'; $_lang['console_err_file_ns'] = 'Файл не выбран!'; +$_lang['console_err_file_nsp'] = 'Укажите имя файла!'; $_lang['console_err_snippet_ns'] = 'Сниппет не выбран!'; $_lang['console_err_snippet_nf'] = 'Сниппет не найден!'; $_lang['console_err_snippet_ae'] = 'Сниппет с таким именем уже существует!'; \ No newline at end of file diff --git a/core/components/console/processors/savefile.class.php b/core/components/console/processors/savefile.class.php index 70d3356..920a71a 100644 --- a/core/components/console/processors/savefile.class.php +++ b/core/components/console/processors/savefile.class.php @@ -1,15 +1,27 @@ getProperty('code','')); $fileName = basename(trim($this->getProperty('name',''))); + $fileName = $this->modx->sanitizeString($fileName); + if (empty($fileName)) { + $this->addFieldError('name',$this->modx->lexicon('console_err_file_nsp')); + return $this->failure($this->modx->lexicon('console_err_file_nsp')); + } + $path = $this->modx->getOption('console_core_path', NULL, $this->modx->getOption('core_path') . 'components/console/').'files/'; if (!is_dir($path) && !mkdir($path,0755)) $this->failure($this->modx->lexicon('console_err_path_nf')); - if (!empty($code) && $fileName) file_put_contents($path.$fileName.'.php', $code ); + + $file = $path . $fileName . '.php'; + if (!empty($code)) { + file_put_contents($file, $code); + } else { + unlink($file); + } return $this->success(); } diff --git a/manager/components/console/js/widgets/console.panel.js b/manager/components/console/js/widgets/console.panel.js index e5f6f86..b0cb96e 100644 --- a/manager/components/console/js/widgets/console.panel.js +++ b/manager/components/console/js/widgets/console.panel.js @@ -317,6 +317,7 @@ Ext.extend(ModConsole.panel.CodeEditor,MODx.Panel, { }, { xtype: 'textfield', name: 'name', + allowBlank: false, value: ModConsole.snippetName || 'test', anchor: '100%' }, { @@ -356,6 +357,7 @@ Ext.extend(ModConsole.panel.CodeEditor,MODx.Panel, { }, { xtype: 'textfield', name: 'name', + allowBlank: false, fieldLabel: _('console_enter_file_name'), value: ModConsole.fileName || 'test', anchor: '100%' @@ -385,6 +387,7 @@ ModConsole.window.SaveCode = function (config) { Ext.applyIf(config, { width: 300, + autoHeight: true, modal: true, url: 'components/console/connectors/console.php', keys: [{ From b722d1f12f4c2093e2c6b93e09a3962caefad260 Mon Sep 17 00:00:00 2001 From: sergant210 Date: Thu, 3 Sep 2015 18:58:02 +0300 Subject: [PATCH 4/5] Edit savefile processor --- core/components/console/processors/savefile.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/components/console/processors/savefile.class.php b/core/components/console/processors/savefile.class.php index 920a71a..4da1583 100644 --- a/core/components/console/processors/savefile.class.php +++ b/core/components/console/processors/savefile.class.php @@ -4,6 +4,10 @@ class ConsoleSaveFileProcessor extends modProcessor{ public $permission = 'console.save_file'; + public function checkPermissions() { + return !empty($this->permission) ? $this->modx->hasPermission($this->permission) : true; + } + public function process() { $code = trim($this->getProperty('code','')); $fileName = basename(trim($this->getProperty('name',''))); From 0c1ce20bd57e071326eb19587f67126098b742ad Mon Sep 17 00:00:00 2001 From: Nikolay Lanets Date: Fri, 4 Sep 2015 17:20:38 +0300 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../console/js/widgets/console.panel.js | 120 ++++++++---------- 1 file changed, 55 insertions(+), 65 deletions(-) diff --git a/manager/components/console/js/widgets/console.panel.js b/manager/components/console/js/widgets/console.panel.js index b0cb96e..ac09ebd 100644 --- a/manager/components/console/js/widgets/console.panel.js +++ b/manager/components/console/js/widgets/console.panel.js @@ -110,67 +110,60 @@ ModConsole.panel.CodeEditor = function(config) { } ,value: this.getCodeEditorValue() },{ - bodyCssClass: 'panel-desc' - ,border: false - ,items: [{ - xtype: 'button' - , text: _('console_exec') - , listeners: { - click: function () { - this.request(); - } - , scope: this - } - },{ - xtype: 'button' - ,text: _('console_save') - ,style: 'marginLeft:10px; float:right' - ,menu: { - items: [{ - text: _('console_save_to_file'), - handler: function() { - this.saveFile(); - }, - scope: this - }, { - text: _('console_save_snippet'), - handler: function() { - this.saveSnippet(); - }, - scope: this - }] - } - ,handler: function(){return false;} - }, { - xtype: 'button' - , text: _('console_load') - , style: 'marginLeft:10px; float:right' - , menu: { - items: [{ - text: _('console_load_from_file'), - handler: function () { - this.getFiles(); - }, - scope: this - }, { - text: _('console_load_from_snippet'), - handler: function () { - this.getSnippets(); - }, - scope: this - }] - } - , handler: function () { - return false; - } - }, { - xtype: 'button' - , text: _('console_clear') - , style: 'float:right' - , handler: function () { - Ext.getCmp('mod-console-codeeditor').setValue('' + ,{ + text: _('console_save') + ,menu: { + items: [{ + text: _('console_save_to_file'), + handler: function() { + this.saveFile(); + }, + scope: this + },{ + text: _('console_save_snippet'), + handler: function() { + this.saveSnippet(); + }, + scope: this + }] + } + } + ,{ + text: _('console_load') + ,menu: { + items: [{ + text: _('console_load_from_file'), + handler: function () { + this.getFiles(); + }, + scope: this + },{ + text: _('console_load_from_snippet'), + handler: function () { + this.getSnippets(); + }, + scope: this + }] + } + },{ + text: _('console_clear') + ,handler: function () { + Ext.getCmp('mod-console-codeeditor').setValue('