From 559276162095e907db21dd3da3c1bea13b4b7c62 Mon Sep 17 00:00:00 2001 From: Kjartan Mannes Date: Sun, 14 Apr 2002 19:34:04 +0000 Subject: This is a major change to the system, needs more testing! Committing Changes by Moshe Weitzman: - admin_user_account(), user_edit(), and user_view() no longer have any hard code for authentication modules. instead authentication modules implement the _user hook. - fixed a couple 'help' typos. - linked the 'REGISTER' text in the login block to the register page. this page now advertises DA better if site employs DA. - admins may now edit everything about a user account (was a feature request). - user #1 may now login immediately, in addition to receiving his password via email. Other changes: - modules and themes are now enabled/disabled in the administrative / settings / modules | themes pages. Requires SQL update and things must be enabled before your site returns to normal. TODO: enable all functionality. (For now just do UPDATE system SET status = 1;) - removed $themes from conf.php. - added a $theme->system() function where theme can specify settings. All themes in the Drupal CVS have been updated to use this. - added _system hook to modules. TODO: update modules to use this. - changed strange use of sprintf to the usual strtr. The disadvantage of sprintf is that it requires translations to keep the string order, which may not be possible in all languages. - an invalid/nonexisting theme in a user profile will now fallback to the BaseTheme instead of crashing. --- includes/conf.php | 16 ---------------- includes/module.inc | 26 +++++++++++--------------- includes/theme.inc | 46 ++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 39 deletions(-) (limited to 'includes') diff --git a/includes/conf.php b/includes/conf.php index 74bb1f061..9014e7500 100644 --- a/includes/conf.php +++ b/includes/conf.php @@ -21,22 +21,6 @@ $db_url = "mysql://drupal:drupal@localhost/drupal"; # If required, update PHP's include path to include your PEAR directory: // ini_set("include_path", ".:/path/to/pear"); -# -# Themes: -# -$themes = array("UnConeD" => array( - "themes/unconed/unconed.theme", - "Internet explorer, Netscape, Opera"), - "Marvin" => array( - "themes/marvin/marvin.theme", - "Internet explorer, Netscape, Opera"), - "Stone Age" => array( - "themes/example/example.theme", - "Internet explorer, Netscape, Opera, Lynx"), - "Goofy" => array( - "themes/goofy/goofy.theme", - "Internet explorer, Netscape, Opera")); - # # Languages / translation / internationalization: # The first language listed in this associative array will diff --git a/includes/module.inc b/includes/module.inc index 8f53e8591..92a4b26bf 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -3,6 +3,10 @@ // initialize modules: function module_init() { + require_once("modules/user.module"); + require_once("modules/drupal.module"); + require_once("modules/system.module"); + require_once("modules/watchdog.module"); module_list(); } @@ -38,21 +42,13 @@ function module_list() { static $list; if (!$list) { - if ($handle = @opendir("modules")) { - $list = array(); - while ($file = readdir($handle)) { - if (".module" == substr($file, -7)) { - $filename = substr($file, 0, -7); - $list[$filename] = $filename; - include "modules/$filename.module"; - } - } - closedir($handle); - asort($list); - } - else { - $list = array(); + $list = array("drupal" => "drupal", "system" => "system", "user" => "user", "watchdog" => "watchdog"); + $result = db_query("SELECT name, filename FROM system WHERE type = 'module' AND status = '1' ORDER BY name"); + while ($module = db_fetch_object($result)) { + $list[$module->name] = $module->name; + @include_once "modules/$module->filename"; } + asort($list); } return $list; @@ -109,4 +105,4 @@ function module_rehash($name) { } } -?> +?> \ No newline at end of file diff --git a/includes/theme.inc b/includes/theme.inc index fa13e2236..40aa23d35 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1,8 +1,21 @@ ". variable_get(site_name, "drupal") .""; $output .= "
"; @@ -68,18 +81,35 @@ class BaseTheme { } -function theme_init() { - global $user, $themes; +function theme_list() { + static $list; - if ($user->theme && file_exists($themes[$theme_name = $user->theme][0])) { - include_once $themes[$theme_name][0]; + if (!$list) { + $list = array(); + $result = db_query("SELECT * FROM system where type = 'theme' AND status = '1' ORDER BY name"); + while ($theme = db_fetch_object($result)) { + $list[$theme->name] = $theme; + } } - else { - include_once $themes[$theme_name = variable_get("theme_default", key($themes))][0]; + + return $list; +} + +function theme_init() { + global $user; + + $themes = theme_list(); + $name = $user->theme ? $user->theme : variable_get("theme_default", 0); + if (is_object($themes[$name])) { + include_once($themes[$name]->filename); + $theme_class = "Theme_$user->theme"; + @$obj =& new $theme_class; + return $obj; } - $theme_class = 'Theme_'. $theme_name; - return new $theme_class(); + watchdog("warning", "No valid themes enabled."); + @$obj =& new BaseTheme; + return $obj; } function theme_blocks($region, &$theme) { -- cgit v1.2.3