summaryrefslogtreecommitdiff
path: root/includes/theme.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-05-05 13:57:29 +0000
committerDries Buytaert <dries@buytaert.net>2001-05-05 13:57:29 +0000
commitbe8e898d23a3f9ca515f59fbcc8d82e112ed7ee8 (patch)
treecf0d05f6b767f36e7feb09a3bc59cbc9a01e459b /includes/theme.inc
parent16818777616eadeb8a4670324e099b95c8d53e3b (diff)
downloadbrdo-be8e898d23a3f9ca515f59fbcc8d82e112ed7ee8.tar.gz
brdo-be8e898d23a3f9ca515f59fbcc8d82e112ed7ee8.tar.bz2
- Uhm. Rewrote the module system: less code clutter, less run-time
overhead, and a lot better (simpler) module API. I had to edit a LOT of files to get this refactored but I'm sure it was worth the effort. For module writers / maintainers: None of the hooks changed, so 95% of the old modules should still work. You can remove some code instead as "$module = array(...)" just became obsolete. Also - and let's thank God for this - the global variable "$repository" has been eliminated to avoid modules relying on, and poking in drupal's internal data structures. Take a look at include/module.inc to investigate the details/changes. - Improved design of the content modules "story", "book" and "node" (to aid smooth integration of permisions + moderate.module). I'm still working on the permissions but I got side tracked for which I "Oops!".
Diffstat (limited to 'includes/theme.inc')
-rw-r--r--includes/theme.inc27
1 files changed, 10 insertions, 17 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 793824d06..8af929744 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -13,31 +13,22 @@ function theme_init() {
}
function theme_link($separator = " | ") {
- global $repository;
$links[] = "<A HREF=\"index.php\">". t("home") ."</A>";
$links[] = "<A HREF=\"search.php\">". t("search") ."</A>";
$links[] = "<A HREF=\"submit.php\">". t("submit") ."</A>";
- if ($repository[forum]) $links[] = "<A HREF=\"module.php?mod=forum\">".t("forum") ."</A>";
- if ($repository[diary]) $links[] = "<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>";
$links[] = "<A HREF=\"account.php\">". t("account") ."</A>";
- if ($repository[book]) $links[] = "<A HREF=\"module.php?mod=book\">". t("handbook") ."</A>";
+ if (module_exist("forum")) $links[] = "<A HREF=\"module.php?mod=forum\">".t("forum") ."</A>";
+ if (module_exist("diary")) $links[] = "<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>";
+ if (module_exist("book")) $links[] = "<A HREF=\"module.php?mod=book\">". t("handbook") ."</A>";
return implode($separator, $links);
}
-function theme_menu($name, $module) {
- global $menu;
- if ($module["menu"]) $menu = ($menu) ? array_merge($menu, $module["menu"]()) : $module["menu"]();
-}
function theme_account($theme) {
- global $user, $links, $menu;
+ global $user;
if ($user->id) {
-
-
- module_iterate("theme_menu");
-
// Display account settings:
$content .= "<LI><A HREF=\"account.php?op=track&topic=comments\">". t("track your comments") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=nodes\">". t("track your nodes") ."</A></LI>\n";
@@ -53,10 +44,12 @@ function theme_account($theme) {
$content .= "<P>\n";
}
- if ($menu) {
- foreach ($menu as $link) $content .= "<LI>$link</LI>\n";
- $content .= "<P>\n";
+ foreach (module_list() as $name) {
+ if ($links = module_invoke($name, "menu")) {
+ foreach ($links as $link) $content .= "<LI>$link</LI>\n";
+ }
}
+ if ($link) $content .= "<P>\n";
$content .= "<LI><A HREF=\"account.php?op=logout\">". t("logout") ."</A></LI>\n";
@@ -92,7 +85,7 @@ function theme_blocks($region, $theme) {
if ($user->id) $result = db_query("SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status = 1 AND l.user = '$user->id'))". (($region == "left" || $region == "right") ? ($region == "left" ? " AND b.region = 0" : " AND b.region = 1") : "") ." ORDER BY weight");
else $result = db_query("SELECT * FROM blocks WHERE status = 2". (($region == "left" || $region == "right") ? ($region == "left" ? " AND region = 0" : " AND region = 1") : "") ." ORDER BY weight");
while ($block = db_fetch_object($result)) {
- $blocks = module_execute($block->module, "block");
+ $blocks = module_invoke($block->module, "block");
$theme->box(t($blocks[$block->offset]["subject"]), $blocks[$block->offset]["content"]);
}
break;