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: [{