ajax.php
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
class N2Ajax
{
public function parseRequest() {
$mode = N2Request::getVar('mode');
switch ($mode) {
case 'pluginmethod':
$this->pluginmethod();
break;
default:
return;
break;
}
}
public function subform($appType, $configurationXmlFile, $values, $control_name, $name) {
if (N2Filesystem::fileexists($configurationXmlFile)) {
N2Loader::import('libraries.form.form');
$form = new N2Form($appType);
$form->loadArray($values);
//$subformValue = array();
//$subformValue[N2Post::getVar('name')] = N2Post::getVar('value');
//$form->loadArray($subformValue);
$form->loadXMLFile($configurationXmlFile);
n2_ob_end_clean_all(); // To clear the output of the platform
ob_start();
$subform = $form->getSubFormAjax(N2Post::getVar('tab'), $name);
$subform->initAjax($control_name);
echo $subform->renderForm();
//echo N2AssetsManager::generateAjaxCSS();
$scripts = N2AssetsManager::generateAjaxJS();
$html = ob_get_clean();
$response = array(
'html' => $html,
'scripts' => $scripts
);
} else {
$response = array('error' => 'Configuration file not found: ' . $configurationXmlFile);
}
return $response;
}
}