2000-12-23 15:20:10 +00:00
|
|
|
<?
|
|
|
|
|
2000-12-24 15:44:29 +00:00
|
|
|
$module = array("page" => "block_page",
|
|
|
|
"admin" => "block_admin");
|
|
|
|
|
|
|
|
function block_page() {
|
|
|
|
global $theme;
|
|
|
|
|
|
|
|
$result = db_query("SELECT * FROM blocks WHERE status = 1 ORDER BY module");
|
|
|
|
|
|
|
|
$theme->header();
|
|
|
|
print "<TABLE BORDER=\"0\">\n";
|
|
|
|
while ($block = db_fetch_object($result)) {
|
|
|
|
if ($state % 3 == 0) print " <TR>\n";
|
|
|
|
print " <TD ALIGN=\"center\" VALIGN=\"top\" WIDTH=\"33%\">\n";
|
|
|
|
$blocks = module_execute($block->module, "block");
|
|
|
|
$theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]);
|
|
|
|
print " </TD>\n";
|
|
|
|
if ($state % 3 == 2) print " </TR>\n";
|
|
|
|
$state += 1;
|
|
|
|
}
|
|
|
|
print "</TABLE>\n";
|
|
|
|
$theme->footer();
|
|
|
|
}
|
2000-12-23 15:20:10 +00:00
|
|
|
|
|
|
|
function block_admin_save($edit) {
|
|
|
|
foreach ($edit as $key=>$value) {
|
|
|
|
db_query("UPDATE blocks SET status = '$value' WHERE name = '$key'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function block_admin_display() {
|
|
|
|
global $repository;
|
|
|
|
|
2000-12-24 15:44:29 +00:00
|
|
|
$result = db_query("SELECT * FROM blocks ORDER BY module");
|
2000-12-23 15:20:10 +00:00
|
|
|
|
|
|
|
// Generate output:
|
|
|
|
$output .= "<FORM ACTION=\"admin.php?mod=block\" METHOD=\"post\">\n";
|
|
|
|
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
|
|
|
|
$output .= " <TR><TH>block</TH><TH>module</TH><TH>status</TH></TR>\n";
|
|
|
|
|
|
|
|
while ($block = db_fetch_object($result)) {
|
|
|
|
$module = ($repository[$block->module]["admin"]) ? "<A HREF=\"admin.php?mod=$block->module\">$block->module</A>" : $block->module;
|
|
|
|
|
|
|
|
$status .= "<SELECT NAME=\"edit[$block->name]\">\n";
|
|
|
|
$status .= " <OPTION VALUE=\"1\"". (($block->status == 1) ? " SELECTED" : "") .">enabled</OPTION>\n";
|
|
|
|
$status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n";
|
|
|
|
$status .= "</SELECT>\n";
|
|
|
|
|
2000-12-24 15:44:29 +00:00
|
|
|
$output .= " <TR><TD>". $block->name ."</TD><TD ALIGN=\"center\">$module</TD><TD>$status</TD></TR>\n";
|
2000-12-23 15:20:10 +00:00
|
|
|
|
|
|
|
unset($status);
|
|
|
|
}
|
|
|
|
|
|
|
|
$output .= "</TABLE>\n";
|
|
|
|
$output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save blocks\">\n";
|
|
|
|
$output .= "</FORM>\n";
|
|
|
|
|
|
|
|
print $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
function block_admin() {
|
|
|
|
global $op, $edit;
|
|
|
|
|
|
|
|
switch ($op) {
|
|
|
|
case "Save blocks":
|
|
|
|
block_admin_save($edit);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
block_admin_display();
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|