- Some first changes to the system.module; tidied up some code, preparations
for theme settings and borrowing some ideas from Kjartan's long-awaited system.module patch.4.2.x
parent
37fe442d89
commit
ad9b03033a
|
@ -35,15 +35,16 @@ function system_perm() {
|
||||||
function system_link($type) {
|
function system_link($type) {
|
||||||
if ($type == "admin" && user_access("administer site configuration")) {
|
if ($type == "admin" && user_access("administer site configuration")) {
|
||||||
menu_add("site configuration", url("admin/system"), "Site configuration.", NULL, NULL, 2);
|
menu_add("site configuration", url("admin/system"), "Site configuration.", NULL, NULL, 2);
|
||||||
menu_add("site settings", url("admin/system/options"), "Site settings.", NULL, "site configuration", 1);
|
menu_add("module selector", url("admin/system/modules/selector"), "Module selector.", NULL, "site configuration", 1);
|
||||||
menu_add("content filters", url("admin/system/filters"), "Content filters.", NULL, "site configuration", 2);
|
menu_add("module settings", url("admin/system/modules/settings"), "Site settings.", NULL, "site configuration", 2);
|
||||||
menu_add("module selector", url("admin/system/modules"), "Module selector.", NULL, "site configuration", 3);
|
menu_add("theme selector", url("admin/system/themes/selector"), "Theme selector.", NULL, "site configuration", 3);
|
||||||
menu_add("theme selector", url("admin/system/themes"), "Theme selector.", NULL, "site configuration", 4);
|
// menu_add("theme settings", url("admin/system/themes/settings"), "Theme selector.", NULL, "site configuration", 4);
|
||||||
|
menu_add("content filters", url("admin/system/filters"), "Content filters.", NULL, "site configuration", 5);
|
||||||
menu_add("help", url("admin/system/help"), "Help.", NULL, "site configuration", 9);
|
menu_add("help", url("admin/system/help"), "Help.", NULL, "site configuration", 9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_view_options() {
|
function system_view_modules() {
|
||||||
global $conf, $cmodes, $corder;
|
global $conf, $cmodes, $corder;
|
||||||
|
|
||||||
// general settings:
|
// general settings:
|
||||||
|
@ -95,6 +96,17 @@ function system_view_options() {
|
||||||
$output .= "<h3><a name=\"$name\">". ucfirst(t("$name")) ." " . t("settings") . "</a></h3>". module_invoke($name, "conf_options") ."<hr />\n";
|
$output .= "<h3><a name=\"$name\">". ucfirst(t("$name")) ." " . t("settings") . "</a></h3>". module_invoke($name, "conf_options") ."<hr />\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function system_view_themes() {
|
||||||
|
foreach (theme_list() as $name) {
|
||||||
|
if (module_hook($name, "conf_options")) {
|
||||||
|
$output .= "<h3><a name=\"$name\">". ucfirst(t("$name")) ." " . t("settings") . "</a></h3>". module_invoke($name, "conf_options") ."<hr />\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +124,7 @@ function system_save($edit = array()) {
|
||||||
variable_set($name, $value);
|
variable_set($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return t("The configuration options have been saved.");
|
return t("the configuration options have been saved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_default($edit = array()) {
|
function system_default($edit = array()) {
|
||||||
|
@ -120,30 +132,33 @@ function system_default($edit = array()) {
|
||||||
variable_del($name);
|
variable_del($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return t("The configuration options have been reset to their default values.");
|
return t("the configuration options have been reset to their default values.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_view($type) {
|
function system_view($type) {
|
||||||
|
|
||||||
|
$links = array();
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "filters":
|
case "filters":
|
||||||
$form = system_view_filters();
|
$form = system_view_filters();
|
||||||
break;
|
break;
|
||||||
|
case "themes":
|
||||||
|
$form = system_view_themes();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
foreach (module_list() as $name) {
|
foreach (module_list() as $name) {
|
||||||
if (module_hook($name, "conf_options")) {
|
if (module_hook($name, "conf_options")) {
|
||||||
$links[] = l(t("$name"), "admin/system#$name");
|
$links[] = "<a href=\"#$name\">". t("$name") ."</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$form = system_view_modules();
|
||||||
$output = "<small>". implode(" :: ", $links) ."</small><hr />";
|
|
||||||
$form = system_view_options();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$form .= form_submit(t("Save configuration"));
|
$form .= form_submit(t("Save configuration"));
|
||||||
$form .= form_submit(t("Reset to defaults"));
|
$form .= form_submit(t("Reset to defaults"));
|
||||||
|
|
||||||
return $output . form($form);
|
print implode(" · ", $links) ."<br />". form($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_dirscan($dir, $mask, $nomask = array(".", "..", "CVS")) {
|
function system_dirscan($dir, $mask, $nomask = array(".", "..", "CVS")) {
|
||||||
|
@ -167,9 +182,21 @@ function system_dirscan($dir, $mask, $nomask = array(".", "..", "CVS")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_listing($type, $directory, $required = array()) {
|
function system_listing($type, $directory, $required = array()) {
|
||||||
|
$op = arg(2);
|
||||||
|
|
||||||
// Make sure we set $type correctly
|
// Make sure we set $type correctly
|
||||||
$type = $type != 'theme' ? "module" : "theme";
|
$type = $type != 'theme' ? "module" : "theme";
|
||||||
|
|
||||||
|
if ($op == t("Save $type settings")) {
|
||||||
|
db_query("UPDATE system SET status = '0' WHERE type = '%d'", $type);
|
||||||
|
foreach ($edit["status"] as $filename => $status) {
|
||||||
|
db_query("UPDATE system SET status = '%d' WHERE filename = '$filename'", $status);
|
||||||
|
}
|
||||||
|
cache_clear_all();
|
||||||
|
|
||||||
|
$message = t("the configuration options have been saved.");
|
||||||
|
}
|
||||||
|
|
||||||
// Find files in the directory.
|
// Find files in the directory.
|
||||||
$files = system_dirscan($directory, "\.$type$");
|
$files = system_dirscan($directory, "\.$type$");
|
||||||
|
|
||||||
|
@ -214,7 +241,9 @@ function system_listing($type, $directory, $required = array()) {
|
||||||
|
|
||||||
$output = table($header, $rows) . form_submit(t("Save $type settings"));
|
$output = table($header, $rows) . form_submit(t("Save $type settings"));
|
||||||
|
|
||||||
return form($output);
|
print form($output);
|
||||||
|
|
||||||
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_admin() {
|
function system_admin() {
|
||||||
|
@ -229,38 +258,36 @@ function system_admin() {
|
||||||
case "help":
|
case "help":
|
||||||
print system_help();
|
print system_help();
|
||||||
break;
|
break;
|
||||||
case t("Save module settings"):
|
|
||||||
db_query("UPDATE system SET status = '0' WHERE type = 'module'");
|
|
||||||
foreach ($edit["status"] as $filename => $status) {
|
|
||||||
db_query("UPDATE system SET status = %d WHERE filename = '$filename'", $status);
|
|
||||||
}
|
|
||||||
cache_clear_all();
|
|
||||||
case "modules":
|
case "modules":
|
||||||
// Note: changing this also requires changing module_init() @ includes/module.inc.
|
if (arg(3) == "settings") {
|
||||||
$required = array("modules/admin.module", "modules/user.module", "modules/system.module", "modules/watchdog.module");
|
print status(system_view("modules"));
|
||||||
print system_listing("module", "modules", $required);
|
|
||||||
break;
|
|
||||||
case t("Save theme settings"):
|
|
||||||
db_query("UPDATE system SET status = '0' WHERE type = 'theme'");
|
|
||||||
foreach ($edit["status"] as $filename => $status) {
|
|
||||||
db_query("UPDATE system SET status = %d WHERE filename = '$filename'", $status);
|
|
||||||
}
|
}
|
||||||
cache_clear_all();
|
else {
|
||||||
|
// NOTE: changing this also requires changing module_init() @ "includes/module.inc".
|
||||||
|
$required = array("modules/admin.module", "modules/user.module", "modules/system.module", "modules/watchdog.module");
|
||||||
|
print status(system_listing("module", "modules", $required));
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "themes":
|
case "themes":
|
||||||
print system_listing("theme", "themes");
|
if (arg(3) == "settings") {
|
||||||
|
print status(system_view("themes"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print status(system_listing("theme", "themes"));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case t("Reset to defaults"):
|
case t("Reset to defaults"):
|
||||||
print status(system_default($edit));
|
print status(system_default($edit));
|
||||||
print system_view(arg(3));
|
print system_view(arg(2));
|
||||||
cache_clear_all();
|
cache_clear_all();
|
||||||
break;
|
break;
|
||||||
case t("Save configuration"):
|
case t("Save configuration"):
|
||||||
print status(system_save($edit));
|
print status(system_save($edit));
|
||||||
print system_view(arg(3));
|
print system_view(arg(2));
|
||||||
cache_clear_all();
|
cache_clear_all();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print system_view($op);
|
print system_view(arg(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -35,15 +35,16 @@ function system_perm() {
|
||||||
function system_link($type) {
|
function system_link($type) {
|
||||||
if ($type == "admin" && user_access("administer site configuration")) {
|
if ($type == "admin" && user_access("administer site configuration")) {
|
||||||
menu_add("site configuration", url("admin/system"), "Site configuration.", NULL, NULL, 2);
|
menu_add("site configuration", url("admin/system"), "Site configuration.", NULL, NULL, 2);
|
||||||
menu_add("site settings", url("admin/system/options"), "Site settings.", NULL, "site configuration", 1);
|
menu_add("module selector", url("admin/system/modules/selector"), "Module selector.", NULL, "site configuration", 1);
|
||||||
menu_add("content filters", url("admin/system/filters"), "Content filters.", NULL, "site configuration", 2);
|
menu_add("module settings", url("admin/system/modules/settings"), "Site settings.", NULL, "site configuration", 2);
|
||||||
menu_add("module selector", url("admin/system/modules"), "Module selector.", NULL, "site configuration", 3);
|
menu_add("theme selector", url("admin/system/themes/selector"), "Theme selector.", NULL, "site configuration", 3);
|
||||||
menu_add("theme selector", url("admin/system/themes"), "Theme selector.", NULL, "site configuration", 4);
|
// menu_add("theme settings", url("admin/system/themes/settings"), "Theme selector.", NULL, "site configuration", 4);
|
||||||
|
menu_add("content filters", url("admin/system/filters"), "Content filters.", NULL, "site configuration", 5);
|
||||||
menu_add("help", url("admin/system/help"), "Help.", NULL, "site configuration", 9);
|
menu_add("help", url("admin/system/help"), "Help.", NULL, "site configuration", 9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_view_options() {
|
function system_view_modules() {
|
||||||
global $conf, $cmodes, $corder;
|
global $conf, $cmodes, $corder;
|
||||||
|
|
||||||
// general settings:
|
// general settings:
|
||||||
|
@ -95,6 +96,17 @@ function system_view_options() {
|
||||||
$output .= "<h3><a name=\"$name\">". ucfirst(t("$name")) ." " . t("settings") . "</a></h3>". module_invoke($name, "conf_options") ."<hr />\n";
|
$output .= "<h3><a name=\"$name\">". ucfirst(t("$name")) ." " . t("settings") . "</a></h3>". module_invoke($name, "conf_options") ."<hr />\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function system_view_themes() {
|
||||||
|
foreach (theme_list() as $name) {
|
||||||
|
if (module_hook($name, "conf_options")) {
|
||||||
|
$output .= "<h3><a name=\"$name\">". ucfirst(t("$name")) ." " . t("settings") . "</a></h3>". module_invoke($name, "conf_options") ."<hr />\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +124,7 @@ function system_save($edit = array()) {
|
||||||
variable_set($name, $value);
|
variable_set($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return t("The configuration options have been saved.");
|
return t("the configuration options have been saved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_default($edit = array()) {
|
function system_default($edit = array()) {
|
||||||
|
@ -120,30 +132,33 @@ function system_default($edit = array()) {
|
||||||
variable_del($name);
|
variable_del($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return t("The configuration options have been reset to their default values.");
|
return t("the configuration options have been reset to their default values.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_view($type) {
|
function system_view($type) {
|
||||||
|
|
||||||
|
$links = array();
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "filters":
|
case "filters":
|
||||||
$form = system_view_filters();
|
$form = system_view_filters();
|
||||||
break;
|
break;
|
||||||
|
case "themes":
|
||||||
|
$form = system_view_themes();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
foreach (module_list() as $name) {
|
foreach (module_list() as $name) {
|
||||||
if (module_hook($name, "conf_options")) {
|
if (module_hook($name, "conf_options")) {
|
||||||
$links[] = l(t("$name"), "admin/system#$name");
|
$links[] = "<a href=\"#$name\">". t("$name") ."</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$form = system_view_modules();
|
||||||
$output = "<small>". implode(" :: ", $links) ."</small><hr />";
|
|
||||||
$form = system_view_options();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$form .= form_submit(t("Save configuration"));
|
$form .= form_submit(t("Save configuration"));
|
||||||
$form .= form_submit(t("Reset to defaults"));
|
$form .= form_submit(t("Reset to defaults"));
|
||||||
|
|
||||||
return $output . form($form);
|
print implode(" · ", $links) ."<br />". form($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_dirscan($dir, $mask, $nomask = array(".", "..", "CVS")) {
|
function system_dirscan($dir, $mask, $nomask = array(".", "..", "CVS")) {
|
||||||
|
@ -167,9 +182,21 @@ function system_dirscan($dir, $mask, $nomask = array(".", "..", "CVS")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_listing($type, $directory, $required = array()) {
|
function system_listing($type, $directory, $required = array()) {
|
||||||
|
$op = arg(2);
|
||||||
|
|
||||||
// Make sure we set $type correctly
|
// Make sure we set $type correctly
|
||||||
$type = $type != 'theme' ? "module" : "theme";
|
$type = $type != 'theme' ? "module" : "theme";
|
||||||
|
|
||||||
|
if ($op == t("Save $type settings")) {
|
||||||
|
db_query("UPDATE system SET status = '0' WHERE type = '%d'", $type);
|
||||||
|
foreach ($edit["status"] as $filename => $status) {
|
||||||
|
db_query("UPDATE system SET status = '%d' WHERE filename = '$filename'", $status);
|
||||||
|
}
|
||||||
|
cache_clear_all();
|
||||||
|
|
||||||
|
$message = t("the configuration options have been saved.");
|
||||||
|
}
|
||||||
|
|
||||||
// Find files in the directory.
|
// Find files in the directory.
|
||||||
$files = system_dirscan($directory, "\.$type$");
|
$files = system_dirscan($directory, "\.$type$");
|
||||||
|
|
||||||
|
@ -214,7 +241,9 @@ function system_listing($type, $directory, $required = array()) {
|
||||||
|
|
||||||
$output = table($header, $rows) . form_submit(t("Save $type settings"));
|
$output = table($header, $rows) . form_submit(t("Save $type settings"));
|
||||||
|
|
||||||
return form($output);
|
print form($output);
|
||||||
|
|
||||||
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
function system_admin() {
|
function system_admin() {
|
||||||
|
@ -229,38 +258,36 @@ function system_admin() {
|
||||||
case "help":
|
case "help":
|
||||||
print system_help();
|
print system_help();
|
||||||
break;
|
break;
|
||||||
case t("Save module settings"):
|
|
||||||
db_query("UPDATE system SET status = '0' WHERE type = 'module'");
|
|
||||||
foreach ($edit["status"] as $filename => $status) {
|
|
||||||
db_query("UPDATE system SET status = %d WHERE filename = '$filename'", $status);
|
|
||||||
}
|
|
||||||
cache_clear_all();
|
|
||||||
case "modules":
|
case "modules":
|
||||||
// Note: changing this also requires changing module_init() @ includes/module.inc.
|
if (arg(3) == "settings") {
|
||||||
$required = array("modules/admin.module", "modules/user.module", "modules/system.module", "modules/watchdog.module");
|
print status(system_view("modules"));
|
||||||
print system_listing("module", "modules", $required);
|
|
||||||
break;
|
|
||||||
case t("Save theme settings"):
|
|
||||||
db_query("UPDATE system SET status = '0' WHERE type = 'theme'");
|
|
||||||
foreach ($edit["status"] as $filename => $status) {
|
|
||||||
db_query("UPDATE system SET status = %d WHERE filename = '$filename'", $status);
|
|
||||||
}
|
}
|
||||||
cache_clear_all();
|
else {
|
||||||
|
// NOTE: changing this also requires changing module_init() @ "includes/module.inc".
|
||||||
|
$required = array("modules/admin.module", "modules/user.module", "modules/system.module", "modules/watchdog.module");
|
||||||
|
print status(system_listing("module", "modules", $required));
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "themes":
|
case "themes":
|
||||||
print system_listing("theme", "themes");
|
if (arg(3) == "settings") {
|
||||||
|
print status(system_view("themes"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print status(system_listing("theme", "themes"));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case t("Reset to defaults"):
|
case t("Reset to defaults"):
|
||||||
print status(system_default($edit));
|
print status(system_default($edit));
|
||||||
print system_view(arg(3));
|
print system_view(arg(2));
|
||||||
cache_clear_all();
|
cache_clear_all();
|
||||||
break;
|
break;
|
||||||
case t("Save configuration"):
|
case t("Save configuration"):
|
||||||
print status(system_save($edit));
|
print status(system_save($edit));
|
||||||
print system_view(arg(3));
|
print system_view(arg(2));
|
||||||
cache_clear_all();
|
cache_clear_all();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print system_view($op);
|
print system_view(arg(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue