-
Notifications
You must be signed in to change notification settings - Fork 3
/
add.php
45 lines (37 loc) · 1.67 KB
/
add.php
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
<?php
require_once("../../global/library.php");
use FormTools\Core;
use FormTools\Modules;
use FormTools\Modules\HooksManager\Rules;
$module = Modules::initModulePage("admin");
$LANG = Core::$L;
$L = $module->getLangStrings();
$hook_info = Rules::getHooks();
$code_hooks = Rules::groupHooksByFile($hook_info["code_hooks"]);
$template_hooks = Rules::groupHooksByFile($hook_info["template_hooks"]);
$js_code_hooks = "var code_hooks = " . json_encode($code_hooks);
$js_template_hooks = "var template_hooks = " . json_encode($template_hooks);
$page_vars = array(
"head_title" => $L["phrase_add_rule"],
"code_hooks" => $code_hooks,
"template_hooks" => $template_hooks
);
$page_vars["head_js"] =<<< EOF
$js_code_hooks
$js_template_hooks
var rules = [];
rules.push("required,rule_name,{$L["validation_no_rule_name"]}");
rules.push("required,hook_type,{$L["validation_no_hook_type"]}");
rules.push("if:hook_type=code,required,code_hook_dropdown,{$L["validation_no_code_hook"]}");
rules.push("if:hook_type=template,required,template_hook_dropdown,{$L["validation_no_template_hook"]}");
rules.push("if:hook_type=template,required,template_hook_code_type,{$L["validation_no_content_type"]}");
rules.push("if:hook_type=custom,required,custom_hook,{$L["validation_no_custom_hook"]}");
rules.push("if:hook_type=custom,reg_exp,custom_hook,^[a-zA-Z0-9_]+$,{$L["validation_invalid_custom_hook_name"]}");
rules.push("if:hook_type=custom,required,custom_hook_code_type,{$L["validation_no_content_type"]}");
if (hm === undefined) {
var hm = {};
}
hm.current_code_hook_type = "code";
$(hm.init_page);
EOF;
$module->displayPage("templates/add.tpl", $page_vars);