From dec9b4709fe65df16eae27cb1bdb2f73b531911f Mon Sep 17 00:00:00 2001 From: yama Date: Fri, 31 Oct 2014 07:40:48 +0900 Subject: [PATCH 1/2] Refactor --- install/assets/plugins/systemField_plugin.tpl | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/install/assets/plugins/systemField_plugin.tpl b/install/assets/plugins/systemField_plugin.tpl index 20af548..3a3daf5 100644 --- a/install/assets/plugins/systemField_plugin.tpl +++ b/install/assets/plugins/systemField_plugin.tpl @@ -24,6 +24,7 @@ Configurtion: */ defined('IN_MANAGER_MODE') or die(); +if ($modx->event->name !== 'OnDocFormRender') return; if(empty($separator)) $separator = ''; if(empty($open_text)) $open_text = 'system content'; @@ -31,10 +32,6 @@ if(empty($position)) $position = 'after'; $get_action = isset($_GET['a']) ? $_GET['a'] : 27; -$e = &$modx->Event; - -if ($e->name == 'OnDocFormRender') { - $output = <<< OUT @@ -148,6 +145,4 @@ window.addEvent('domready', function(){ OUT; -$e->output($output); - -} +$modx->event->output($output); From af14e1040bfac92cda15dfd8b131411610aba4b8 Mon Sep 17 00:00:00 2001 From: yama Date: Fri, 31 Oct 2014 08:11:09 +0900 Subject: [PATCH 2/2] Refactor --- assets/plugins/systemField.js.inc | 108 +++++++++++++++ install/assets/plugins/systemField_plugin.tpl | 129 ++---------------- 2 files changed, 121 insertions(+), 116 deletions(-) create mode 100644 assets/plugins/systemField.js.inc diff --git a/assets/plugins/systemField.js.inc b/assets/plugins/systemField.js.inc new file mode 100644 index 0000000..10df3af --- /dev/null +++ b/assets/plugins/systemField.js.inc @@ -0,0 +1,108 @@ + + + diff --git a/install/assets/plugins/systemField_plugin.tpl b/install/assets/plugins/systemField_plugin.tpl index 3a3daf5..caf83b1 100644 --- a/install/assets/plugins/systemField_plugin.tpl +++ b/install/assets/plugins/systemField_plugin.tpl @@ -28,121 +28,18 @@ if ($modx->event->name !== 'OnDocFormRender') return; if(empty($separator)) $separator = ''; if(empty($open_text)) $open_text = 'system content'; -if(empty($position)) $position = 'after'; - -$get_action = isset($_GET['a']) ? $_GET['a'] : 27; - -$output = <<< OUT - - - - - -OUT; +if(empty($position)) $position = 'after'; + +$ph['separator'] = $separator; +$ph['open_text'] = $open_text; +$ph['position'] = $position; +$ph['get_action'] = isset($_GET['a']) ? $_GET['a'] : 27;; +$output = file_get_contents(MODX_BASE_PATH . 'assets/plugins/systemField/systemField.js.inc'); + +foreach($ph as $k=>$v) +{ + $k = "[+{$k}+]"; + $output = str_replace($k,$v,$output); +} $modx->event->output($output);