Skip to content

Commit 360401d

Browse files
committed
update for new Module structure
1 parent 06f5a3a commit 360401d

21 files changed

+730
-749
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

code/Module.class.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace FormTools\Modules\SystemCheck;
4+
5+
6+
use FormTools\Module as FormToolsModule;
7+
8+
9+
class Module extends FormToolsModule
10+
{
11+
// required properties
12+
protected $moduleName = "System Check";
13+
protected $author = "Ben Keen";
14+
protected $authorEmail = "[email protected]";
15+
protected $authorLink = "http://formtools.org";
16+
protected $version = "2.1.0";
17+
protected $date = "2017-09-23";
18+
protected $originLanguage = "en_us";
19+
20+
protected $jsFiles = array("scripts/tests.js");
21+
protected $cssFiles = array("css/styles.css");
22+
23+
protected $nav = array(
24+
"module_name" => array("index.php", false),
25+
"phrase_file_verification" => array("files.php", true),
26+
"phrase_table_verification" => array("tables.php", true),
27+
"phrase_hook_verification" => array("hooks.php", true),
28+
"phrase_orphan_clean_up" => array("orphans.php", true),
29+
"phrase_environment_info" => array("env.php", false),
30+
"word_help" => array("help.php", false)
31+
);
32+
}
File renamed without changes.
File renamed without changes.
+121-123
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,121 @@
1-
<?php
2-
3-
/**
4-
* actions.php
5-
*
6-
* This file handles all server-side responses for Ajax requests. All information is returned in JSON
7-
* format.
8-
*/
9-
10-
require_once("../../../../global/library.php");
11-
12-
use FormTools\Core;
13-
use FormTools\Modules;
14-
use FormTools\Settings;
15-
use FormTools\Themes;
16-
17-
use FormTools\Modules\SystemCheck\Files;
18-
use FormTools\Modules\SystemCheck\General;
19-
use FormTools\Modules\SystemCheck\Hooks;
20-
use FormTools\Modules\SystemCheck\Tables;
21-
use FormTools\Modules\SystemCheck\Orphans;
22-
23-
Core::init();
24-
Core::$user->checkAuth("admin");
25-
Modules::initModulePage();
26-
27-
// the action to take and the ID of the page where it will be displayed (allows for
28-
// multiple calls on same page to load content in unique areas)
29-
$request = array_merge($_GET, $_POST);
30-
$action = $request["action"];
31-
$settings = Settings::get();
32-
$root_dir = Core::getRootDir();
33-
34-
switch ($action) {
35-
36-
// Stage 1 of the Table Verification test: returns a list of tables to test for a particular component
37-
case "get_component_tables":
38-
$component = $request["component"];
39-
40-
// N.B. from 2.1.5 onwards, the Core stores its own DB structure
41-
if ($component == "core") {
42-
require_once("$root_dir/global/misc/config_core.php");
43-
$tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE));
44-
} else {
45-
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
46-
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
47-
$tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"]));
48-
}
49-
echo json_encode(array("tables" => $tables));
50-
break;
51-
52-
// Stage 2 of the Table Verification test: verifies the table structure
53-
case "verify_table":
54-
$component = $request["component"];
55-
if ($component == "core") {
56-
require_once("$root_dir/global/misc/config_core.php");
57-
$info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]);
58-
$info["table_name"] = $request["table_name"];
59-
echo json_encode($info);
60-
} else {
61-
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
62-
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
63-
$info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]);
64-
$info["table_name"] = $request["table_name"];
65-
echo json_encode($info);
66-
}
67-
break;
68-
69-
// verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks
70-
// in a single step and returns the result
71-
case "verify_module_hooks":
72-
$module_id = $request["module_id"];
73-
$module_info = Modules::getModule($module_id);
74-
$module_folder = $module_info["module_folder"];
75-
$module_version = $module_info["version"];
76-
$result = Hooks::verifyModuleHooks($module_folder);
77-
78-
echo json_encode(array(
79-
"module_id" => $module_id,
80-
"module_folder" => $module_folder,
81-
"module_name" => $module_info["module_name"],
82-
"result" => $result
83-
));
84-
break;
85-
86-
case "verify_component_files":
87-
$component = $request["component"];
88-
89-
$return_info = array("result" => "pass");
90-
if ($component == "core") {
91-
$missing_files = Files::checkCoreFiles();
92-
$return_info["component_type"] = "core";
93-
$return_info["component_name"] = "Form Tools Core";
94-
}
95-
if (preg_match("/^module_/", $component)) {
96-
$module_id = preg_replace("/^module_/", "", $component);
97-
$module_info = Modules::getModule($module_id);
98-
$missing_files = Files::checkModuleFiles($module_info["module_folder"]);
99-
$return_info["component_type"] = "module";
100-
$return_info["component_name"] = $module_info["module_name"];
101-
}
102-
if (preg_match("/^theme_/", $component)) {
103-
$theme_id = preg_replace("/^theme_/", "", $component);
104-
$theme_info = Themes::getTheme($theme_id);
105-
$missing_files = Files::checkThemeFiles($theme_info["theme_folder"]);
106-
$return_info["component_type"] = "theme";
107-
$return_info["component_name"] = $theme_info["theme_name"];
108-
}
109-
if (!empty($missing_files)) {
110-
$return_info["result"] = "fail";
111-
$return_info["missing_files"] = $missing_files;
112-
}
113-
echo json_encode($return_info);
114-
break;
115-
116-
case "find_table_orphans":
117-
$remove_orphans = isset($request["remove_orphans"]) ? true : false;
118-
$results = Orphans::findTableOrphans($request["table_name"], $remove_orphans);
119-
echo json_encode($results);
120-
break;
121-
}
122-
123-
1+
<?php
2+
3+
/**
4+
* actions.php
5+
*
6+
* This file handles all server-side responses for Ajax requests. All information is returned in JSON
7+
* format.
8+
*/
9+
10+
require_once("../../../global/library.php");
11+
12+
use FormTools\Core;
13+
use FormTools\Modules;
14+
use FormTools\Settings;
15+
use FormTools\Themes;
16+
17+
use FormTools\Modules\SystemCheck\Files;
18+
use FormTools\Modules\SystemCheck\General;
19+
use FormTools\Modules\SystemCheck\Hooks;
20+
use FormTools\Modules\SystemCheck\Tables;
21+
use FormTools\Modules\SystemCheck\Orphans;
22+
23+
$module = Modules::initModulePage("admin");
24+
25+
// the action to take and the ID of the page where it will be displayed (allows for
26+
// multiple calls on same page to load content in unique areas)
27+
$request = array_merge($_GET, $_POST);
28+
$action = $request["action"];
29+
$settings = Settings::get();
30+
$root_dir = Core::getRootDir();
31+
32+
switch ($action) {
33+
34+
// Stage 1 of the Table Verification test: returns a list of tables to test for a particular component
35+
case "get_component_tables":
36+
$component = $request["component"];
37+
38+
// N.B. from 2.1.5 onwards, the Core stores its own DB structure
39+
if ($component == "core") {
40+
require_once("$root_dir/global/misc/config_core.php");
41+
$tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE));
42+
} else {
43+
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
44+
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
45+
$tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"]));
46+
}
47+
echo json_encode(array("tables" => $tables));
48+
break;
49+
50+
// Stage 2 of the Table Verification test: verifies the table structure
51+
case "verify_table":
52+
$component = $request["component"];
53+
if ($component == "core") {
54+
require_once("$root_dir/global/misc/config_core.php");
55+
$info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]);
56+
$info["table_name"] = $request["table_name"];
57+
echo json_encode($info);
58+
} else {
59+
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
60+
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
61+
$info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]);
62+
$info["table_name"] = $request["table_name"];
63+
echo json_encode($info);
64+
}
65+
break;
66+
67+
// verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks
68+
// in a single step and returns the result
69+
case "verify_module_hooks":
70+
$module_id = $request["module_id"];
71+
$module_info = Modules::getModule($module_id);
72+
$module_folder = $module_info["module_folder"];
73+
$module_version = $module_info["version"];
74+
$result = Hooks::verifyModuleHooks($module_folder);
75+
76+
echo json_encode(array(
77+
"module_id" => $module_id,
78+
"module_folder" => $module_folder,
79+
"module_name" => $module_info["module_name"],
80+
"result" => $result
81+
));
82+
break;
83+
84+
case "verify_component_files":
85+
$component = $request["component"];
86+
87+
$return_info = array("result" => "pass");
88+
if ($component == "core") {
89+
$missing_files = Files::checkCoreFiles();
90+
$return_info["component_type"] = "core";
91+
$return_info["component_name"] = "Form Tools Core";
92+
}
93+
if (preg_match("/^module_/", $component)) {
94+
$module_id = preg_replace("/^module_/", "", $component);
95+
$module_info = Modules::getModule($module_id);
96+
$missing_files = Files::checkModuleFiles($module_info["module_folder"]);
97+
$return_info["component_type"] = "module";
98+
$return_info["component_name"] = $module_info["module_name"];
99+
}
100+
if (preg_match("/^theme_/", $component)) {
101+
$theme_id = preg_replace("/^theme_/", "", $component);
102+
$theme_info = Themes::getTheme($theme_id);
103+
$missing_files = Files::checkThemeFiles($theme_info["theme_folder"]);
104+
$return_info["component_type"] = "theme";
105+
$return_info["component_name"] = $theme_info["theme_name"];
106+
}
107+
if (!empty($missing_files)) {
108+
$return_info["result"] = "fail";
109+
$return_info["missing_files"] = $missing_files;
110+
}
111+
echo json_encode($return_info);
112+
break;
113+
114+
case "find_table_orphans":
115+
$remove_orphans = isset($request["remove_orphans"]) ? true : false;
116+
$results = Orphans::findTableOrphans($request["table_name"], $remove_orphans);
117+
echo json_encode($results);
118+
break;
119+
}
120+
121+
+42-42
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
.untested {
2-
color: #cccccc;
3-
}
4-
.passed {
5-
color: green;
6-
}
7-
.failed {
8-
color: red;
9-
}
10-
11-
table.log_table .full_log_heading {
12-
background-color: green;
13-
color: white;
14-
font-weight: bold;
15-
font-size: 8pt;
16-
padding-left: 3px;
17-
}
18-
table.log_table .error_log_heading {
19-
background-color: #990000;
20-
color: white;
21-
font-weight: bold;
22-
font-size: 8pt;
23-
padding-left: 3px;
24-
}
25-
table.log_table td {
26-
background-color: #efefef;
27-
}
28-
table.log_table textarea {
29-
width: 340px;
30-
height: 400px;
31-
font-size: 10px;
32-
line-height: 10pt;
33-
padding: 10px;
34-
}
35-
.list_table td img {
36-
margin-top: 4px;
37-
}
38-
39-
.index_link_table td {
40-
padding-bottom: 5px;
41-
}
42-
1+
.untested {
2+
color: #cccccc;
3+
}
4+
.passed {
5+
color: green;
6+
}
7+
.failed {
8+
color: red;
9+
}
10+
11+
table.log_table .full_log_heading {
12+
background-color: green;
13+
color: white;
14+
font-weight: bold;
15+
font-size: 8pt;
16+
padding-left: 3px;
17+
}
18+
table.log_table .error_log_heading {
19+
background-color: #990000;
20+
color: white;
21+
font-weight: bold;
22+
font-size: 8pt;
23+
padding-left: 3px;
24+
}
25+
table.log_table td {
26+
background-color: #efefef;
27+
}
28+
table.log_table textarea {
29+
width: 340px;
30+
height: 400px;
31+
font-size: 10px;
32+
line-height: 10pt;
33+
padding: 10px;
34+
}
35+
.list_table td img {
36+
margin-top: 4px;
37+
}
38+
39+
.index_link_table td {
40+
padding-bottom: 5px;
41+
}
42+
4343
tr.no_test td { color: #aaaaaa; }

env.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
use FormTools\General;
77
use FormTools\Modules;
88

9-
Core::init();
10-
Core::$user->checkAuth("admin");
11-
Modules::initModulePage();
12-
$L = Modules::getModuleLangFile("system_check", Core::$user->getLang());
9+
$module = Modules::initModulePage("admin");
10+
$L = $module->getLangStrings();
1311

1412
$page = Modules::loadModuleField("system_check", "page", "page", "summary");
1513
$root_url = Core::getRootUrl();

0 commit comments

Comments
 (0)