Skip to content

Commit 363cf44

Browse files
committed
Starting on FT3 update
1 parent 3a372b4 commit 363cf44

23 files changed

Lines changed: 2370 additions & 2572 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
## module-system_check
22

33
This module replaces the older Database Integrity module. It offers a few simple, quick tests to run on your Form Tools
4-
installation: kind of like taking your car to get it serviced - except this is free!
4+
installation: kind of like taking your car to get it serviced.
55

66
### Documentation
77

8-
[http://modules.formtools.org/system_check/](http://modules.formtools.org/system_check/)
8+
[https://docs.formtools.org/modules/system_check/](https://docs.formtools.org/modules/system_check/)
99

1010
### Form Tools Extensions
1111

12-
For further information about Form Tools extensions, check out the following link:
13-
[http://www.formtools.org/extensions.php](http://www.formtools.org/extensions.php)
12+
For a full list of Form Tools modules, see:
13+
[https://modules.formtools.org/](https://modules.formtools.org/)

files.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<?php
22

33
require_once("../../global/library.php");
4-
ft_init_module_page();
4+
5+
use FormTools\Modules\Files;
6+
use FormTools\Modules\General;
7+
8+
9+
ft_init_module_page();
510

611
$settings = ft_get_settings();
712
$core_version = ($settings["release_type"] == "beta") ? "{$settings["program_version"]}-beta-{$settings["release_date"]}" : $settings["program_version"];
@@ -13,8 +18,8 @@
1318

1419
$page_vars = array();
1520
$page_vars["core_version"] = $core_version;
16-
$page_vars["module_list"] = sc_get_compatible_modules("files");
17-
$page_vars["theme_list"] = sc_get_compatible_themes();
21+
$page_vars["module_list"] = General::getCompatibleModules("files");
22+
$page_vars["theme_list"] = Files::getCompatibleThemes();
1823
$page_vars["head_string"] =<<< EOF
1924
<script src="{$g_root_url}/modules/system_check/global/scripts/tests.js"></script>
2025
<link type="text/css" rel="stylesheet" href="{$g_root_url}/modules/system_check/global/css/styles.css">

ft3.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

global/code/Files.class.php

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
3+
4+
namespace FormTools\Modules\SystemCheck;
5+
6+
use FormTools\Core;
7+
use FormTools\Themes;
8+
9+
10+
class Files
11+
{
12+
/**
13+
* Helper function to return a list of files that are missing from the Core.
14+
*
15+
* @return array
16+
*/
17+
public static function checkCoreFiles()
18+
{
19+
$root_dir = Core::getRootDir();
20+
21+
if (!is_file("$root_dir/global/misc/config_core.php")) {
22+
return array();
23+
}
24+
25+
require_once("$root_dir/global/misc/config_core.php");
26+
27+
if (!isset($FILES)) {
28+
return array();
29+
}
30+
31+
$missing_files = array();
32+
foreach ($FILES as $file) {
33+
// ignore the install/ folder folder + files
34+
if (preg_match("/^install/", $file)) {
35+
continue;
36+
}
37+
38+
if (!is_file("$root_dir/$file") && !is_dir("$root_dir/$file")) {
39+
$missing_files[] = $file;
40+
}
41+
}
42+
43+
return $missing_files;
44+
}
45+
46+
47+
/**
48+
* Helper function to look at all installed themes and see which are compatible with the File Verification
49+
* test (i.e. which have a theme_config.php file defined in the root).
50+
*/
51+
public static function getCompatibleThemes()
52+
{
53+
$root_dir = Core::getRootDir();
54+
$themes = Themes::getList();
55+
56+
$compatible_themes = array();
57+
foreach ($themes as $theme_info) {
58+
$theme_folder = $theme_info["theme_folder"];
59+
60+
if (is_file("$root_dir/themes/$theme_folder/theme_config.php")) {
61+
$compatible_themes[] = $theme_info;
62+
}
63+
}
64+
65+
return $compatible_themes;
66+
}
67+
68+
69+
public static function checkModuleFiles($module_folder)
70+
{
71+
$root_dir = Core::getRootDir();
72+
$file = "$root_dir/modules/$module_folder/module_config.php";
73+
if (!is_file($file)) {
74+
return array();
75+
}
76+
77+
require_once($file);
78+
79+
if (!isset($FILES)) {
80+
return array();
81+
}
82+
83+
$missing_files = array();
84+
$root = "modules/$module_folder";
85+
foreach ($FILES as $file) {
86+
if (!is_file("$root_dir/$root/$file") && !is_dir("$root_dir/$root/$file")) {
87+
$missing_files[] = "$root/$file";
88+
}
89+
}
90+
91+
return $missing_files;
92+
}
93+
94+
95+
public static function checkThemeFiles($theme_folder)
96+
{
97+
$root_dir = Core::getRootDir();
98+
$file = "$root_dir/themes/$theme_folder/theme_config.php";
99+
if (!is_file($file)) {
100+
return array();
101+
}
102+
103+
require_once($file);
104+
105+
if (!isset($FILES)) {
106+
return array();
107+
}
108+
109+
$missing_files = array();
110+
$root = "themes/$theme_folder";
111+
foreach ($FILES as $file) {
112+
if (!is_file("$root_dir/$root/$file") && !is_dir("$root_dir/$root/$file")) {
113+
$missing_files[] = "$root/$file";
114+
}
115+
}
116+
117+
return $missing_files;
118+
}
119+
120+
}

0 commit comments

Comments
 (0)