From 10267210927846619e39e76ac173d9295851b948 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 28 Jan 2010 14:11:14 +0000 Subject: Fix broken module loading in admin. New module parameter system. --- utils/admin.php | 7 ++++++- utils/modules.php | 22 +++++++++++++++++++++- utils/modules/config.php | 2 ++ utils/modules/discography.php | 3 +++ utils/modules/events.php | 2 +- utils/modules/gallery.php | 10 +++++----- utils/modules/guestbook.php | 2 +- utils/modules/links.php | 2 +- utils/modules/news.php | 32 +++++++++++++++++++++++++------- utils/modules/pages.php | 2 +- 10 files changed, 66 insertions(+), 18 deletions(-) diff --git a/utils/admin.php b/utils/admin.php index 03f56bc..d0303c9 100644 --- a/utils/admin.php +++ b/utils/admin.php @@ -1,9 +1,12 @@
Admin
- $module) { if($m == $modulename) $admin_module = $module; echo "$module->admin_title\n"; diff --git a/utils/modules.php b/utils/modules.php index 54682a4..b77beb8 100644 --- a/utils/modules.php +++ b/utils/modules.php @@ -19,9 +19,29 @@ function loadModule($modulename) } } +function loadAllModules() +{ + loadModule("config"); + loadModule("discography"); + loadModule("events"); + loadModule("gallery"); + loadModule("guestbook"); + loadModule("icons"); + loadModule("links"); + loadModule("members"); + loadModule("news"); + loadModule("pages"); +} + function getModuleParams($code) { - return explode(",", $code); + $params = array(); + $ps = explode(",", $code); + foreach($ps as $p) { + $v = explode("=", $p); + $params[$v[0]] = $v[1]; + } + return $params; } function runModule($code) diff --git a/utils/modules/config.php b/utils/modules/config.php index 4afb264..d25961a 100644 --- a/utils/modules/config.php +++ b/utils/modules/config.php @@ -1,6 +1,8 @@ \n"; $lyrics = $GLOBALS["lyrics"]; $number = $GLOBALS["track"]; + //foreach($params as $param => $value) {} + if($lyrics && $number) { if($this->discs) { foreach($this->discs as $disc) { diff --git a/utils/modules/events.php b/utils/modules/events.php index d8631ec..9fdf0b8 100644 --- a/utils/modules/events.php +++ b/utils/modules/events.php @@ -237,7 +237,7 @@ class Events { public function run($params) { - foreach($params as $param) { + foreach($params as $param => $value) { switch($param) { case "coming": return $this->showcoming(-1); diff --git a/utils/modules/gallery.php b/utils/modules/gallery.php index 6b2f384..4c7edc5 100644 --- a/utils/modules/gallery.php +++ b/utils/modules/gallery.php @@ -378,18 +378,18 @@ class Gallery { $str = ""; $str .= "\n\n"; - foreach($params as $param) { + foreach($params as $param => $value) { switch($param) { + case "random": + $str .= $this->showRandomPhoto(); + break; + default: if($p != "" && $a != "") $str .= $this->showPhoto($a, $p); else if($a != "" && $this->albums[$a] && $p == "") $str .= $this->albums[$a]->show(" ", $this->maxwidth_icon, $this->maxheight_icon); else $str .= $this->showAlbums(); break; - - case "random": - $str .= $this->showRandomPhoto(); - break; } } $str .= "\n"; diff --git a/utils/modules/guestbook.php b/utils/modules/guestbook.php index 2d5db8a..200322d 100644 --- a/utils/modules/guestbook.php +++ b/utils/modules/guestbook.php @@ -328,7 +328,7 @@ class Guestbook { $showeditor = false; $showposts = 0; - foreach($params as $param) { + foreach($params as $param => $value) { switch($param) { case "editor": $showeditor = true; diff --git a/utils/modules/links.php b/utils/modules/links.php index cf0cfed..ba68122 100644 --- a/utils/modules/links.php +++ b/utils/modules/links.php @@ -96,7 +96,7 @@ class Links { $groupid = "all"; - foreach($params as $param) { + foreach($params as $param => $value) { if(!$param) continue; switch($param) { case "all": diff --git a/utils/modules/news.php b/utils/modules/news.php index 75cb748..4d00b24 100644 --- a/utils/modules/news.php +++ b/utils/modules/news.php @@ -272,14 +272,32 @@ class News { public function run($params) { - global $show; + $str = ""; + + $module = "all"; + $number = -1; + + foreach($params as $param => $value) { + switch($param) { + case "show": + $module = $value; + break; + + case "number": + $number = $value; + break; + + case "all": + default: + $module = "all"; + $number = -1; + break; + } + } - switch($params) { - default: - if($show == "all") return $this->show(-1, "all"); - else return $this->show(3, "main"); - break; - } + $str .= $this->show($number, $module); + + return $str; } public function show($number, $category) diff --git a/utils/modules/pages.php b/utils/modules/pages.php index d3ee0aa..16d6759 100644 --- a/utils/modules/pages.php +++ b/utils/modules/pages.php @@ -24,7 +24,7 @@ class Page { $str = Markdown($this->content); - if(preg_match_all("/\[\[([\?,a-zA-Z0-9_]+)\]\]/", $str, $res)) { + if(preg_match_all("/\[\[([\?,a-zA-Z0-9_=]+)\]\]/", $str, $res)) { $modulecodes = array_unique($res[1]); foreach($modulecodes as $modulecode) { -- cgit v1.2.3