Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Add compatibility to StaticCache Plugin v2 #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion core/components/ajaxform/model/ajaxform/ajaxform.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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|@FILE\s[^\']*\/snippet\.ajaxform\.php)\',\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']);

Expand Down