Commit 8d103a08 authored by Dries's avatar Dries

- Committed Marco's block rewrite:

   + Blocks are not longer called if not rendered: major performance
     improvement.
   + Fixed some bugs (preview option was broken, path option was broken).
   + Removed "ascii"-type blocks.
   + Added permission to for "PHP blocks"
   + ...

  NOTES:

   + You'll want to run "update.php":

       ALTER TABLE blocks DROP remove;
       ALTER TABLE blocks DROP name;

   + You'll want to update your custom modules as well as the modules in
     the contrib repository.  Block function should now read:

       function *_block($op = "list", $delta = 0) {
         if ($op == "list") {
           return array of block infos
         }
         else {
           return subject and content of $delta block
         }
       }
parent 2ec14f35
......@@ -619,6 +619,14 @@ function form_submit($value) {
return "<input type=\"submit\" name=\"op\" value=\"". check_form($value) ."\" />\n";
}
function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $description = 0, $extra = 0) {
for ($n = (-1*$delta); $n <= $delta; $n++) {
$weights[$n] = $n;
}
return form_select($title, $name, $value, $weights, $description, $extra);
}
/**
* Build an URL; use this functions when you must write an URL
* for example in a form or a redirect.
......
......@@ -69,25 +69,4 @@ function module_hook($name, $hook) {
return function_exists($name ."_". $hook);
}
// rehash module-exported blocks:
function module_rehash_blocks($name) {
db_query("UPDATE blocks SET remove = '1' WHERE module = '$name'");
if ($blocks = module_invoke($name, "block")) {
foreach ($blocks as $delta => $block) {
foreach ($block as $item => $data) {
$block[$item] = addslashes($data);
}
if (!db_fetch_object(db_query("SELECT * FROM blocks WHERE module = '$name' AND name = '$block[info]'"))) {
db_query("INSERT INTO blocks (name, module, delta) VALUES ('$block[info]', '$name', '$delta')");
}
else {
db_query("UPDATE blocks SET delta = '$delta', remove = '0' WHERE module = '$name' AND name = '$block[info]'");
}
}
}
db_query("DELETE FROM blocks WHERE module = '$name' AND remove = '1'");
}
?>
\ No newline at end of file
......@@ -123,15 +123,15 @@ function theme_init() {
}
function theme_blocks($region, &$theme) {
global $id, $PHP_SELF, $user;
global $user, $PHP_SELF;
$result = db_query("SELECT * FROM blocks WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = '%s' " : "") ."ORDER BY weight, name", $region == "left" ? 0 : 1);
$result = db_query("SELECT * FROM blocks WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = '%s' " : "") ."ORDER BY weight, module", $region == "left" ? 0 : 1);
while ($result && ($block = db_fetch_object($result))) {
if (($block->status && (!$user->uid || !$block->custom)) || ($block->custom && $user->block[$block->name])) {
$blocks = module_invoke($block->module, "block");
if ($blocks[$block->delta]["content"]) {
$theme->box($blocks[$block->delta]["subject"], $blocks[$block->delta]["content"], $region);
if ((($block->status && (!$user->uid || !$block->custom)) || ($block->custom && $user->block[$block->module][$block->delta])) && (!$block->path || preg_match("|$block->path|", $PHP_SELF))) {
$block_data = module_invoke($block->module, "block", "view", $block->delta);
if ($block_data["content"]) {
$theme->box($block_data["subject"], $block_data["content"], $region);
}
}
}
......
......@@ -93,20 +93,44 @@ function import_feed_block($feed) {
return $output;
}
function import_block() {
return array_merge(import_get_bundles(), import_get_feeds());
function import_block($op, $delta) {
if ($op == "list") {
$result = db_query("SELECT * FROM bundle ORDER BY title");
while ($bundle = db_fetch_object($result)) {
$block[$bundle->bid]["info"] = "$bundle->title bundle";
}
$result = db_query("SELECT * FROM feed ORDER BY fid");
while ($feed = db_fetch_object($result)) {
$block[$feed->fid]["info"] = "$feed->title feed";
}
return $block;
}
else {
$feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $delta));
if ($feed) {
$block["subject"] = $feed->title;
$block["content"] = import_feed_block($feed) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "feed", "id" => $feed->fid), "", array("title" => t("View this feed's recent news."))) ."</div></p>";
}
else {
// it was a bundle. this is NOT elegant
$bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $delta));
$block["subject"] = $bundle->title;
$block["content"] = import_bundle_block($bundle->attributes) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "bundle", "id" => $bundle->bid), "", array("title" => t("View this bundle's recent news."))) ."</div></p>";
}
return $block;
}
}
function import_get_bundles($attributes = 0) {
$result = db_query("SELECT * FROM bundle ORDER BY title");
$i = 0;
while ($bundle = db_fetch_object($result)) {
$block[$i]["subject"] = $bundle->title;
$block[$i]["content"] = import_bundle_block($bundle->attributes) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "bundle", "id" => $bundle->bid), "", array("title" => t("View this bundle's recent news."))) ."</div></p>";
$block[$i]["info"] = "$bundle->title bundle";
$i++;
$block[$bundle->bid]["subject"] = $bundle->title;
$block[$bundle->bid]["content"] = import_bundle_block($bundle->attributes) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "bundle", "id" => $bundle->bid), "", array("title" => t("View this bundle's recent news."))) ."</div></p>";
$block[$bundle->bid]["info"] = "$bundle->title bundle";
}
return $block;
......@@ -115,13 +139,10 @@ function import_get_bundles($attributes = 0) {
function import_get_feeds($attributes = 0) {
$result = db_query("SELECT * FROM feed ORDER BY fid");
$i = 0;
while ($feed = db_fetch_object($result)) {
$block[$i]["subject"] = $feed->title;
$block[$i]["content"] = import_feed_block($feed) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "feed", "id" => $feed->fid), "", array("title" => t("View this feed's recent news."))) ."</div></p>";
$block[$i]["info"] = "$feed->title feed";
$i++;
$block[$feed->fid]["subject"] = $feed->title;
$block[$feed->fid]["content"] = import_feed_block($feed) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "feed", "id" => $feed->fid), "", array("title" => t("View this feed's recent news."))) ."</div></p>";
$block[$feed->fid]["info"] = "$feed->title feed";
}
return $block;
......@@ -289,10 +310,10 @@ function import_save_bundle($edit) {
db_query("DELETE FROM bundle WHERE bid = '%s'", $edit["bid"]);
}
else if ($edit["title"]) {
db_query("INSERT INTO bundle (title, attributes) VALUES ('%s', '%s')", $edit["title"], $edit["attributes"]);
// a single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id("import");
db_query("INSERT INTO bundle (bid, title, attributes) VALUES ('%d', '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]);
}
module_rehash_blocks("import");
}
function import_form_feed($edit = array()) {
......@@ -328,7 +349,9 @@ function import_save_feed($edit) {
db_query("DELETE FROM item WHERE fid = '%s'", $edit["fid"]);
}
else if ($edit["title"]) {
db_query("INSERT INTO feed (title, url, attributes, refresh) VALUES ('%s', '%s', '%s', '%s')", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
// a single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id("import");
db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES ('%d', '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
}
}
......@@ -694,26 +717,24 @@ function import_page_feeds() {
function import_page_blocks($blocks) {
global $theme;
$count = count($blocks);
$items = ceil($count / 3);
$c1 = min($items, $count);
$c2 = min(2 * $items, $count);
$c3 = $count;
$i = 0;
$theme->header();
$theme->box(t("News feeds"), import_page_info());
print "<table cellpadding=\"0\" cellspacing=\"5\" border=\"0\" width=\"100%\">\n";
print " <tr>\n";
print " <td width=\"33%\" valign=\"top\">\n";
for ($i; $i < $c1; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]);
print " </td>\n";
print " <td width=\"33%\" valign=\"top\">\n";
for ($i; $i < $c2; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]);
print " </td>\n";
print " <td width=\"33%\" valign=\"top\">\n";
for ($i; $i < $c3; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]);
print " </td>\n";
for ($t = 0; $t < 3; $t++) {
$i = 1;
print " <td width=\"33%\" valign=\"top\">\n";
while ($block = each($blocks)) {
$theme->box($block["value"]["subject"], $block["value"]["content"]);
if ($i == ceil(count($blocks) / 3)) {
break;
}
$i++;
}
print " </td>\n";
}
print " </tr>\n";
print "</table>\n";
$theme->footer();
......@@ -748,4 +769,4 @@ function import_page() {
}
}
?>
?>
\ No newline at end of file
......@@ -93,20 +93,44 @@ function import_feed_block($feed) {
return $output;
}
function import_block() {
return array_merge(import_get_bundles(), import_get_feeds());
function import_block($op, $delta) {
if ($op == "list") {
$result = db_query("SELECT * FROM bundle ORDER BY title");
while ($bundle = db_fetch_object($result)) {
$block[$bundle->bid]["info"] = "$bundle->title bundle";
}
$result = db_query("SELECT * FROM feed ORDER BY fid");
while ($feed = db_fetch_object($result)) {
$block[$feed->fid]["info"] = "$feed->title feed";
}
return $block;
}
else {
$feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $delta));
if ($feed) {
$block["subject"] = $feed->title;
$block["content"] = import_feed_block($feed) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "feed", "id" => $feed->fid), "", array("title" => t("View this feed's recent news."))) ."</div></p>";
}
else {
// it was a bundle. this is NOT elegant
$bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $delta));
$block["subject"] = $bundle->title;
$block["content"] = import_bundle_block($bundle->attributes) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "bundle", "id" => $bundle->bid), "", array("title" => t("View this bundle's recent news."))) ."</div></p>";
}
return $block;
}
}
function import_get_bundles($attributes = 0) {
$result = db_query("SELECT * FROM bundle ORDER BY title");
$i = 0;
while ($bundle = db_fetch_object($result)) {
$block[$i]["subject"] = $bundle->title;
$block[$i]["content"] = import_bundle_block($bundle->attributes) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "bundle", "id" => $bundle->bid), "", array("title" => t("View this bundle's recent news."))) ."</div></p>";
$block[$i]["info"] = "$bundle->title bundle";
$i++;
$block[$bundle->bid]["subject"] = $bundle->title;
$block[$bundle->bid]["content"] = import_bundle_block($bundle->attributes) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "bundle", "id" => $bundle->bid), "", array("title" => t("View this bundle's recent news."))) ."</div></p>";
$block[$bundle->bid]["info"] = "$bundle->title bundle";
}
return $block;
......@@ -115,13 +139,10 @@ function import_get_bundles($attributes = 0) {
function import_get_feeds($attributes = 0) {
$result = db_query("SELECT * FROM feed ORDER BY fid");
$i = 0;
while ($feed = db_fetch_object($result)) {
$block[$i]["subject"] = $feed->title;
$block[$i]["content"] = import_feed_block($feed) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "feed", "id" => $feed->fid), "", array("title" => t("View this feed's recent news."))) ."</div></p>";
$block[$i]["info"] = "$feed->title feed";
$i++;
$block[$feed->fid]["subject"] = $feed->title;
$block[$feed->fid]["content"] = import_feed_block($feed) ."<p><div align=\"right\">". lm(t("more"), array("mod" => "import", "op" => "feed", "id" => $feed->fid), "", array("title" => t("View this feed's recent news."))) ."</div></p>";
$block[$feed->fid]["info"] = "$feed->title feed";
}
return $block;
......@@ -289,10 +310,10 @@ function import_save_bundle($edit) {
db_query("DELETE FROM bundle WHERE bid = '%s'", $edit["bid"]);
}
else if ($edit["title"]) {
db_query("INSERT INTO bundle (title, attributes) VALUES ('%s', '%s')", $edit["title"], $edit["attributes"]);
// a single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id("import");
db_query("INSERT INTO bundle (bid, title, attributes) VALUES ('%d', '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]);
}
module_rehash_blocks("import");
}
function import_form_feed($edit = array()) {
......@@ -328,7 +349,9 @@ function import_save_feed($edit) {
db_query("DELETE FROM item WHERE fid = '%s'", $edit["fid"]);
}
else if ($edit["title"]) {
db_query("INSERT INTO feed (title, url, attributes, refresh) VALUES ('%s', '%s', '%s', '%s')", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
// a single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id("import");
db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES ('%d', '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
}
}
......@@ -694,26 +717,24 @@ function import_page_feeds() {
function import_page_blocks($blocks) {
global $theme;
$count = count($blocks);
$items = ceil($count / 3);
$c1 = min($items, $count);
$c2 = min(2 * $items, $count);
$c3 = $count;
$i = 0;
$theme->header();
$theme->box(t("News feeds"), import_page_info());
print "<table cellpadding=\"0\" cellspacing=\"5\" border=\"0\" width=\"100%\">\n";
print " <tr>\n";
print " <td width=\"33%\" valign=\"top\">\n";
for ($i; $i < $c1; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]);
print " </td>\n";
print " <td width=\"33%\" valign=\"top\">\n";
for ($i; $i < $c2; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]);
print " </td>\n";
print " <td width=\"33%\" valign=\"top\">\n";
for ($i; $i < $c3; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]);
print " </td>\n";
for ($t = 0; $t < 3; $t++) {
$i = 1;
print " <td width=\"33%\" valign=\"top\">\n";
while ($block = each($blocks)) {
$theme->box($block["value"]["subject"], $block["value"]["content"]);
if ($i == ceil(count($blocks) / 3)) {
break;
}
$i++;
}
print " </td>\n";
}
print " </tr>\n";
print "</table>\n";
$theme->footer();
......@@ -748,4 +769,4 @@ function import_page() {
}
}
?>
?>
\ No newline at end of file
......@@ -102,14 +102,20 @@ function archive_display($original = 0) {
return $output;
}
function archive_block() {
function archive_block($op = "list", $delta = 0) {
global $date;
$block[0]["subject"] = "Browse archives";
$block[0]["content"] = archive_display($date);
$block[0]["info"] = "Calendar to browse archives";
return $block;
if ($op == "list") {
$blocks[0]["info"] = t("Calendar to browse archives");
return $blocks;
}
else {
switch ($delta) {
case 0:
$block["subject"] = t("Browse archives");
$block["content"] = archive_display($date);
return $block;
}
}
}
function archive_link($type) {
......@@ -169,10 +175,11 @@ function archive_page() {
}
}
else {
$theme->box(t("Access denied"), message_access());
#$theme->box(t("Access denied"), message_access());
message_access();
}
$theme->footer();
}
?>
?>
\ No newline at end of file
......@@ -102,14 +102,20 @@ function archive_display($original = 0) {
return $output;
}
function archive_block() {
function archive_block($op = "list", $delta = 0) {
global $date;
$block[0]["subject"] = "Browse archives";
$block[0]["content"] = archive_display($date);
$block[0]["info"] = "Calendar to browse archives";
return $block;
if ($op == "list") {
$blocks[0]["info"] = t("Calendar to browse archives");
return $blocks;
}
else {
switch ($delta) {
case 0:
$block["subject"] = t("Browse archives");
$block["content"] = archive_display($date);
return $block;
}
}
}
function archive_link($type) {
......@@ -169,10 +175,11 @@ function archive_page() {
}
}
else {
$theme->box(t("Access denied"), message_access());
#$theme->box(t("Access denied"), message_access());
message_access();
}
$theme->footer();
}
?>
?>
\ No newline at end of file
......@@ -13,9 +13,9 @@ function block_help() {
<p>The content of the site can be almost entirely altered through <I>boxes</I>. Simply put, boxes are small bits of text, HTML or PHP code which will get plugged into the site just like any other block. Boxes are typically used to add custom blocks to the site.</p>
<p>Each box consists of a title and an associated block of text, HTML or PHP code that can be as long as you wish and that will 'render' the content of the box.</p>
<h3>PHP boxes</h3>
<p>If you know how to script in PHP, PHP boxes are easy to create. Don't worry if you're no PHP-wizard: simply use ASCII or HTML boxes instead.</p>
<p>If you know how to script in PHP, PHP boxes are easy to create. Don't worry if you're no PHP-wizard: simply use HTML boxes instead.</p>
<p>You can use any piece of PHP code to make up the content of a PHP box: this implies that you can declare and use functions, consult the SQL database, access configuration settings and much more. A PHP box's code is stored in the database and the engine will dynamically embed the PHP code just-in-time for execution.</p>
<p>There are however some factors to keep in mind when using and creating PHP boxes: PHP boxes can be extremely useful and flexible, yet they can be dangerous and insecure if not properly used. If you are not familiar with PHP, SQL or with the site engine, avoid experimenting with PHP boxes because you can - and probably will - corrupt your database or render your site unusable! If you don't plan to do fancy stuff with boxes then you're probably better off with ASCII or HTML boxes.</p>
<p>There are however some factors to keep in mind when using and creating PHP boxes: PHP boxes can be extremely useful and flexible, yet they can be dangerous and insecure if not properly used. If you are not familiar with PHP, SQL or with the site engine, avoid experimenting with PHP boxes because you can - and probably will - corrupt your database or render your site unusable! If you don't plan to do fancy stuff with boxes then you're probably better off with HTML boxes.</p>
<p>Remember that the code within each PHP box must be valid PHP code -- including things like correctly terminating statements with a semicolon so that the parser won't die. It is highly recommended that you develop your boxes separately using a simple test script on top of a test database before migrating to your production environment.</p>
<p>Note that you can use global variables such as configuration parameters within the scope of a PHP box. Also keep in mind that variables which have been given values in a PHP box will retain these values in the engine or module afterwards.</p>
<p>You can use the <code>return</code> statement to return the actual content for your block as well.</p>
......@@ -55,44 +55,86 @@ function block_link($type) {
return $links ? $links : array();
}
function block_block() {
$result = db_query("SELECT * FROM boxes ORDER BY title");
while ($block = db_fetch_object($result)) {
$blocks[$block->bid]["subject"] = check_output($block->title);
$blocks[$block->bid]["content"] = ($block->type == 2) ? eval($block->body) : $block->body;
$blocks[$block->bid]["info"] = check_output($block->info);
function block_block($op = "list", $delta = 0) {
if ($op == "list") {
$result = db_query("SELECT bid, title, info FROM boxes ORDER BY title");
while ($block = db_fetch_object($result)) {
$blocks[$block->bid]["info"] = check_output($block->info);
}
return $blocks;
}
else {
$block = db_fetch_object(db_query("SELECT * FROM boxes WHERE bid = '%d'", $delta));
$data["subject"] = check_output($block->title);
$data["content"] = ($block->type == 1) ? eval($block->body) : $block->body;
return $data;
}
return $blocks;
}
function block_admin_save($edit) {
foreach ($edit as $key => $value) {
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE name = '%s'", $value["region"], $value["status"], $value["custom"], $value["path"], $value["weight"], $key);
foreach ($edit as $module => $blocks) {
foreach ($blocks as $delta => $block) {
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE module = '%s' AND delta = '%d'", $block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
}
}
}
function block_admin_display() {
function block_rehash() {
$result = db_query("SELECT * FROM blocks ORDER BY weight");
while ($old_block = db_fetch_object($result)) {
$old_blocks[$old_block->module][$old_block->delta] = $old_block;
}
db_query("DELETE FROM blocks");
foreach (module_list() as $module) {
$module_blocks = module_invoke($module, "block", "list");
if ($module_blocks) {
foreach ($module_blocks as $delta => $block) {
$block["module"] = $module;
$block["delta"] = $delta;
if ($old_blocks[$module][$delta]) {
$block["status"] = $old_blocks[$module][$delta]->status;
$block["weight"] = $old_blocks[$module][$delta]->weight;
$block["region"] = $old_blocks[$module][$delta]->region;
$block["path"] = $old_blocks[$module][$delta]->path;
$block["custom"] = $old_blocks[$module][$delta]->custom;
}
else {
$block["status"] = $block["weight"] = $block["region"] = $block["custom"] = 0;
$block["path"] = "";
}
// reinsert blocks into table
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%d', '%d', '%d', '%d', '%s', '%d')", $block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
$blocks[] = $block;
}
}
}
return $blocks;
}
function block_admin_display() {
// Generate output:
$output = "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= "<tr><th>block</th><th>module</th><th>enabled</th><th>custom</th><th>weight</th><th>region</th><th>path</th><th colspan=\"2\">operations</th></tr>\n";
while ($block = db_fetch_object($result)) {
$weights = array(0 => 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$output .= '<tr>';
//$output .= '<td>'. la($block->name, array("mod" => "block", "op" => "view", "id" => $block->delta), "", array("title" => t("View the block details"))) .'</td>';
$output .= "<td>$block->name</td>";
$output .= '<td>'. (module_hook($block->module, "admin") ? la($block->module, array("mod" => $block->module), "", array("title" => t("Administer module"))) : $block->module) .'</td>';
$output .= '<td align="center">'. form_checkbox(NULL, "$block->name][status", 1, $block->status) .'</td>';
$output .= '<td align="center">'. form_checkbox(NULL, "$block->name][custom", 1, $block->custom) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][weight", $block->weight, $weights) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][region", $block->region, array("left", "right")) .'</td>';
$output .= '<td>'. form_textfield(NULL, "$block->name][path", $block->path, 10, 255) .'</td>';
if ($block->module == 'block') {
$output .= '<td>'. la(t("edit"), array("mod" => "block", "op" => "edit", "id" => $block->delta)) .'</td>';
$output .= '<td>'. la(t("delete"), array("mod" => "block", "op" => "delete", "id" => $block->delta)) .'</td>';
$blocks = block_rehash();
foreach ($blocks as $block) {
$output .= "<tr>";
$output .= "<td>".$block["info"]."</td>";
$output .= "<td>". (module_hook($block["module"], "admin") ? la($block["module"], array("mod" => $module), "", array("title" => t("Administer module"))) : $block["module"]) ."</td>";
$output .= "<td align=\"center\">". form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]) ."</td>";
$output .= "<td align=\"center\">". form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]) ."</td>";
$output .= "<td>". form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]) ."</td>";
$output .= "<td>". form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array("left", "right")) ."</td>";
$output .= "<td>". form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255) ."</td>";
if ($block["module"] == 'block') {
$output .= "<td>". la(t("edit"), array("mod" => "block", "op" => "edit", "id" => $block["delta"])) ."</td>";
$output .= "<td>". la(t("delete"), array("mod" => "block", "op" => "delete", "id" => $block["delta"])) ."</td>";
}
$output .= "</tr>\n";
}
......@@ -107,12 +149,20 @@ function block_admin_preview() {
$result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 0 ORDER BY weight");
$lblocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) $lblocks .= " <tr><td nowrap>". ($block->status == 2 ? "<b>$block->name</b>" : $block->name) ."</td><td>$block->weight</td></tr>\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
$name = $block_data[$block->delta]["info"];
$lblocks .= " <tr><td nowrap=\"nowrap\">". ($block->status == 2 ? "<b>$name</b>" : $name) ."</td><td>$block->weight</td></tr>\n";
}
$lblocks .= "</table>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 1 ORDER BY weight");
$rblocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) $rblocks .= " <tr><td nowrap>". ($block->status == 2 ? "<b>$block->name</b>" : $block->name) ."</td><td>$block->weight</td></tr>\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
$name = $block_data[$block->delta]["info"];
$rblocks .= " <tr><td nowrap=\"nowrap\">". ($block->status == 2 ? "<b>$name</b>" : $name) ."</td><td>$block->weight</td></tr>\n";
}
$rblocks .= "</table>\n";
$output .= "<h3>layout scheme #1:</h3>\n";
......@@ -124,7 +174,11 @@ function block_admin_preview() {
$result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight");