- intermediate commit: some bugfixes, changes and some drastic

changes to block and module support
3-00
Dries Buytaert 2000-12-23 15:13:34 +00:00
parent 5976e2f85e
commit 0cadc4e683
7 changed files with 81 additions and 52 deletions

View File

@ -32,4 +32,5 @@ ErrorDocument 500 /error.php
php_value session.cookie_lifetime 2000000 php_value session.cookie_lifetime 2000000
php_value session.gc_maxlifetime 2000000 php_value session.gc_maxlifetime 2000000
php_value session.cache_expire 200000 php_value session.cache_expire 200000
php_value session.save_path /tmp/dropsessions
</IfModule> </IfModule>

View File

@ -1,39 +1,50 @@
<? <?
// temporary permission solution: // validate user permission:
if (!$user->id || ($user->permissions != 1 && $user->id > 1)) exit(); if (!$user->id || ($user->permissions != 1 && $user->id > 1)) exit();
include "includes/admin.inc"; include_once "includes/theme.inc";
include "includes/cron.inc"; include_once "includes/cron.inc";
// display admin header: function admin_page($mod) {
admin_header(); global $repository, $menu, $modules;
// generate administrator menu: function module($name, $module) {
$handle = opendir("modules"); global $menu, $modules;
while ($file = readdir($handle)) { if ($module["admin"]) $output .= "<A HREF=\"admin.php?mod=$name\">$name</A> | ";
if ($filename = substr($file, 0, strpos($file, ".module"))) { $menu .= $output;
if ($filename == $mod) {
$output .= "$filename | ";
} }
else {
include_once "modules/$filename.module"; ?>
if ($module["cron"] && !cron_get($filename)) cron_set($filename, 172800); <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
if ($module["admin"]) $output .= "<A HREF=\"admin.php?mod=$filename\">$filename</A> | "; <HTML>
} <HEAD><TITLE><? echo $site_name; ?> administration center</TITLE></HEAD>
} <STYLE>
} body { font-family: helvetica, arial; }
closedir($handle); h1 { font-size: 14pt; font-weight: bold; color: #990000; }
h2 { font-family: helvetica, arial; font-size: 12pt; font-weight: bold; }
print "<HR>$output <A HREF=\"\">home</A><HR>"; h3 { font-family: helvetica, arial; font-size: 14pt; font-weight: bold; }
th { font-family: helvetica, arial; text-align: center; background-color: #CCCCCC; color: #995555; }
// display administrator body: td { font-family: helvetica, arial; }
if ($mod) { </STYLE>
include "modules/$mod.module"; <BODY BGCOLOR="#FFFFFF" LINK="#005599" VLINK="#004499" ALINK="#FF0000">
if ($function = $module["admin"]) $function(); <H1>Administration center</H1>
} <?
// display admin footer: module_iterate("module");
admin_footer();
?>
<HR><? echo $menu; ?><A HREF="">home</A><HR>
<?
module_execute($mod, "admin");
?>
</BODY>
</HTML>
<?
}
admin_page($mod);
?> ?>

View File

@ -1,6 +1,23 @@
<? <?
include "includes/cron.inc"; include "includes/theme.inc";
function cron_run($cron) {
global $repository;
$time = time();
$result = db_query("SELECT * FROM crons WHERE $time - timestamp > scheduled");
while ($task = db_fetch_object($result)) {
if ($repository[$task->module]["cron"]) {
watchdog("message", "cron: executed '". $task->module ."_cron()'");
$repository[$task->module]["cron"]();
}
}
db_query("UPDATE crons SET timestamp = $time WHERE $time - timestamp > scheduled");
}
cron_run(); cron_run();

View File

@ -5,6 +5,7 @@ include_once "includes/database.inc";
include_once "includes/watchdog.inc"; include_once "includes/watchdog.inc";
include_once "includes/function.inc"; include_once "includes/function.inc";
include_once "includes/droplet.inc"; include_once "includes/droplet.inc";
include_once "includes/module.inc";
include_once "includes/widget.inc"; include_once "includes/widget.inc";
include_once "includes/user.inc"; include_once "includes/user.inc";

View File

@ -1,5 +1,21 @@
<? <?
function display_module_blocks() {
global $repository, $theme;
function display_block($name, $module) {
global $theme;
if ($blocks = module_execute($name, "block")) {
foreach ($blocks as $id=>$block) {
$theme->box($block["subject"], $block["content"]);
}
}
}
module_iterate("display_block");
}
function display_morelink($theme, $story) { function display_morelink($theme, $story) {
return ($story->article) ? "[ <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | ". strlen($story->article) ." bytes | <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]"; return ($story->article) ? "[ <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | ". strlen($story->article) ." bytes | <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]";
} }
@ -72,20 +88,6 @@ function display_comment_moderation($id, $author, $score, $votes) {
return $output; return $output;
} }
function display_new_diaries($theme, $num = 20) {
$result = db_query("SELECT u.userid, d.timestamp FROM diaries d LEFT JOIN users u ON d.author = u.id ORDER BY timestamp DESC LIMIT $num");
while ($diary = db_fetch_object($result)) {
if ($time != date("F jS", $diary->timestamp)) {
$content .= "<P><B>". date("l, M jS", $diary->timestamp) ."</B></P>\n";
$time = date("F jS", $diary->timestamp);
}
$content .= "<LI><A HREF=\"module.php?mod=diary&op=view&name=$diary->userid\">$diary->userid</A></LI>\n";
}
$content .= "<P ALIGN=\"right\">[ <A HREF=\"module.php?mod=diary\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>";
$theme->box("Recent diary entries", $content);
}
function display_new_headlines($theme, $num = 10) { function display_new_headlines($theme, $num = 10) {
global $user; global $user;
@ -115,7 +117,7 @@ function display_account($theme) {
$content .= "<P>\n"; $content .= "<P>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=diary\">edit your diary</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=edit&topic=diary\">edit your diary</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">edit your information</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">edit your information</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=page\">edit your settings</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">edit your settings</A></LI>\n";
$content .= "<P>\n"; $content .= "<P>\n";
$content .= "<LI><A HREF=\"account.php?op=view&topic=diary\">view your diary</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=view&topic=diary\">view your diary</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=view&topic=info\">view your information</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=view&topic=info\">view your information</A></LI>\n";

View File

@ -1,6 +1,6 @@
<? <?
include "modules/$mod.module"; include_once "includes/theme.inc";
if ($function = $module["page"]) $function(); module_execute($mod, "page");
?> ?>

View File

@ -256,14 +256,11 @@
### Display account: ### Display account:
display_account($this); display_account($this);
### Display calendar: ### Display old headlines:
display_old_headlines($this); display_old_headlines($this);
### Display calendar: ### Display module blocks:
$this->box("Browse archives", droplet_get("calendar")); display_module_blocks();
### Display new diary entries:
display_new_diaries($this);
} }
elseif (strstr($PHP_SELF, "account.php")) { elseif (strstr($PHP_SELF, "account.php")) {
### Display account: ### Display account: