diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 8 | ||||
-rw-r--r-- | includes/module.inc | 21 | ||||
-rw-r--r-- | includes/theme.inc | 12 |
3 files changed, 14 insertions, 27 deletions
diff --git a/includes/common.inc b/includes/common.inc index 3e3460597..dc1e5027a 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -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. diff --git a/includes/module.inc b/includes/module.inc index d908ceb25..7a248d236 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -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 diff --git a/includes/theme.inc b/includes/theme.inc index 62239da12..da4d3ca06 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -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); } } } |