From 80b5d9ceae5ffda41e808aca5cb51b27d91b8024 Mon Sep 17 00:00:00 2001 From: Alexey Ch Date: Thu, 2 Jun 2016 14:37:44 +0500 Subject: [PATCH 1/2] Add compatibility to StaticCache Plugin v2 https://github.com/opengeek/statcache --- .../ajaxform/model/ajaxform/ajaxform.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/components/ajaxform/model/ajaxform/ajaxform.class.php b/core/components/ajaxform/model/ajaxform/ajaxform.class.php index ad54974..e6f4bbf 100644 --- a/core/components/ajaxform/model/ajaxform/ajaxform.class.php +++ b/core/components/ajaxform/model/ajaxform/ajaxform.class.php @@ -102,7 +102,20 @@ public function loadJsCss($objectName = 'AjaxForm') public function process($action, array $fields = array()) { if (!isset($_SESSION['AjaxForm'][$action])) { - return $this->error('af_err_action_nf'); + if ($res = $this->modx->getObject('modResource',$fields['pageId'])){ + $tpl = $this->modx->getObject('modTemplate',$res->template); + $tpl = $tpl->content; + preg_match_all('/{\$_modx->runSnippet\(\'!Ajaxform\',\s((?:(?!\)}).)*)/i', $tpl, $matches); + if(isset($matches[1][0])){ + eval('$scriptProperties = '. $matches[1][0] .';'); + if ($scriptProperties){ + $_SESSION['AjaxForm'][$action] = $scriptProperties; + } + else return $this->error('af_err_action_nf'); + } + else return $this->error('af_err_action_nf'); + } + else return $this->error('af_err_action_nf'); } unset($fields['af_action'], $_POST['af_action']); From 0c542d67ee524eb7cbe5ac6bd94c47dc9f0229f7 Mon Sep 17 00:00:00 2001 From: Alexey Ch Date: Tue, 20 Feb 2018 13:36:24 +0500 Subject: [PATCH 2/2] Update ajaxform.class.php --- core/components/ajaxform/model/ajaxform/ajaxform.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/components/ajaxform/model/ajaxform/ajaxform.class.php b/core/components/ajaxform/model/ajaxform/ajaxform.class.php index e6f4bbf..af9500a 100644 --- a/core/components/ajaxform/model/ajaxform/ajaxform.class.php +++ b/core/components/ajaxform/model/ajaxform/ajaxform.class.php @@ -105,7 +105,7 @@ public function process($action, array $fields = array()) if ($res = $this->modx->getObject('modResource',$fields['pageId'])){ $tpl = $this->modx->getObject('modTemplate',$res->template); $tpl = $tpl->content; - preg_match_all('/{\$_modx->runSnippet\(\'!Ajaxform\',\s((?:(?!\)}).)*)/i', $tpl, $matches); + preg_match_all('/{\$_modx->runSnippet\(\'(?:!Ajaxform|@FILE\s[^\']*\/snippet\.ajaxform\.php)\',\s((?:(?!\)}).)*)/i', $tpl, $matches); if(isset($matches[1][0])){ eval('$scriptProperties = '. $matches[1][0] .';'); if ($scriptProperties){